intro_gui.c
author rubidium
Tue, 22 Aug 2006 14:38:37 +0000
changeset 4344 5d0e40cd67b9
parent 4308 61f5aa8143f6
child 4512 7151d4ee3a0f
permissions -rw-r--r--
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1796
diff changeset
     4
#include "openttd.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 206
diff changeset
     5
#include "table/strings.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     6
#include "functions.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "player.h"
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
    11
#include "network.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1891
diff changeset
    12
#include "variables.h"
3888
7a781a439c30 (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"
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    14
#include "heightmap.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    15
#include "genworld.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
static const Widget _select_game_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    18
{    WWT_CAPTION, RESIZE_NONE, 13,   0, 335,   0,  13, STR_0307_OPENTTD,         STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    19
{     WWT_IMGBTN, RESIZE_NONE, 13,   0, 335,  14, 176, STR_NULL,                 STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    20
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167,  22,  33, STR_0140_NEW_GAME,        STR_02FB_START_A_NEW_GAME},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    21
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325,  22,  33, STR_0141_LOAD_GAME,       STR_02FC_LOAD_A_SAVED_GAME},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    22
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167,  40,  51, STR_029A_PLAY_SCENARIO,   STR_0303_START_A_NEW_GAME_USING},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    23
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325,  40,  51, STR_PLAY_HEIGHTMAP,       STR_PLAY_HEIGHTMAP_HINT},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    24
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167,  58,  69, STR_0220_CREATE_SCENARIO, STR_02FE_CREATE_A_CUSTOMIZED_GAME},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    25
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325,  58,  69, STR_MULTIPLAYER,          STR_0300_SELECT_MULTIPLAYER_GAME},
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
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    27
{    WWT_PANEL_2, RESIZE_NONE, 12,  10,  86,  77, 131, 0x1312,                   STR_030E_SELECT_TEMPERATE_LANDSCAPE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    28
{    WWT_PANEL_2, RESIZE_NONE, 12,  90, 166,  77, 131, 0x1314,                   STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    29
{    WWT_PANEL_2, RESIZE_NONE, 12, 170, 246,  77, 131, 0x1316,                   STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    30
{    WWT_PANEL_2, RESIZE_NONE, 12, 250, 326,  77, 131, 0x1318,                   STR_0311_SELECT_TOYLAND_LANDSCAPE},
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
    31
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    32
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167, 139, 150, STR_0148_GAME_OPTIONS,    STR_0301_DISPLAY_GAME_OPTIONS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    33
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 139, 150, STR_01FE_DIFFICULTY,      STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    34
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167, 157, 168, STR_CONFIG_PATCHES,       STR_CONFIG_PATCHES_TIP},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4308
diff changeset
    35
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 157, 168, 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
    36
{    WIDGETS_END },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
    39
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
    40
extern void HandleOnEditTextCancel(void);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
    41
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    42
static inline void SetNewLandscapeType(byte landscape)
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    43
{
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    44
	_opt_newgame.landscape = landscape;
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    45
	InvalidateWindowClasses(WC_SELECT_GAME);
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    46
}
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
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
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	case WE_PAINT:
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    52
		w->click_state = (w->click_state & ~(0xF << 8)) | (1 << (_opt_newgame.landscape + 8));
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1390
diff changeset
    53
		SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	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
    58
		switch (e->click.widget) {
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    59
		case 2: ShowGenerateLandscape(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
		case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    61
		case 4: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    62
		case 5: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    63
		case 6: ShowCreateScenario(); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    64
		case 7:
1620
02ca79396482 (svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents: 1619
diff changeset
    65
#ifdef ENABLE_NETWORK
105
44e894da0fef (svn r106) New network core (by sign_de)
dominik
parents: 74
diff changeset
    66
			if (!_network_available) {
2749
46aba09ca365 (svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents: 2725
diff changeset
    67
				ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3888
diff changeset
    68
			} 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
    69
				ShowNetworkGameWindow();
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3888
diff changeset
    70
			}
1620
02ca79396482 (svn r2124) Final _select_game_widgets[] reordering, even landscape panels in place now.
pasky
parents: 1619
diff changeset
    71
#else
2749
46aba09ca365 (svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents: 2725
diff changeset
    72
			ShowErrorMessage(INVALID_STRING_ID ,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
    73
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
			break;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    75
		case 8: case 9: case 10: case 11:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    76
			SetNewLandscapeType(e->click.widget - 8);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    77
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    78
		case 12: ShowGameOptions(); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    79
		case 13: ShowGameDifficulty(); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    80
		case 14: ShowPatchesSelection(); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    81
		case 15: 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
    82
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
		break;
4308
61f5aa8143f6 (svn r5955) -Fix r5728: 2 very important lines for ShowQueryString where removed by excident.
truelight
parents: 4300
diff changeset
    84
61f5aa8143f6 (svn r5955) -Fix r5728: 2 very important lines for ShowQueryString where removed by excident.
truelight
parents: 4300
diff changeset
    85
		case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
61f5aa8143f6 (svn r5955) -Fix r5728: 2 very important lines for ShowQueryString where removed by excident.
truelight
parents: 4300
diff changeset
    86
		case WE_ON_EDIT_TEXT_CANCEL: HandleOnEditTextCancel(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
static const WindowDesc _select_game_desc = {
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    91
	WDP_CENTER, WDP_CENTER, 336, 177,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	WC_SELECT_GAME,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	_select_game_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	SelectGameWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
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
    98
void ShowSelectGameWindow(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	AllocateWindowDesc(&_select_game_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
static const Widget _ask_abandon_game_widgets[] = {
2725
5c632bc5be28 (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
   104
{ WWT_CLOSEBOX, RESIZE_NONE,  4,   0,  10,   0,  13, STR_00C5,      STR_018B_CLOSE_WINDOW},
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
   105
{  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
   106
{   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
   107
{  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
   108
{  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
   109
{  WIDGETS_END },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   112
static void AskAbandonGameWndProc(Window *w, WindowEvent *e)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   113
{
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   114
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
#if defined(_WIN32)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   118
		SetDParam(0, STR_0133_WINDOWS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
#elif defined(__APPLE__)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   120
		SetDParam(0, STR_0135_OSX);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
#elif defined(__BEOS__)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   122
		SetDParam(0, STR_OSNAME_BEOS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
#elif defined(__MORPHOS__)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   124
		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
   125
#elif defined(__AMIGA__)
587
2fa4963eb92c (svn r1007) Remove the last SET_DPARAM (:
tron
parents: 569
diff changeset
   126
		SetDParam(0, STR_OSNAME_AMIGAOS);
810
7c51ba5a4368 (svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents: 774
diff changeset
   127
#elif defined(__OS2__)
7c51ba5a4368 (svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents: 774
diff changeset
   128
		SetDParam(0, STR_OSNAME_OS2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
#else
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   130
		SetDParam(0, STR_0134_UNIX);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
#endif
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   132
		DrawStringMultiCenter(90, 38, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	case WE_CLICK:
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   136
		switch (e->click.widget) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   137
			case 3: DeleteWindow(w);   break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   138
			case 4: _exit_game = true; break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
		break;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   141
161
74453c59315c (svn r162) -Feature: when exit game window pops up, 'Enter' quits the game
darkvater
parents: 129
diff changeset
   142
	case WE_KEYPRESS: /* Exit game on pressing 'Enter' */
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   143
		switch (e->keypress.keycode) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   144
			case WKC_RETURN:
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   145
			case WKC_NUM_ENTER:
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   146
				_exit_game = true;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   147
				break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2204
diff changeset
   148
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   149
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
static const WindowDesc _ask_abandon_game_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	WDP_CENTER, WDP_CENTER, 180, 92,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
	WC_ASK_ABANDON_GAME,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	_ask_abandon_game_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	AskAbandonGameWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
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
   161
void AskExitGame(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	AllocateWindowDescFront(&_ask_abandon_game_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
static const Widget _ask_quit_game_widgets[] = {
2725
5c632bc5be28 (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
   168
{ WWT_CLOSEBOX, RESIZE_NONE,  4,   0,  10,   0,  13, STR_00C5,           STR_018B_CLOSE_WINDOW},
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
   169
{  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
   170
{   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
   171
{  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
   172
{  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
   173
{  WIDGETS_END },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   176
static void AskQuitGameWndProc(Window *w, WindowEvent *e)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   177
{
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   178
	switch (e->event) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   179
		case WE_PAINT:
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   180
			DrawWindowWidgets(w);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   181
			DrawStringMultiCenter(
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   182
				90, 38,
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   183
				_game_mode != GM_EDITOR ?
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   184
					STR_0160_ARE_YOU_SURE_YOU_WANT_TO : STR_029B_ARE_YOU_SURE_YOU_WANT_TO,
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   185
				178
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   186
			);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   187
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   189
		case WE_CLICK:
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   190
			switch (e->click.widget) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   191
				case 3: DeleteWindow(w);        break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   192
				case 4: _switch_mode = SM_MENU; break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   193
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
			break;
661
a0bdbdffb06a (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 654
diff changeset
   195
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   196
		case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   197
			if (e->keypress.keycode == WKC_RETURN) _switch_mode = SM_MENU;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   198
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
static const WindowDesc _ask_quit_game_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	WDP_CENTER, WDP_CENTER, 180, 92,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
	WC_QUIT_GAME,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
	_ask_quit_game_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
	AskQuitGameWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
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
   211
void AskExitToGameMenu(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
	AllocateWindowDescFront(&_ask_quit_game_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
}