OpenTTD Source  14.0-beta3
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"
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/geometry_func.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 
51  enum AlignmentH : byte {
52  LEFT,
53  CENTRE,
54  RIGHT,
55  };
57  enum AlignmentV : byte {
58  TOP,
59  MIDDLE,
60  BOTTOM,
61  };
62 
63  int command_index = 0;
64  Point position{ 0, 0 };
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 
79  {
80  if (this->vehicle != INVALID_VEHICLE) {
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;
108  uint mouse_idle_time;
109  Point mouse_idle_pos;
110 
116  {
117  intro_viewport_commands.clear();
118 
119  /* Regular expression matching the commands: T, spaces, integer, spaces, flags, spaces, integer */
120  const char *sign_langauge = "^T\\s*([0-9]+)\\s*([-+A-Z0-9]+)\\s*([0-9]+)";
121  std::regex re(sign_langauge, 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)) {
130  /* Sequence index from the first matching group. */
131  vc.command_index = std::stoi(match[1].str());
132  /* Sign coordinates for positioning. */
133  vc.position = RemapCoords(sign->x, sign->y, sign->z);
134  /* Delay from the third matching group. */
135  vc.delay = std::stoi(match[3].str()) * 1000; // milliseconds
136 
137  /* Parse flags from second matching group. */
138  enum IdType {
139  ID_NONE, ID_VEHICLE
140  } id_type = ID_NONE;
141  for (char c : match[2].str()) {
142  if (isdigit(c)) {
143  if (id_type == ID_VEHICLE) {
144  vc.vehicle = vc.vehicle * 10 + (c - '0');
145  }
146  } else {
147  id_type = ID_NONE;
148  switch (toupper(c)) {
149  case '-': vc.zoom_adjust = +1; break;
150  case '+': vc.zoom_adjust = -1; break;
151  case 'T': vc.align_v = IntroGameViewportCommand::TOP; break;
152  case 'M': vc.align_v = IntroGameViewportCommand::MIDDLE; break;
153  case 'B': vc.align_v = IntroGameViewportCommand::BOTTOM; break;
154  case 'L': vc.align_h = IntroGameViewportCommand::LEFT; break;
155  case 'C': vc.align_h = IntroGameViewportCommand::CENTRE; break;
156  case 'R': vc.align_h = IntroGameViewportCommand::RIGHT; break;
157  case 'P': vc.pan_to_next = true; break;
158  case 'V': id_type = ID_VEHICLE; vc.vehicle = 0; break;
159  }
160  }
161  }
162 
163  /* Successfully parsed, store. */
164  intro_viewport_commands.push_back(vc);
165  signs_to_delete.push_back(sign->index);
166  }
167  }
168 
169  /* Sort the commands by sequence index. */
170  std::sort(intro_viewport_commands.begin(), intro_viewport_commands.end(), [](const IntroGameViewportCommand &a, const IntroGameViewportCommand &b) { return a.command_index < b.command_index; });
171 
172  /* Delete all the consumed signs, from last ID to first ID. */
173  std::sort(signs_to_delete.begin(), signs_to_delete.end(), [](SignID a, SignID b) { return a > b; });
174  for (SignID sign_id : signs_to_delete) {
175  delete Sign::Get(sign_id);
176  }
177  }
178 
179  SelectGameWindow(WindowDesc *desc) : Window(desc)
180  {
181  this->CreateNestedTree();
182  this->FinishInitNested(0);
183  this->OnInvalidateData();
184 
186 
187  this->cur_viewport_command_index = (size_t)-1;
188  this->cur_viewport_command_time = 0;
189  this->mouse_idle_time = 0;
190  this->mouse_idle_pos = _cursor.pos;
191  }
192 
193  void OnRealtimeTick(uint delta_ms) override
194  {
195  /* Move the main game viewport according to intro viewport commands. */
196 
197  if (intro_viewport_commands.empty()) return;
198 
199  bool suppress_panning = true;
200  if (this->mouse_idle_pos.x != _cursor.pos.x || this->mouse_idle_pos.y != _cursor.pos.y) {
201  this->mouse_idle_pos = _cursor.pos;
202  this->mouse_idle_time = 2000;
203  } else if (this->mouse_idle_time > delta_ms) {
204  this->mouse_idle_time -= delta_ms;
205  } else {
206  this->mouse_idle_time = 0;
207  suppress_panning = false;
208  }
209 
210  /* Determine whether to move to the next command or stay at current. */
211  bool changed_command = false;
212  if (this->cur_viewport_command_index >= intro_viewport_commands.size()) {
213  /* Reached last, rotate back to start of the list. */
214  this->cur_viewport_command_index = 0;
215  changed_command = true;
216  } else {
217  /* Check if current command has elapsed and switch to next. */
218  this->cur_viewport_command_time += delta_ms;
219  if (this->cur_viewport_command_time >= intro_viewport_commands[this->cur_viewport_command_index].delay) {
220  this->cur_viewport_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
221  this->cur_viewport_command_time = 0;
222  changed_command = true;
223  }
224  }
225 
227  Window *mw = GetMainWindow();
228  Viewport *vp = mw->viewport;
229 
230  /* Early exit if the current command hasn't elapsed and isn't animated. */
231  if (!changed_command && !vc.pan_to_next && vc.vehicle == INVALID_VEHICLE) return;
232 
233  /* Suppress panning commands, while user interacts with GUIs. */
234  if (!changed_command && suppress_panning) return;
235 
236  /* Reset the zoom level. */
237  if (changed_command) FixTitleGameZoom(vc.zoom_adjust);
238 
239  /* Calculate current command position (updates followed vehicle coordinates). */
240  Point pos = vc.PositionForViewport(vp);
241 
242  /* Calculate panning (linear interpolation between current and next command position). */
243  if (vc.pan_to_next) {
244  size_t next_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
245  IntroGameViewportCommand &nvc = intro_viewport_commands[next_command_index];
246  Point pos2 = nvc.PositionForViewport(vp);
247  const double t = this->cur_viewport_command_time / (double)vc.delay;
248  pos.x = pos.x + (int)(t * (pos2.x - pos.x));
249  pos.y = pos.y + (int)(t * (pos2.y - pos.y));
250  }
251 
252  /* Update the viewport position. */
253  mw->viewport->dest_scrollpos_x = mw->viewport->scrollpos_x = pos.x;
254  mw->viewport->dest_scrollpos_y = mw->viewport->scrollpos_y = pos.y;
255  UpdateViewportPosition(mw, delta_ms);
256  mw->SetDirty(); // Required during panning, otherwise logo graphics disappears
257 
258  /* If there is only one command, we just executed it and don't need to do any more */
260  }
261 
267  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
268  {
269  if (!gui_scope) return;
274  }
275 
276  void OnInit() override
277  {
278  bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion();
279  this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
280 
281  bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
282  this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
283  }
284 
285  void DrawWidget(const Rect &r, WidgetID widget) const override
286  {
287  switch (widget) {
288  case WID_SGI_BASESET:
290  DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_BASESET, TC_FROMSTRING, SA_CENTER);
291  break;
292 
293  case WID_SGI_TRANSLATION:
295  DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
296  break;
297  }
298  }
299 
300  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
301  {
302  switch (widget) {
306  size->height += WidgetDimensions::scaled.fullbevel.Vertical();
307  break;
308  }
309  }
310 
311  void OnResize() override
312  {
313  bool changed = false;
314 
315  if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_BASESET); wid != nullptr && wid->current_x > 0) {
317  changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_BASESET), 3);
318  }
319 
320  if (NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_SGI_TRANSLATION); wid != nullptr && wid->current_x > 0) {
322  changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION), 3);
323  }
324 
325  if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED);
326  }
327 
328  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
329  {
330  /* Do not create a network server when you (just) have closed one of the game
331  * creation/load windows for the network server. */
333 
334  switch (widget) {
336  if (_ctrl_pressed) {
338  } else {
340  }
341  break;
342 
347 
349  if (!_network_available) {
350  ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
351  } else {
352  ShowNetworkGameWindow();
353  }
354  break;
355 
359  break;
360 
361  case WID_SGI_OPTIONS: ShowGameOptions(); break;
362  case WID_SGI_HIGHSCORE: ShowHighscoreTable(); break;
363  case WID_SGI_HELP: ShowHelpWindow(); break;
365  case WID_SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
367  if (!_network_available) {
368  ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
369  } else {
371  }
372  break;
375  case WID_SGI_EXIT: HandleExitGameRequest(); break;
376  }
377  }
378 };
379 
380 static constexpr NWidgetPart _nested_select_game_widgets[] = {
381  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_INTRO_CAPTION, STR_NULL),
382  NWidget(WWT_PANEL, COLOUR_BROWN),
384 
386  /* 'New Game' and 'Load Game' buttons */
388  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GENERATE_GAME), SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetFill(1, 0),
389  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_LOAD_GAME), SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetFill(1, 0),
390  EndContainer(),
391 
392  /* 'Play Scenario' and 'Play Heightmap' buttons */
394  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_SCENARIO), SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetFill(1, 0),
395  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_HEIGHTMAP), SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_TOOLTIP_PLAY_HEIGHTMAP), SetFill(1, 0),
396  EndContainer(),
397 
398  /* 'Scenario Editor' and 'Multiplayer' buttons */
400  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EDIT_SCENARIO), SetDataTip(STR_INTRO_SCENARIO_EDITOR, STR_INTRO_TOOLTIP_SCENARIO_EDITOR), SetFill(1, 0),
401  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_NETWORK), SetDataTip(STR_INTRO_MULTIPLAYER, STR_INTRO_TOOLTIP_MULTIPLAYER), SetFill(1, 0),
402  EndContainer(),
403  EndContainer(),
404 
405  /* Climate selection buttons */
407  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_TEMPERATE_LANDSCAPE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
408  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_ARCTIC_LANDSCAPE), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
409  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_TROPIC_LANDSCAPE), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
410  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_SGI_TOYLAND_LANDSCAPE), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
411  EndContainer(),
412 
415  NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_BASESET), SetFill(1, 0),
416  EndContainer(),
417  EndContainer(),
418 
421  NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_TRANSLATION), SetFill(1, 0),
422  EndContainer(),
423  EndContainer(),
424 
426  /* 'Game Options' and 'Settings' buttons */
428  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_OPTIONS), SetDataTip(STR_INTRO_GAME_OPTIONS, STR_INTRO_TOOLTIP_GAME_OPTIONS), SetFill(1, 0),
429  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_SETTINGS_OPTIONS), SetDataTip(STR_INTRO_CONFIG_SETTINGS_TREE, STR_INTRO_TOOLTIP_CONFIG_SETTINGS_TREE), SetFill(1, 0),
430  EndContainer(),
431 
432  /* 'AI Settings' and 'Game Script Settings' buttons */
434  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_AI_SETTINGS), SetDataTip(STR_INTRO_AI_SETTINGS, STR_INTRO_TOOLTIP_AI_SETTINGS), SetFill(1, 0),
435  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GS_SETTINGS), SetDataTip(STR_INTRO_GAMESCRIPT_SETTINGS, STR_INTRO_TOOLTIP_GAMESCRIPT_SETTINGS), SetFill(1, 0),
436  EndContainer(),
437 
438  /* 'Check Online Content' and 'NewGRF Settings' buttons */
440  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_CONTENT_DOWNLOAD), SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), SetFill(1, 0),
441  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GRF_SETTINGS), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_INTRO_TOOLTIP_NEWGRF_SETTINGS), SetFill(1, 0),
442  EndContainer(),
443  EndContainer(),
444 
445  /* 'Help and Manuals' and 'Highscore Table' buttons */
447  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_HELP), SetDataTip(STR_INTRO_HELP, STR_INTRO_TOOLTIP_HELP), SetFill(1, 0),
448  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_HIGHSCORE), SetDataTip(STR_INTRO_HIGHSCORE, STR_INTRO_TOOLTIP_HIGHSCORE), SetFill(1, 0),
449  EndContainer(),
450 
451  /* 'Exit' button */
453  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EXIT), SetMinimalSize(128, 0), SetDataTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
454  EndContainer(),
455  EndContainer(),
456  EndContainer(),
457 };
458 
459 static WindowDesc _select_game_desc(__FILE__, __LINE__,
460  WDP_CENTER, nullptr, 0, 0,
462  WDF_NO_CLOSE,
463  std::begin(_nested_select_game_widgets), std::end(_nested_select_game_widgets)
464 );
465 
466 void ShowSelectGameWindow()
467 {
468  new SelectGameWindow(&_select_game_desc);
469 }
470 
471 static void AskExitGameCallback(Window *, bool confirmed)
472 {
473  if (confirmed) {
475  _exit_game = true;
476  }
477 }
478 
479 void AskExitGame()
480 {
481  ShowQuery(
482  STR_QUIT_CAPTION,
483  STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD,
484  nullptr,
485  AskExitGameCallback,
486  true
487  );
488 }
489 
490 
491 static void AskExitToGameMenuCallback(Window *, bool confirmed)
492 {
493  if (confirmed) {
496  }
497 }
498 
499 void AskExitToGameMenu()
500 {
501  ShowQuery(
502  STR_ABANDON_GAME_CAPTION,
503  (_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY,
504  nullptr,
505  AskExitToGameMenuCallback,
506  true
507  );
508 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:469
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:2023
network_content.h
NWidgetResizeBase
Base class for a resizable nested widget.
Definition: widget_type.h:291
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
IntroGameViewportCommand::vehicle
VehicleID vehicle
Vehicle to follow, or INVALID_VEHICLE if not following a vehicle.
Definition: intro_gui.cpp:65
WID_SGI_BASESET
@ WID_SGI_BASESET
Baseset errors.
Definition: intro_widget.h:26
WID_SGI_GENERATE_GAME
@ WID_SGI_GENERATE_GAME
Generate game button.
Definition: intro_widget.h:15
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:55
FT_SCENARIO
@ FT_SCENARIO
old or new scenario
Definition: fileio_type.h:19
Pool::PoolItem<&_vehicle_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:335
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
ShowQuery
void ShowQuery(StringID caption, StringID 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:1230
IntroGameViewportCommand::zoom_adjust
int zoom_adjust
Adjustment to zoom level from base zoom level.
Definition: intro_gui.cpp:67
landscape_type.h
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
WID_SGI_CONTENT_DOWNLOAD
@ WID_SGI_CONTENT_DOWNLOAD
Content Download button.
Definition: intro_widget.h:34
IsInsideMM
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:268
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Definition: error_gui.cpp:367
WID_SGI_AI_SETTINGS
@ WID_SGI_AI_SETTINGS
AI button.
Definition: intro_widget.h:35
WID_SGI_GS_SETTINGS
@ WID_SGI_GS_SETTINGS
Game Script button.
Definition: intro_widget.h:36
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:356
IntroGameViewportCommand::delay
uint delay
Delay until next command.
Definition: intro_gui.cpp:66
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
WC_SELECT_GAME
@ WC_SELECT_GAME
Select game window; Window numbers:
Definition: window_type.h:442
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:312
IntroGameViewportCommand::command_index
int command_index
Sequence number of the command (order they are performed in).
Definition: intro_gui.cpp:63
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
SelectGameWindow
Definition: intro_gui.cpp:101
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:1130
ai_gui.hpp
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
vehicle_base.h
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:1183
SelectGameWindow::cur_viewport_command_time
uint cur_viewport_command_time
Time spent (milliseconds) on current viewport command.
Definition: intro_gui.cpp:107
WID_SGI_LOAD_GAME
@ WID_SGI_LOAD_GAME
Load game button.
Definition: intro_widget.h:16
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2893
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
ViewportData::dest_scrollpos_y
int32_t dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:251
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
network_gui.h
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:240
fios.h
SignID
uint16_t SignID
The type of the IDs of signs.
Definition: signs_type.h:14
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:1069
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition: genworld_gui.cpp:1060
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
genworld.h
WID_SGI_TRANSLATION_SELECTION
@ WID_SGI_TRANSLATION_SELECTION
Translation selection.
Definition: intro_widget.h:27
textbuf_gui.h
Vehicle::x_pos
int32_t x_pos
x coordinate.
Definition: vehicle_base.h:299
WID_SGI_PLAY_NETWORK
@ WID_SGI_PLAY_NETWORK
Play network button.
Definition: intro_widget.h:20
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:619
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:63
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:508
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:1188
Viewport
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
ClearErrorMessages
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:328
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition: fileio_type.h:49
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:1048
WID_SGI_EDIT_SCENARIO
@ WID_SGI_EDIT_SCENARIO
Edit scenario button.
Definition: intro_widget.h:19
IntroGameViewportCommand
A viewport command for the main menu background (intro game).
Definition: intro_gui.cpp:49
WF_CENTERED
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
Definition: window_gui.h:232
ViewportData::dest_scrollpos_x
int32_t dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:250
game_gui.hpp
WID_SGI_PLAY_SCENARIO
@ WID_SGI_PLAY_SCENARIO
Play scenario button.
Definition: intro_widget.h:17
INVALID_VEHICLE
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:54
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
highscore.h
WID_SGI_ARCTIC_LANDSCAPE
@ WID_SGI_ARCTIC_LANDSCAPE
Select arctic landscape button.
Definition: intro_widget.h:22
IntroGameViewportCommand::position
Point position
Calculated world coordinate to position viewport top-left at.
Definition: intro_gui.cpp:64
_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:167
GUISettings::missing_strings_threshold
byte missing_strings_threshold
the number of missing strings before showing the warning
Definition: settings_type.h:193
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:110
SelectGameWindow::ReadIntroGameViewportCommands
void ReadIntroGameViewportCommands()
Find and parse all viewport command signs.
Definition: intro_gui.cpp:115
ViewportData::scrollpos_y
int32_t scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:249
WID_SGI_OPTIONS
@ WID_SGI_OPTIONS
Options button.
Definition: intro_widget.h:29
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:953
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
_current_language
const LanguageMetadata * _current_language
The currently loaded language.
Definition: strings.cpp:54
safeguards.h
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:294
VehicleID
uint32_t VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
sprites.h
Viewport::virtual_width
int virtual_width
width << zoom
Definition: viewport_type.h:30
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
WDF_NO_CLOSE
@ WDF_NO_CLOSE
This window can't be interactively closed.
Definition: window_gui.h:200
language.h
WID_SGI_HIGHSCORE
@ WID_SGI_HIGHSCORE
Highscore button.
Definition: intro_widget.h:30
stdafx.h
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:914
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
SelectGameWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: intro_gui.cpp:267
landscape.h
NetworkSurveyHandler::Transmit
void Transmit(Reason reason, bool blocking=false)
Transmit the survey.
Definition: network_survey.cpp:87
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition: game_gui.cpp:476
viewport_func.h
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
WID_SGI_SETTINGS_OPTIONS
@ WID_SGI_SETTINGS_OPTIONS
Settings button.
Definition: intro_widget.h:32
Vehicle::z_pos
int32_t z_pos
z coordinate.
Definition: vehicle_base.h:301
GENERATE_NEW_SEED
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
Definition: genworld.h:24
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Definition: highscore_gui.cpp:236
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
WID_SGI_HELP
@ WID_SGI_HELP
Help and manuals button.
Definition: intro_widget.h:31
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:48
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:775
rev.h
SelectGameWindow::cur_viewport_command_index
size_t cur_viewport_command_index
Index of currently active viewport command.
Definition: intro_gui.cpp:105
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:384
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
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:1220
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
LanguagePackHeader::missing
uint16_t missing
number of missing strings.
Definition: language.h:40
GetMainWindow
Window * GetMainWindow()
Get the main window, i.e.
Definition: window.cpp:1128
geometry_func.hpp
IntroGameViewportCommand::align_v
AlignmentV align_v
Vertical alignment.
Definition: intro_gui.cpp:70
SetNewLandscapeType
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
Definition: genworld_gui.cpp:64
SelectGameWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: intro_gui.cpp:311
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
ViewportData::scrollpos_x
int32_t scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:248
WID_SGI_TROPIC_LANDSCAPE
@ WID_SGI_TROPIC_LANDSCAPE
Select tropic landscape button.
Definition: intro_widget.h:23
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:327
IntroGameViewportCommand::AlignmentH
AlignmentH
Horizontal alignment value.
Definition: intro_gui.cpp:51
IntroGameViewportCommand::align_h
AlignmentH align_h
Horizontal alignment.
Definition: intro_gui.cpp:69
Sign
Definition: signs_base.h:21
WID_SGI_PLAY_HEIGHTMAP
@ WID_SGI_PLAY_HEIGHTMAP
Play heightmap button.
Definition: intro_widget.h:18
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:20
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
UpdateViewportPosition
void UpdateViewportPosition(Window *w, uint32_t delta_ms)
Update the viewport position being displayed.
Definition: viewport.cpp:1910
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:26
SM_MENU
@ SM_MENU
Switch to game intro menu.
Definition: openttd.h:33
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
Vehicle::y_pos
int32_t y_pos
y coordinate.
Definition: vehicle_base.h:300
IntroGameViewportCommand::AlignmentV
AlignmentV
Vertical alignment value.
Definition: intro_gui.cpp:57
network.h
IntroGameViewportCommand::PositionForViewport
Point PositionForViewport(const Viewport *vp)
Calculate effective position.
Definition: intro_gui.cpp:78
window_func.h
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:348
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition: widget_type.h:1232
WID_SGI_BASESET_SELECTION
@ WID_SGI_BASESET_SELECTION
Baseset selection.
Definition: intro_widget.h:25
help_gui.h
gui.h
Window
Data structure for an opened window.
Definition: window_gui.h:267
network_survey.h
Viewport::virtual_height
int virtual_height
height << zoom
Definition: viewport_type.h:31
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
_network_available
bool _network_available
is network mode available?
Definition: network.cpp:61
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:82
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:324
intro_widget.h
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
CursorVars::pos
Point pos
logical mouse position
Definition: gfx_type.h:117
WID_SGI_EXIT
@ WID_SGI_EXIT
Exit button.
Definition: intro_widget.h:37
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:233
SelectGameWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: intro_gui.cpp:276
WID_SGI_TEMPERATE_LANDSCAPE
@ WID_SGI_TEMPERATE_LANDSCAPE
Select temperate landscape button.
Definition: intro_widget.h:21
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:142
WID_SGI_TOYLAND_LANDSCAPE
@ WID_SGI_TOYLAND_LANDSCAPE
Select toyland landscape button.
Definition: intro_widget.h:24
WID_SGI_GRF_SETTINGS
@ WID_SGI_GRF_SETTINGS
NewGRF button.
Definition: intro_widget.h:33
_is_network_server
bool _is_network_server
Does this client wants to be a network-server?
Definition: network.cpp:63
NetworkSurveyHandler::Reason::EXIT
@ EXIT
User is exiting the application.
SelectGameWindow::intro_viewport_commands
std::vector< IntroGameViewportCommand > intro_viewport_commands
Vector of viewport commands parsed.
Definition: intro_gui.cpp:103
WID_SGI_TRANSLATION
@ WID_SGI_TRANSLATION
Translation errors.
Definition: intro_widget.h:28
signs_base.h
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:56
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:636
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:82
_grfconfig_newgame
GRFConfig * _grfconfig_newgame
First item in list of default GRF set up.
Definition: newgrf_config.cpp:165