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"
|
2011-12-10 13:54:10 +00:00
|
|
|
#include "error.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
2021-04-09 18:39:56 +00:00
|
|
|
#include "window_func.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#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"
|
2021-04-09 18:39:56 +00:00
|
|
|
#include "landscape.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"
|
2022-11-10 20:39:09 +00:00
|
|
|
#include "game/game_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"
|
2012-12-05 19:37:15 +00:00
|
|
|
#include "highscore.h"
|
2021-04-09 18:39:56 +00:00
|
|
|
#include "signs_base.h"
|
|
|
|
#include "viewport_func.h"
|
|
|
|
#include "vehicle_base.h"
|
|
|
|
#include <regex>
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-12-15 22:22:55 +00:00
|
|
|
#include "widgets/intro_widget.h"
|
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
#include "table/sprites.h"
|
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2021-04-09 18:39:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A viewport command for the main menu background (intro game).
|
|
|
|
*/
|
|
|
|
struct IntroGameViewportCommand {
|
|
|
|
/** Horizontal alignment value. */
|
|
|
|
enum AlignmentH : byte {
|
|
|
|
LEFT,
|
|
|
|
CENTRE,
|
|
|
|
RIGHT,
|
|
|
|
};
|
|
|
|
/** Vertical alignment value. */
|
|
|
|
enum AlignmentV : byte {
|
|
|
|
TOP,
|
|
|
|
MIDDLE,
|
|
|
|
BOTTOM,
|
|
|
|
};
|
|
|
|
|
|
|
|
int command_index = 0; ///< Sequence number of the command (order they are performed in).
|
|
|
|
Point position{ 0, 0 }; ///< Calculated world coordinate to position viewport top-left at.
|
|
|
|
VehicleID vehicle = INVALID_VEHICLE; ///< Vehicle to follow, or INVALID_VEHICLE if not following a vehicle.
|
|
|
|
uint delay = 0; ///< Delay until next command.
|
|
|
|
int zoom_adjust = 0; ///< Adjustment to zoom level from base zoom level.
|
|
|
|
bool pan_to_next = false; ///< If true, do a smooth pan from this position to the next.
|
|
|
|
AlignmentH align_h = CENTRE; ///< Horizontal alignment.
|
|
|
|
AlignmentV align_v = MIDDLE; ///< Vertical alignment.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate effective position.
|
|
|
|
* This will update the position field if a vehicle is followed.
|
|
|
|
* @param vp Viewport to calculate position for.
|
|
|
|
* @return Calculated position in the viewport.
|
|
|
|
*/
|
|
|
|
Point PositionForViewport(const Viewport *vp)
|
|
|
|
{
|
|
|
|
if (this->vehicle != INVALID_VEHICLE) {
|
|
|
|
const Vehicle *v = Vehicle::Get(this->vehicle);
|
|
|
|
this->position = RemapCoords(v->x_pos, v->y_pos, v->z_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
Point p;
|
|
|
|
switch (this->align_h) {
|
|
|
|
case LEFT: p.x = this->position.x; break;
|
|
|
|
case CENTRE: p.x = this->position.x - vp->virtual_width / 2; break;
|
|
|
|
case RIGHT: p.x = this->position.x - vp->virtual_width; break;
|
|
|
|
}
|
|
|
|
switch (this->align_v) {
|
|
|
|
case TOP: p.y = this->position.y; break;
|
|
|
|
case MIDDLE: p.y = this->position.y - vp->virtual_height / 2; break;
|
|
|
|
case BOTTOM: p.y = this->position.y - vp->virtual_height; break;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-17 21:20:58 +00:00
|
|
|
struct SelectGameWindow : public Window {
|
2021-04-09 18:39:56 +00:00
|
|
|
/** Vector of viewport commands parsed. */
|
|
|
|
std::vector<IntroGameViewportCommand> intro_viewport_commands;
|
|
|
|
/** Index of currently active viewport command. */
|
|
|
|
size_t cur_viewport_command_index;
|
|
|
|
/** Time spent (milliseconds) on current viewport command. */
|
|
|
|
uint cur_viewport_command_time;
|
2021-10-23 13:13:39 +00:00
|
|
|
uint mouse_idle_time;
|
|
|
|
Point mouse_idle_pos;
|
2021-04-09 18:39:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find and parse all viewport command signs.
|
|
|
|
* Fills the intro_viewport_commands vector and deletes parsed signs from the world.
|
|
|
|
*/
|
|
|
|
void ReadIntroGameViewportCommands()
|
|
|
|
{
|
|
|
|
intro_viewport_commands.clear();
|
|
|
|
|
|
|
|
/* Regular expression matching the commands: T, spaces, integer, spaces, flags, spaces, integer */
|
|
|
|
const char *sign_langauge = "^T\\s*([0-9]+)\\s*([-+A-Z0-9]+)\\s*([0-9]+)";
|
|
|
|
std::regex re(sign_langauge, std::regex_constants::icase);
|
|
|
|
|
|
|
|
/* List of signs successfully parsed to delete afterwards. */
|
|
|
|
std::vector<SignID> signs_to_delete;
|
|
|
|
|
|
|
|
for (const Sign *sign : Sign::Iterate()) {
|
|
|
|
std::smatch match;
|
|
|
|
if (std::regex_search(sign->name, match, re)) {
|
|
|
|
IntroGameViewportCommand vc;
|
|
|
|
/* Sequence index from the first matching group. */
|
|
|
|
vc.command_index = std::stoi(match[1].str());
|
|
|
|
/* Sign coordinates for positioning. */
|
|
|
|
vc.position = RemapCoords(sign->x, sign->y, sign->z);
|
|
|
|
/* Delay from the third matching group. */
|
|
|
|
vc.delay = std::stoi(match[3].str()) * 1000; // milliseconds
|
|
|
|
|
|
|
|
/* Parse flags from second matching group. */
|
|
|
|
enum IdType {
|
|
|
|
ID_NONE, ID_VEHICLE
|
|
|
|
} id_type = ID_NONE;
|
|
|
|
for (char c : match[2].str()) {
|
|
|
|
if (isdigit(c)) {
|
|
|
|
if (id_type == ID_VEHICLE) {
|
|
|
|
vc.vehicle = vc.vehicle * 10 + (c - '0');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
id_type = ID_NONE;
|
|
|
|
switch (toupper(c)) {
|
|
|
|
case '-': vc.zoom_adjust = +1; break;
|
|
|
|
case '+': vc.zoom_adjust = -1; break;
|
|
|
|
case 'T': vc.align_v = IntroGameViewportCommand::TOP; break;
|
|
|
|
case 'M': vc.align_v = IntroGameViewportCommand::MIDDLE; break;
|
|
|
|
case 'B': vc.align_v = IntroGameViewportCommand::BOTTOM; break;
|
|
|
|
case 'L': vc.align_h = IntroGameViewportCommand::LEFT; break;
|
|
|
|
case 'C': vc.align_h = IntroGameViewportCommand::CENTRE; break;
|
|
|
|
case 'R': vc.align_h = IntroGameViewportCommand::RIGHT; break;
|
|
|
|
case 'P': vc.pan_to_next = true; break;
|
|
|
|
case 'V': id_type = ID_VEHICLE; vc.vehicle = 0; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Successfully parsed, store. */
|
|
|
|
intro_viewport_commands.push_back(vc);
|
|
|
|
signs_to_delete.push_back(sign->index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sort the commands by sequence index. */
|
|
|
|
std::sort(intro_viewport_commands.begin(), intro_viewport_commands.end(), [](const IntroGameViewportCommand &a, const IntroGameViewportCommand &b) { return a.command_index < b.command_index; });
|
|
|
|
|
|
|
|
/* Delete all the consumed signs, from last ID to first ID. */
|
|
|
|
std::sort(signs_to_delete.begin(), signs_to_delete.end(), [](SignID a, SignID b) { return a > b; });
|
|
|
|
for (SignID sign_id : signs_to_delete) {
|
|
|
|
delete Sign::Get(sign_id);
|
|
|
|
}
|
|
|
|
}
|
2009-03-22 21:16:57 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
SelectGameWindow(WindowDesc *desc) : Window(desc)
|
2008-05-17 21:20:58 +00:00
|
|
|
{
|
2013-05-26 19:23:42 +00:00
|
|
|
this->CreateNestedTree();
|
|
|
|
this->FinishInitNested(0);
|
2010-05-21 06:59:45 +00:00
|
|
|
this->OnInvalidateData();
|
2021-04-09 18:39:56 +00:00
|
|
|
|
|
|
|
this->ReadIntroGameViewportCommands();
|
|
|
|
|
|
|
|
this->cur_viewport_command_index = (size_t)-1;
|
|
|
|
this->cur_viewport_command_time = 0;
|
2021-10-23 13:13:39 +00:00
|
|
|
this->mouse_idle_time = 0;
|
|
|
|
this->mouse_idle_pos = _cursor.pos;
|
2021-04-09 18:39:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnRealtimeTick(uint delta_ms) override
|
|
|
|
{
|
|
|
|
/* Move the main game viewport according to intro viewport commands. */
|
|
|
|
|
|
|
|
if (intro_viewport_commands.empty()) return;
|
|
|
|
|
2021-10-23 13:13:39 +00:00
|
|
|
bool suppress_panning = true;
|
|
|
|
if (this->mouse_idle_pos.x != _cursor.pos.x || this->mouse_idle_pos.y != _cursor.pos.y) {
|
|
|
|
this->mouse_idle_pos = _cursor.pos;
|
|
|
|
this->mouse_idle_time = 2000;
|
|
|
|
} else if (this->mouse_idle_time > delta_ms) {
|
|
|
|
this->mouse_idle_time -= delta_ms;
|
|
|
|
} else {
|
|
|
|
this->mouse_idle_time = 0;
|
|
|
|
suppress_panning = false;
|
|
|
|
}
|
|
|
|
|
2021-04-09 18:39:56 +00:00
|
|
|
/* Determine whether to move to the next command or stay at current. */
|
|
|
|
bool changed_command = false;
|
|
|
|
if (this->cur_viewport_command_index >= intro_viewport_commands.size()) {
|
|
|
|
/* Reached last, rotate back to start of the list. */
|
|
|
|
this->cur_viewport_command_index = 0;
|
|
|
|
changed_command = true;
|
|
|
|
} else {
|
|
|
|
/* Check if current command has elapsed and switch to next. */
|
|
|
|
this->cur_viewport_command_time += delta_ms;
|
|
|
|
if (this->cur_viewport_command_time >= intro_viewport_commands[this->cur_viewport_command_index].delay) {
|
|
|
|
this->cur_viewport_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
|
|
|
|
this->cur_viewport_command_time = 0;
|
|
|
|
changed_command = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IntroGameViewportCommand &vc = intro_viewport_commands[this->cur_viewport_command_index];
|
2023-01-06 22:24:38 +00:00
|
|
|
Window *mw = GetMainWindow();
|
2021-04-09 18:39:56 +00:00
|
|
|
Viewport *vp = mw->viewport;
|
|
|
|
|
|
|
|
/* Early exit if the current command hasn't elapsed and isn't animated. */
|
|
|
|
if (!changed_command && !vc.pan_to_next && vc.vehicle == INVALID_VEHICLE) return;
|
|
|
|
|
2021-10-23 13:13:39 +00:00
|
|
|
/* Suppress panning commands, while user interacts with GUIs. */
|
|
|
|
if (!changed_command && suppress_panning) return;
|
|
|
|
|
2021-04-09 18:39:56 +00:00
|
|
|
/* Reset the zoom level. */
|
|
|
|
if (changed_command) FixTitleGameZoom(vc.zoom_adjust);
|
|
|
|
|
|
|
|
/* Calculate current command position (updates followed vehicle coordinates). */
|
|
|
|
Point pos = vc.PositionForViewport(vp);
|
|
|
|
|
|
|
|
/* Calculate panning (linear interpolation between current and next command position). */
|
|
|
|
if (vc.pan_to_next) {
|
|
|
|
size_t next_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
|
|
|
|
IntroGameViewportCommand &nvc = intro_viewport_commands[next_command_index];
|
|
|
|
Point pos2 = nvc.PositionForViewport(vp);
|
|
|
|
const double t = this->cur_viewport_command_time / (double)vc.delay;
|
|
|
|
pos.x = pos.x + (int)(t * (pos2.x - pos.x));
|
|
|
|
pos.y = pos.y + (int)(t * (pos2.y - pos.y));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the viewport position. */
|
|
|
|
mw->viewport->dest_scrollpos_x = mw->viewport->scrollpos_x = pos.x;
|
|
|
|
mw->viewport->dest_scrollpos_y = mw->viewport->scrollpos_y = pos.y;
|
|
|
|
UpdateViewportPosition(mw);
|
|
|
|
mw->SetDirty(); // Required during panning, otherwise logo graphics disappears
|
|
|
|
|
|
|
|
/* If there is only one command, we just executed it and don't need to do any more */
|
|
|
|
if (intro_viewport_commands.size() == 1 && vc.vehicle == INVALID_VEHICLE) intro_viewport_commands.clear();
|
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.
|
|
|
|
*/
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
2008-05-17 21:20:58 +00:00
|
|
|
{
|
2011-03-13 21:31:29 +00:00
|
|
|
if (!gui_scope) return;
|
2011-12-16 16:49:53 +00:00
|
|
|
this->SetWidgetLoweredState(WID_SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
|
|
|
|
this->SetWidgetLoweredState(WID_SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC);
|
|
|
|
this->SetWidgetLoweredState(WID_SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC);
|
|
|
|
this->SetWidgetLoweredState(WID_SGI_TOYLAND_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TOYLAND);
|
2009-06-28 21:23:37 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnInit() override
|
2009-07-04 15:35:36 +00:00
|
|
|
{
|
2017-01-14 18:30:26 +00:00
|
|
|
bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion();
|
|
|
|
this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
|
|
|
|
|
|
|
|
bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
|
|
|
|
this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
|
2011-08-21 19:23:06 +00:00
|
|
|
}
|
2009-07-18 10:46:55 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void DrawWidget(const Rect &r, int widget) const override
|
2011-08-21 19:23:06 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2017-01-14 18:30:26 +00:00
|
|
|
case WID_SGI_BASESET:
|
|
|
|
SetDParam(0, _missing_extra_graphics);
|
|
|
|
DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_BASESET, TC_FROMSTRING, SA_CENTER);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_TRANSLATION:
|
2011-08-21 19:23:06 +00:00
|
|
|
SetDParam(0, _current_language->missing);
|
|
|
|
DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
2011-08-21 19:23:06 +00:00
|
|
|
{
|
2017-01-14 18:30:26 +00:00
|
|
|
StringID str = 0;
|
2011-08-21 19:23:06 +00:00
|
|
|
switch (widget) {
|
2017-01-14 18:30:26 +00:00
|
|
|
case WID_SGI_BASESET:
|
|
|
|
SetDParam(0, _missing_extra_graphics);
|
|
|
|
str = STR_INTRO_BASESET;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WID_SGI_TRANSLATION:
|
2011-08-21 19:23:06 +00:00
|
|
|
SetDParam(0, _current_language->missing);
|
2017-01-14 18:30:26 +00:00
|
|
|
str = STR_INTRO_TRANSLATION;
|
2011-08-21 19:23:06 +00:00
|
|
|
break;
|
2017-01-14 18:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (str != 0) {
|
|
|
|
int height = GetStringHeight(str, size->width);
|
|
|
|
if (height > 3 * FONT_HEIGHT_NORMAL) {
|
|
|
|
/* Don't let the window become too high. */
|
|
|
|
Dimension textdim = GetStringBoundingBox(str);
|
|
|
|
textdim.height *= 3;
|
|
|
|
textdim.width -= textdim.width / 2;
|
|
|
|
*size = maxdim(*size, textdim);
|
|
|
|
} else {
|
|
|
|
size->height = height + padding.height;
|
2011-08-21 19:23:06 +00:00
|
|
|
}
|
2009-07-04 15:35:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
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. */
|
2011-12-16 16:49:53 +00:00
|
|
|
if (IsInsideMM(widget, WID_SGI_GENERATE_GAME, WID_SGI_EDIT_SCENARIO + 1)) _is_network_server = false;
|
2007-04-30 20:05:31 +00:00
|
|
|
|
2008-05-17 21:20:58 +00:00
|
|
|
switch (widget) {
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_GENERATE_GAME:
|
2009-03-12 16:48:28 +00:00
|
|
|
if (_ctrl_pressed) {
|
|
|
|
StartNewGameWithoutGUI(GENERATE_NEW_SEED);
|
|
|
|
} else {
|
|
|
|
ShowGenerateLandscape();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-09-04 16:06:50 +00:00
|
|
|
case WID_SGI_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
|
|
|
|
case WID_SGI_PLAY_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
|
|
|
|
case WID_SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break;
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_EDIT_SCENARIO: StartScenarioEditor(); break;
|
2008-05-17 21:20:58 +00:00
|
|
|
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_PLAY_NETWORK:
|
2008-05-17 21:20:58 +00:00
|
|
|
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;
|
|
|
|
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_TEMPERATE_LANDSCAPE: case WID_SGI_ARCTIC_LANDSCAPE:
|
|
|
|
case WID_SGI_TROPIC_LANDSCAPE: case WID_SGI_TOYLAND_LANDSCAPE:
|
|
|
|
SetNewLandscapeType(widget - WID_SGI_TEMPERATE_LANDSCAPE);
|
2008-05-17 21:20:58 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_OPTIONS: ShowGameOptions(); break;
|
2012-12-05 19:37:15 +00:00
|
|
|
case WID_SGI_HIGHSCORE: ShowHighscoreTable(); break;
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_SETTINGS_OPTIONS:ShowGameSettings(); break;
|
|
|
|
case WID_SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
|
|
|
|
case WID_SGI_CONTENT_DOWNLOAD:
|
2009-01-17 16:53:32 +00:00
|
|
|
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;
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_AI_SETTINGS: ShowAIConfigWindow(); break;
|
2022-11-10 20:39:09 +00:00
|
|
|
case WID_SGI_GS_SETTINGS: ShowGSConfigWindow(); break;
|
2011-12-16 16:49:53 +00:00
|
|
|
case WID_SGI_EXIT: HandleExitGameRequest(); break;
|
2008-05-17 21:20:58 +00:00
|
|
|
}
|
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),
|
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* 'New Game' and 'Load Game' buttons */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GENERATE_GAME), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_LOAD_GAME), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
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),
|
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* 'Play Scenario' and 'Play Heightmap' buttons */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_SCENARIO), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_HEIGHTMAP), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
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),
|
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* 'Scenario Editor' and 'Multiplayer' buttons */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EDIT_SCENARIO), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(STR_INTRO_SCENARIO_EDITOR, STR_INTRO_TOOLTIP_SCENARIO_EDITOR), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_NETWORK), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(STR_INTRO_MULTIPLAYER, STR_INTRO_TOOLTIP_MULTIPLAYER), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 7),
|
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* Climate selection buttons */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_TEMPERATE_LANDSCAPE), SetMinimalSize(77, 55),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_ARCTIC_LANDSCAPE), SetMinimalSize(77, 55),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_TROPIC_LANDSCAPE), SetMinimalSize(77, 55),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_TOYLAND_LANDSCAPE), SetMinimalSize(77, 55),
|
2009-11-24 18:05:55 +00:00
|
|
|
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),
|
2017-01-14 18:30:26 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_SGI_BASESET_SELECTION),
|
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_BASESET), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
|
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_SGI_TRANSLATION_SELECTION),
|
2011-08-21 19:23:06 +00:00
|
|
|
NWidget(NWID_VERTICAL),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_TRANSLATION), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
|
2011-08-21 19:23:06 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
2009-11-24 18:05:55 +00:00
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* 'Game Options' and 'Settings' buttons */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_OPTIONS), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(STR_INTRO_GAME_OPTIONS, STR_INTRO_TOOLTIP_GAME_OPTIONS), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
2012-12-05 19:37:15 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_SETTINGS_OPTIONS), SetMinimalSize(158, 12),
|
2014-10-09 21:16:29 +00:00
|
|
|
SetDataTip(STR_INTRO_CONFIG_SETTINGS_TREE, STR_INTRO_TOOLTIP_CONFIG_SETTINGS_TREE), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
2009-11-24 18:05:55 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* 'AI Settings' and 'Game Script Settings' buttons */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2022-12-25 18:26:26 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_AI_SETTINGS), SetMinimalSize(158, 12),
|
2022-11-10 20:39:09 +00:00
|
|
|
SetDataTip(STR_INTRO_AI_SETTINGS, STR_INTRO_TOOLTIP_AI_SETTINGS), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
2022-12-25 18:26:26 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GS_SETTINGS), SetMinimalSize(158, 12),
|
|
|
|
SetDataTip(STR_INTRO_GAMESCRIPT_SETTINGS, STR_INTRO_TOOLTIP_GAMESCRIPT_SETTINGS), SetPadding(0, 10, 0, 0), SetFill(1, 0),
|
2009-11-24 18:05:55 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* 'Check Online Content' and 'NewGRF Settings' buttons */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_CONTENT_DOWNLOAD), SetMinimalSize(158, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), SetPadding(0, 0, 0, 10), SetFill(1, 0),
|
2022-12-25 18:26:26 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_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),
|
|
|
|
|
|
|
|
/* 'Highscore Table' button */
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_HIGHSCORE), SetMinimalSize(316, 12),
|
|
|
|
SetDataTip(STR_INTRO_HIGHSCORE, STR_INTRO_TOOLTIP_HIGHSCORE), SetPadding(0, 10, 0, 10), SetFill(1, 0),
|
2009-11-24 18:05:55 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
|
|
|
|
2022-12-25 18:26:26 +00:00
|
|
|
/* 'Exit' button */
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2011-12-16 16:49:53 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EXIT), SetMinimalSize(128, 12),
|
2009-11-24 18:05:55 +00:00
|
|
|
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(),
|
|
|
|
};
|
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _select_game_desc(
|
2019-04-10 21:07:06 +00:00
|
|
|
WDP_CENTER, nullptr, 0, 0,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SELECT_GAME, WC_NONE,
|
2012-11-11 16:10:43 +00:00
|
|
|
0,
|
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
|
|
|
{
|
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,
|
2019-04-10 21:07:06 +00:00
|
|
|
nullptr,
|
2006-12-29 17:56:34 +00:00
|
|
|
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
|
|
|
{
|
2011-12-10 15:14:11 +00:00
|
|
|
if (confirmed) {
|
|
|
|
_switch_mode = SM_MENU;
|
|
|
|
ClearErrorMessages();
|
|
|
|
}
|
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,
|
2019-04-10 21:07:06 +00:00
|
|
|
nullptr,
|
2006-12-29 17:56:34 +00:00
|
|
|
AskExitToGameMenuCallback
|
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|