author | Darkvater |
Thu, 21 Apr 2005 16:20:38 +0000 | |
changeset 1717 | 967d110db3e3 |
parent 1711 | 786fc0df2b6e |
child 1728 | 7cd90080eff5 |
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 |
|
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
15 |
#if 0 |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
16 |
static void ShowSelectTutorialWindow() {} |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
17 |
#endif |
0 | 18 |
|
19 |
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
|
20 |
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL}, |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
21 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 335, 14, 196, STR_NULL, 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
|
22 |
{ 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
|
23 |
{ 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
|
24 |
{ 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
|
25 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING}, |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
26 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 10, 86, 59, 113, 0x1312, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
27 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 90, 166, 59, 113, 0x1314, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
28 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 170, 246, 59, 113, 0x1316, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
29 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 250, 326, 59, 113, 0x1318, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
30 |
|
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
31 |
{ WWT_PANEL, RESIZE_NONE, 12, 219, 254, 120, 131, STR_NULL, STR_NULL}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
32 |
{ WWT_CLOSEBOX, RESIZE_NONE, 12, 255, 266, 120, 131, STR_0225, STR_NULL}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
33 |
{ WWT_PANEL, RESIZE_NONE, 12, 279, 314, 120, 131, STR_NULL, STR_NULL}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
34 |
{ WWT_CLOSEBOX, RESIZE_NONE, 12, 315, 326, 120, 131, STR_0225, STR_NULL}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
35 |
|
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
36 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 138, 149, STR_SINGLE_PLAYER, STR_02FF_SELECT_SINGLE_PLAYER_GAME}, |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
37 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 138, 149, STR_MULTIPLAYER, STR_0300_SELECT_MULTIPLAYER_GAME}, |
1625
debcaaef0ccc
(svn r2129) Reverted r2125 and depending revisions (map size selector in the intro window). Will be done in a separate dialog. This also fixes showing of various rail/road-related strings.
pasky
parents:
1624
diff
changeset
|
38 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 159, 170, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS}, |
debcaaef0ccc
(svn r2129) Reverted r2125 and depending revisions (map size selector in the intro window). Will be done in a separate dialog. This also fixes showing of various rail/road-related strings.
pasky
parents:
1624
diff
changeset
|
39 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 159, 170, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS}, |
debcaaef0ccc
(svn r2129) Reverted r2125 and depending revisions (map size selector in the intro window). Will be done in a separate dialog. This also fixes showing of various rail/road-related strings.
pasky
parents:
1624
diff
changeset
|
40 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 177, 188, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP}, |
debcaaef0ccc
(svn r2129) Reverted r2125 and depending revisions (map size selector in the intro window). Will be done in a separate dialog. This also fixes showing of various rail/road-related strings.
pasky
parents:
1624
diff
changeset
|
41 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 177, 188, 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
|
42 |
{ WIDGETS_END }, |
0 | 43 |
}; |
44 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
45 |
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
|
46 |
extern void HandleOnEditTextCancel(void); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
47 |
|
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
48 |
static void SelectGameWndProc(Window *w, WindowEvent *e) |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
49 |
{ |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
50 |
/* We do +/- 6 for the map_xy because 64 is 2^6, but it is the lowest available element */ |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
51 |
static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID}; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
52 |
|
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
53 |
switch (e->event) { |
0 | 54 |
case WE_PAINT: |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
55 |
w->click_state = (w->click_state & ~(1 << 14) & ~(0xF << 6)) | (1 << (_opt_newgame.landscape + 6)) | (1 << 14); |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1390
diff
changeset
|
56 |
SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level); |
0 | 57 |
DrawWindowWidgets(w); |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
58 |
|
1717
967d110db3e3
(svn r2221) - Fix: "Map size" is two words. Also draw the string right-aligned in the intro gui so it doesn't matter how long it is in other languages.
Darkvater
parents:
1711
diff
changeset
|
59 |
DrawStringRightAligned(216, 121, STR_MAPSIZE, 0); |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
60 |
DrawString(223, 121, mapsizes[_patches.map_x - 6], 0x10); |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
61 |
DrawString(270, 121, STR_BY, 0); |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
62 |
DrawString(283, 121, mapsizes[_patches.map_y - 6], 0x10); |
0 | 63 |
break; |
64 |
||
65 |
case WE_CLICK: |
|
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
66 |
switch (e->click.widget) { |
0 | 67 |
case 2: DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME); break; |
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
// 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
|
73 |
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
|
74 |
break; |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
75 |
case 10: case 11: /* Mapsize X */ |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
76 |
ShowDropDownMenu(w, mapsizes, _patches.map_x - 6, 11, 0, 0); |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
77 |
break; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
78 |
case 12: case 13: /* Mapsize Y */ |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
79 |
ShowDropDownMenu(w, mapsizes, _patches.map_y - 6, 13, 0, 0); |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
80 |
break; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
81 |
case 15: |
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
82 |
#ifdef ENABLE_NETWORK |
105 | 83 |
if (!_network_available) { |
774
258c11431acb
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
770
diff
changeset
|
84 |
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
|
85 |
} 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
|
86 |
ShowNetworkGameWindow(); |
1620
02ca79396482
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
87 |
#else |
774
258c11431acb
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
770
diff
changeset
|
88 |
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
|
89 |
#endif |
0 | 90 |
break; |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
91 |
case 16: ShowGameOptions(); break; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
92 |
case 17: ShowGameDifficulty(); break; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
93 |
case 18: ShowPatchesSelection(); break; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
94 |
case 19: 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
|
95 |
} |
0 | 96 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
97 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
98 |
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
99 |
case WE_ON_EDIT_TEXT_CANCEL: HandleOnEditTextCancel(); break; |
1711
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
100 |
|
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
101 |
case WE_DROPDOWN_SELECT: /* Mapsize selection */ |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
102 |
switch (e->dropdown.button) { |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
103 |
case 11: _patches.map_x = e->dropdown.index + 6; break; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
104 |
case 13: _patches.map_y = e->dropdown.index + 6; break; |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
105 |
} |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
106 |
SetWindowDirty(w); |
786fc0df2b6e
(svn r2215) - Feature: Add a temporary mapsize selector to the intro gui. This is sufficient until the real window is designed & coded.
Darkvater
parents:
1625
diff
changeset
|
107 |
break; |
0 | 108 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
109 |
|
0 | 110 |
} |
111 |
||
112 |
static const WindowDesc _select_game_desc = { |
|
1625
debcaaef0ccc
(svn r2129) Reverted r2125 and depending revisions (map size selector in the intro window). Will be done in a separate dialog. This also fixes showing of various rail/road-related strings.
pasky
parents:
1624
diff
changeset
|
113 |
WDP_CENTER, WDP_CENTER, 336, 197, |
0 | 114 |
WC_SELECT_GAME,0, |
115 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
116 |
_select_game_widgets, |
|
117 |
SelectGameWndProc |
|
118 |
}; |
|
119 |
||
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
|
120 |
void ShowSelectGameWindow(void) |
0 | 121 |
{ |
122 |
AllocateWindowDesc(&_select_game_desc); |
|
123 |
} |
|
124 |
||
125 |
||
126 |
// p1 = mode |
|
127 |
// 0 - start new game |
|
128 |
// 1 - close new game dialog |
|
129 |
||
130 |
int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
131 |
{ |
|
132 |
if (!(flags & DC_EXEC)) |
|
133 |
return 0; |
|
134 |
||
135 |
switch(p1) { |
|
136 |
case 0: // show select game window |
|
137 |
AskForNewGameToStart(); |
|
138 |
break; |
|
139 |
case 1: // close select game window |
|
140 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
141 |
break; |
|
142 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
143 |
|
0 | 144 |
return 0; |
145 |
} |
|
146 |
||
147 |
int32 CmdGenRandomNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
148 |
{ |
|
149 |
if (!(flags & DC_EXEC)) |
|
150 |
return 0; |
|
151 |
||
152 |
// this forces stuff into test mode. |
|
153 |
_docommand_recursive = 0; |
|
154 |
||
206 | 155 |
_random_seeds[0][0] = p1; |
156 |
_random_seeds[0][1] = p2; |
|
0 | 157 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
158 |
SwitchMode(SM_NEWGAME); |
0 | 159 |
return 0; |
160 |
} |
|
161 |
||
162 |
int32 CmdLoadGame(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
163 |
{ |
|
164 |
if (!(flags & DC_EXEC)) |
|
165 |
return 0; |
|
166 |
||
167 |
// ShowSaveLoadDialog(0); |
|
168 |
return 0; |
|
169 |
} |
|
170 |
||
171 |
int32 CmdCreateScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
172 |
{ |
|
173 |
if (!(flags & DC_EXEC)) |
|
174 |
return 0; |
|
175 |
||
176 |
_switch_mode = SM_EDITOR; |
|
177 |
return 0; |
|
178 |
} |
|
179 |
||
180 |
int32 CmdSetSinglePlayer(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
181 |
{ |
|
182 |
printf("CmdSetSinglePlayer\n"); |
|
183 |
return 0; |
|
184 |
} |
|
185 |
||
186 |
int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
187 |
{ |
|
188 |
if (!(flags & DC_EXEC)) |
|
189 |
return 0; |
|
190 |
||
191 |
// this forces stuff into test mode. |
|
192 |
_docommand_recursive = 0; |
|
193 |
||
206 | 194 |
_random_seeds[0][0] = p1; |
195 |
_random_seeds[0][1] = p2; |
|
0 | 196 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
197 |
SwitchMode(SM_START_SCENARIO); |
0 | 198 |
return 0; |
199 |
} |
|
200 |
||
201 |
||
202 |
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
|
203 |
{ 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
|
204 |
{ 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
|
205 |
{ 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
|
206 |
{ 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
|
207 |
{ 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
|
208 |
{ WIDGETS_END }, |
0 | 209 |
}; |
210 |
||
211 |
static void AskAbandonGameWndProc(Window *w, WindowEvent *e) { |
|
212 |
switch(e->event) { |
|
213 |
case WE_PAINT: |
|
214 |
DrawWindowWidgets(w); |
|
215 |
#if defined(_WIN32) |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
216 |
SetDParam(0, STR_0133_WINDOWS); |
0 | 217 |
#elif defined(__APPLE__) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
218 |
SetDParam(0, STR_0135_OSX); |
0 | 219 |
#elif defined(__BEOS__) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
220 |
SetDParam(0, STR_OSNAME_BEOS); |
0 | 221 |
#elif defined(__MORPHOS__) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
222 |
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
|
223 |
#elif defined(__AMIGA__) |
587 | 224 |
SetDParam(0, STR_OSNAME_AMIGAOS); |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
774
diff
changeset
|
225 |
#elif defined(__OS2__) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
774
diff
changeset
|
226 |
SetDParam(0, STR_OSNAME_OS2); |
0 | 227 |
#else |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
228 |
SetDParam(0, STR_0134_UNIX); |
0 | 229 |
#endif |
230 |
DrawStringMultiCenter(0x5A, 0x26, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178); |
|
231 |
return; |
|
232 |
||
233 |
case WE_CLICK: |
|
234 |
switch(e->click.widget) { |
|
235 |
case 3: |
|
236 |
DeleteWindow(w); |
|
237 |
break; |
|
238 |
case 4: |
|
239 |
_exit_game = true; |
|
240 |
break; |
|
241 |
} |
|
242 |
break; |
|
161
74453c59315c
(svn r162) -Feature: when exit game window pops up, 'Enter' quits the game
darkvater
parents:
129
diff
changeset
|
243 |
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
|
244 |
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
|
245 |
_exit_game = true; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
246 |
break; |
0 | 247 |
} |
248 |
} |
|
249 |
||
250 |
static const WindowDesc _ask_abandon_game_desc = { |
|
251 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
252 |
WC_ASK_ABANDON_GAME,0, |
|
253 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
254 |
_ask_abandon_game_widgets, |
|
255 |
AskAbandonGameWndProc |
|
256 |
}; |
|
257 |
||
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
|
258 |
void AskExitGame(void) |
0 | 259 |
{ |
260 |
AllocateWindowDescFront(&_ask_abandon_game_desc, 0); |
|
261 |
} |
|
262 |
||
263 |
||
264 |
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
|
265 |
{ 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
|
266 |
{ 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
|
267 |
{ 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
|
268 |
{ 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
|
269 |
{ 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
|
270 |
{ WIDGETS_END }, |
0 | 271 |
}; |
272 |
||
273 |
static void AskQuitGameWndProc(Window *w, WindowEvent *e) { |
|
274 |
switch(e->event) { |
|
275 |
case WE_PAINT: |
|
276 |
DrawWindowWidgets(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
277 |
DrawStringMultiCenter(0x5A, 0x26, |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
278 |
_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
|
279 |
STR_029B_ARE_YOU_SURE_YOU_WANT_TO, |
0 | 280 |
178); |
281 |
return; |
|
282 |
||
283 |
case WE_CLICK: |
|
284 |
switch(e->click.widget) { |
|
285 |
case 3: |
|
286 |
DeleteWindow(w); |
|
287 |
break; |
|
288 |
case 4: |
|
289 |
_switch_mode = SM_MENU; |
|
290 |
break; |
|
291 |
} |
|
292 |
break; |
|
661
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
293 |
|
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
294 |
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
|
295 |
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
|
296 |
_switch_mode = SM_MENU; |
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
297 |
break; |
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
298 |
|
0 | 299 |
} |
300 |
} |
|
301 |
||
302 |
static const WindowDesc _ask_quit_game_desc = { |
|
303 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
304 |
WC_QUIT_GAME,0, |
|
305 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
306 |
_ask_quit_game_widgets, |
|
307 |
AskQuitGameWndProc |
|
308 |
}; |
|
309 |
||
310 |
||
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
|
311 |
void AskExitToGameMenu(void) |
0 | 312 |
{ |
313 |
AllocateWindowDescFront(&_ask_quit_game_desc, 0); |
|
314 |
} |
|
315 |
||
316 |
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
317 |
{ |
|
318 |
if (flags & DC_EXEC) { |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1390
diff
changeset
|
319 |
_opt_newgame.landscape = p1; |
0 | 320 |
InvalidateWindowClasses(WC_SELECT_GAME); |
321 |
} |
|
322 |
return 0; |
|
323 |
} |