src/intro_gui.cpp
author KUDr
Sun, 04 Mar 2007 22:36:22 +0000
branchcpp_gui
changeset 6289 be3d8bd9fb02
parent 6286 6e8eec87fa9d
child 6298 c30fe89622df
permissions -rw-r--r--
(svn r9010) [cpp_gui] -Add: Sticky button widget
-Codechange: part of widget.h moved to separate file widget_types.h to minimize dependencies
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
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6283
diff changeset
     3
/** @file intro_gui.cpp */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6283
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1796
diff changeset
     6
#include "openttd.h"
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4830
diff changeset
     7
#include "table/sprites.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     8
#include "functions.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "player.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    13
#include "network/network.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1891
diff changeset
    14
#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
    15
#include "settings.h"
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    16
#include "heightmap.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    17
#include "genworld.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    18
#include "network/network_gui.h"
5237
c14c97d7030a (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    19
#include "newgrf.h"
6289
be3d8bd9fb02 (svn r9010) [cpp_gui] -Add: Sticky button widget
KUDr
parents: 6286
diff changeset
    20
#include "widget/widget_types.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
    22
static const OldWidget _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
    23
{    WWT_CAPTION, RESIZE_NONE, 13,   0, 335,   0,  13, STR_0307_OPENTTD,         STR_NULL},
5237
c14c97d7030a (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    24
{      WWT_PANEL, RESIZE_NONE, 13,   0, 335,  14, 194, 0x0,                      STR_NULL},
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
    25
{ 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
    26
{ 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
    27
{ 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
    28
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325,  40,  51, STR_PLAY_HEIGHTMAP,       STR_PLAY_HEIGHTMAP_HINT},
6145
d34703513ed0 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 6144
diff changeset
    29
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167,  58,  69, STR_SCENARIO_EDITOR,      STR_02FE_CREATE_A_CUSTOMIZED_GAME},
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
    30
{ 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
    31
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
    32
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  10,  86,  77, 131, SPR_SELECT_TEMPERATE,     STR_030E_SELECT_TEMPERATE_LANDSCAPE},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
    33
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  90, 166,  77, 131, SPR_SELECT_SUB_ARCTIC,    STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
    34
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246,  77, 131, SPR_SELECT_SUB_TROPICAL,  STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
    35
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326,  77, 131, SPR_SELECT_TOYLAND,       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
    36
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
    37
{ 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
    38
{ 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
    39
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167, 157, 168, STR_CONFIG_PATCHES,       STR_CONFIG_PATCHES_TIP},
5237
c14c97d7030a (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    40
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 157, 168, STR_NEWGRF_SETTINGS_BUTTON, STR_NULL},
c14c97d7030a (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    41
5315
ce659994e392 (svn r7471) -Codechange: Centre the 'quit' button on the main menu.
Darkvater
parents: 5237
diff changeset
    42
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 104, 231, 175, 186, STR_0304_QUIT,            STR_0305_QUIT_OPENTTD},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
    43
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    46
static inline void SetNewLandscapeType(byte landscape)
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    47
{
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    48
	_opt_newgame.landscape = landscape;
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    49
	InvalidateWindowClasses(WC_SELECT_GAME);
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    50
}
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    51
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
    52
static void SelectGameWndProc(BaseWindow *w, WindowEvent *e)
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
    53
{
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
    54
	switch (e->event) {
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6241
diff changeset
    55
	case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + 8); break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
    56
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	case WE_PAINT:
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6241
diff changeset
    58
		w->SetWidgetLoweredState(8,  _opt_newgame.landscape == LT_NORMAL);
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6241
diff changeset
    59
		w->SetWidgetLoweredState(9,  _opt_newgame.landscape == LT_HILLY);
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6241
diff changeset
    60
		w->SetWidgetLoweredState(10, _opt_newgame.landscape == LT_DESERT);
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6241
diff changeset
    61
		w->SetWidgetLoweredState(11, _opt_newgame.landscape == LT_CANDY);
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1390
diff changeset
    62
		SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6150
diff changeset
    63
		w->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
    67
		switch (e->we.click.widget) {
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    68
		case 2: ShowGenerateLandscape(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
		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
    70
		case 4: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    71
		case 5: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
6150
648233476115 (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 6145
diff changeset
    72
		case 6: StartScenarioEditor(); break;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    73
		case 7:
105
44e894da0fef (svn r106) New network core (by sign_de)
dominik
parents: 74
diff changeset
    74
			if (!_network_available) {
2749
46aba09ca365 (svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents: 2725
diff changeset
    75
				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
    76
			} 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
    77
				ShowNetworkGameWindow();
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3888
diff changeset
    78
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
			break;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    80
		case 8: case 9: case 10: case 11:
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6241
diff changeset
    81
			w->RaiseWidget(_opt_newgame.landscape + 8);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
    82
			SetNewLandscapeType(e->we.click.widget - 8);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    83
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    84
		case 12: ShowGameOptions(); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    85
		case 13: ShowGameDifficulty(); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    86
		case 14: ShowPatchesSelection(); break;
5352
82a50c80b0c4 (svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents: 5315
diff changeset
    87
		case 15: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
5237
c14c97d7030a (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    88
		case 16: HandleExitGameRequest(); 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
    89
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
static const WindowDesc _select_game_desc = {
5237
c14c97d7030a (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    95
	WDP_CENTER, WDP_CENTER, 336, 195,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5835
diff changeset
    96
	WC_SELECT_GAME, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	_select_game_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	SelectGameWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
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
   102
void ShowSelectGameWindow(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   104
	BaseWindow::Allocate(&_select_game_desc);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   105
	WindowFactory::NewWindow(WC_TEST1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   108
static void AskExitGameCallback(BaseWindow *w, bool confirmed)
5670
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   109
{
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   110
	if (confirmed) _exit_game = true;
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   111
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
5670
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   113
void AskExitGame(void)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   114
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
#if defined(_WIN32)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   116
		SetDParam(0, STR_0133_WINDOWS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
#elif defined(__APPLE__)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   118
		SetDParam(0, STR_0135_OSX);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
#elif defined(__BEOS__)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   120
		SetDParam(0, STR_OSNAME_BEOS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
#elif defined(__MORPHOS__)
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_MORPHOS);
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 810
diff changeset
   123
#elif defined(__AMIGA__)
587
2fa4963eb92c (svn r1007) Remove the last SET_DPARAM (:
tron
parents: 569
diff changeset
   124
		SetDParam(0, STR_OSNAME_AMIGAOS);
810
7c51ba5a4368 (svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents: 774
diff changeset
   125
#elif defined(__OS2__)
7c51ba5a4368 (svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents: 774
diff changeset
   126
		SetDParam(0, STR_OSNAME_OS2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
#else
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   128
		SetDParam(0, STR_0134_UNIX);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
#endif
5670
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   130
	ShowQuery(
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   131
		STR_00C7_QUIT,
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   132
		STR_00CA_ARE_YOU_SURE_YOU_WANT_TO,
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   133
		NULL,
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   134
		AskExitGameCallback
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   135
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   139
static void AskExitToGameMenuCallback(BaseWindow *w, bool confirmed)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   140
{
5670
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   141
	if (confirmed) _switch_mode = SM_MENU;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
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
   144
void AskExitToGameMenu(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
{
5670
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   146
	ShowQuery(
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   147
		STR_0161_QUIT_GAME,
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   148
		(_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_QUIT_SCENARIO_QUERY,
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   149
		NULL,
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   150
		AskExitToGameMenuCallback
c6dcca763ebb (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   151
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
}
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   153
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   154
static const WindowDesc _select_game_desc_2 = {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   155
	40, 40, 336, 195,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   156
	WC_SELECT_GAME, WC_NONE,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   157
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   158
	NULL,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   159
	NULL
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   160
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   161
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   162
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   163
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   164
template <> struct WindowT<WC_TEST1> : public BaseWindow {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   165
6286
6e8eec87fa9d (svn r9006) [cpp_gui] -Add: Label widget (MiHaMiX)
KUDr
parents: 6285
diff changeset
   166
	gui::WidgetPtr m_label1;
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   167
	gui::WidgetPtr m_button1;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   168
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   169
	WindowT()
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6282
diff changeset
   170
		: BaseWindow(WC_TEST1, STR_015B_OPENTTD, COLOUR_BROWN, gui::FF_NONE)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   171
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   172
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   173
6279
c75b2c7222ff (svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents: 6278
diff changeset
   174
	/*virtual*/ void CreateWidgets()
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   175
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   176
		/* set common window properties */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   177
		SetTopLeft(Point16(140, 40));
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   178
		SetSize(Point16(336, 195));
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6273
diff changeset
   179
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   180
		/* add controls */
6286
6e8eec87fa9d (svn r9006) [cpp_gui] -Add: Label widget (MiHaMiX)
KUDr
parents: 6285
diff changeset
   181
		m_label1 = new gui::Label(this, 22, gui::FF_NONE, Rect16(104, 155, 231, 166), STR_0305_QUIT_OPENTTD, STR_0305_QUIT_OPENTTD, COLOUR_BROWN);
6e8eec87fa9d (svn r9006) [cpp_gui] -Add: Label widget (MiHaMiX)
KUDr
parents: 6285
diff changeset
   182
		m_label1->SetAnchors(PIN_RIGHT | PIN_BOTTOM);
6e8eec87fa9d (svn r9006) [cpp_gui] -Add: Label widget (MiHaMiX)
KUDr
parents: 6285
diff changeset
   183
		AddWidget(m_label1);
6e8eec87fa9d (svn r9006) [cpp_gui] -Add: Label widget (MiHaMiX)
KUDr
parents: 6285
diff changeset
   184
6e8eec87fa9d (svn r9006) [cpp_gui] -Add: Label widget (MiHaMiX)
KUDr
parents: 6285
diff changeset
   185
		/* add controls */
6e8eec87fa9d (svn r9006) [cpp_gui] -Add: Label widget (MiHaMiX)
KUDr
parents: 6285
diff changeset
   186
		m_button1 = new gui::TextButton(this, 23, gui::FF_NONE, COLOUR_YELLOW, Rect16(104, 175, 231, 186), STR_0305_QUIT_OPENTTD, STR_0304_QUIT);
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6273
diff changeset
   187
		m_button1->SetAnchors(PIN_RIGHT | PIN_BOTTOM);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   188
		AddWidget(m_button1);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   189
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   190
		/* connect control callbacks */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   191
		m_button1->AddReflectHandlerT(&WindowT::Button1_OnClick);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   192
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   193
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6279
diff changeset
   194
	void Button1_OnClick(gui::EvtLeftClick &e)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   195
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   196
		/* move window randomly */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   197
		SetTopLeft(TopLeft() + Point16(rand() % 21 - 10, rand() % 21 - 10));
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   198
		SetDirty();
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   199
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   200
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   201
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   202
//RESIZE_NONE, 12, 104, 231, 175, 186, STR_0304_QUIT,            STR_0305_QUIT_OPENTTD
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   203
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
   204
WindowFactoryT<WC_TEST1> _register_window_select_game;