summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/ISettingsPanel.java
blob: f5577e9bda736ca8aa410f2f2d3bfd4076b0f812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
package jrummikub.view;

import java.awt.Color;
import java.util.List;
import java.util.Set;

import jrummikub.model.GameSettings;
import jrummikub.model.PlayerSettings.Type;
import jrummikub.model.StoneColor;
import jrummikub.util.IEvent;
import jrummikub.util.IEvent1;
import jrummikub.util.IEvent2;

/**
 * The panel for the game setup
 */
public interface ISettingsPanel {
	/**
	 * The list of player colors
	 */
	public final static Color[] PLAYER_COLORS = { new Color(1.0f, 0, 0), // red
			new Color(0, 1.0f, 0), // lime
			new Color(1.0f, 1.0f, 0), // yellow
			new Color(0, 0, 1.0f), // blue
			new Color(1.0f, 0, 1.0f), // fuchsia
			new Color(0, 1.0f, 1.0f), // aqua
			new Color(0.5f, 0, 0), // maroon
			new Color(0, 0.5f, 0), // green
			new Color(0.5f, 0.5f, 0), // olive
			new Color(0, 0, 0.5f), // navy
			new Color(0.5f, 0, 0.5f), // purple
			new Color(0, 0.5f, 0.5f), // teal
			new Color(0, 0, 0), // black
			new Color(0.5f, 0.5f, 0.5f), // gray
			new Color(0.75f, 0.75f, 0.75f), // silver
			new Color(1.0f, 1.0f, 1.0f), // white
	};

	/**
	 * Sets the settings mode according to the point of the game
	 * 
	 * @param mode
	 *          settings mode to be set (join, offer, network, default)
	 */
	public void setSettingsMode(SettingsMode mode);

	/**
	 * The add player event is emitted when the user wants to add a player to the
	 * player list
	 * 
	 * @return the event
	 */
	public IEvent getAddPlayerEvent();

	/**
	 * The remove player event is emitted when the user wants to remove a player
	 * remove the player list
	 * 
	 * @return the event
	 */
	public IEvent1<Integer> getRemovePlayerEvent();

	/**
	 * The change player color event is emitted when the user wants change a
	 * player's color
	 * 
	 * @return the event
	 */
	public IEvent2<Integer, Color> getChangePlayerColorEvent();

	/**
	 * The change player color event is emitted when the user wants change a
	 * player's name
	 * 
	 * @return the event
	 */
	public IEvent2<Integer, String> getChangePlayerNameEvent();

	/**
	 * The change player color event is emitted when the user wants change a
	 * player's type
	 * 
	 * @return the event
	 */
	public IEvent2<Integer, Type> getChangePlayerTypeEvent();

	/**
	 * The change initial meld threshold event is emitted when the user wants
	 * change the initial meld threshold
	 * 
	 * @return the event
	 */
	public IEvent1<Integer> getChangeInitialMeldThresholdEvent();

	/**
	 * The change StoneSet number event is emitted when the user wants to use more
	 * or less than 2 StoneSets per color
	 * 
	 * @return number of SoneSets
	 */
	public IEvent1<Integer> getChangeStoneSetNumberEvent();

	/**
	 * The change number of Stones dealt event is emitted when the user wants to
	 * be dealt more or less than 14 Stones at the game start
	 * 
	 * @return number of Stones dealt
	 */
	public IEvent1<Integer> getChangeNumberOfStonesDealtEvent();

	/**
	 * The change highest value event is emitted when the user wants to set the
	 * highest Stone value
	 * 
	 * @return highest Stone value
	 */
	public IEvent1<Integer> getChangeHighestValueEvent();

	/**
	 * The change Stone colors event is emitted when the user chooses the stone
	 * colors to play with. Minimum 3, maximum 8
	 * 
	 * @return set of used StoneColors
	 */
	public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent();

	/**
	 * the start game event is emitted when the user wants to start the game
	 * 
	 * @return the event
	 */
	public IEvent getStartGameEvent();

	/**
	 * Sets an error to display
	 * 
	 * @param error
	 *          the kind of error
	 */
	public void setError(SettingsError error);

	/**
	 * Enables or disables the start game button
	 * 
	 * @param enable
	 *          specifies if the button is to be enabled or disabled
	 */
	public void enableStartGameButton(boolean enable);

	/**
	 * Enables or disables the add player button
	 * 
	 * @param enable
	 *          specifies if the button is to be enabled or disabled
	 */
	public void enableAddPlayerButton(boolean enable);

	/**
	 * Enables or disables the remove player buttons
	 * 
	 * @param enable
	 *          specifies if the buttons are to be enabled or disabled
	 */

	public void enableRemovePlayerButtons(List<Boolean> enable);

	/**
	 * Sets the game settings to display
	 * 
	 * @param gameSettings
	 *          the settings
	 */
	public void setGameSettings(GameSettings gameSettings);

	/**
	 * Emitted when the joker number is changed
	 * 
	 * @return the event
	 */
	public IEvent1<Integer> getChangeJokerNumberEvent();

	/**
	 * Emitted when totalTime for a turn is changed
	 * 
	 * @return the event
	 */
	public IEvent1<Integer> getChangeTimeEvent();

	/**
	 * Emitted when no limits is chosen
	 * 
	 * @return the event
	 */
	public IEvent1<Boolean> getChangeNoLimitsEvent();

	/**
	 * Emitted when the variables are reset to the default values
	 * 
	 * @return the event
	 */
	public IEvent getSetVariantDefaultEvent();

	/**
	 * Emitted when the children variant is chosen
	 * 
	 * @return the event
	 */
	public IEvent getSetVariantChildrenEvent();

	/**
	 * Emitted when the user wants to go back to the panel before
	 * 
	 * @return the event
	 */
	public IEvent getBackEvent();

	/**
	 * Sets the types of players allowed at the given point in game
	 * 
	 * @param choices
	 *          list of types for each player
	 */
	public void setPlayerTypeChoices(List<List<Type>> choices);

	/**
	 * Sets the names of players editable if allowed at the given point in game
	 * 
	 * @param editable
	 *          states if the players name is editable for each player
	 */
	public void setPlayerNamesEditable(List<Boolean> editable);

	/**
	 * The offer new game event is emitted when a new game is started and looking
	 * for players
	 * 
	 * @return the event
	 */
	public IEvent getOfferGameEvent();

	/**
	 * Sets the player colors which can be chosen
	 * 
	 * @param colors
	 *          a Set of colors which are not taken yet
	 */
	public void setPlayerColors(Set<Color> colors);

	/**
	 * The change see hand size event is emitted when the player chooses to see
	 * the other players hand sizes
	 * 
	 * @return the event
	 */
	public IEvent1<Boolean> getChangeSeeHandSizeEvent();

	/**
	 * Specifies the different kinds of settings errors that can be displayed
	 */
	public enum SettingsError {
		/** Everything is ok */
		NO_ERROR,
		/** A player name is used twice */
		DUPLICATE_PLAYER_NAME_ERROR,
		/** A player has an empty name */
		NO_PLAYER_NAME_ERROR,
		/** More Stones than present would be dealed */
		NOT_ENOUGH_STONES_ERROR,
		/** Less than 3 colors are selected */
		NOT_ENOUGH_COLORS_ERROR,

		// warnings
		/** threshold higher 100 */
		TOO_HIGH_THRESHOLD_WARNING,
		/** Only computer players added */
		COMPUTER_PLAYERS_ONLY_WARNING,

		// info
		/** no network players have joined */
		WAITING_FOR_PLAYERS
	}

	/**
	 * SettingsPanel can be used with different functions in different situations
	 */
	public enum SettingsMode {
		/** Local game settings */
		DEFAULT,
		/** */
		NETWORK_SETUP,
		/** */
		NETWORK_OFFER,
		/** */
		NETWORK_JOIN
	}
}