project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/RoomStateManager.java
changeset 10017 de822cd3df3a
parent 7584 7831c84cc644
equal deleted inserted replaced
10015:4feced261c68 10017:de822cd3df3a
    31  * This interface is supposed to abstract the handling of room state for several
    31  * This interface is supposed to abstract the handling of room state for several
    32  * fragments that can display and manipulate it. The purpose of this is to allow
    32  * fragments that can display and manipulate it. The purpose of this is to allow
    33  * using these fragments both for setting up networked and local games, despite
    33  * using these fragments both for setting up networked and local games, despite
    34  * the fact that for local games the settings can be changed immediately in
    34  * the fact that for local games the settings can be changed immediately in
    35  * memory, while they have to be sent out to the server for networked games.
    35  * memory, while they have to be sent out to the server for networked games.
    36  * 
    36  *
    37  * If/when the state changes as result of calling one of the "changeX" or
    37  * If/when the state changes as result of calling one of the "changeX" or
    38  * "requestX" functions, that will also trigger the corresponding change
    38  * "requestX" functions, that will also trigger the corresponding change
    39  * listener method. There is no guarantee that calling a changeX method will
    39  * listener method. There is no guarantee that calling a changeX method will
    40  * actually change the setting (e.g. if you're not room chief).
    40  * actually change the setting (e.g. if you're not room chief).
    41  * 
    41  *
    42  * For local games, getChiefStatus is always true.
    42  * For local games, getChiefStatus is always true.
    43  * 
    43  *
    44  * Implementations of this interface are probably not thread safe and should
    44  * Implementations of this interface are probably not thread safe and should
    45  * only be used on the UI thread.
    45  * only be used on the UI thread.
    46  */
    46  */
    47 public interface RoomStateManager {
    47 public interface RoomStateManager {
    48 	// Query current state
    48     // Query current state
    49 	MapRecipe getMapRecipe();
    49     MapRecipe getMapRecipe();
    50 	boolean getChiefStatus();
    50     boolean getChiefStatus();
    51 	Scheme getScheme();
    51     Scheme getScheme();
    52 	String getGameStyle();
    52     String getGameStyle();
    53 	Weaponset getWeaponset();
    53     Weaponset getWeaponset();
    54 	Map<String, TeamInGame> getTeams();
    54     Map<String, TeamInGame> getTeams();
    55 	
       
    56 	// Manipulate state
       
    57 	void changeMapRecipe(MapRecipe map);
       
    58 	void changeMapTheme(String theme);
       
    59 
    55 
    60 	/**
    56     // Manipulate state
    61 	 * This function sets both the map's name and generator. There is no function
    57     void changeMapRecipe(MapRecipe map);
    62 	 * to change them independendly since e.g. the QtFrontend relies on them being
    58     void changeMapTheme(String theme);
    63 	 * consistent.
    59 
    64 	 * 
    60     /**
    65 	 * If the name parameter is equal to one of the MapRecipe.MAPNAME_REGULAR, MAPNAME_MAZE
    61      * This function sets both the map's name and generator. There is no function
    66 	 * or MAPNAME_DRAWN constants, the map generator is set accordingly. Otherwise, the
    62      * to change them independendly since e.g. the QtFrontend relies on them being
    67 	 * map generator is set to represent a mapfile. The map's name is always set to
    63      * consistent.
    68 	 * the parameter.
    64      *
    69 	 */
    65      * If the name parameter is equal to one of the MapRecipe.MAPNAME_REGULAR, MAPNAME_MAZE
    70 	void changeMapNameAndGenerator(String mapName);
    66      * or MAPNAME_DRAWN constants, the map generator is set accordingly. Otherwise, the
    71 	void changeMapTemplate(int template);
    67      * map generator is set to represent a mapfile. The map's name is always set to
    72 	void changeMazeSize(int mazeSize);
    68      * the parameter.
    73 	void changeMapSeed(String seed);
    69      */
    74 	void changeMapDrawdata(byte[] drawdata);
    70     void changeMapNameAndGenerator(String mapName);
    75 	
    71     void changeMapTemplate(int template);
    76 	void changeScheme(Scheme scheme);
    72     void changeMazeSize(int mazeSize);
    77 	void changeGameStyle(String style);
    73     void changeMapSeed(String seed);
    78 	void changeWeaponset(Weaponset weaponset);
    74     void changeMapDrawdata(byte[] drawdata);
    79 	
    75 
    80 	void requestAddTeam(Team team, int colorIndex);
    76     void changeScheme(Scheme scheme);
    81 	void requestRemoveTeam(String teamname);
    77     void changeGameStyle(String style);
    82 	void changeTeamColorIndex(String teamname, int colorIndex);
    78     void changeWeaponset(Weaponset weaponset);
    83 	void changeTeamHogCount(String teamname, int hogcount);
    79 
    84 	
    80     void requestAddTeam(Team team, int colorIndex);
    85 	// Observe changes
    81     void requestRemoveTeam(String teamname);
    86 	void addListener(Listener observer);
    82     void changeTeamColorIndex(String teamname, int colorIndex);
    87 	void removeListener(Listener observer);
    83     void changeTeamHogCount(String teamname, int hogcount);
    88 	
    84 
    89 	public interface Listener {
    85     // Observe changes
    90 		void onMapChanged(MapRecipe recipe);
    86     void addListener(Listener observer);
    91 		void onChiefStatusChanged(boolean isChief);
    87     void removeListener(Listener observer);
    92 		void onSchemeChanged(Scheme scheme);
    88 
    93 		void onGameStyleChanged(String gameStyle);
    89     public interface Listener {
    94 		void onWeaponsetChanged(Weaponset weaponset);
    90         void onMapChanged(MapRecipe recipe);
    95 		void onTeamsChanged(Map<String, TeamInGame> teams);
    91         void onChiefStatusChanged(boolean isChief);
    96 	}
    92         void onSchemeChanged(Scheme scheme);
    97 	
    93         void onGameStyleChanged(String gameStyle);
    98 	public static class ListenerAdapter implements Listener {
    94         void onWeaponsetChanged(Weaponset weaponset);
    99 		public void onMapChanged(MapRecipe recipe) {}
    95         void onTeamsChanged(Map<String, TeamInGame> teams);
   100 		public void onChiefStatusChanged(boolean isChief) {}
    96     }
   101 		public void onSchemeChanged(Scheme scheme) {}
    97 
   102 		public void onGameStyleChanged(String gameStyle) {}
    98     public static class ListenerAdapter implements Listener {
   103 		public void onWeaponsetChanged(Weaponset weaponset) {}
    99         public void onMapChanged(MapRecipe recipe) {}
   104 		public void onTeamsChanged(Map<String, TeamInGame> teams) {}
   100         public void onChiefStatusChanged(boolean isChief) {}
   105 	}
   101         public void onSchemeChanged(Scheme scheme) {}
   106 	
   102         public void onGameStyleChanged(String gameStyle) {}
   107 	public interface Provider {
   103         public void onWeaponsetChanged(Weaponset weaponset) {}
   108 		RoomStateManager getRoomStateManager();
   104         public void onTeamsChanged(Map<String, TeamInGame> teams) {}
   109 	}
   105     }
       
   106 
       
   107     public interface Provider {
       
   108         RoomStateManager getRoomStateManager();
       
   109     }
   110 }
   110 }