2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
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"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#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"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "variables.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 "heightmap.h"
|
|
|
|
#include "genworld.h"
|
2007-01-02 17:34:03 +00:00
|
|
|
#include "network/network_gui.h"
|
2006-12-04 14:27:54 +00:00
|
|
|
#include "newgrf.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2007-12-27 17:29:27 +00:00
|
|
|
#include "fios.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "gfx_func.h"
|
2008-01-13 14:37:30 +00:00
|
|
|
#include "settings_type.h"
|
2008-05-06 22:17:12 +00:00
|
|
|
#include "functions.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"
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static const Widget _select_game_widgets[] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
|
2006-12-04 14:27:54 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 13, 0, 335, 14, 194, 0x0, STR_NULL},
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 40, 51, STR_PLAY_HEIGHTMAP, STR_PLAY_HEIGHTMAP_HINT},
|
2007-02-01 16:21:56 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 58, 69, STR_SCENARIO_EDITOR, STR_02FE_CREATE_A_CUSTOMIZED_GAME},
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 58, 69, STR_MULTIPLAYER, STR_0300_SELECT_MULTIPLAYER_GAME},
|
|
|
|
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 10, 86, 77, 131, SPR_SELECT_TEMPERATE, STR_030E_SELECT_TEMPERATE_LANDSCAPE},
|
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 90, 166, 77, 131, SPR_SELECT_SUB_ARCTIC, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
|
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246, 77, 131, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
|
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 77, 131, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE},
|
2006-08-22 14:38:37 +00:00
|
|
|
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 139, 150, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 139, 150, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 157, 168, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP},
|
2006-12-04 14:27:54 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 157, 168, STR_NEWGRF_SETTINGS_BUTTON, STR_NULL},
|
|
|
|
|
2006-12-10 15:28:11 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 104, 231, 175, 186, STR_0304_QUIT, STR_0305_QUIT_OPENTTD},
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-05-12 00:18:30 +00:00
|
|
|
static inline void SetNewLandscapeType(byte landscape)
|
|
|
|
{
|
2008-05-25 22:36:44 +00:00
|
|
|
_settings_newgame.game_creation.landscape = landscape;
|
2005-05-12 00:18:30 +00:00
|
|
|
InvalidateWindowClasses(WC_SELECT_GAME);
|
|
|
|
}
|
|
|
|
|
2008-05-17 21:20:58 +00:00
|
|
|
struct SelectGameWindow : public Window {
|
|
|
|
private:
|
|
|
|
enum SelectGameIntroWidgets {
|
|
|
|
SGI_GENERATE_GAME = 2,
|
|
|
|
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,
|
|
|
|
SGI_OPTIONS,
|
|
|
|
SGI_DIFFICULTIES,
|
|
|
|
SGI_PATCHES_OPTIONS,
|
|
|
|
SGI_GRF_SETTINGS,
|
|
|
|
SGI_EXIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
SelectGameWindow(const WindowDesc *desc) : Window(desc)
|
|
|
|
{
|
2008-05-25 22:36:44 +00:00
|
|
|
this->LowerWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
|
2008-05-17 21:20:58 +00:00
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
|
}
|
2008-01-20 03:56:15 +00:00
|
|
|
|
2008-05-17 21:20:58 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2008-05-25 22:36:44 +00:00
|
|
|
this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
|
|
|
|
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);
|
|
|
|
SetDParam(0, STR_6801_EASY + _settings_newgame.difficulty.diff_level);
|
2008-05-17 21:20:58 +00:00
|
|
|
this->DrawWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
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) {
|
|
|
|
case SGI_GENERATE_GAME: ShowGenerateLandscape(); break;
|
|
|
|
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) {
|
|
|
|
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
|
|
|
} else {
|
|
|
|
ShowNetworkGameWindow();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
|
|
|
|
case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE:
|
2008-05-25 22:36:44 +00:00
|
|
|
this->RaiseWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
|
2008-05-17 21:20:58 +00:00
|
|
|
SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SGI_OPTIONS: ShowGameOptions(); break;
|
|
|
|
case SGI_DIFFICULTIES: ShowGameDifficulty(); break;
|
|
|
|
case SGI_PATCHES_OPTIONS: ShowPatchesSelection(); break;
|
|
|
|
case SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
|
|
|
|
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
|
|
|
|
|
|
|
static const WindowDesc _select_game_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_CENTER, WDP_CENTER, 336, 195, 336, 195,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SELECT_GAME, WC_NONE,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
|
|
_select_game_widgets,
|
|
|
|
};
|
|
|
|
|
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);
|
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);
|
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(
|
|
|
|
STR_00C7_QUIT,
|
|
|
|
STR_00CA_ARE_YOU_SURE_YOU_WANT_TO,
|
|
|
|
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(
|
|
|
|
STR_0161_QUIT_GAME,
|
|
|
|
(_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_QUIT_SCENARIO_QUERY,
|
|
|
|
NULL,
|
|
|
|
AskExitToGameMenuCallback
|
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|