author | darkvater |
Tue, 17 Aug 2004 15:31:04 +0000 | |
changeset 74 | d23a80ef6361 |
parent 0 | 29654efe3188 |
child 105 | 44e894da0fef |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
3 |
||
4 |
#include "window.h" |
|
5 |
#include "gui.h" |
|
6 |
#include "viewport.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "player.h" |
|
9 |
#include "command.h" |
|
10 |
||
11 |
extern void MakeNewGame(); |
|
12 |
extern void StartScenario(); |
|
13 |
||
14 |
/* |
|
15 |
static void ShowSelectTutorialWindow() |
|
16 |
{ |
|
17 |
} |
|
18 |
*/ |
|
19 |
||
20 |
static const Widget _select_game_widgets[] = { |
|
74
d23a80ef6361
(svn r75) -Add proper crediting to graphics artists to about box.
darkvater
parents:
0
diff
changeset
|
21 |
{ WWT_CAPTION, 13, 0, 335, 0, 13, STR_0307_OPENTTD}, |
0 | 22 |
{ WWT_IMGBTN, 13, 0, 335, 14, 196, 0x0}, |
23 |
{ WWT_PUSHTXTBTN, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME}, |
|
24 |
{ WWT_PUSHTXTBTN, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME_FROM}, |
|
25 |
//{ WWT_PUSHTXTBTN, 12, 10, 167, 177, 188, STR_0142_TUTORIAL_DEMONSTRATION, STR_02FD_VIEW_DEMONSTRATIONS_TUTORIALS}, |
|
26 |
{ WWT_PUSHTXTBTN, 12, 10, 167, 177, 188, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP}, |
|
27 |
{ WWT_PUSHTXTBTN, 12, 10, 167, 40, 51, STR_0220_CREATE_SCENARIO, STR_02FE_CREATE_A_CUSTOMIZED_GAME}, |
|
28 |
{ WWT_PUSHTXTBTN, 12, 10, 167, 136, 147, STR_SINGLE_PLAYER, STR_02FF_SELECT_SINGLE_PLAYER_GAME}, |
|
29 |
{ WWT_PUSHTXTBTN, 12, 168, 325, 136, 147, STR_MULTIPLAYER, STR_0300_SELECT_TWO_PLAYER_GAME}, |
|
30 |
{ WWT_PUSHTXTBTN, 12, 10, 167, 159, 170, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS}, |
|
31 |
{ WWT_PUSHTXTBTN, 12, 168, 325, 159, 170, STR_01FE_DIFFICULTY,STR_0302_DISPLAY_DIFFICULTY_OPTIONS}, |
|
32 |
{ WWT_PUSHTXTBTN, 12, 168, 325, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING}, |
|
74
d23a80ef6361
(svn r75) -Add proper crediting to graphics artists to about box.
darkvater
parents:
0
diff
changeset
|
33 |
{ WWT_PUSHTXTBTN, 12, 168, 325, 177, 188, STR_0304_QUIT, STR_0305_LEAVE_OPENTTD}, |
0 | 34 |
{ WWT_PANEL_2, 12, 10, 85, 69, 122, 0x1312, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
35 |
{ WWT_PANEL_2, 12, 90, 165, 69, 122, 0x1314, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
|
36 |
{ WWT_PANEL_2, 12, 170, 245, 69, 122, 0x1316, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
|
37 |
{ WWT_PANEL_2, 12, 250, 325, 69, 122, 0x1318, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
|
38 |
{ WWT_LAST}, |
|
39 |
}; |
|
40 |
||
41 |
static void SelectGameWndProc(Window *w, WindowEvent *e) { |
|
42 |
switch(e->event) { |
|
43 |
case WE_PAINT: |
|
44 |
w->click_state = (w->click_state & ~(0xC0) & ~(0xF << 12)) | (1 << (_new_opt.landscape+12)) | (!_networking?(1<<6):(1<<7)); |
|
45 |
w->disabled_state = _networking ? 0x30 : 0; |
|
46 |
SET_DPARAM16(0, STR_6801_EASY + _new_opt.diff_level); |
|
47 |
DrawWindowWidgets(w); |
|
48 |
break; |
|
49 |
||
50 |
case WE_CLICK: |
|
51 |
switch(e->click.widget) { |
|
52 |
case 2: DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME); break; |
|
53 |
case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break; |
|
54 |
case 4: ShowPatchesSelection(); break; |
|
55 |
case 5: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break; |
|
56 |
case 6: |
|
57 |
if (_networking) |
|
58 |
DoCommandP(0, 0, 0, NULL, CMD_SET_SINGLE_PLAYER); |
|
59 |
break; |
|
60 |
case 7: |
|
61 |
ShowNetworkGameWindow(); |
|
62 |
break; |
|
63 |
case 8: ShowGameOptions(); break; |
|
64 |
case 9: ShowGameDifficulty(); break; |
|
65 |
case 10:ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
|
66 |
case 11:AskExitGame(); break; |
|
67 |
case 12: case 13: case 14: case 15: |
|
68 |
DoCommandP(0, e->click.widget - 12, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE); |
|
69 |
break; |
|
70 |
} |
|
71 |
break; |
|
72 |
} |
|
73 |
} |
|
74 |
||
75 |
static const WindowDesc _select_game_desc = { |
|
76 |
WDP_CENTER, WDP_CENTER, 336, 197, |
|
77 |
WC_SELECT_GAME,0, |
|
78 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
79 |
_select_game_widgets, |
|
80 |
SelectGameWndProc |
|
81 |
}; |
|
82 |
||
83 |
void ShowSelectGameWindow() |
|
84 |
{ |
|
85 |
AllocateWindowDesc(&_select_game_desc); |
|
86 |
} |
|
87 |
||
88 |
||
89 |
// p1 = mode |
|
90 |
// 0 - start new game |
|
91 |
// 1 - close new game dialog |
|
92 |
||
93 |
int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
94 |
{ |
|
95 |
if (!(flags & DC_EXEC)) |
|
96 |
return 0; |
|
97 |
||
98 |
switch(p1) { |
|
99 |
case 0: // show select game window |
|
100 |
AskForNewGameToStart(); |
|
101 |
break; |
|
102 |
case 1: // close select game window |
|
103 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
104 |
break; |
|
105 |
} |
|
106 |
||
107 |
return 0; |
|
108 |
} |
|
109 |
||
110 |
int32 CmdGenRandomNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
111 |
{ |
|
112 |
if (!(flags & DC_EXEC)) |
|
113 |
return 0; |
|
114 |
||
115 |
// this forces stuff into test mode. |
|
116 |
_docommand_recursive = 0; |
|
117 |
||
118 |
_random_seed_1 = p1; |
|
119 |
_random_seed_2 = p2; |
|
120 |
||
121 |
if (_networking) { NetworkStartSync(); } |
|
122 |
||
123 |
MakeNewGame(); |
|
124 |
return 0; |
|
125 |
} |
|
126 |
||
127 |
int32 CmdLoadGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
128 |
{ |
|
129 |
if (!(flags & DC_EXEC)) |
|
130 |
return 0; |
|
131 |
||
132 |
// ShowSaveLoadDialog(0); |
|
133 |
return 0; |
|
134 |
} |
|
135 |
||
136 |
int32 CmdCreateScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
137 |
{ |
|
138 |
if (!(flags & DC_EXEC)) |
|
139 |
return 0; |
|
140 |
||
141 |
_switch_mode = SM_EDITOR; |
|
142 |
return 0; |
|
143 |
} |
|
144 |
||
145 |
int32 CmdSetSinglePlayer(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
146 |
{ |
|
147 |
printf("CmdSetSinglePlayer\n"); |
|
148 |
return 0; |
|
149 |
} |
|
150 |
||
151 |
int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
152 |
{ |
|
153 |
if (!(flags & DC_EXEC)) |
|
154 |
return 0; |
|
155 |
||
156 |
// this forces stuff into test mode. |
|
157 |
_docommand_recursive = 0; |
|
158 |
||
159 |
_random_seed_1 = p1; |
|
160 |
_random_seed_2 = p2; |
|
161 |
||
162 |
if (_networking) { NetworkStartSync(); } |
|
163 |
||
164 |
StartScenario(); |
|
165 |
return 0; |
|
166 |
} |
|
167 |
||
168 |
||
169 |
static const Widget _ask_abandon_game_widgets[] = { |
|
170 |
{ WWT_TEXTBTN, 4, 0, 10, 0, 13, STR_00C5}, |
|
171 |
{ WWT_CAPTION, 4, 11, 179, 0, 13, STR_00C7_QUIT}, |
|
172 |
{ WWT_IMGBTN, 4, 0, 179, 14, 91, 0x0}, |
|
173 |
{ WWT_TEXTBTN, 12, 25, 84, 72, 83, STR_00C9_NO}, |
|
174 |
{ WWT_TEXTBTN, 12, 95, 154, 72, 83, STR_00C8_YES}, |
|
175 |
{ WWT_LAST}, |
|
176 |
}; |
|
177 |
||
178 |
static void AskAbandonGameWndProc(Window *w, WindowEvent *e) { |
|
179 |
switch(e->event) { |
|
180 |
case WE_PAINT: |
|
181 |
DrawWindowWidgets(w); |
|
182 |
#if defined(_WIN32) |
|
183 |
SET_DPARAM16(0, STR_0133_WINDOWS); |
|
184 |
#elif defined(__APPLE__) |
|
185 |
SET_DPARAM16(0, STR_0135_OSX); |
|
186 |
#elif defined(__BEOS__) |
|
187 |
SET_DPARAM16(0, STR_OSNAME_BEOS); |
|
188 |
#elif defined(__MORPHOS__) |
|
189 |
SET_DPARAM16(0, STR_OSNAME_MORPHOS); |
|
190 |
#else |
|
191 |
SET_DPARAM16(0, STR_0134_UNIX); |
|
192 |
#endif |
|
193 |
DrawStringMultiCenter(0x5A, 0x26, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178); |
|
194 |
return; |
|
195 |
||
196 |
case WE_CLICK: |
|
197 |
switch(e->click.widget) { |
|
198 |
case 3: |
|
199 |
DeleteWindow(w); |
|
200 |
break; |
|
201 |
case 4: |
|
202 |
_exit_game = true; |
|
203 |
break; |
|
204 |
} |
|
205 |
break; |
|
206 |
} |
|
207 |
} |
|
208 |
||
209 |
static const WindowDesc _ask_abandon_game_desc = { |
|
210 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
211 |
WC_ASK_ABANDON_GAME,0, |
|
212 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
213 |
_ask_abandon_game_widgets, |
|
214 |
AskAbandonGameWndProc |
|
215 |
}; |
|
216 |
||
217 |
void AskExitGame() |
|
218 |
{ |
|
219 |
AllocateWindowDescFront(&_ask_abandon_game_desc, 0); |
|
220 |
} |
|
221 |
||
222 |
||
223 |
static const Widget _ask_quit_game_widgets[] = { |
|
224 |
{ WWT_TEXTBTN, 4, 0, 10, 0, 13, STR_00C5}, |
|
225 |
{ WWT_CAPTION, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME}, |
|
226 |
{ WWT_IMGBTN, 4, 0, 179, 14, 91, 0x0}, |
|
227 |
{ WWT_TEXTBTN, 12, 25, 84, 72, 83, STR_00C9_NO}, |
|
228 |
{ WWT_TEXTBTN, 12, 95, 154, 72, 83, STR_00C8_YES}, |
|
229 |
{ WWT_LAST}, |
|
230 |
}; |
|
231 |
||
232 |
static void AskQuitGameWndProc(Window *w, WindowEvent *e) { |
|
233 |
switch(e->event) { |
|
234 |
case WE_PAINT: |
|
235 |
DrawWindowWidgets(w); |
|
236 |
DrawStringMultiCenter(0x5A, 0x26, |
|
237 |
_game_mode != GM_EDITOR ? STR_0160_ARE_YOU_SURE_YOU_WANT_TO : |
|
238 |
STR_029B_ARE_YOU_SURE_YOU_WANT_TO, |
|
239 |
178); |
|
240 |
return; |
|
241 |
||
242 |
case WE_CLICK: |
|
243 |
switch(e->click.widget) { |
|
244 |
case 3: |
|
245 |
DeleteWindow(w); |
|
246 |
break; |
|
247 |
case 4: |
|
248 |
_switch_mode = SM_MENU; |
|
249 |
break; |
|
250 |
} |
|
251 |
break; |
|
252 |
} |
|
253 |
} |
|
254 |
||
255 |
static const WindowDesc _ask_quit_game_desc = { |
|
256 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
257 |
WC_QUIT_GAME,0, |
|
258 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
259 |
_ask_quit_game_widgets, |
|
260 |
AskQuitGameWndProc |
|
261 |
}; |
|
262 |
||
263 |
||
264 |
void AskExitToGameMenu() |
|
265 |
{ |
|
266 |
AllocateWindowDescFront(&_ask_quit_game_desc, 0); |
|
267 |
} |
|
268 |
||
269 |
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
270 |
{ |
|
271 |
if (flags & DC_EXEC) { |
|
272 |
// XXX: some stuff |
|
273 |
_new_opt.landscape = p1; |
|
274 |
InvalidateWindowClasses(WC_SELECT_GAME); |
|
275 |
} |
|
276 |
return 0; |
|
277 |
} |