OpenTTD Source: src/intro_gui.cpp Source File

OpenTTD Source 15.0-RC2

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