| author | dominik |
| Mon, 23 Aug 2004 07:50:01 +0000 | |
| changeset 114 | 6a2af0c2d0db |
| parent 105 | 44e894da0fef |
| child 126 | 152df0cc4ac2 |
| 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: |
|
| 105 | 61 |
if (!_network_available) {
|
62 |
ShowErrorMessage(-1,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); |
|
63 |
} else ShowNetworkGameWindow(); |
|
| 0 | 64 |
break; |
65 |
case 8: ShowGameOptions(); break; |
|
66 |
case 9: ShowGameDifficulty(); break; |
|
67 |
case 10:ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
|
68 |
case 11:AskExitGame(); break; |
|
69 |
case 12: case 13: case 14: case 15: |
|
70 |
DoCommandP(0, e->click.widget - 12, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE); |
|
71 |
break; |
|
72 |
} |
|
73 |
break; |
|
74 |
} |
|
75 |
} |
|
76 |
||
77 |
static const WindowDesc _select_game_desc = {
|
|
78 |
WDP_CENTER, WDP_CENTER, 336, 197, |
|
79 |
WC_SELECT_GAME,0, |
|
80 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
81 |
_select_game_widgets, |
|
82 |
SelectGameWndProc |
|
83 |
}; |
|
84 |
||
85 |
void ShowSelectGameWindow() |
|
86 |
{
|
|
87 |
AllocateWindowDesc(&_select_game_desc); |
|
88 |
} |
|
89 |
||
90 |
||
91 |
// p1 = mode |
|
92 |
// 0 - start new game |
|
93 |
// 1 - close new game dialog |
|
94 |
||
95 |
int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
96 |
{
|
|
97 |
if (!(flags & DC_EXEC)) |
|
98 |
return 0; |
|
99 |
||
100 |
switch(p1) {
|
|
101 |
case 0: // show select game window |
|
102 |
AskForNewGameToStart(); |
|
103 |
break; |
|
104 |
case 1: // close select game window |
|
105 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
106 |
break; |
|
107 |
} |
|
108 |
||
109 |
return 0; |
|
110 |
} |
|
111 |
||
112 |
int32 CmdGenRandomNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
113 |
{
|
|
114 |
if (!(flags & DC_EXEC)) |
|
115 |
return 0; |
|
116 |
||
117 |
// this forces stuff into test mode. |
|
118 |
_docommand_recursive = 0; |
|
119 |
||
120 |
_random_seed_1 = p1; |
|
121 |
_random_seed_2 = p2; |
|
122 |
||
| 105 | 123 |
if (_networking) { NetworkStartSync(true); }
|
| 0 | 124 |
|
125 |
MakeNewGame(); |
|
126 |
return 0; |
|
127 |
} |
|
128 |
||
129 |
int32 CmdLoadGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
130 |
{
|
|
131 |
if (!(flags & DC_EXEC)) |
|
132 |
return 0; |
|
133 |
||
134 |
// ShowSaveLoadDialog(0); |
|
135 |
return 0; |
|
136 |
} |
|
137 |
||
138 |
int32 CmdCreateScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
139 |
{
|
|
140 |
if (!(flags & DC_EXEC)) |
|
141 |
return 0; |
|
142 |
||
143 |
_switch_mode = SM_EDITOR; |
|
144 |
return 0; |
|
145 |
} |
|
146 |
||
147 |
int32 CmdSetSinglePlayer(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
148 |
{
|
|
149 |
printf("CmdSetSinglePlayer\n");
|
|
150 |
return 0; |
|
151 |
} |
|
152 |
||
153 |
int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
154 |
{
|
|
155 |
if (!(flags & DC_EXEC)) |
|
156 |
return 0; |
|
157 |
||
158 |
// this forces stuff into test mode. |
|
159 |
_docommand_recursive = 0; |
|
160 |
||
161 |
_random_seed_1 = p1; |
|
162 |
_random_seed_2 = p2; |
|
163 |
||
| 105 | 164 |
if (_networking) { NetworkStartSync(true); }
|
| 0 | 165 |
|
166 |
StartScenario(); |
|
167 |
return 0; |
|
168 |
} |
|
169 |
||
170 |
||
171 |
static const Widget _ask_abandon_game_widgets[] = {
|
|
172 |
{ WWT_TEXTBTN, 4, 0, 10, 0, 13, STR_00C5},
|
|
173 |
{ WWT_CAPTION, 4, 11, 179, 0, 13, STR_00C7_QUIT},
|
|
174 |
{ WWT_IMGBTN, 4, 0, 179, 14, 91, 0x0},
|
|
175 |
{ WWT_TEXTBTN, 12, 25, 84, 72, 83, STR_00C9_NO},
|
|
176 |
{ WWT_TEXTBTN, 12, 95, 154, 72, 83, STR_00C8_YES},
|
|
177 |
{ WWT_LAST},
|
|
178 |
}; |
|
179 |
||
180 |
static void AskAbandonGameWndProc(Window *w, WindowEvent *e) {
|
|
181 |
switch(e->event) {
|
|
182 |
case WE_PAINT: |
|
183 |
DrawWindowWidgets(w); |
|
184 |
#if defined(_WIN32) |
|
185 |
SET_DPARAM16(0, STR_0133_WINDOWS); |
|
186 |
#elif defined(__APPLE__) |
|
187 |
SET_DPARAM16(0, STR_0135_OSX); |
|
188 |
#elif defined(__BEOS__) |
|
189 |
SET_DPARAM16(0, STR_OSNAME_BEOS); |
|
190 |
#elif defined(__MORPHOS__) |
|
191 |
SET_DPARAM16(0, STR_OSNAME_MORPHOS); |
|
192 |
#else |
|
193 |
SET_DPARAM16(0, STR_0134_UNIX); |
|
194 |
#endif |
|
195 |
DrawStringMultiCenter(0x5A, 0x26, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178); |
|
196 |
return; |
|
197 |
||
198 |
case WE_CLICK: |
|
199 |
switch(e->click.widget) {
|
|
200 |
case 3: |
|
201 |
DeleteWindow(w); |
|
202 |
break; |
|
203 |
case 4: |
|
204 |
_exit_game = true; |
|
205 |
break; |
|
206 |
} |
|
207 |
break; |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
static const WindowDesc _ask_abandon_game_desc = {
|
|
212 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
213 |
WC_ASK_ABANDON_GAME,0, |
|
214 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
215 |
_ask_abandon_game_widgets, |
|
216 |
AskAbandonGameWndProc |
|
217 |
}; |
|
218 |
||
219 |
void AskExitGame() |
|
220 |
{
|
|
221 |
AllocateWindowDescFront(&_ask_abandon_game_desc, 0); |
|
222 |
} |
|
223 |
||
224 |
||
225 |
static const Widget _ask_quit_game_widgets[] = {
|
|
226 |
{ WWT_TEXTBTN, 4, 0, 10, 0, 13, STR_00C5},
|
|
227 |
{ WWT_CAPTION, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME},
|
|
228 |
{ WWT_IMGBTN, 4, 0, 179, 14, 91, 0x0},
|
|
229 |
{ WWT_TEXTBTN, 12, 25, 84, 72, 83, STR_00C9_NO},
|
|
230 |
{ WWT_TEXTBTN, 12, 95, 154, 72, 83, STR_00C8_YES},
|
|
231 |
{ WWT_LAST},
|
|
232 |
}; |
|
233 |
||
234 |
static void AskQuitGameWndProc(Window *w, WindowEvent *e) {
|
|
235 |
switch(e->event) {
|
|
236 |
case WE_PAINT: |
|
237 |
DrawWindowWidgets(w); |
|
238 |
DrawStringMultiCenter(0x5A, 0x26, |
|
239 |
_game_mode != GM_EDITOR ? STR_0160_ARE_YOU_SURE_YOU_WANT_TO : |
|
240 |
STR_029B_ARE_YOU_SURE_YOU_WANT_TO, |
|
241 |
178); |
|
242 |
return; |
|
243 |
||
244 |
case WE_CLICK: |
|
245 |
switch(e->click.widget) {
|
|
246 |
case 3: |
|
247 |
DeleteWindow(w); |
|
248 |
break; |
|
249 |
case 4: |
|
250 |
_switch_mode = SM_MENU; |
|
251 |
break; |
|
252 |
} |
|
253 |
break; |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
static const WindowDesc _ask_quit_game_desc = {
|
|
258 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
259 |
WC_QUIT_GAME,0, |
|
260 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
261 |
_ask_quit_game_widgets, |
|
262 |
AskQuitGameWndProc |
|
263 |
}; |
|
264 |
||
265 |
||
266 |
void AskExitToGameMenu() |
|
267 |
{
|
|
268 |
AllocateWindowDescFront(&_ask_quit_game_desc, 0); |
|
269 |
} |
|
270 |
||
271 |
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
272 |
{
|
|
273 |
if (flags & DC_EXEC) {
|
|
274 |
// XXX: some stuff |
|
275 |
_new_opt.landscape = p1; |
|
276 |
InvalidateWindowClasses(WC_SELECT_GAME); |
|
277 |
} |
|
278 |
return 0; |
|
279 |
} |