OpenTTD Source 20260711-master-g3fb3006dff
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
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"
30#include "language.h"
31#include "rev.h"
32#include "highscore.h"
33#include "signs_base.h"
34#include "viewport_func.h"
35#include "vehicle_base.h"
36#include <regex>
37
39
40#include "table/strings.h"
41#include "table/sprites.h"
42
43#include "safeguards.h"
44
45
50 int command_index = 0;
51 Point position{ 0, 0 };
52 VehicleID vehicle = VehicleID::Invalid();
53 uint delay = 0;
54 int zoom_adjust = 0;
55 bool pan_to_next = false;
57
65 {
66 if (this->vehicle != VehicleID::Invalid()) {
67 const Vehicle *v = Vehicle::Get(this->vehicle);
68 this->position = RemapCoords(v->x_pos, v->y_pos, v->z_pos);
69 }
70
71 Point p;
72 switch (this->align.ResolveRTL()) {
73 case AlignmentH::ForceLeft: p.x = this->position.x; break;
74 case AlignmentH::Centre: p.x = this->position.x - vp.virtual_width / 2; break;
75 case AlignmentH::ForceRight: p.x = this->position.x - vp.virtual_width; break;
76 default: NOT_REACHED();
77 }
78 switch (this->align.v) {
79 case AlignmentV::Top: p.y = this->position.y; break;
80 case AlignmentV::Middle: p.y = this->position.y - vp.virtual_height / 2; break;
81 case AlignmentV::Bottom: p.y = this->position.y - vp.virtual_height; break;
82 }
83 return p;
84 }
85};
86
87
88struct SelectGameWindow : public Window {
90 std::vector<IntroGameViewportCommand> intro_viewport_commands{};
92 size_t cur_viewport_command_index = SIZE_MAX;
95 uint mouse_idle_time = 0;
96 Point mouse_idle_pos{};
97
103 {
105
106 /* Regular expression matching the commands: T, spaces, integer, spaces, flags, spaces, integer */
107 static const std::string sign_language = "^T\\s*([0-9]+)\\s*([-+A-Z0-9]+)\\s*([0-9]+)";
108 std::regex re(sign_language, std::regex_constants::icase);
109
110 /* List of signs successfully parsed to delete afterwards. */
111 std::vector<SignID> signs_to_delete;
112
113 for (const Sign *sign : Sign::Iterate()) {
114 std::smatch match;
115 if (!std::regex_search(sign->name, match, re)) continue;
116
118 /* Sequence index from the first matching group. */
119 if (auto value = ParseInteger<int>(match[1].str()); value.has_value()) {
120 vc.command_index = *value;
121 } else {
122 continue;
123 }
124 /* Sign coordinates for positioning. */
125 vc.position = RemapCoords(sign->x, sign->y, sign->z);
126 /* Delay from the third matching group. */
127 if (auto value = ParseInteger<uint>(match[3].str()); value.has_value()) {
128 vc.delay = *value * 1000; // milliseconds
129 } else {
130 continue;
131 }
132
133 /* Parse flags from second matching group. */
134 auto flags = match[2].str();
135 StringConsumer consumer{flags};
136 while (consumer.AnyBytesLeft()) {
137 auto c = consumer.ReadUtf8();
138 switch (toupper(c)) {
139 case '-': vc.zoom_adjust = +1; break;
140 case '+': vc.zoom_adjust = -1; break;
141 case 'T': vc.align.v = AlignmentV::Top; break;
142 case 'M': vc.align.v = AlignmentV::Middle; break;
143 case 'B': vc.align.v = AlignmentV::Bottom; break;
144 case 'L': vc.align.h = AlignmentH::ForceLeft; break;
145 case 'C': vc.align.h = AlignmentH::Centre; break;
146 case 'R': vc.align.h = AlignmentH::ForceRight; break;
147 case 'P': vc.pan_to_next = true; break;
148 case 'V': vc.vehicle = static_cast<VehicleID>(consumer.ReadIntegerBase<uint32_t>(10, VehicleID::Invalid().base())); break;
149 }
150 }
151
152 /* Successfully parsed, store. */
153 intro_viewport_commands.push_back(vc);
154 signs_to_delete.push_back(sign->index);
155 }
156
157 /* Sort the commands by sequence index. */
158 std::sort(intro_viewport_commands.begin(), intro_viewport_commands.end(), [](const IntroGameViewportCommand &a, const IntroGameViewportCommand &b) { return a.command_index < b.command_index; });
159
160 /* Delete all the consumed signs, from last ID to first ID. */
161 std::sort(signs_to_delete.begin(), signs_to_delete.end(), [](SignID a, SignID b) { return a > b; });
162 for (SignID sign_id : signs_to_delete) {
163 delete Sign::Get(sign_id);
164 }
165 }
166
167 SelectGameWindow(WindowDesc &desc) : Window(desc), mouse_idle_pos(_cursor.pos)
168 {
169 this->CreateNestedTree();
170 this->FinishInitNested(0);
171 this->OnInvalidateData();
172
174 }
175
176 void OnRealtimeTick(uint delta_ms) override
177 {
178 /* Move the main game viewport according to intro viewport commands. */
179
180 if (intro_viewport_commands.empty()) return;
181
182 bool suppress_panning = true;
183 if (this->mouse_idle_pos.x != _cursor.pos.x || this->mouse_idle_pos.y != _cursor.pos.y) {
184 this->mouse_idle_pos = _cursor.pos;
185 this->mouse_idle_time = 2000;
186 } else if (this->mouse_idle_time > delta_ms) {
187 this->mouse_idle_time -= delta_ms;
188 } else {
189 this->mouse_idle_time = 0;
190 suppress_panning = false;
191 }
192
193 /* Determine whether to move to the next command or stay at current. */
194 bool changed_command = false;
195 if (this->cur_viewport_command_index >= intro_viewport_commands.size()) {
196 /* Reached last, rotate back to start of the list. */
197 this->cur_viewport_command_index = 0;
198 changed_command = true;
199 } else {
200 /* Check if current command has elapsed and switch to next. */
201 this->cur_viewport_command_time += delta_ms;
202 if (this->cur_viewport_command_time >= intro_viewport_commands[this->cur_viewport_command_index].delay) {
203 this->cur_viewport_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
204 this->cur_viewport_command_time = 0;
205 changed_command = true;
206 }
207 }
208
209 IntroGameViewportCommand &vc = intro_viewport_commands[this->cur_viewport_command_index];
210 Window *mw = GetMainWindow();
211
212 /* Early exit if the current command hasn't elapsed and isn't animated. */
213 if (!changed_command && !vc.pan_to_next && vc.vehicle == VehicleID::Invalid()) return;
214
215 /* Suppress panning commands, while user interacts with GUIs. */
216 if (!changed_command && suppress_panning) return;
217
218 /* Reset the zoom level. */
219 if (changed_command) FixTitleGameZoom(vc.zoom_adjust);
220
221 /* Calculate current command position (updates followed vehicle coordinates). */
222 Point pos = vc.PositionForViewport(*mw->viewport);
223
224 /* Calculate panning (linear interpolation between current and next command position). */
225 if (vc.pan_to_next) {
226 size_t next_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
227 IntroGameViewportCommand &nvc = intro_viewport_commands[next_command_index];
228 Point pos2 = nvc.PositionForViewport(*mw->viewport);
229 const double t = this->cur_viewport_command_time / (double)vc.delay;
230 pos.x = pos.x + (int)(t * (pos2.x - pos.x));
231 pos.y = pos.y + (int)(t * (pos2.y - pos.y));
232 }
233
234 /* Update the viewport position. */
235 mw->viewport->dest_scrollpos_x = mw->viewport->scrollpos_x = pos.x;
236 mw->viewport->dest_scrollpos_y = mw->viewport->scrollpos_y = pos.y;
237 UpdateViewportPosition(mw, delta_ms);
238 mw->SetDirty(); // Required during panning, otherwise logo graphics disappears
239
240 /* If there is only one command, we just executed it and don't need to do any more */
241 if (intro_viewport_commands.size() == 1 && vc.vehicle == VehicleID::Invalid()) intro_viewport_commands.clear();
242 }
243
244 void OnInit() override
245 {
246 bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion();
247 this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
248
249 bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
250 this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
251 }
252
253 void DrawWidget(const Rect &r, WidgetID widget) const override
254 {
255 switch (widget) {
256 case WID_SGI_BASESET:
258 break;
259
261 DrawStringMultiLine(r, GetString(STR_INTRO_TRANSLATION, _current_language->missing), TextColour::FromString, {AlignmentH::Centre, AlignmentV::Middle});
262 break;
263 }
264 }
265
266 void OnResize() override
267 {
268 bool changed = false;
269
270 if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_BASESET); wid != nullptr && wid->current_x > 0) {
271 changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_BASESET, _missing_extra_graphics), 3);
272 }
273
274 if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_TRANSLATION); wid != nullptr && wid->current_x > 0) {
275 changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION, _current_language->missing), 3);
276 }
277
278 if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred));
279 }
280
281 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
282 {
283 switch (widget) {
285 _is_network_server = false;
286 if (_ctrl_pressed) {
288 } else {
290 }
291 break;
293 _is_network_server = false;
295 break;
297 _is_network_server = false;
299 break;
301 _is_network_server = false;
303 break;
305 _is_network_server = false;
307 break;
308
310 if (!_network_available) {
311 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WarningLevel::Error);
312 } else {
314 }
315 break;
316
317 case WID_SGI_OPTIONS: ShowGameOptions(); break;
319 case WID_SGI_HELP: ShowHelpWindow(); break;
321 if (!_network_available) {
322 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WarningLevel::Error);
323 } else {
325 }
326 break;
327 case WID_SGI_EXIT: HandleExitGameRequest(); break;
328 }
329 }
330};
331
332static constexpr std::initializer_list<NWidgetPart> _nested_select_game_widgets = {
333 NWidget(WWT_CAPTION, Colours::Brown), SetStringTip(STR_INTRO_CAPTION),
336
337 /* Single player */
344 EndContainer(),
345
346 /* Multi player */
349 EndContainer(),
350
354 EndContainer(),
355 EndContainer(),
356
360 EndContainer(),
361 EndContainer(),
362
363 /* Other */
369 EndContainer(),
370
372 NWidget(WWT_PUSHTXTBTN, Colours::Orange, WID_SGI_EXIT), SetToolbarMinimalSize(1), SetStringTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
373 EndContainer(),
374 EndContainer(),
375 EndContainer(),
376};
377
380 WindowPosition::Center, {}, 0, 0,
381 WindowClass::SelectGame, WindowClass::None,
383 _nested_select_game_widgets
384);
385
386void ShowSelectGameWindow()
387{
389}
390
391static void AskExitGameCallback(Window *, bool confirmed)
392{
393 if (confirmed) {
395 _exit_game = true;
396 }
397}
398
399void AskExitGame()
400{
401 ShowQuery(
402 GetEncodedString(STR_QUIT_CAPTION),
403 GetEncodedString(STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD),
404 nullptr,
405 AskExitGameCallback,
406 true
407 );
408}
409
410
411static void AskExitToGameMenuCallback(Window *, bool confirmed)
412{
413 if (confirmed) {
416 }
417}
418
419void AskExitToGameMenu()
420{
421 ShowQuery(
422 GetEncodedString(STR_ABANDON_GAME_CAPTION),
423 GetEncodedString((_game_mode != GameMode::Editor) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY),
424 nullptr,
425 AskExitToGameMenuCallback,
426 true
427 );
428}
Window for configuring the AIs.
Base class for a resizable nested widget.
@ Exit
User is exiting the application.
Parse data from a string / buffer.
char32_t ReadUtf8(char32_t def='?')
Read UTF-8 character, and advance reader.
bool AnyBytesLeft() const noexcept
Check whether any bytes left to read.
T ReadIntegerBase(int base, T def=0, bool clamp=false)
Read and parse an integer in number 'base', and advance the reader.
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:95
Functions related to errors.
void ClearErrorMessages()
Clear all errors from the queue.
@ 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.
@ Load
File is being loaded.
Definition fileio_type.h:54
@ Savegame
old or new savegame
Definition fileio_type.h:19
@ Scenario
old or new scenario
Definition fileio_type.h:20
@ Heightmap
heightmap file
Definition fileio_type.h:21
Declarations for savegames operations.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Window for configuring GS.
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.
@ ForceRight
Force align to the right.
@ Centre
Align to the centre.
@ Start
Align to the start, LTR/RTL aware.
@ ForceLeft
Force align to the left.
@ Bottom
Align to the bottom.
@ Top
Align to the top.
@ Middle
Align to the middle.
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:39
SwitchMode _switch_mode
The next mainloop command.
Definition gfx.cpp:50
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition gfx.cpp:787
Functions related to the gfx engine.
@ Invalid
Invalid marker.
Definition gfx_type.h:302
@ Orange
Orange.
Definition gfx_type.h:297
@ Brown
Brown.
Definition gfx_type.h:298
@ FromString
Marker for telling to use the colour from the string.
Definition gfx_type.h:317
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
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 SetSpriteStringTip(SpriteID sprite, StringID string, StringID tip={})
Widget part function for setting the sprite, string and tooltip.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
constexpr NWidgetPart SetAlignment(Alignment 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:972
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.
static WindowDesc _select_game_desc(WindowPosition::Center, {}, 0, 0, WindowClass::SelectGame, WindowClass::None, WindowDefaultFlag::NoClose, _nested_select_game_widgets)
Window definition for the select game window.
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:81
Types related to the landscape.
Information about languages and their files.
const LanguageMetadata * _current_language
The currently loaded language.
Definition strings.cpp:54
#define Point
Macro that prevents name conflicts between included headers.
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=ContentType::End, ContentType type2=ContentType::End)
Show the content list window with a given set of content.
void ShowNetworkGameWindow()
Show the server list window.
GUIs related to networking.
NetworkSurveyHandler _survey
The handler for sending surveys for statistics.
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.
@ Editor
In the scenario editor.
Definition openttd.h:21
@ 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.
PoolID< uint16_t, struct SignIDTag, 64000, 0xFFFF > SignID
The type of the IDs of signs.
Definition signs_type.h:16
This file contains all sprite-related enums and defines.
static const SpriteID SPR_IMG_COMPANY_GENERAL
Definition sprites.h:1247
static const SpriteID SPR_IMG_SAVE
Definition sprites.h:1241
static const SpriteID SPR_IMG_SHOW_VEHICLES
Definition sprites.h:1251
static const SpriteID SPR_IMG_SHOW_COUNTOURS
Definition sprites.h:1250
static const SpriteID SPR_IMG_SUBSIDIES
Definition sprites.h:1244
static const SpriteID SPR_IMG_SETTINGS
Definition sprites.h:1240
static const SpriteID SPR_IMG_COMPANY_LEAGUE
Definition sprites.h:1249
static const SpriteID SPR_IMG_QUERY
Definition sprites.h:1269
static const SpriteID SPR_IMG_SMALLMAP
Definition sprites.h:1242
static const SpriteID SPR_IMG_LANDSCAPING
Definition sprites.h:1266
Definition of base types and functions in a cross-platform compatible way.
Parse strings.
static std::optional< T > ParseInteger(std::string_view arg, int base=10, bool clamp=false)
Change a string into its number representation.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
Functions related to OTTD's strings.
Horizontal and vertical alignment.
AlignmentH ResolveRTL() const
Resolve horizontal alignment for the current text direction.
AlignmentV v
Vertical alignment.
AlignmentH h
Horizontal alignment.
T y
Y coordinate.
T x
X coordinate.
A viewport command for the main menu background (intro game).
Definition intro_gui.cpp:49
int zoom_adjust
Adjustment to zoom level from base zoom level.
Definition intro_gui.cpp:54
Point PositionForViewport(const Viewport &vp)
Calculate effective position.
Definition intro_gui.cpp:64
uint delay
Delay until next command.
Definition intro_gui.cpp:53
Alignment align
Alignment.
Definition intro_gui.cpp:56
VehicleID vehicle
Vehicle to follow, or VehicleID::Invalid() if not following a vehicle.
Definition intro_gui.cpp:52
bool pan_to_next
If true, do a smooth pan from this position to the next.
Definition intro_gui.cpp:55
int command_index
Sequence number of the command (order they are performed in).
Definition intro_gui.cpp:50
Point position
Calculated world coordinate to position viewport top-left at.
Definition intro_gui.cpp:51
static Pool::IterateWrapper< Sign > Iterate(size_t from=0)
static Vehicle * Get(auto index)
Specification of a rectangle with absolute coordinates of all edges.
std::vector< IntroGameViewportCommand > intro_viewport_commands
Vector of viewport commands parsed.
Definition intro_gui.cpp:90
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.
Definition intro_gui.cpp:92
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.
Definition intro_gui.cpp:94
void OnInit() override
Notification that the nested widget tree gets initialized.
void ReadIntroGameViewportCommand()
Find and parse all viewport command signs.
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:172
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:984
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition window_gui.h:798
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1814
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:1804
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition window.cpp:1838
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition window_gui.h:989
WindowFlags flags
Window flags.
Definition window_gui.h:300
Stuff related to the text buffer GUI.
Base class for all vehicles.
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
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:39
@ WWT_CAPTION
Window caption (window title between closebox and stickybox).
Definition widget_type.h:52
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:71
@ 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:1187
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.
Definition window_gui.h:158
@ Centred
Window is centered and shall stay centered after ReInit.
Definition window_gui.h:234
@ Center
Center the window.
Definition window_gui.h:147
int WidgetID
Widget ID.
Definition window_type.h:21