OpenTTD Source 20261112-master-gbcbec5e63f
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.h"
23#include "strings_func.h"
24#include "fios.h"
25#include "gfx_func.h"
27#include "language.h"
28#include "rev.h"
29#include "highscore.h"
30#include "signs_base.h"
31#include "viewport_func.h"
32#include "vehicle_base.h"
33#include <regex>
34
36
37#include "table/strings.h"
38#include "table/sprites.h"
39
40#include "safeguards.h"
41
42
47 int command_index = 0;
48 Point position{ 0, 0 };
49 VehicleID vehicle = VehicleID::Invalid();
50 uint delay = 0;
51 int zoom_adjust = 0;
52 bool pan_to_next = false;
54
62 {
63 if (this->vehicle != VehicleID::Invalid()) {
64 const Vehicle *v = Vehicle::Get(this->vehicle);
65 this->position = RemapCoords(v->x_pos, v->y_pos, v->z_pos);
66 }
67
68 Point p;
69 switch (this->align.ResolveRTL()) {
70 case AlignmentH::ForceLeft: p.x = this->position.x; break;
71 case AlignmentH::Centre: p.x = this->position.x - vp.virtual_width / 2; break;
72 case AlignmentH::ForceRight: p.x = this->position.x - vp.virtual_width; break;
73 default: NOT_REACHED();
74 }
75 switch (this->align.v) {
76 case AlignmentV::Top: p.y = this->position.y; break;
77 case AlignmentV::Middle: p.y = this->position.y - vp.virtual_height / 2; break;
78 case AlignmentV::Bottom: p.y = this->position.y - vp.virtual_height; break;
79 }
80 return p;
81 }
82};
83
84
85struct SelectGameWindow : public Window {
87 std::vector<IntroGameViewportCommand> intro_viewport_commands{};
89 size_t cur_viewport_command_index = SIZE_MAX;
92 uint mouse_idle_time = 0;
93 Point mouse_idle_pos{};
94
100 {
102
103 /* Regular expression matching the commands: T, spaces, integer, spaces, flags, spaces, integer */
104 static const std::string sign_language = "^T\\s*([0-9]+)\\s*([-+A-Z0-9]+)\\s*([0-9]+)";
105 std::regex re(sign_language, std::regex_constants::icase);
106
107 /* List of signs successfully parsed to delete afterwards. */
108 std::vector<SignID> signs_to_delete;
109
110 for (const Sign *sign : Sign::Iterate()) {
111 std::smatch match;
112 if (!std::regex_search(sign->name, match, re)) continue;
113
115 /* Sequence index from the first matching group. */
116 if (auto value = ParseInteger<int>(match[1].str()); value.has_value()) {
117 vc.command_index = *value;
118 } else {
119 continue;
120 }
121 /* Sign coordinates for positioning. */
122 vc.position = RemapCoords(sign->x, sign->y, sign->z);
123 /* Delay from the third matching group. */
124 if (auto value = ParseInteger<uint>(match[3].str()); value.has_value()) {
125 vc.delay = *value * 1000; // milliseconds
126 } else {
127 continue;
128 }
129
130 /* Parse flags from second matching group. */
131 auto flags = match[2].str();
132 StringConsumer consumer{flags};
133 while (consumer.AnyBytesLeft()) {
134 auto c = consumer.ReadUtf8();
135 switch (toupper(c)) {
136 case '-': vc.zoom_adjust = +1; break;
137 case '+': vc.zoom_adjust = -1; break;
138 case 'T': vc.align.v = AlignmentV::Top; break;
139 case 'M': vc.align.v = AlignmentV::Middle; break;
140 case 'B': vc.align.v = AlignmentV::Bottom; break;
141 case 'L': vc.align.h = AlignmentH::ForceLeft; break;
142 case 'C': vc.align.h = AlignmentH::Centre; break;
143 case 'R': vc.align.h = AlignmentH::ForceRight; break;
144 case 'P': vc.pan_to_next = true; break;
145 case 'V': vc.vehicle = static_cast<VehicleID>(consumer.ReadIntegerBase<uint32_t>(10, VehicleID::Invalid().base())); break;
146 }
147 }
148
149 /* Successfully parsed, store. */
150 intro_viewport_commands.push_back(vc);
151 signs_to_delete.push_back(sign->index);
152 }
153
154 /* Sort the commands by sequence index. */
155 std::sort(intro_viewport_commands.begin(), intro_viewport_commands.end(), [](const IntroGameViewportCommand &a, const IntroGameViewportCommand &b) { return a.command_index < b.command_index; });
156
157 /* Delete all the consumed signs, from last ID to first ID. */
158 std::sort(signs_to_delete.begin(), signs_to_delete.end(), [](SignID a, SignID b) { return a > b; });
159 for (SignID sign_id : signs_to_delete) {
160 delete Sign::Get(sign_id);
161 }
162 }
163
164 SelectGameWindow(WindowDesc &desc) : Window(desc), mouse_idle_pos(_cursor.pos)
165 {
166 this->CreateNestedTree();
167 this->FinishInitNested(0);
168 this->OnInvalidateData();
169
171 }
172
173 void OnRealtimeTick(uint delta_ms) override
174 {
175 /* Move the main game viewport according to intro viewport commands. */
176
177 if (intro_viewport_commands.empty()) return;
178
179 bool suppress_panning = true;
180 if (this->mouse_idle_pos.x != _cursor.pos.x || this->mouse_idle_pos.y != _cursor.pos.y) {
181 this->mouse_idle_pos = _cursor.pos;
182 this->mouse_idle_time = 2000;
183 } else if (this->mouse_idle_time > delta_ms) {
184 this->mouse_idle_time -= delta_ms;
185 } else {
186 this->mouse_idle_time = 0;
187 suppress_panning = false;
188 }
189
190 /* Determine whether to move to the next command or stay at current. */
191 bool changed_command = false;
192 if (this->cur_viewport_command_index >= intro_viewport_commands.size()) {
193 /* Reached last, rotate back to start of the list. */
194 this->cur_viewport_command_index = 0;
195 changed_command = true;
196 } else {
197 /* Check if current command has elapsed and switch to next. */
198 this->cur_viewport_command_time += delta_ms;
199 if (this->cur_viewport_command_time >= intro_viewport_commands[this->cur_viewport_command_index].delay) {
200 this->cur_viewport_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
201 this->cur_viewport_command_time = 0;
202 changed_command = true;
203 }
204 }
205
206 IntroGameViewportCommand &vc = intro_viewport_commands[this->cur_viewport_command_index];
207 Window *mw = GetMainWindow();
208
209 /* Early exit if the current command hasn't elapsed and isn't animated. */
210 if (!changed_command && !vc.pan_to_next && vc.vehicle == VehicleID::Invalid()) return;
211
212 /* Suppress panning commands, while user interacts with GUIs. */
213 if (!changed_command && suppress_panning) return;
214
215 /* Reset the zoom level. */
216 if (changed_command) FixTitleGameZoom(vc.zoom_adjust);
217
218 /* Calculate current command position (updates followed vehicle coordinates). */
219 Point pos = vc.PositionForViewport(*mw->viewport);
220
221 /* Calculate panning (linear interpolation between current and next command position). */
222 if (vc.pan_to_next) {
223 size_t next_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
224 IntroGameViewportCommand &nvc = intro_viewport_commands[next_command_index];
225 Point pos2 = nvc.PositionForViewport(*mw->viewport);
226 const double t = this->cur_viewport_command_time / (double)vc.delay;
227 pos.x = pos.x + (int)(t * (pos2.x - pos.x));
228 pos.y = pos.y + (int)(t * (pos2.y - pos.y));
229 }
230
231 /* Update the viewport position. */
232 mw->viewport->dest_scrollpos_x = mw->viewport->scrollpos_x = pos.x;
233 mw->viewport->dest_scrollpos_y = mw->viewport->scrollpos_y = pos.y;
234 UpdateViewportPosition(mw, delta_ms);
235 mw->SetDirty(); // Required during panning, otherwise logo graphics disappears
236
237 /* If there is only one command, we just executed it and don't need to do any more */
238 if (intro_viewport_commands.size() == 1 && vc.vehicle == VehicleID::Invalid()) intro_viewport_commands.clear();
239 }
240
241 void OnInit() override
242 {
243 bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion();
244 this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
245
246 bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
247 this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
248 }
249
250 void DrawWidget(const Rect &r, WidgetID widget) const override
251 {
252 switch (widget) {
253 case WID_SGI_BASESET:
255 break;
256
258 DrawStringMultiLine(r, GetString(STR_INTRO_TRANSLATION, _current_language->missing), TextColour::FromString, {AlignmentH::Centre, AlignmentV::Middle});
259 break;
260 }
261 }
262
263 void OnResize() override
264 {
265 bool changed = false;
266
267 if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_BASESET); wid != nullptr && wid->current_x > 0) {
268 changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_BASESET, _missing_extra_graphics), 3);
269 }
270
271 if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_TRANSLATION); wid != nullptr && wid->current_x > 0) {
272 changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION, _current_language->missing), 3);
273 }
274
275 if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred));
276 }
277
278 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
279 {
280 switch (widget) {
282 _is_network_server = false;
283 if (IsCtrlPressed()) {
285 } else {
287 }
288 break;
290 _is_network_server = false;
292 break;
294 _is_network_server = false;
296 break;
298 _is_network_server = false;
300 break;
302 _is_network_server = false;
304 break;
305
307 if (!_network_available) {
308 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WarningLevel::Error);
309 } else {
311 }
312 break;
313
314 case WID_SGI_OPTIONS: ShowGameOptions(); break;
316 case WID_SGI_HELP: ShowHelpWindow(); break;
318 if (!_network_available) {
319 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WarningLevel::Error);
320 } else {
322 }
323 break;
324 case WID_SGI_EXIT: HandleExitGameRequest(); break;
325 }
326 }
327};
328
329static constexpr std::initializer_list<NWidgetPart> _nested_select_game_widgets = {
330 NWidget(WWT_CAPTION, Colours::Brown), SetStringTip(STR_INTRO_CAPTION),
333
334 /* Single player */
341 EndContainer(),
342
343 /* Multi player */
346 EndContainer(),
347
351 EndContainer(),
352 EndContainer(),
353
357 EndContainer(),
358 EndContainer(),
359
360 /* Other */
366 EndContainer(),
367
369 NWidget(WWT_PUSHTXTBTN, Colours::Orange, WID_SGI_EXIT), SetToolbarMinimalSize(1), SetStringTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
370 EndContainer(),
371 EndContainer(),
372 EndContainer(),
373};
374
377 WindowPosition::Center, {}, 0, 0,
378 WindowClass::SelectGame, WindowClass::None,
380 _nested_select_game_widgets
381);
382
383void ShowSelectGameWindow()
384{
386}
387
388static void AskExitGameCallback(Window *, bool confirmed)
389{
390 if (confirmed) {
392 _exit_game = true;
393 }
394}
395
396void AskExitGame()
397{
398 ShowQuery(
399 GetEncodedString(STR_QUIT_CAPTION),
400 GetEncodedString(STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD),
401 nullptr,
402 AskExitGameCallback,
403 true
404 );
405}
406
407
408static void AskExitToGameMenuCallback(Window *, bool confirmed)
409{
410 if (confirmed) {
413 }
414}
415
416void AskExitToGameMenu()
417{
418 ShowQuery(
419 GetEncodedString(STR_ABANDON_GAME_CAPTION),
420 GetEncodedString((_game_mode != GameMode::Editor) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY),
421 nullptr,
422 AskExitToGameMenuCallback,
423 true
424 );
425}
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:94
Functions related to errors.
void ClearErrorMessages()
Clear all errors from the queue.
@ Error
Errors (eg. saving/loading failed).
Definition error.h:24
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:53
@ Savegame
old or new savegame
Definition fileio_type.h:18
@ Scenario
old or new scenario
Definition fileio_type.h:19
@ Heightmap
heightmap file
Definition fileio_type.h:20
Declarations for savegames operations.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Functions related to world/map generation.
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
Definition genworld.h:23
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.
SwitchMode _switch_mode
The next mainloop command.
Definition gfx.cpp:45
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:782
Functions related to the gfx engine.
bool IsCtrlPressed()
Test if the ctrl key is pressed.
Definition gfx_func.h:82
@ 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:1013
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
Information about languages and their files.
const LanguageMetadata * _current_language
The currently loaded language.
Definition strings.cpp:53
#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:67
bool _network_available
is network mode available?
Definition network.cpp:65
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:1253
static const SpriteID SPR_IMG_SAVE
Definition sprites.h:1247
static const SpriteID SPR_IMG_SHOW_VEHICLES
Definition sprites.h:1257
static const SpriteID SPR_IMG_SHOW_COUNTOURS
Definition sprites.h:1256
static const SpriteID SPR_IMG_SUBSIDIES
Definition sprites.h:1250
static const SpriteID SPR_IMG_SETTINGS
Definition sprites.h:1246
static const SpriteID SPR_IMG_COMPANY_LEAGUE
Definition sprites.h:1255
static const SpriteID SPR_IMG_QUERY
Definition sprites.h:1275
static const SpriteID SPR_IMG_SMALLMAP
Definition sprites.h:1248
static const SpriteID SPR_IMG_LANDSCAPING
Definition sprites.h:1272
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:89
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:423
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:46
int zoom_adjust
Adjustment to zoom level from base zoom level.
Definition intro_gui.cpp:51
Point PositionForViewport(const Viewport &vp)
Calculate effective position.
Definition intro_gui.cpp:61
uint delay
Delay until next command.
Definition intro_gui.cpp:50
Alignment align
Alignment.
Definition intro_gui.cpp:53
VehicleID vehicle
Vehicle to follow, or VehicleID::Invalid() if not following a vehicle.
Definition intro_gui.cpp:49
bool pan_to_next
If true, do a smooth pan from this position to the next.
Definition intro_gui.cpp:52
int command_index
Sequence number of the command (order they are performed in).
Definition intro_gui.cpp:47
Point position
Calculated world coordinate to position viewport top-left at.
Definition intro_gui.cpp:48
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:87
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:89
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:91
void OnInit() override
Notification that the nested widget tree gets initialized.
void ReadIntroGameViewportCommand()
Find and parse all viewport command signs.
Definition intro_gui.cpp:99
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:171
Data structure for an opened window.
Definition window_gui.h:272
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:1025
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition window_gui.h:818
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1855
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
Definition window_gui.h:317
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1845
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition window.cpp:1879
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
WindowFlags flags
Window flags.
Definition window_gui.h:299
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:1228
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:157
@ Centred
Window is centered and shall stay centered after ReInit.
Definition window_gui.h:233
@ Center
Center the window.
Definition window_gui.h:146
int WidgetID
Widget ID.
Definition window_type.h:21