src/intro_gui.cpp
author rubidium
Thu, 18 Dec 2008 12:23:08 +0000
changeset 10436 8d3a9fbe8f19
parent 10385 4f9838649c7f
permissions -rw-r--r--
(svn r14689) -Change: make configure die on commonly made user mistakes, like not having SDL development files or zlib headers installed; you can still compile a dedicated server or a binary without zlib, but you have to explicitly force it.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8970
diff changeset
     3
/** @file intro_gui.cpp The main menu GUI. */
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5899
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1796
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     8
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     9
#include "textbuf_gui.h"
5469
7edfc643abbc (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: 5431
diff changeset
    10
#include "network/network.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1891
diff changeset
    11
#include "variables.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    12
#include "heightmap.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4171
diff changeset
    13
#include "genworld.h"
5469
7edfc643abbc (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: 5431
diff changeset
    14
#include "network/network_gui.h"
5237
4fce3ea379c2 (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    15
#include "newgrf.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    16
#include "strings_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    17
#include "window_func.h"
8149
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8131
diff changeset
    18
#include "fios.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8208
diff changeset
    19
#include "gfx_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    20
#include "settings_type.h"
9117
87f472043e9e (svn r12977) -Codechange: remove quite some redundant (duplicate) function declarations.
rubidium
parents: 9111
diff changeset
    21
#include "functions.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    23
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    24
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    25
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
static const Widget _select_game_widgets[] = {
9745
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    27
{     WWT_CAPTION,  RESIZE_NONE,  COLOUR_BROWN,    0,   335,    0,   13,  STR_0307_OPENTTD,           STR_NULL},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    28
{       WWT_PANEL,  RESIZE_NONE,  COLOUR_BROWN,    0,   335,   14,  194,  0x0,                        STR_NULL},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    29
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,   10,  167,   22,   33,  STR_0140_NEW_GAME,          STR_02FB_START_A_NEW_GAME},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    30
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,  168,  325,   22,   33,  STR_0141_LOAD_GAME,         STR_02FC_LOAD_A_SAVED_GAME},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    31
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,   10,  167,   40,   51,  STR_029A_PLAY_SCENARIO,     STR_0303_START_A_NEW_GAME_USING},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    32
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,  168,  325,   40,   51,  STR_PLAY_HEIGHTMAP,         STR_PLAY_HEIGHTMAP_HINT},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    33
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,   10,  167,   58,   69,  STR_SCENARIO_EDITOR,        STR_02FE_CREATE_A_CUSTOMIZED_GAME},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    34
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,  168,  325,   58,   69,  STR_MULTIPLAYER,            STR_0300_SELECT_MULTIPLAYER_GAME},
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
    35
9745
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    36
{    WWT_IMGBTN_2,  RESIZE_NONE,  COLOUR_ORANGE,   10,   86,   77,  131,  SPR_SELECT_TEMPERATE,       STR_030E_SELECT_TEMPERATE_LANDSCAPE},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    37
{    WWT_IMGBTN_2,  RESIZE_NONE,  COLOUR_ORANGE,   90,  166,   77,  131,  SPR_SELECT_SUB_ARCTIC,      STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    38
{    WWT_IMGBTN_2,  RESIZE_NONE,  COLOUR_ORANGE,  170,  246,   77,  131,  SPR_SELECT_SUB_TROPICAL,    STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    39
{    WWT_IMGBTN_2,  RESIZE_NONE,  COLOUR_ORANGE,  250,  326,   77,  131,  SPR_SELECT_TOYLAND,         STR_0311_SELECT_TOYLAND_LANDSCAPE},
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
    40
9745
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    41
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,   10,  167,  139,  150,  STR_0148_GAME_OPTIONS,      STR_0301_DISPLAY_GAME_OPTIONS},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    42
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,  168,  325,  139,  150,  STR_01FE_DIFFICULTY,        STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    43
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,   10,  167,  157,  168,  STR_CONFIG_PATCHES,         STR_CONFIG_PATCHES_TIP},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    44
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,  168,  325,  157,  168,  STR_NEWGRF_SETTINGS_BUTTON, STR_NULL},
5237
4fce3ea379c2 (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 4938
diff changeset
    45
9745
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    46
{  WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_ORANGE,  104,  231,  175,  186,  STR_0304_QUIT,              STR_0305_QUIT_OPENTTD},
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    47
{     WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    50
static inline void SetNewLandscapeType(byte landscape)
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    51
{
9358
2e1e4d2f71dd (svn r13255) -Codechange: move _opt to _settings.
rubidium
parents: 9317
diff changeset
    52
	_settings_newgame.game_creation.landscape = landscape;
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    53
	InvalidateWindowClasses(WC_SELECT_GAME);
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    54
}
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1728
diff changeset
    55
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    56
struct SelectGameWindow : public Window {
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    57
private:
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    58
	enum SelectGameIntroWidgets {
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    59
		SGI_GENERATE_GAME = 2,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    60
		SGI_LOAD_GAME,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    61
		SGI_PLAY_SCENARIO,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    62
		SGI_PLAY_HEIGHTMAP,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    63
		SGI_EDIT_SCENARIO,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    64
		SGI_PLAY_NETWORK,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    65
		SGI_TEMPERATE_LANDSCAPE,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    66
		SGI_ARCTIC_LANDSCAPE,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    67
		SGI_TROPIC_LANDSCAPE,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    68
		SGI_TOYLAND_LANDSCAPE,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    69
		SGI_OPTIONS,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    70
		SGI_DIFFICULTIES,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    71
		SGI_PATCHES_OPTIONS,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    72
		SGI_GRF_SETTINGS,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    73
		SGI_EXIT,
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    74
	};
8365
5cfbac748261 (svn r11931) -Codechange: enumify the widgets numbers. Give breathing room on the case switches too...
belugas
parents: 8364
diff changeset
    75
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    76
public:
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    77
	SelectGameWindow(const WindowDesc *desc) : Window(desc)
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    78
	{
9358
2e1e4d2f71dd (svn r13255) -Codechange: move _opt to _settings.
rubidium
parents: 9317
diff changeset
    79
		this->LowerWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    80
		this->FindWindowPlacementAndResize(desc);
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    81
	}
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
    82
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    83
	virtual void OnPaint()
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    84
	{
9358
2e1e4d2f71dd (svn r13255) -Codechange: move _opt to _settings.
rubidium
parents: 9317
diff changeset
    85
		this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
9745
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    86
		this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE,    _settings_newgame.game_creation.landscape == LT_ARCTIC);
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    87
		this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE,    _settings_newgame.game_creation.landscape == LT_TROPIC);
80eea324560c (svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
belugas
parents: 9358
diff changeset
    88
		this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE,   _settings_newgame.game_creation.landscape == LT_TOYLAND);
9358
2e1e4d2f71dd (svn r13255) -Codechange: move _opt to _settings.
rubidium
parents: 9317
diff changeset
    89
		SetDParam(0, STR_6801_EASY + _settings_newgame.difficulty.diff_level);
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    90
		this->DrawWidgets();
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    91
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    93
	virtual void OnClick(Point pt, int widget)
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    94
	{
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6555
diff changeset
    95
#ifdef ENABLE_NETWORK
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    96
		/* Do not create a network server when you (just) have closed one of the game
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    97
		 * creation/load windows for the network server. */
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
    98
		if (IsInsideMM(widget, SGI_GENERATE_GAME, SGI_EDIT_SCENARIO + 1)) _is_network_server = false;
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6555
diff changeset
    99
#endif /* ENABLE_NETWORK */
6555
418ca90354d4 (svn r9757) -Fix [FS#1244842]: when you have closed the "Load game"/"New game" windows accessible from the "New Server" window, any creation of new game/loading from the intro menu should not start a server.
rubidium
parents: 6357
diff changeset
   100
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   101
		switch (widget) {
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   102
			case SGI_GENERATE_GAME:  ShowGenerateLandscape(); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   103
			case SGI_LOAD_GAME:      ShowSaveLoadDialog(SLD_LOAD_GAME); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   104
			case SGI_PLAY_SCENARIO:  ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   105
			case SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   106
			case SGI_EDIT_SCENARIO:  StartScenarioEditor(); break;
8365
5cfbac748261 (svn r11931) -Codechange: enumify the widgets numbers. Give breathing room on the case switches too...
belugas
parents: 8364
diff changeset
   107
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   108
			case SGI_PLAY_NETWORK:
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   109
				if (!_network_available) {
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   110
					ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   111
				} else {
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   112
					ShowNetworkGameWindow();
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   113
				}
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   114
				break;
8365
5cfbac748261 (svn r11931) -Codechange: enumify the widgets numbers. Give breathing room on the case switches too...
belugas
parents: 8364
diff changeset
   115
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   116
			case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   117
			case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE:
9358
2e1e4d2f71dd (svn r13255) -Codechange: move _opt to _settings.
rubidium
parents: 9317
diff changeset
   118
				this->RaiseWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   119
				SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE);
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   120
				break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   121
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   122
			case SGI_OPTIONS:         ShowGameOptions(); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   123
			case SGI_DIFFICULTIES:    ShowGameDifficulty(); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   124
			case SGI_PATCHES_OPTIONS: ShowPatchesSelection(); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   125
			case SGI_GRF_SETTINGS:    ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   126
			case SGI_EXIT:            HandleExitGameRequest(); break;
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   127
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	}
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   129
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
static const WindowDesc _select_game_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   132
	WDP_CENTER, WDP_CENTER, 336, 195, 336, 195,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5584
diff changeset
   133
	WC_SELECT_GAME, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	_select_game_widgets,
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
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6221
diff changeset
   138
void ShowSelectGameWindow()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
{
9282
f8bcac5d5ae3 (svn r13148) -Codechange: make a class of the SelectGameWindow.
glx
parents: 9273
diff changeset
   140
	new SelectGameWindow(&_select_game_desc);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
5419
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   143
static void AskExitGameCallback(Window *w, bool confirmed)
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   144
{
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   145
	if (confirmed) _exit_game = true;
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   146
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6221
diff changeset
   148
void AskExitGame()
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   149
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
#if defined(_WIN32)
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8366
diff changeset
   151
		SetDParam(0, STR_OSNAME_WINDOWS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
#elif defined(__APPLE__)
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8366
diff changeset
   153
		SetDParam(0, STR_OSNAME_OSX);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
#elif defined(__BEOS__)
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   155
		SetDParam(0, STR_OSNAME_BEOS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
#elif defined(__MORPHOS__)
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   157
		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
   158
#elif defined(__AMIGA__)
587
ea2a8bd38f41 (svn r1007) Remove the last SET_DPARAM (:
tron
parents: 569
diff changeset
   159
		SetDParam(0, STR_OSNAME_AMIGAOS);
810
a1494b19bd2a (svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents: 774
diff changeset
   160
#elif defined(__OS2__)
a1494b19bd2a (svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents: 774
diff changeset
   161
		SetDParam(0, STR_OSNAME_OS2);
6221
dcdd06445346 (svn r9018) -Change: added SunOS as OS name in the quit dialog
miham
parents: 6201
diff changeset
   162
#elif defined(SUNOS)
dcdd06445346 (svn r9018) -Change: added SunOS as OS name in the quit dialog
miham
parents: 6201
diff changeset
   163
		SetDParam(0, STR_OSNAME_SUNOS);
10385
4f9838649c7f (svn r14636) -Add: DOS port of OpenTTD, without network support though.
rubidium
parents: 9745
diff changeset
   164
#elif defined(DOS)
4f9838649c7f (svn r14636) -Add: DOS port of OpenTTD, without network support though.
rubidium
parents: 9745
diff changeset
   165
		SetDParam(0, STR_OSNAME_DOS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
#else
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8366
diff changeset
   167
		SetDParam(0, STR_OSNAME_UNIX);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
#endif
5419
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   169
	ShowQuery(
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   170
		STR_00C7_QUIT,
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   171
		STR_00CA_ARE_YOU_SURE_YOU_WANT_TO,
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   172
		NULL,
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   173
		AskExitGameCallback
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   174
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
5419
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   178
static void AskExitToGameMenuCallback(Window *w, bool confirmed)
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   179
{
5419
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   180
	if (confirmed) _switch_mode = SM_MENU;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6221
diff changeset
   183
void AskExitToGameMenu()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
{
5419
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   185
	ShowQuery(
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   186
		STR_0161_QUIT_GAME,
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   187
		(_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_QUIT_SCENARIO_QUERY,
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   188
		NULL,
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   189
		AskExitToGameMenuCallback
a3d7068578bd (svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
Darkvater
parents: 5352
diff changeset
   190
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
}