OpenTTD Source 20250528-master-g3aca5d62a8
intro_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10#include "stdafx.h"
11#include "error.h"
12#include "gui.h"
13#include "window_gui.h"
14#include "window_func.h"
15#include "textbuf_gui.h"
16#include "help_gui.h"
17#include "network/network.h"
18#include "genworld.h"
19#include "network/network_gui.h"
22#include "landscape_type.h"
23#include "landscape.h"
24#include "strings_func.h"
25#include "fios.h"
26#include "ai/ai_gui.hpp"
27#include "game/game_gui.hpp"
28#include "gfx_func.h"
31#include "language.h"
32#include "rev.h"
33#include "highscore.h"
34#include "signs_base.h"
35#include "viewport_func.h"
36#include "vehicle_base.h"
37#include <regex>
38
40
41#include "table/strings.h"
42#include "table/sprites.h"
43
44#include "safeguards.h"
45
46
52 enum AlignmentH : uint8_t {
53 LEFT,
54 CENTRE,
55 RIGHT,
56 };
58 enum AlignmentV : uint8_t {
59 TOP,
60 MIDDLE,
61 BOTTOM,
62 };
63
64 int command_index = 0;
65 Point position{ 0, 0 };
66 VehicleID vehicle = VehicleID::Invalid();
67 uint delay = 0;
68 int zoom_adjust = 0;
69 bool pan_to_next = false;
72
80 {
81 if (this->vehicle != VehicleID::Invalid()) {
82 const Vehicle *v = Vehicle::Get(this->vehicle);
83 this->position = RemapCoords(v->x_pos, v->y_pos, v->z_pos);
84 }
85
86 Point p;
87 switch (this->align_h) {
88 case LEFT: p.x = this->position.x; break;
89 case CENTRE: p.x = this->position.x - vp.virtual_width / 2; break;
90 case RIGHT: p.x = this->position.x - vp.virtual_width; break;
91 }
92 switch (this->align_v) {
93 case TOP: p.y = this->position.y; break;
94 case MIDDLE: p.y = this->position.y - vp.virtual_height / 2; break;
95 case BOTTOM: p.y = this->position.y - vp.virtual_height; break;
96 }
97 return p;
98 }
99};
100
101
102struct SelectGameWindow : public Window {
104 std::vector<IntroGameViewportCommand> intro_viewport_commands{};
106 size_t cur_viewport_command_index = SIZE_MAX;
109 uint mouse_idle_time = 0;
110 Point mouse_idle_pos{};
111
117 {
119
120 /* Regular expression matching the commands: T, spaces, integer, spaces, flags, spaces, integer */
121 static const std::string sign_language = "^T\\s*([0-9]+)\\s*([-+A-Z0-9]+)\\s*([0-9]+)";
122 std::regex re(sign_language, std::regex_constants::icase);
123
124 /* List of signs successfully parsed to delete afterwards. */
125 std::vector<SignID> signs_to_delete;
126
127 for (const Sign *sign : Sign::Iterate()) {
128 std::smatch match;
129 if (!std::regex_search(sign->name, match, re)) continue;
130
132 /* Sequence index from the first matching group. */
133 if (auto value = ParseInteger<int>(match[1].str()); value.has_value()) {
134 vc.command_index = *value;
135 } else {
136 continue;
137 }
138 /* Sign coordinates for positioning. */
139 vc.position = RemapCoords(sign->x, sign->y, sign->z);
140 /* Delay from the third matching group. */
141 if (auto value = ParseInteger<uint>(match[3].str()); value.has_value()) {
142 vc.delay = *value * 1000; // milliseconds
143 } else {
144 continue;
145 }
146
147 /* Parse flags from second matching group. */
148 auto flags = match[2].str();
149 StringConsumer consumer{flags};
150 while (consumer.AnyBytesLeft()) {
151 auto c = consumer.ReadUtf8();
152 switch (toupper(c)) {
153 case '-': vc.zoom_adjust = +1; break;
154 case '+': vc.zoom_adjust = -1; break;
155 case 'T': vc.align_v = IntroGameViewportCommand::TOP; break;
156 case 'M': vc.align_v = IntroGameViewportCommand::MIDDLE; break;
157 case 'B': vc.align_v = IntroGameViewportCommand::BOTTOM; break;
158 case 'L': vc.align_h = IntroGameViewportCommand::LEFT; break;
159 case 'C': vc.align_h = IntroGameViewportCommand::CENTRE; break;
160 case 'R': vc.align_h = IntroGameViewportCommand::RIGHT; break;
161 case 'P': vc.pan_to_next = true; break;
162 case 'V': vc.vehicle = static_cast<VehicleID>(consumer.ReadIntegerBase<uint32_t>(10, VehicleID::Invalid().base())); break;
163 }
164 }
165
166 /* Successfully parsed, store. */
167 intro_viewport_commands.push_back(vc);
168 signs_to_delete.push_back(sign->index);
169 }
170
171 /* Sort the commands by sequence index. */
172 std::sort(intro_viewport_commands.begin(), intro_viewport_commands.end(), [](const IntroGameViewportCommand &a, const IntroGameViewportCommand &b) { return a.command_index < b.command_index; });
173
174 /* Delete all the consumed signs, from last ID to first ID. */
175 std::sort(signs_to_delete.begin(), signs_to_delete.end(), [](SignID a, SignID b) { return a > b; });
176 for (SignID sign_id : signs_to_delete) {
177 delete Sign::Get(sign_id);
178 }
179 }
180
181 SelectGameWindow(WindowDesc &desc) : Window(desc), mouse_idle_pos(_cursor.pos)
182 {
183 this->CreateNestedTree();
184 this->FinishInitNested(0);
185 this->OnInvalidateData();
186
188 }
189
190 void OnRealtimeTick(uint delta_ms) override
191 {
192 /* Move the main game viewport according to intro viewport commands. */
193
194 if (intro_viewport_commands.empty()) return;
195
196 bool suppress_panning = true;
197 if (this->mouse_idle_pos.x != _cursor.pos.x || this->mouse_idle_pos.y != _cursor.pos.y) {
198 this->mouse_idle_pos = _cursor.pos;
199 this->mouse_idle_time = 2000;
200 } else if (this->mouse_idle_time > delta_ms) {
201 this->mouse_idle_time -= delta_ms;
202 } else {
203 this->mouse_idle_time = 0;
204 suppress_panning = false;
205 }
206
207 /* Determine whether to move to the next command or stay at current. */
208 bool changed_command = false;
209 if (this->cur_viewport_command_index >= intro_viewport_commands.size()) {
210 /* Reached last, rotate back to start of the list. */
211 this->cur_viewport_command_index = 0;
212 changed_command = true;
213 } else {
214 /* Check if current command has elapsed and switch to next. */
215 this->cur_viewport_command_time += delta_ms;
216 if (this->cur_viewport_command_time >= intro_viewport_commands[this->cur_viewport_command_index].delay) {
217 this->cur_viewport_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
218 this->cur_viewport_command_time = 0;
219 changed_command = true;
220 }
221 }
222
224 Window *mw = GetMainWindow();
225
226 /* Early exit if the current command hasn't elapsed and isn't animated. */
227 if (!changed_command && !vc.pan_to_next && vc.vehicle == VehicleID::Invalid()) return;
228
229 /* Suppress panning commands, while user interacts with GUIs. */
230 if (!changed_command && suppress_panning) return;
231
232 /* Reset the zoom level. */
233 if (changed_command) FixTitleGameZoom(vc.zoom_adjust);
234
235 /* Calculate current command position (updates followed vehicle coordinates). */
236 Point pos = vc.PositionForViewport(*mw->viewport);
237
238 /* Calculate panning (linear interpolation between current and next command position). */
239 if (vc.pan_to_next) {
240 size_t next_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
241 IntroGameViewportCommand &nvc = intro_viewport_commands[next_command_index];
242 Point pos2 = nvc.PositionForViewport(*mw->viewport);
243 const double t = this->cur_viewport_command_time / (double)vc.delay;
244 pos.x = pos.x + (int)(t * (pos2.x - pos.x));
245 pos.y = pos.y + (int)(t * (pos2.y - pos.y));
246 }
247
248 /* Update the viewport position. */
249 mw->viewport->dest_scrollpos_x = mw->viewport->scrollpos_x = pos.x;
250 mw->viewport->dest_scrollpos_y = mw->viewport->scrollpos_y = pos.y;
251 UpdateViewportPosition(mw, delta_ms);
252 mw->SetDirty(); // Required during panning, otherwise logo graphics disappears
253
254 /* If there is only one command, we just executed it and don't need to do any more */
255 if (intro_viewport_commands.size() == 1 && vc.vehicle == VehicleID::Invalid()) intro_viewport_commands.clear();
256 }
257
258 void OnInit() override
259 {
260 bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion();
261 this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
262
263 bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
264 this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
265 }
266
267 void DrawWidget(const Rect &r, WidgetID widget) const override
268 {
269 switch (widget) {
270 case WID_SGI_BASESET:
271 DrawStringMultiLine(r, GetString(STR_INTRO_BASESET, _missing_extra_graphics), TC_FROMSTRING, SA_CENTER);
272 break;
273
275 DrawStringMultiLine(r, GetString(STR_INTRO_TRANSLATION, _current_language->missing), TC_FROMSTRING, SA_CENTER);
276 break;
277 }
278 }
279
280 void OnResize() override
281 {
282 bool changed = false;
283
284 if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_BASESET); wid != nullptr && wid->current_x > 0) {
285 changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_BASESET, _missing_extra_graphics), 3);
286 }
287
288 if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_TRANSLATION); wid != nullptr && wid->current_x > 0) {
289 changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION, _current_language->missing), 3);
290 }
291
292 if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred));
293 }
294
295 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
296 {
297 switch (widget) {
299 _is_network_server = false;
300 if (_ctrl_pressed) {
302 } else {
304 }
305 break;
307 _is_network_server = false;
309 break;
311 _is_network_server = false;
313 break;
315 _is_network_server = false;
317 break;
319 _is_network_server = false;
321 break;
322
324 if (!_network_available) {
325 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WL_ERROR);
326 } else {
327 ShowNetworkGameWindow();
328 }
329 break;
330
331 case WID_SGI_OPTIONS: ShowGameOptions(); break;
333 case WID_SGI_HELP: ShowHelpWindow(); break;
335 if (!_network_available) {
336 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WL_ERROR);
337 } else {
339 }
340 break;
341 case WID_SGI_EXIT: HandleExitGameRequest(); break;
342 }
343 }
344};
345
346static constexpr NWidgetPart _nested_select_game_widgets[] = {
347 NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_INTRO_CAPTION),
348 NWidget(WWT_PANEL, COLOUR_BROWN),
350
351 /* Single player */
353 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_GENERATE_GAME), SetSpriteStringTip(SPR_IMG_LANDSCAPING, STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
354 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_HEIGHTMAP), SetSpriteStringTip(SPR_IMG_SHOW_COUNTOURS, STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_TOOLTIP_PLAY_HEIGHTMAP), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
355 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_SCENARIO), SetSpriteStringTip(SPR_IMG_SUBSIDIES, STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
356 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_LOAD_GAME), SetSpriteStringTip(SPR_IMG_SAVE, STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
357 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_HIGHSCORE), SetSpriteStringTip(SPR_IMG_COMPANY_LEAGUE, STR_INTRO_HIGHSCORE, STR_INTRO_TOOLTIP_HIGHSCORE), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
358 EndContainer(),
359
360 /* Multi player */
362 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_NETWORK), SetSpriteStringTip(SPR_IMG_COMPANY_GENERAL, STR_INTRO_MULTIPLAYER, STR_INTRO_TOOLTIP_MULTIPLAYER), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
363 EndContainer(),
364
367 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SGI_BASESET), SetFill(1, 0),
368 EndContainer(),
369 EndContainer(),
370
373 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SGI_TRANSLATION), SetFill(1, 0),
374 EndContainer(),
375 EndContainer(),
376
377 /* Other */
379 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_OPTIONS), SetSpriteStringTip(SPR_IMG_SETTINGS, STR_INTRO_GAME_OPTIONS, STR_INTRO_TOOLTIP_GAME_OPTIONS), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
380 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_CONTENT_DOWNLOAD), SetSpriteStringTip(SPR_IMG_SHOW_VEHICLES, STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
381 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_EDIT_SCENARIO), SetSpriteStringTip(SPR_IMG_SMALLMAP, STR_INTRO_SCENARIO_EDITOR, STR_INTRO_TOOLTIP_SCENARIO_EDITOR), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
382 NWidget(WWT_PUSHIMGTEXTBTN, COLOUR_ORANGE, WID_SGI_HELP), SetSpriteStringTip(SPR_IMG_QUERY, STR_INTRO_HELP, STR_INTRO_TOOLTIP_HELP), SetAlignment(SA_LEFT | SA_VERT_CENTER), SetFill(1, 0),
383 EndContainer(),
384
386 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EXIT), SetMinimalSize(0, 20 + WidgetDimensions::unscaled.framerect.Vertical()), SetStringTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
387 EndContainer(),
388 EndContainer(),
389 EndContainer(),
390};
391
392static WindowDesc _select_game_desc(
393 WDP_CENTER, {}, 0, 0,
396 _nested_select_game_widgets
397);
398
399void ShowSelectGameWindow()
400{
401 new SelectGameWindow(_select_game_desc);
402}
403
404static void AskExitGameCallback(Window *, bool confirmed)
405{
406 if (confirmed) {
408 _exit_game = true;
409 }
410}
411
412void AskExitGame()
413{
414 ShowQuery(
415 GetEncodedString(STR_QUIT_CAPTION),
416 GetEncodedString(STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD),
417 nullptr,
418 AskExitGameCallback,
419 true
420 );
421}
422
423
424static void AskExitToGameMenuCallback(Window *, bool confirmed)
425{
426 if (confirmed) {
429 }
430}
431
432void AskExitToGameMenu()
433{
434 ShowQuery(
435 GetEncodedString(STR_ABANDON_GAME_CAPTION),
436 GetEncodedString((_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY),
437 nullptr,
438 AskExitToGameMenuCallback,
439 true
440 );
441}
Window for configuring the AIs
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
uint current_x
Current horizontal size (after resizing).
Base class for a resizable nested widget.
@ EXIT
User is exiting the application.
void Transmit(Reason reason, bool blocking=false)
Transmit the survey.
Parse data from a string / buffer.
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
Functions related to errors.
void ClearErrorMessages()
Clear all errors from the queue.
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition error.h:26
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
@ SLO_LOAD
File is being loaded.
Definition fileio_type.h:53
@ FT_SCENARIO
old or new scenario
Definition fileio_type.h:19
@ FT_HEIGHTMAP
heightmap file
Definition fileio_type.h:20
@ FT_SAVEGAME
old or new savegame
Definition fileio_type.h:18
Declarations for savegames operations.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition fios_gui.cpp:984
Window for configuring the Games
Functions related to world/map generation.
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
Definition genworld.h:25
void StartScenarioEditor()
Start with a scenario editor.
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
void ShowGenerateLandscape()
Start with a normal game.
Geometry functions.
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:38
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition gfx.cpp:775
SwitchMode _switch_mode
The next mainloop command.
Definition gfx.cpp:49
Functions related to the gfx engine.
@ SA_LEFT
Left align the text.
Definition gfx_type.h:383
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:393
@ SA_VERT_CENTER
Vertically center the text.
Definition gfx_type.h:389
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
constexpr NWidgetPart SetSpriteStringTip(SpriteID sprite, StringID string, StringID tip={})
Widget part function for setting the sprite, string and tooltip.
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:955
GUI functions that shouldn't be here.
void ShowGameOptions()
Open the game options window.
GUI to access manuals and related.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Types related to the intro widgets.
@ WID_SGI_PLAY_NETWORK
Play network button.
@ WID_SGI_TRANSLATION
Translation errors.
@ WID_SGI_BASESET
Baseset errors.
@ WID_SGI_GENERATE_GAME
Generate game button.
@ WID_SGI_EDIT_SCENARIO
Edit scenario button.
@ WID_SGI_LOAD_GAME
Load game button.
@ WID_SGI_PLAY_HEIGHTMAP
Play heightmap button.
@ WID_SGI_HIGHSCORE
Highscore button.
@ WID_SGI_EXIT
Exit button.
@ WID_SGI_BASESET_SELECTION
Baseset selection.
@ WID_SGI_CONTENT_DOWNLOAD
Content Download button.
@ WID_SGI_HELP
Help and manuals button.
@ WID_SGI_TRANSLATION_SELECTION
Translation selection.
@ WID_SGI_OPTIONS
Options button.
@ WID_SGI_PLAY_SCENARIO
Play scenario button.
Functions related to OTTD's landscape.
Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
Definition landscape.h:79
Types related to the landscape.
Information about languages and their files.
const LanguageMetadata * _current_language
The currently loaded language.
Definition strings.cpp:55
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
bool _is_network_server
Does this client wants to be a network-server?
Definition network.cpp:71
bool _network_available
is network mode available?
Definition network.cpp:69
Basic functions/variables used all over the place.
Part of the network protocol handling content distribution.
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
GUIs related to networking.
Part of the network protocol handling opt-in survey.
uint _missing_extra_graphics
Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset.
@ SM_MENU
Switch to game intro menu.
Definition openttd.h:33
declaration of OTTD revision dependent variables
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
Base class for signs.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
Parse strings.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:91
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:415
Functions related to OTTD's strings.
GUISettings gui
settings related to the GUI
Point pos
logical mouse position
Definition gfx_type.h:126
uint8_t missing_strings_threshold
the number of missing strings before showing the warning
A viewport command for the main menu background (intro game).
Definition intro_gui.cpp:50
int zoom_adjust
Adjustment to zoom level from base zoom level.
Definition intro_gui.cpp:68
Point PositionForViewport(const Viewport &vp)
Calculate effective position.
Definition intro_gui.cpp:79
uint delay
Delay until next command.
Definition intro_gui.cpp:67
VehicleID vehicle
Vehicle to follow, or VehicleID::Invalid() if not following a vehicle.
Definition intro_gui.cpp:66
bool pan_to_next
If true, do a smooth pan from this position to the next.
Definition intro_gui.cpp:69
AlignmentH align_h
Horizontal alignment.
Definition intro_gui.cpp:70
AlignmentH
Horizontal alignment value.
Definition intro_gui.cpp:52
AlignmentV
Vertical alignment value.
Definition intro_gui.cpp:58
AlignmentV align_v
Vertical alignment.
Definition intro_gui.cpp:71
int command_index
Sequence number of the command (order they are performed in).
Definition intro_gui.cpp:64
Point position
Calculated world coordinate to position viewport top-left at.
Definition intro_gui.cpp:65
uint16_t missing
number of missing strings.
Definition language.h:40
Partial widget specification to allow NWidgets to be written nested.
Coordinates of a point in 2D.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * Get(auto index)
Returns Titem with given index.
Specification of a rectangle with absolute coordinates of all edges.
void ReadIntroGameViewportCommands()
Find and parse all viewport command signs.
std::vector< IntroGameViewportCommand > intro_viewport_commands
Vector of viewport commands parsed.
void OnResize() override
Called after the window got resized.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
size_t cur_viewport_command_index
Index of currently active viewport command.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
uint cur_viewport_command_time
Time spent (milliseconds) on current viewport command.
void OnInit() override
Notification that the nested widget tree gets initialized.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Vehicle data structure.
int32_t z_pos
z coordinate.
int32_t y_pos
y coordinate.
int32_t x_pos
x coordinate.
Data structure for viewport, display of a part of the world.
int virtual_width
width << zoom
int virtual_height
height << zoom
High level window description.
Definition window_gui.h:167
Data structure for an opened window.
Definition window_gui.h:273
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:967
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition window_gui.h:792
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1778
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
Definition window_gui.h:318
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1768
WindowFlags flags
Window flags.
Definition window_gui.h:300
Stuff related to the text buffer GUI.
Base class for all vehicles.
void UpdateViewportPosition(Window *w, uint32_t delta_ms)
Update the viewport position being displayed.
Functions related to (drawing on) viewports.
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
@ WWT_PUSHIMGTEXTBTN
Normal push-button (no toggle button) with image and text caption.
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:40
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:53
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:69
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:38
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:72
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Window * GetMainWindow()
Get the main window, i.e.
Definition window.cpp:1169
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ NoClose
This window can't be interactively closed.
@ Centred
Window is centered and shall stay centered after ReInit.
@ WDP_CENTER
Center the window.
Definition window_gui.h:145
int WidgetID
Widget ID.
Definition window_type.h:20
@ WC_SELECT_GAME
Select game window; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:47