~ubuntu-branches/ubuntu/raring/hedgewars/raring-backports

« back to all changes in this revision

Viewing changes to project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/RoomStateManager.java

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-06-21 17:55:04 UTC
  • mfrom: (19.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20130621175504-otv451gi461tj4bn
Tags: 0.9.19.3-1~ubuntu13.04.1
No-change backport to raring (LP: #1191816)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
 
3
 * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
package org.hedgewars.hedgeroid;
 
21
 
 
22
import java.util.Map;
 
23
 
 
24
import org.hedgewars.hedgeroid.Datastructures.MapRecipe;
 
25
import org.hedgewars.hedgeroid.Datastructures.Scheme;
 
26
import org.hedgewars.hedgeroid.Datastructures.Team;
 
27
import org.hedgewars.hedgeroid.Datastructures.TeamInGame;
 
28
import org.hedgewars.hedgeroid.Datastructures.Weaponset;
 
29
 
 
30
/**
 
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
 
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
 
35
 * memory, while they have to be sent out to the server for networked games.
 
36
 * 
 
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
 
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).
 
41
 * 
 
42
 * For local games, getChiefStatus is always true.
 
43
 * 
 
44
 * Implementations of this interface are probably not thread safe and should
 
45
 * only be used on the UI thread.
 
46
 */
 
47
public interface RoomStateManager {
 
48
        // Query current state
 
49
        MapRecipe getMapRecipe();
 
50
        boolean getChiefStatus();
 
51
        Scheme getScheme();
 
52
        String getGameStyle();
 
53
        Weaponset getWeaponset();
 
54
        Map<String, TeamInGame> getTeams();
 
55
        
 
56
        // Manipulate state
 
57
        void changeMapRecipe(MapRecipe map);
 
58
        void changeMapTheme(String theme);
 
59
 
 
60
        /**
 
61
         * This function sets both the map's name and generator. There is no function
 
62
         * to change them independendly since e.g. the QtFrontend relies on them being
 
63
         * consistent.
 
64
         * 
 
65
         * If the name parameter is equal to one of the MapRecipe.MAPNAME_REGULAR, MAPNAME_MAZE
 
66
         * or MAPNAME_DRAWN constants, the map generator is set accordingly. Otherwise, the
 
67
         * map generator is set to represent a mapfile. The map's name is always set to
 
68
         * the parameter.
 
69
         */
 
70
        void changeMapNameAndGenerator(String mapName);
 
71
        void changeMapTemplate(int template);
 
72
        void changeMazeSize(int mazeSize);
 
73
        void changeMapSeed(String seed);
 
74
        void changeMapDrawdata(byte[] drawdata);
 
75
        
 
76
        void changeScheme(Scheme scheme);
 
77
        void changeGameStyle(String style);
 
78
        void changeWeaponset(Weaponset weaponset);
 
79
        
 
80
        void requestAddTeam(Team team, int colorIndex);
 
81
        void requestRemoveTeam(String teamname);
 
82
        void changeTeamColorIndex(String teamname, int colorIndex);
 
83
        void changeTeamHogCount(String teamname, int hogcount);
 
84
        
 
85
        // Observe changes
 
86
        void addListener(Listener observer);
 
87
        void removeListener(Listener observer);
 
88
        
 
89
        public interface Listener {
 
90
                void onMapChanged(MapRecipe recipe);
 
91
                void onChiefStatusChanged(boolean isChief);
 
92
                void onSchemeChanged(Scheme scheme);
 
93
                void onGameStyleChanged(String gameStyle);
 
94
                void onWeaponsetChanged(Weaponset weaponset);
 
95
                void onTeamsChanged(Map<String, TeamInGame> teams);
 
96
        }
 
97
        
 
98
        public static class ListenerAdapter implements Listener {
 
99
                public void onMapChanged(MapRecipe recipe) {}
 
100
                public void onChiefStatusChanged(boolean isChief) {}
 
101
                public void onSchemeChanged(Scheme scheme) {}
 
102
                public void onGameStyleChanged(String gameStyle) {}
 
103
                public void onWeaponsetChanged(Weaponset weaponset) {}
 
104
                public void onTeamsChanged(Map<String, TeamInGame> teams) {}
 
105
        }
 
106
        
 
107
        public interface Provider {
 
108
                RoomStateManager getRoomStateManager();
 
109
        }
 
110
}