author | tron |
Tue, 27 Jun 2006 21:25:53 +0000 | |
changeset 4077 | d4d440dd8925 |
parent 3888 | 3cbfc7edbc2b |
child 4171 | 5c6e60c392c3 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1796
diff
changeset
|
4 |
#include "openttd.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
206
diff
changeset
|
5 |
#include "table/strings.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
0 | 7 |
#include "window.h" |
8 |
#include "gui.h" |
|
9 |
#include "gfx.h" |
|
10 |
#include "player.h" |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
11 |
#include "network.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1891
diff
changeset
|
12 |
#include "variables.h" |
3888
3cbfc7edbc2b
(svn r4944) Codechange: make _patches_newgame available via settings.h and remove instances of extern Patches _patches_newgame in .c files
rubidium
parents:
3207
diff
changeset
|
13 |
#include "settings.h" |
0 | 14 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
15 |
extern void SwitchMode(int new_mode); |
0 | 16 |
|
17 |
static const Widget _select_game_widgets[] = { |
|
1618
70408b5c4e28
(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
|
18 |
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL}, |
1711
1365fd255634
(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
|
19 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 335, 14, 196, STR_NULL, STR_NULL}, |
1618
70408b5c4e28
(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_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME}, |
70408b5c4e28
(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
|
21 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME}, |
70408b5c4e28
(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, 40, 51, STR_0220_CREATE_SCENARIO,STR_02FE_CREATE_A_CUSTOMIZED_GAME}, |
1619
11108fa4b24d
(svn r2123) Reordered _select_game_widets[] to follow a sensible order.
pasky
parents:
1618
diff
changeset
|
23 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING}, |
1711
1365fd255634
(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
|
24 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 10, 86, 59, 113, 0x1312, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
1365fd255634
(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
|
25 |
{ WWT_PANEL_2, RESIZE_NONE, 12, 90, 166, 59, 113, 0x1314, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
1365fd255634
(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, 170, 246, 59, 113, 0x1316, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
1365fd255634
(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, 250, 326, 59, 113, 0x1318, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
1365fd255634
(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 |
|
1365fd255634
(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, RESIZE_NONE, 12, 219, 254, 120, 131, STR_NULL, STR_NULL}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
30 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 255, 266, 120, 131, STR_0225, STR_NULL}, |
1711
1365fd255634
(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, 279, 314, 120, 131, STR_NULL, STR_NULL}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
32 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 315, 326, 120, 131, STR_0225, STR_NULL}, |
1711
1365fd255634
(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 |
|
1365fd255634
(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_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 138, 149, STR_SINGLE_PLAYER, STR_02FF_SELECT_SINGLE_PLAYER_GAME}, |
1365fd255634
(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 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 138, 149, STR_MULTIPLAYER, STR_0300_SELECT_MULTIPLAYER_GAME}, |
1625
c2849df304da
(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
|
36 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 159, 170, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS}, |
c2849df304da
(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
|
37 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 159, 170, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS}, |
c2849df304da
(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, 177, 188, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP}, |
c2849df304da
(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, 177, 188, STR_0304_QUIT, STR_0305_QUIT_OPENTTD}, |
1618
70408b5c4e28
(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
|
40 |
{ WIDGETS_END }, |
0 | 41 |
}; |
42 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
43 |
extern void HandleOnEditText(WindowEvent *e); |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
44 |
extern void HandleOnEditTextCancel(void); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
45 |
|
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
46 |
static inline void CreateScenario(void) {_switch_mode = SM_EDITOR;} |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
47 |
|
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
48 |
static inline void SetNewLandscapeType(byte landscape) |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
49 |
{ |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
50 |
_opt_newgame.landscape = landscape; |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
51 |
InvalidateWindowClasses(WC_SELECT_GAME); |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
52 |
} |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
53 |
|
1711
1365fd255634
(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
|
54 |
static void SelectGameWndProc(Window *w, WindowEvent *e) |
1365fd255634
(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 |
{ |
1365fd255634
(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
|
56 |
/* We do +/- 6 for the map_xy because 64 is 2^6, but it is the lowest available element */ |
1365fd255634
(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
|
57 |
static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID}; |
1365fd255634
(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 |
|
1365fd255634
(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
|
59 |
switch (e->event) { |
0 | 60 |
case WE_PAINT: |
1711
1365fd255634
(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 |
w->click_state = (w->click_state & ~(1 << 14) & ~(0xF << 6)) | (1 << (_opt_newgame.landscape + 6)) | (1 << 14); |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1390
diff
changeset
|
62 |
SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level); |
0 | 63 |
DrawWindowWidgets(w); |
1711
1365fd255634
(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
|
64 |
|
1717
44bff152f15f
(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
|
65 |
DrawStringRightAligned(216, 121, STR_MAPSIZE, 0); |
3207
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
66 |
DrawString(223, 121, mapsizes[_patches_newgame.map_x - 6], 0x10); |
1711
1365fd255634
(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
|
67 |
DrawString(270, 121, STR_BY, 0); |
3207
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
68 |
DrawString(283, 121, mapsizes[_patches_newgame.map_y - 6], 0x10); |
0 | 69 |
break; |
70 |
||
71 |
case WE_CLICK: |
|
1711
1365fd255634
(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
|
72 |
switch (e->click.widget) { |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
73 |
case 2: AskForNewGameToStart(); break; |
0 | 74 |
case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break; |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
75 |
case 4: CreateScenario(); break; |
1619
11108fa4b24d
(svn r2123) Reordered _select_game_widets[] to follow a sensible order.
pasky
parents:
1618
diff
changeset
|
76 |
case 5: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
1620
a8b502e4b25f
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
77 |
case 6: case 7: case 8: case 9: |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
78 |
SetNewLandscapeType(e->click.widget - 6); |
1620
a8b502e4b25f
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
79 |
break; |
1711
1365fd255634
(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 |
case 10: case 11: /* Mapsize X */ |
3207
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
81 |
ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, 11, 0, 0); |
1711
1365fd255634
(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
|
82 |
break; |
1365fd255634
(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
|
83 |
case 12: case 13: /* Mapsize Y */ |
3207
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
84 |
ShowDropDownMenu(w, mapsizes, _patches_newgame.map_y - 6, 13, 0, 0); |
1711
1365fd255634
(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
|
85 |
break; |
1365fd255634
(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
|
86 |
case 15: |
1620
a8b502e4b25f
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
87 |
#ifdef ENABLE_NETWORK |
105 | 88 |
if (!_network_available) { |
2749
c9312a4a1efe
(svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents:
2725
diff
changeset
|
89 |
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3888
diff
changeset
|
90 |
} 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
|
91 |
ShowNetworkGameWindow(); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3888
diff
changeset
|
92 |
} |
1620
a8b502e4b25f
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
93 |
#else |
2749
c9312a4a1efe
(svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents:
2725
diff
changeset
|
94 |
ShowErrorMessage(INVALID_STRING_ID ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); |
1620
a8b502e4b25f
(svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents:
1619
diff
changeset
|
95 |
#endif |
0 | 96 |
break; |
1711
1365fd255634
(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
|
97 |
case 16: ShowGameOptions(); break; |
1365fd255634
(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
|
98 |
case 17: ShowGameDifficulty(); break; |
1365fd255634
(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
|
99 |
case 18: ShowPatchesSelection(); break; |
1365fd255634
(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 |
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
|
101 |
} |
0 | 102 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
103 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
104 |
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
105 |
case WE_ON_EDIT_TEXT_CANCEL: HandleOnEditTextCancel(); break; |
1711
1365fd255634
(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 |
|
1365fd255634
(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 |
case WE_DROPDOWN_SELECT: /* Mapsize selection */ |
1365fd255634
(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
|
108 |
switch (e->dropdown.button) { |
3207
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
109 |
/* We need a *hacky* here because generateworld is called with _patches |
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
110 |
* but it only gets the new value INSIDE generateworld so not setting it would |
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
111 |
* break generating a new game on the run (eg MP) */ |
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
112 |
case 11: _patches.map_x = _patches_newgame.map_x = e->dropdown.index + 6; break; |
231948813b05
(svn r3875) - [Patches] Fix up the intro menu so the right values for the mapsize are shown (the default ones). Setting the value involves a small hack in that we also set the _patches value because that is used for world-generation and only inside there do the values get copied from _newgame
Darkvater
parents:
2791
diff
changeset
|
113 |
case 13: _patches.map_y = _patches_newgame.map_y = e->dropdown.index + 6; break; |
1711
1365fd255634
(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
|
114 |
} |
1365fd255634
(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
|
115 |
SetWindowDirty(w); |
1365fd255634
(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
|
116 |
break; |
0 | 117 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
118 |
|
0 | 119 |
} |
120 |
||
121 |
static const WindowDesc _select_game_desc = { |
|
1625
c2849df304da
(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
|
122 |
WDP_CENTER, WDP_CENTER, 336, 197, |
0 | 123 |
WC_SELECT_GAME,0, |
124 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
125 |
_select_game_widgets, |
|
126 |
SelectGameWndProc |
|
127 |
}; |
|
128 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
129 |
void ShowSelectGameWindow(void) |
0 | 130 |
{ |
131 |
AllocateWindowDesc(&_select_game_desc); |
|
132 |
} |
|
133 |
||
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
134 |
void GenRandomNewGame(uint32 rnd1, uint32 rnd2) |
0 | 135 |
{ |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
136 |
_random_seeds[0][0] = rnd1; |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1728
diff
changeset
|
137 |
_random_seeds[0][1] = rnd2; |
0 | 138 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
139 |
SwitchMode(SM_NEWGAME); |
0 | 140 |
} |
141 |
||
1796
614d996f6be7
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1794
diff
changeset
|
142 |
void StartScenarioEditor(uint32 rnd1, uint32 rnd2) |
0 | 143 |
{ |
1796
614d996f6be7
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1794
diff
changeset
|
144 |
_random_seeds[0][0] = rnd1; |
614d996f6be7
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1794
diff
changeset
|
145 |
_random_seeds[0][1] = rnd2; |
0 | 146 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
147 |
SwitchMode(SM_START_SCENARIO); |
0 | 148 |
} |
149 |
||
150 |
static const Widget _ask_abandon_game_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
151 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1618
70408b5c4e28
(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
|
152 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_00C7_QUIT, STR_NULL}, |
70408b5c4e28
(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
|
153 |
{ WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL}, |
70408b5c4e28
(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
|
154 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL}, |
70408b5c4e28
(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
|
155 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL}, |
70408b5c4e28
(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
|
156 |
{ WIDGETS_END }, |
0 | 157 |
}; |
158 |
||
2639 | 159 |
static void AskAbandonGameWndProc(Window* w, WindowEvent* e) |
160 |
{ |
|
161 |
switch (e->event) { |
|
0 | 162 |
case WE_PAINT: |
163 |
DrawWindowWidgets(w); |
|
164 |
#if defined(_WIN32) |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
165 |
SetDParam(0, STR_0133_WINDOWS); |
0 | 166 |
#elif defined(__APPLE__) |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
167 |
SetDParam(0, STR_0135_OSX); |
0 | 168 |
#elif defined(__BEOS__) |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
169 |
SetDParam(0, STR_OSNAME_BEOS); |
0 | 170 |
#elif defined(__MORPHOS__) |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
171 |
SetDParam(0, STR_OSNAME_MORPHOS); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
810
diff
changeset
|
172 |
#elif defined(__AMIGA__) |
587 | 173 |
SetDParam(0, STR_OSNAME_AMIGAOS); |
810
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
774
diff
changeset
|
174 |
#elif defined(__OS2__) |
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
774
diff
changeset
|
175 |
SetDParam(0, STR_OSNAME_OS2); |
0 | 176 |
#else |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
177 |
SetDParam(0, STR_0134_UNIX); |
0 | 178 |
#endif |
2639 | 179 |
DrawStringMultiCenter(90, 38, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178); |
0 | 180 |
return; |
181 |
||
182 |
case WE_CLICK: |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
183 |
switch (e->click.widget) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
184 |
case 3: DeleteWindow(w); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
185 |
case 4: _exit_game = true; break; |
0 | 186 |
} |
187 |
break; |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
188 |
|
161
74453c59315c
(svn r162) -Feature: when exit game window pops up, 'Enter' quits the game
darkvater
parents:
129
diff
changeset
|
189 |
case WE_KEYPRESS: /* Exit game on pressing 'Enter' */ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
190 |
switch (e->keypress.keycode) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
191 |
case WKC_RETURN: |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
192 |
case WKC_NUM_ENTER: |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
193 |
_exit_game = true; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
194 |
break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2204
diff
changeset
|
195 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
196 |
break; |
0 | 197 |
} |
198 |
} |
|
199 |
||
200 |
static const WindowDesc _ask_abandon_game_desc = { |
|
201 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
202 |
WC_ASK_ABANDON_GAME,0, |
|
203 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
204 |
_ask_abandon_game_widgets, |
|
205 |
AskAbandonGameWndProc |
|
206 |
}; |
|
207 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
208 |
void AskExitGame(void) |
0 | 209 |
{ |
210 |
AllocateWindowDescFront(&_ask_abandon_game_desc, 0); |
|
211 |
} |
|
212 |
||
213 |
||
214 |
static const Widget _ask_quit_game_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
215 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1618
70408b5c4e28
(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
|
216 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME, STR_NULL}, |
70408b5c4e28
(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
|
217 |
{ WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL}, |
70408b5c4e28
(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
|
218 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL}, |
70408b5c4e28
(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
|
219 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL}, |
70408b5c4e28
(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
|
220 |
{ WIDGETS_END }, |
0 | 221 |
}; |
222 |
||
2639 | 223 |
static void AskQuitGameWndProc(Window* w, WindowEvent* e) |
224 |
{ |
|
225 |
switch (e->event) { |
|
226 |
case WE_PAINT: |
|
227 |
DrawWindowWidgets(w); |
|
228 |
DrawStringMultiCenter( |
|
229 |
90, 38, |
|
230 |
_game_mode != GM_EDITOR ? |
|
231 |
STR_0160_ARE_YOU_SURE_YOU_WANT_TO : STR_029B_ARE_YOU_SURE_YOU_WANT_TO, |
|
232 |
178 |
|
233 |
); |
|
234 |
break; |
|
0 | 235 |
|
2639 | 236 |
case WE_CLICK: |
237 |
switch (e->click.widget) { |
|
238 |
case 3: DeleteWindow(w); break; |
|
239 |
case 4: _switch_mode = SM_MENU; break; |
|
240 |
} |
|
0 | 241 |
break; |
661
0d0a151aa4cd
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
654
diff
changeset
|
242 |
|
2639 | 243 |
case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */ |
244 |
if (e->keypress.keycode == WKC_RETURN) _switch_mode = SM_MENU; |
|
245 |
break; |
|
0 | 246 |
} |
247 |
} |
|
248 |
||
249 |
static const WindowDesc _ask_quit_game_desc = { |
|
250 |
WDP_CENTER, WDP_CENTER, 180, 92, |
|
251 |
WC_QUIT_GAME,0, |
|
252 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS, |
|
253 |
_ask_quit_game_widgets, |
|
254 |
AskQuitGameWndProc |
|
255 |
}; |
|
256 |
||
257 |
||
1093
4fdc46eaf423
(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 AskExitToGameMenu(void) |
0 | 259 |
{ |
260 |
AllocateWindowDescFront(&_ask_quit_game_desc, 0); |
|
261 |
} |