author | pasky |
Sat, 02 Apr 2005 15:59:07 +0000 | |
changeset 1623 | 30298d952174 |
parent 1621 | 8c2c67a094ec |
child 1624 | 30351c8532f9 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
206
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "window.h" |
5 |
#include "gui.h" |
|
6 |
#include "viewport.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "player.h" |
|
129
df1a60bc0d70
(svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents:
126
diff
changeset
|
9 |
#include "command.h" |
126 | 10 |
#include "console.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
11 |
#include "network.h" |
0 | 12 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
13 |
extern void SwitchMode(int new_mode); |
0 | 14 |
|
15 |
/* |
|
16 |
static void ShowSelectTutorialWindow() |
|
17 |
{ |
|
18 |
} |
|
19 |
*/ |
|
20 |
||
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
21 |
/* We go from TOP to the BOTTOM and from LEFT to the RIGHT. I know this is |
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
22 |
* a highly unusual concept, guys, but I hope you'll manage to follow. --pasky */ |
0 | 23 |
static const Widget _select_game_widgets[] = { |
1618
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
24 |
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL}, |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
25 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 335, 14, 233, 0x0, STR_NULL}, |
1618
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
26 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
27 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
28 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 40, 51, STR_0220_CREATE_SCENARIO,STR_02FE_CREATE_A_CUSTOMIZED_GAME}, |
1619
b7108dc3fb3d
(svn r2123) Reordered _select_game_widets[] to follow a sensible order.
pasky
parents:
1618
diff
changeset
|
29 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING}, |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
30 |
|
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
31 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 10, 85, 67, 120, 0x1312, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
32 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 90, 165, 67, 120, 0x1314, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
33 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 170, 245, 67, 120, 0x1316, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
34 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 250, 325, 67, 120, 0x1318, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
35 |
|
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
36 |
/* string&0x1000 shows the number encoded in the lowest 12 bits. Using |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
37 |
* just dparams gives some extremely weird results, so this is after |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
38 |
* all the most elegant solution. --pasky */ |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
39 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 57, 128, 139, 0x1040, STR_MAP_WIDTH_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
40 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 64, 111, 128, 139, 0x1080, STR_MAP_WIDTH_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
41 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 117, 164, 128, 139, 0x1100, STR_MAP_WIDTH_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
42 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 171, 218, 128, 139, 0x1200, STR_MAP_WIDTH_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
43 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 224, 271, 128, 139, 0x1400, STR_MAP_WIDTH_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
44 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 278, 325, 128, 139, 0x1800, STR_MAP_WIDTH_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
45 |
|
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
46 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 57, 144, 155, 0x1040, STR_MAP_HEIGHT_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
47 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 64, 111, 144, 155, 0x1080, STR_MAP_HEIGHT_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
48 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 117, 164, 144, 155, 0x1100, STR_MAP_HEIGHT_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
49 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 171, 218, 144, 155, 0x1200, STR_MAP_HEIGHT_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
50 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 224, 271, 144, 155, 0x1400, STR_MAP_HEIGHT_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
51 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 278, 325, 144, 155, 0x1800, STR_MAP_HEIGHT_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
52 |
|
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
53 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 173, 184, STR_SINGLE_PLAYER, STR_02FF_SELECT_SINGLE_PLAYER_GAME}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
54 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 173, 184, STR_MULTIPLAYER, STR_0300_SELECT_MULTIPLAYER_GAME}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
55 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 196, 207, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
56 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 196, 207, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
57 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 214, 225, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP}, |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
58 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 214, 225, STR_0304_QUIT, STR_0305_QUIT_OPENTTD}, |
1618
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
59 |
{ WIDGETS_END }, |
0 | 60 |
}; |
61 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
62 |
extern void HandleOnEditText(WindowEvent *e); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
63 |
extern void HandleOnEditTextCancel(void); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
64 |
|
0 | 65 |
static void SelectGameWndProc(Window *w, WindowEvent *e) { |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
66 |
switch (e->event) { |
0 | 67 |
case WE_PAINT: |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
68 |
w->click_state &= ~(1<<22) & ~(0xF << 6) & ~(0xFFF << 11); |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
69 |
w->click_state |= (1<<22) | (1 << (_opt_newgame.landscape + 6)); |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
70 |
w->click_state |= (1 << (10 + _patches.map_x - 6)) | (1 << (16 + _patches.map_y - 6)); |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1390
diff
changeset
|
71 |
SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level); |
0 | 72 |
DrawWindowWidgets(w); |
73 |
break; |
|
74 |
||
75 |
case WE_CLICK: |
|
76 |
switch(e->click.widget) { |
|
77 |
case 2: DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME); break; |
|
78 |
case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break; |
|
1619
b7108dc3fb3d
(svn r2123) Reordered _select_game_widets[] to follow a sensible order.
pasky
parents:
1618
diff
changeset
|
79 |
case 4: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break; |
b7108dc3fb3d
(svn r2123) Reordered _select_game_widets[] to follow a sensible order.
pasky
parents:
1618
diff
changeset
|
80 |
case 5: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
81 |
case 6: case 7: case 8: case 9: |
1623
30298d952174
(svn r2127) Get rid again of the CmdSetNewMapSize(), which was agreed to be just useless clutter. (Perhaps we should get rid of CmdSetNewLandscapeType() too, but I won't take responsibility for that. ;-)
pasky
parents:
1621
diff
changeset
|
82 |
// XXX: Useless usage of the CMD infrastructure? |
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
83 |
DoCommandP(0, e->click.widget - 6, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE); |
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
84 |
break; |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
85 |
case 10: case 11: case 12: case 13: case 14: case 15: |
1623
30298d952174
(svn r2127) Get rid again of the CmdSetNewMapSize(), which was agreed to be just useless clutter. (Perhaps we should get rid of CmdSetNewLandscapeType() too, but I won't take responsibility for that. ;-)
pasky
parents:
1621
diff
changeset
|
86 |
_patches.map_x = 6 + e->click.widget - 10; |
30298d952174
(svn r2127) Get rid again of the CmdSetNewMapSize(), which was agreed to be just useless clutter. (Perhaps we should get rid of CmdSetNewLandscapeType() too, but I won't take responsibility for that. ;-)
pasky
parents:
1621
diff
changeset
|
87 |
InvalidateWindowClasses(WC_SELECT_GAME); |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
88 |
break; |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
89 |
case 16: case 17: case 18: case 19: case 20: case 21: |
1623
30298d952174
(svn r2127) Get rid again of the CmdSetNewMapSize(), which was agreed to be just useless clutter. (Perhaps we should get rid of CmdSetNewLandscapeType() too, but I won't take responsibility for that. ;-)
pasky
parents:
1621
diff
changeset
|
90 |
_patches.map_y = 6 + e->click.widget - 16; |
30298d952174
(svn r2127) Get rid again of the CmdSetNewMapSize(), which was agreed to be just useless clutter. (Perhaps we should get rid of CmdSetNewLandscapeType() too, but I won't take responsibility for that. ;-)
pasky
parents:
1621
diff
changeset
|
91 |
InvalidateWindowClasses(WC_SELECT_GAME); |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
92 |
break; |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
93 |
case 23: |
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
94 |
#ifdef ENABLE_NETWORK |
105 | 95 |
if (!_network_available) { |
774
258c11431acb
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
770
diff
changeset
|
96 |
ShowErrorMessage(-1, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); |
258c11431acb
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
770
diff
changeset
|
97 |
} else |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
161
diff
changeset
|
98 |
ShowNetworkGameWindow(); |
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
99 |
#else |
774
258c11431acb
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
770
diff
changeset
|
100 |
ShowErrorMessage(-1 ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); |
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
101 |
#endif |
0 | 102 |
break; |
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
103 |
case 24: ShowGameOptions(); break; |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
104 |
case 25: ShowGameDifficulty(); break; |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
105 |
case 26: ShowPatchesSelection(); break; |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
106 |
case 27: AskExitGame(); break; |
129
df1a60bc0d70
(svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents:
126
diff
changeset
|
107 |
} |
0 | 108 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
109 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
110 |
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
111 |
case WE_ON_EDIT_TEXT_CANCEL: HandleOnEditTextCancel(); break; |
0 | 112 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
113 |
|
0 | 114 |
} |
115 |
||
116 |
static const WindowDesc _select_game_desc = { |
|
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
117 |
WDP_CENTER, WDP_CENTER, 336, 234, |
0 | 118 |
WC_SELECT_GAME,0, |
119 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
120 |
_select_game_widgets, |
|
121 |
SelectGameWndProc |
|
122 |
}; |
|
123 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
124 |
void ShowSelectGameWindow(void) |
0 | 125 |
{ |
126 |
AllocateWindowDesc(&_select_game_desc); |
|
127 |
} |
|
128 |
||
129 |
||
130 |
// p1 = mode |
|
131 |
// 0 - start new game |
|
132 |
// 1 - close new game dialog |
|
133 |
||
134 |
int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
135 |
{ |
|
136 |
if (!(flags & DC_EXEC)) |
|
137 |
return 0; |
|
138 |
||
139 |
switch(p1) { |
|
140 |
case 0: // show select game window |
|
141 |
AskForNewGameToStart(); |
|
142 |
break; |
|
143 |
case 1: // close select game window |
|
144 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
145 |
break; |
|
146 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
147 |
|
0 | 148 |
return 0; |
149 |
} |
|
150 |
||
151 |
int32 CmdGenRandomNewGame(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 |
||
206 | 159 |
_random_seeds[0][0] = p1; |
160 |
_random_seeds[0][1] = p2; |
|
0 | 161 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
162 |
SwitchMode(SM_NEWGAME); |
0 | 163 |
return 0; |
164 |
} |
|
165 |
||
166 |
int32 CmdLoadGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
167 |
{ |
|
168 |
if (!(flags & DC_EXEC)) |
|
169 |
return 0; |
|
170 |
||
171 |
// ShowSaveLoadDialog(0); |
|
172 |
return 0; |
|
173 |
} |
|
174 |
||
175 |
int32 CmdCreateScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
176 |
{ |
|
177 |
if (!(flags & DC_EXEC)) |
|
178 |
return 0; |
|
179 |
||
180 |
_switch_mode = SM_EDITOR; |
|
181 |
return 0; |
|
182 |
} |
|
183 |
||
184 |
int32 CmdSetSinglePlayer(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
185 |
{ |
|
186 |
printf("CmdSetSinglePlayer\n"); |
|
187 |
return 0; |
|
188 |
} |
|
189 |
||
190 |
int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
191 |
{ |
|
192 |
if (!(flags & DC_EXEC)) |
|
193 |
return 0; |
|
194 |
||
195 |
// this forces stuff into test mode. |
|
196 |
_docommand_recursive = 0; |
|
197 |
||
206 | 198 |
_random_seeds[0][0] = p1; |
199 |
_random_seeds[0][1] = p2; |
|
0 | 200 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
201 |
SwitchMode(SM_START_SCENARIO); |
0 | 202 |
return 0; |
203 |
} |
|
204 |
||
205 |
||
206 |
static const Widget _ask_abandon_game_widgets[] = { |
|
1618
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
207 |
{ WWT_TEXTBTN, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
208 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_00C7_QUIT, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
209 |
{ WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
210 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
211 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
212 |
{ WIDGETS_END }, |
0 | 213 |
}; |
214 |
||
215 |
static void AskAbandonGameWndProc(Window *w, WindowEvent *e) { |
|
216 |
switch(e->event) { |
|
217 |
case WE_PAINT: |
|
218 |
DrawWindowWidgets(w); |
|
219 |
#if defined(_WIN32) |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
220 |
SetDParam(0, STR_0133_WINDOWS); |
0 | 221 |
#elif defined(__APPLE__) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
222 |
SetDParam(0, STR_0135_OSX); |
0 | 223 |
#elif defined(__BEOS__) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
224 |
SetDParam(0, STR_OSNAME_BEOS); |
0 | 225 |
#elif defined(__MORPHOS__) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
226 |
SetDParam(0, STR_OSNAME_MORPHOS); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
810
diff
changeset
|
227 |
#elif defined(__AMIGA__) |
587 | 228 |
SetDParam(0, STR_OSNAME_AMIGAOS); |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
774
diff
changeset
|
229 |
#elif defined(__OS2__) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
774
diff
changeset
|
230 |
SetDParam(0, STR_OSNAME_OS2); |
0 | 231 |
#else |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
232 |
SetDParam(0, STR_0134_UNIX); |
0 | 233 |
#endif |
234 |
DrawStringMultiCenter(0x5A, 0x26, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178); |
|
235 |
return; |
|
236 |
||
237 |
case WE_CLICK: |
|
238 |
switch(e->click.widget) { |
|
239 |
case 3: |
|
240 |
DeleteWindow(w); |
|
241 |
break; |
|
242 |
case 4: |
|
243 |
_exit_game = true; |
|
244 |
break; |
|
245 |
} |
|
246 |
break; |
|
161
74453c59315c
(svn r162) -Feature: when exit game window pops up, 'Enter' quits the game
darkvater
parents:
129
diff
changeset
|
247 |
case WE_KEYPRESS: /* Exit game on pressing 'Enter' */ |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1093
diff
changeset
|
248 |
if (e->keypress.keycode == WKC_RETURN || e->keypress.keycode == WKC_NUM_ENTER) |
161
74453c59315c
(svn r162) -Feature: when exit game window pops up, 'Enter' quits the game
darkvater
parents:
129
diff
changeset
|
249 |
_exit_game = true; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
250 |
break; |
0 | 251 |
} |
252 |
} |
|
253 |
||
254 |
static const WindowDesc _ask_abandon_game_desc = { |
|
255 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
256 |
WC_ASK_ABANDON_GAME,0, |
|
257 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
258 |
_ask_abandon_game_widgets, |
|
259 |
AskAbandonGameWndProc |
|
260 |
}; |
|
261 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
262 |
void AskExitGame(void) |
0 | 263 |
{ |
264 |
AllocateWindowDescFront(&_ask_abandon_game_desc, 0); |
|
265 |
} |
|
266 |
||
267 |
||
268 |
static const Widget _ask_quit_game_widgets[] = { |
|
1618
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
269 |
{ WWT_TEXTBTN, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
270 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
271 |
{ WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
272 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
273 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL}, |
0aff378a53ec
(svn r2122) Reformatted the widget tables so that they don't look so ugly anymore, especially with different tab widths than 2.
pasky
parents:
1500
diff
changeset
|
274 |
{ WIDGETS_END }, |
0 | 275 |
}; |
276 |
||
277 |
static void AskQuitGameWndProc(Window *w, WindowEvent *e) { |
|
278 |
switch(e->event) { |
|
279 |
case WE_PAINT: |
|
280 |
DrawWindowWidgets(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
281 |
DrawStringMultiCenter(0x5A, 0x26, |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
282 |
_game_mode != GM_EDITOR ? STR_0160_ARE_YOU_SURE_YOU_WANT_TO : |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
283 |
STR_029B_ARE_YOU_SURE_YOU_WANT_TO, |
0 | 284 |
178); |
285 |
return; |
|
286 |
||
287 |
case WE_CLICK: |
|
288 |
switch(e->click.widget) { |
|
289 |
case 3: |
|
290 |
DeleteWindow(w); |
|
291 |
break; |
|
292 |
case 4: |
|
293 |
_switch_mode = SM_MENU; |
|
294 |
break; |
|
295 |
} |
|
296 |
break; |
|
661
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
297 |
|
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
298 |
case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */ |
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
299 |
if (e->keypress.keycode == WKC_RETURN) |
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
300 |
_switch_mode = SM_MENU; |
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
301 |
break; |
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
302 |
|
0 | 303 |
} |
304 |
} |
|
305 |
||
306 |
static const WindowDesc _ask_quit_game_desc = { |
|
307 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
308 |
WC_QUIT_GAME,0, |
|
309 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
310 |
_ask_quit_game_widgets, |
|
311 |
AskQuitGameWndProc |
|
312 |
}; |
|
313 |
||
314 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
315 |
void AskExitToGameMenu(void) |
0 | 316 |
{ |
317 |
AllocateWindowDescFront(&_ask_quit_game_desc, 0); |
|
318 |
} |
|
319 |
||
320 |
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
321 |
{ |
|
322 |
if (flags & DC_EXEC) { |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1390
diff
changeset
|
323 |
_opt_newgame.landscape = p1; |
0 | 324 |
InvalidateWindowClasses(WC_SELECT_GAME); |
325 |
} |
|
326 |
return 0; |
|
327 |
} |
|
1621
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
328 |
|
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
329 |
int32 CmdSetNewMapSize(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
330 |
{ |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
331 |
if (flags & DC_EXEC) { |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
332 |
} |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
333 |
return 0; |
8c2c67a094ec
(svn r2125) - Feature: In the intro dialog, show a map size selector below the landscape type selector.
pasky
parents:
1620
diff
changeset
|
334 |
} |