2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file intro_gui.cpp The main menu GUI. */
|
2007-03-03 04:04:22 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
|
|
|
#include "textbuf_gui.h"
|
2007-01-02 17:34:03 +00:00
|
|
|
#include "network/network.h"
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
#include "genworld.h"
|
2007-01-02 17:34:03 +00:00
|
|
|
#include "network/network_gui.h"
|
2009-01-17 16:53:32 +00:00
|
|
|
#include "network/network_content.h"
|
2009-01-31 20:16:06 +00:00
|
|
|
#include "landscape_type.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2007-12-27 17:29:27 +00:00
|
|
|
#include "fios.h"
|
2009-01-20 16:49:10 +00:00
|
|
|
#include "ai/ai_gui.hpp"
|
2009-03-12 16:48:28 +00:00
|
|
|
#include "gfx_func.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "core/geometry_func.hpp"
|
2011-08-21 19:23:06 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "rev.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
#include "table/sprites.h"
|
|
|
|
|
2009-03-22 21:16:57 +00:00
|
|
|
enum SelectGameIntroWidgets {
|
|
|
|
SGI_GENERATE_GAME,
|
|
|
|
SGI_LOAD_GAME,
|
|
|
|
SGI_PLAY_SCENARIO,
|
|
|
|
SGI_PLAY_HEIGHTMAP,
|
|
|
|
SGI_EDIT_SCENARIO,
|
|
|
|
SGI_PLAY_NETWORK,
|
|
|
|
SGI_TEMPERATE_LANDSCAPE,
|
|
|
|
SGI_ARCTIC_LANDSCAPE,
|
|
|
|
SGI_TROPIC_LANDSCAPE,
|
|
|
|
SGI_TOYLAND_LANDSCAPE,
|
2011-08-21 19:23:06 +00:00
|
|
|
SGI_TRANSLATION_SELECTION,
|
|
|
|
SGI_TRANSLATION,
|
2009-03-22 21:16:57 +00:00
|
|
|
SGI_OPTIONS,
|
|
|
|
SGI_DIFFICULTIES,
|
|
|
|
SGI_SETTINGS_OPTIONS,
|
|
|
|
SGI_GRF_SETTINGS,
|
|
|
|
SGI_CONTENT_DOWNLOAD,
|
|
|
|
SGI_AI_SETTINGS,
|
|
|
|
SGI_EXIT,
|
|
|
|
};
|
|
|
|
|
2008-05-17 21:20:58 +00:00
|
|
|
struct SelectGameWindow : public Window {
|
2009-03-22 21:16:57 +00:00
|
|
|
|
2009-06-04 14:34:38 +00:00
|
|
|
SelectGameWindow(const WindowDesc *desc) : Window()
|
2008-05-17 21:20:58 +00:00
|
|
|
{
|
2011-08-21 19:23:06 +00:00
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
this->FinishInitNested(desc, 0);
|
2010-05-21 06:59:45 +00:00
|
|
|
this->OnInvalidateData();
|
2008-05-17 21:20:58 +00:00
|
|
|
}
|
2008-01-20 03:56:15 +00:00
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @param data Information about the changed data.
|
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
|
*/
|
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
2008-05-17 21:20:58 +00:00
|
|
|
{
|
2011-03-13 21:31:29 +00:00
|
|
|
if (!gui_scope) return;
|
2008-05-25 22:36:44 +00:00
|
|
|
this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
|
2008-07-30 16:23:55 +00:00
|
|
|
this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC);
|
|
|
|
this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC);
|
|
|
|
this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TOYLAND);
|
2009-06-28 21:23:37 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 11:54:53 +00:00
|
|
|
virtual void SetStringParameters(int widget) const
|
2009-06-28 22:23:26 +00:00
|
|
|
{
|
2009-07-25 11:54:53 +00:00
|
|
|
if (widget == SGI_DIFFICULTIES) SetDParam(0, STR_DIFFICULTY_LEVEL_EASY + _settings_newgame.difficulty.diff_level);
|
2009-06-28 22:23:26 +00:00
|
|
|
}
|
|
|
|
|
2011-08-21 19:23:06 +00:00
|
|
|
virtual void OnInit()
|
2009-07-04 15:35:36 +00:00
|
|
|
{
|
2011-08-21 19:23:06 +00:00
|
|
|
bool missing = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
|
|
|
|
this->GetWidget<NWidgetStacked>(SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing ? 0 : SZSP_NONE);
|
|
|
|
}
|
2009-07-18 10:46:55 +00:00
|
|
|
|
2011-08-21 19:23:06 +00:00
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case SGI_TRANSLATION:
|
|
|
|
SetDParam(0, _current_language->missing);
|
|
|
|
DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case SGI_DIFFICULTIES: {
|
|
|
|
Dimension textdim = {0, 0};
|
|
|
|
for (uint i = STR_DIFFICULTY_LEVEL_EASY; i <= STR_DIFFICULTY_LEVEL_CUSTOM; i++) {
|
|
|
|
SetDParam(0, i);
|
|
|
|
textdim = maxdim(textdim, GetStringBoundingBox(STR_INTRO_DIFFICULTY));
|
|
|
|
}
|
|
|
|
textdim.width += padding.width;
|
|
|
|
textdim.height += padding.height;
|
|
|
|
*size = maxdim(*size, textdim);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SGI_TRANSLATION: {
|
|
|
|
SetDParam(0, _current_language->missing);
|
|
|
|
int height = GetStringHeight(STR_INTRO_TRANSLATION, size->width);
|
|
|
|
if (height > 3 * FONT_HEIGHT_NORMAL) {
|
|
|
|
/* Don't let the window become too high. */
|
|
|
|
Dimension textdim = GetStringBoundingBox(STR_INTRO_TRANSLATION);
|
|
|
|
textdim.height *= 3;
|
|
|
|
textdim.width -= textdim.width / 2;
|
|
|
|
*size = maxdim(*size, textdim);
|
|
|
|
} else {
|
|
|
|
size->height = height + padding.height;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-07-04 15:35:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-17 21:20:58 +00:00
|
|
|
{
|
2007-06-13 17:34:05 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
2008-05-17 21:20:58 +00:00
|
|
|
/* Do not create a network server when you (just) have closed one of the game
|
|
|
|
* creation/load windows for the network server. */
|
|
|
|
if (IsInsideMM(widget, SGI_GENERATE_GAME, SGI_EDIT_SCENARIO + 1)) _is_network_server = false;
|
2007-06-13 17:34:05 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
2007-04-30 20:05:31 +00:00
|
|
|
|
2008-05-17 21:20:58 +00:00
|
|
|
switch (widget) {
|
2009-03-12 16:48:28 +00:00
|
|
|
case SGI_GENERATE_GAME:
|
|
|
|
if (_ctrl_pressed) {
|
|
|
|
StartNewGameWithoutGUI(GENERATE_NEW_SEED);
|
|
|
|
} else {
|
|
|
|
ShowGenerateLandscape();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-05-17 21:20:58 +00:00
|
|
|
case SGI_LOAD_GAME: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
|
|
|
|
case SGI_PLAY_SCENARIO: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
|
|
|
|
case SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
|
|
|
|
case SGI_EDIT_SCENARIO: StartScenarioEditor(); break;
|
|
|
|
|
|
|
|
case SGI_PLAY_NETWORK:
|
|
|
|
if (!_network_available) {
|
2010-02-24 14:46:15 +00:00
|
|
|
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
|
2008-05-17 21:20:58 +00:00
|
|
|
} else {
|
|
|
|
ShowNetworkGameWindow();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
|
|
|
|
case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE:
|
|
|
|
SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SGI_OPTIONS: ShowGameOptions(); break;
|
|
|
|
case SGI_DIFFICULTIES: ShowGameDifficulty(); break;
|
2009-02-08 12:25:13 +00:00
|
|
|
case SGI_SETTINGS_OPTIONS:ShowGameSettings(); break;
|
2008-05-17 21:20:58 +00:00
|
|
|
case SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
|
2009-01-17 16:53:32 +00:00
|
|
|
case SGI_CONTENT_DOWNLOAD:
|
|
|
|
if (!_network_available) {
|
2010-02-24 14:46:15 +00:00
|
|
|
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
|
2009-01-17 16:53:32 +00:00
|
|
|
} else {
|
|
|
|
ShowNetworkContentListWindow();
|
|
|
|
}
|
|
|
|
break;
|
2009-01-20 16:49:10 +00:00
|
|
|
case SGI_AI_SETTINGS: ShowAIConfigWindow(); break;
|
2008-05-17 21:20:58 +00:00
|
|
|
case SGI_EXIT: HandleExitGameRequest(); break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-17 21:20:58 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-03-22 21:16:57 +00:00
|
|
|
static const NWidgetPart _nested_select_game_widgets[] = {
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_INTRO_CAPTION, STR_NULL),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 8),
|
|
|
|
|
|
|
|
/* 'generate game' and 'load game' buttons */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_GENERATE_GAME), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_LOAD_GAME), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
|
|
|
/* 'play scenario' and 'play heightmap' buttons */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_PLAY_SCENARIO), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_PLAY_HEIGHTMAP), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_TOOLTIP_PLAY_HEIGHTMAP), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
|
|
|
/* 'edit scenario' and 'play multiplayer' buttons */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_EDIT_SCENARIO), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_SCENARIO_EDITOR, STR_INTRO_TOOLTIP_SCENARIO_EDITOR), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_PLAY_NETWORK), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_MULTIPLAYER, STR_INTRO_TOOLTIP_MULTIPLAYER), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 7),
|
|
|
|
|
|
|
|
/* climate selection buttons */
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0), SetFill(1, 0),
|
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, SGI_TEMPERATE_LANDSCAPE), SetMinimalSize(77, 55),
|
|
|
|
SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, SGI_ARCTIC_LANDSCAPE), SetMinimalSize(77, 55),
|
|
|
|
SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, SGI_TROPIC_LANDSCAPE), SetMinimalSize(77, 55),
|
|
|
|
SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, SGI_TOYLAND_LANDSCAPE), SetMinimalSize(77, 55),
|
|
|
|
SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 7),
|
2011-08-21 19:23:06 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, SGI_TRANSLATION_SELECTION),
|
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidget(WWT_EMPTY, COLOUR_ORANGE, SGI_TRANSLATION), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
|
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
2009-11-24 18:05:55 +00:00
|
|
|
|
|
|
|
/* 'game options' and 'difficulty options' buttons */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_OPTIONS), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_GAME_OPTIONS, STR_INTRO_TOOLTIP_GAME_OPTIONS), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_DIFFICULTIES), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_DIFFICULTY, STR_INTRO_TOOLTIP_DIFFICULTY_OPTIONS), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
|
|
|
/* 'advanced settings' and 'newgrf settings' buttons */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_SETTINGS_OPTIONS), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_ADVANCED_SETTINGS, STR_INTRO_TOOLTIP_ADVANCED_SETTINGS), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_GRF_SETTINGS), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_INTRO_TOOLTIP_NEWGRF_SETTINGS), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
|
|
|
/* 'online content' and 'ai settings' buttons */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_CONTENT_DOWNLOAD), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_AI_SETTINGS), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_AI_SETTINGS, STR_INTRO_TOOLTIP_AI_SETTINGS), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
|
|
|
/* 'exit program' button */
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_EXIT), SetMinimalSize(128, 12),
|
|
|
|
SetDataTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
|
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 8),
|
2009-03-22 21:16:57 +00:00
|
|
|
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _select_game_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_CENTER, 0, 0,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SELECT_GAME, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_UNCLICK_BUTTONS,
|
2009-03-22 21:16:57 +00:00
|
|
|
_nested_select_game_widgets, lengthof(_nested_select_game_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ShowSelectGameWindow()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-17 21:20:58 +00:00
|
|
|
new SelectGameWindow(&_select_game_desc);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-12-29 17:56:34 +00:00
|
|
|
static void AskExitGameCallback(Window *w, bool confirmed)
|
|
|
|
{
|
|
|
|
if (confirmed) _exit_game = true;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void AskExitGame()
|
2005-11-14 19:48:04 +00:00
|
|
|
{
|
2004-08-09 17:04:08 +00:00
|
|
|
#if defined(_WIN32)
|
2008-01-27 17:32:12 +00:00
|
|
|
SetDParam(0, STR_OSNAME_WINDOWS);
|
2004-08-09 17:04:08 +00:00
|
|
|
#elif defined(__APPLE__)
|
2008-01-27 17:32:12 +00:00
|
|
|
SetDParam(0, STR_OSNAME_OSX);
|
2004-08-09 17:04:08 +00:00
|
|
|
#elif defined(__BEOS__)
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, STR_OSNAME_BEOS);
|
2009-09-21 18:36:33 +00:00
|
|
|
#elif defined(__HAIKU__)
|
|
|
|
SetDParam(0, STR_OSNAME_HAIKU);
|
2004-08-09 17:04:08 +00:00
|
|
|
#elif defined(__MORPHOS__)
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, STR_OSNAME_MORPHOS);
|
2005-01-03 19:45:18 +00:00
|
|
|
#elif defined(__AMIGA__)
|
2004-12-10 15:12:48 +00:00
|
|
|
SetDParam(0, STR_OSNAME_AMIGAOS);
|
2004-12-27 10:40:04 +00:00
|
|
|
#elif defined(__OS2__)
|
|
|
|
SetDParam(0, STR_OSNAME_OS2);
|
2007-03-05 17:05:41 +00:00
|
|
|
#elif defined(SUNOS)
|
|
|
|
SetDParam(0, STR_OSNAME_SUNOS);
|
2008-11-26 13:12:45 +00:00
|
|
|
#elif defined(DOS)
|
|
|
|
SetDParam(0, STR_OSNAME_DOS);
|
2004-08-09 17:04:08 +00:00
|
|
|
#else
|
2008-01-27 17:32:12 +00:00
|
|
|
SetDParam(0, STR_OSNAME_UNIX);
|
2004-08-09 17:04:08 +00:00
|
|
|
#endif
|
2006-12-29 17:56:34 +00:00
|
|
|
ShowQuery(
|
2009-04-21 23:40:56 +00:00
|
|
|
STR_QUIT_CAPTION,
|
2009-08-05 17:59:21 +00:00
|
|
|
STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD,
|
2006-12-29 17:56:34 +00:00
|
|
|
NULL,
|
|
|
|
AskExitGameCallback
|
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-29 17:56:34 +00:00
|
|
|
static void AskExitToGameMenuCallback(Window *w, bool confirmed)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-12-29 17:56:34 +00:00
|
|
|
if (confirmed) _switch_mode = SM_MENU;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void AskExitToGameMenu()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-12-29 17:56:34 +00:00
|
|
|
ShowQuery(
|
2009-04-21 23:40:56 +00:00
|
|
|
STR_ABANDON_GAME_CAPTION,
|
2010-02-10 20:20:18 +00:00
|
|
|
(_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY,
|
2006-12-29 17:56:34 +00:00
|
|
|
NULL,
|
|
|
|
AskExitToGameMenuCallback
|
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|