|
1 package org.hedgewars.hedgeroid; |
|
2 |
|
3 import org.hedgewars.hedgeroid.Datastructures.MapRecipe; |
|
4 import org.hedgewars.hedgeroid.Datastructures.Scheme; |
|
5 import org.hedgewars.hedgeroid.Datastructures.Weaponset; |
|
6 |
|
7 /** |
|
8 * This interface is supposed to abstract the handling of room state for several fragments |
|
9 * that can display and manipulate it. The purpose of this is to allow using these fragments |
|
10 * both for setting up networked and local games, despite the fact that for local games |
|
11 * the settings can be changed immediately in memory, while they have to be sent out to the |
|
12 * server for networked games. |
|
13 * |
|
14 * If/when the state changes as result of calling one of the "changeX" functions, that will |
|
15 * also trigger the corresponding change listener method. There is no guarantee that calling |
|
16 * a changeX method will actually change the setting (e.g. if you're not room chief). |
|
17 * |
|
18 * For local games, getChiefStatus is always true. |
|
19 * |
|
20 * Implementations of this interface are probably not thread safe and should only be used on |
|
21 * the UI thread. |
|
22 */ |
|
23 public interface RoomStateManager { |
|
24 // Query current state |
|
25 MapRecipe getMapRecipe(); |
|
26 boolean getChiefStatus(); |
|
27 Scheme getScheme(); |
|
28 String getGameStyle(); |
|
29 Weaponset getWeaponset(); |
|
30 |
|
31 // Manipulate state |
|
32 void changeMapRecipe(MapRecipe map); |
|
33 void changeMapTheme(String theme); |
|
34 |
|
35 /** |
|
36 * This function sets both the map's name and generator. There is no function |
|
37 * to change them independendly since e.g. the QtFrontend relies on them being |
|
38 * consistent. |
|
39 * |
|
40 * If the name parameter is equal to one of the MapRecipe.MAPNAME_REGULAR, MAPNAME_MAZE |
|
41 * or MAPNAME_DRAWN constants, the map generator is set accordingly. Otherwise, the |
|
42 * map generator is set to represent a mapfile. The map's name is always set to |
|
43 * the parameter. |
|
44 */ |
|
45 void changeMapNameAndGenerator(String mapName); |
|
46 void changeMapTemplate(int template); |
|
47 void changeMazeSize(int mazeSize); |
|
48 void changeMapSeed(String seed); |
|
49 void changeMapDrawdata(byte[] drawdata); |
|
50 |
|
51 void changeScheme(Scheme scheme); |
|
52 void changeGameStyle(String style); |
|
53 void changeWeaponset(Weaponset weaponset); |
|
54 |
|
55 // Observe state |
|
56 void registerObserver(Observer observer); |
|
57 void unregisterObserver(Observer observer); |
|
58 |
|
59 public interface Observer { |
|
60 void onMapChanged(MapRecipe recipe); |
|
61 void onChiefStatusChanged(boolean isChief); |
|
62 void onSchemeChanged(Scheme scheme); |
|
63 void onGameStyleChanged(String gameStyle); |
|
64 void onWeaponsetChanged(Weaponset weaponset); |
|
65 } |
|
66 |
|
67 public interface Provider { |
|
68 RoomStateManager getRoomStateManager(); |
|
69 } |
|
70 } |