OpenTTD Source  13.2.1
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 "network/network.h"
17 #include "genworld.h"
18 #include "network/network_gui.h"
20 #include "landscape_type.h"
21 #include "landscape.h"
22 #include "strings_func.h"
23 #include "fios.h"
24 #include "ai/ai_gui.hpp"
25 #include "game/game_gui.hpp"
26 #include "gfx_func.h"
27 #include "core/geometry_func.hpp"
28 #include "language.h"
29 #include "rev.h"
30 #include "highscore.h"
31 #include "signs_base.h"
32 #include "viewport_func.h"
33 #include "vehicle_base.h"
34 #include <regex>
35 
36 #include "widgets/intro_widget.h"
37 
38 #include "table/strings.h"
39 #include "table/sprites.h"
40 
41 #include "safeguards.h"
42 
43 
49  enum AlignmentH : byte {
50  LEFT,
51  CENTRE,
52  RIGHT,
53  };
55  enum AlignmentV : byte {
56  TOP,
57  MIDDLE,
58  BOTTOM,
59  };
60 
61  int command_index = 0;
62  Point position{ 0, 0 };
64  uint delay = 0;
65  int zoom_adjust = 0;
66  bool pan_to_next = false;
67  AlignmentH align_h = CENTRE;
68  AlignmentV align_v = MIDDLE;
69 
77  {
78  if (this->vehicle != INVALID_VEHICLE) {
79  const Vehicle *v = Vehicle::Get(this->vehicle);
80  this->position = RemapCoords(v->x_pos, v->y_pos, v->z_pos);
81  }
82 
83  Point p;
84  switch (this->align_h) {
85  case LEFT: p.x = this->position.x; break;
86  case CENTRE: p.x = this->position.x - vp->virtual_width / 2; break;
87  case RIGHT: p.x = this->position.x - vp->virtual_width; break;
88  }
89  switch (this->align_v) {
90  case TOP: p.y = this->position.y; break;
91  case MIDDLE: p.y = this->position.y - vp->virtual_height / 2; break;
92  case BOTTOM: p.y = this->position.y - vp->virtual_height; break;
93  }
94  return p;
95  }
96 };
97 
98 
99 struct SelectGameWindow : public Window {
101  std::vector<IntroGameViewportCommand> intro_viewport_commands;
106  uint mouse_idle_time;
107  Point mouse_idle_pos;
108 
114  {
115  intro_viewport_commands.clear();
116 
117  /* Regular expression matching the commands: T, spaces, integer, spaces, flags, spaces, integer */
118  const char *sign_langauge = "^T\\s*([0-9]+)\\s*([-+A-Z0-9]+)\\s*([0-9]+)";
119  std::regex re(sign_langauge, std::regex_constants::icase);
120 
121  /* List of signs successfully parsed to delete afterwards. */
122  std::vector<SignID> signs_to_delete;
123 
124  for (const Sign *sign : Sign::Iterate()) {
125  std::smatch match;
126  if (std::regex_search(sign->name, match, re)) {
128  /* Sequence index from the first matching group. */
129  vc.command_index = std::stoi(match[1].str());
130  /* Sign coordinates for positioning. */
131  vc.position = RemapCoords(sign->x, sign->y, sign->z);
132  /* Delay from the third matching group. */
133  vc.delay = std::stoi(match[3].str()) * 1000; // milliseconds
134 
135  /* Parse flags from second matching group. */
136  enum IdType {
137  ID_NONE, ID_VEHICLE
138  } id_type = ID_NONE;
139  for (char c : match[2].str()) {
140  if (isdigit(c)) {
141  if (id_type == ID_VEHICLE) {
142  vc.vehicle = vc.vehicle * 10 + (c - '0');
143  }
144  } else {
145  id_type = ID_NONE;
146  switch (toupper(c)) {
147  case '-': vc.zoom_adjust = +1; break;
148  case '+': vc.zoom_adjust = -1; break;
149  case 'T': vc.align_v = IntroGameViewportCommand::TOP; break;
150  case 'M': vc.align_v = IntroGameViewportCommand::MIDDLE; break;
151  case 'B': vc.align_v = IntroGameViewportCommand::BOTTOM; break;
152  case 'L': vc.align_h = IntroGameViewportCommand::LEFT; break;
153  case 'C': vc.align_h = IntroGameViewportCommand::CENTRE; break;
154  case 'R': vc.align_h = IntroGameViewportCommand::RIGHT; break;
155  case 'P': vc.pan_to_next = true; break;
156  case 'V': id_type = ID_VEHICLE; vc.vehicle = 0; break;
157  }
158  }
159  }
160 
161  /* Successfully parsed, store. */
162  intro_viewport_commands.push_back(vc);
163  signs_to_delete.push_back(sign->index);
164  }
165  }
166 
167  /* Sort the commands by sequence index. */
168  std::sort(intro_viewport_commands.begin(), intro_viewport_commands.end(), [](const IntroGameViewportCommand &a, const IntroGameViewportCommand &b) { return a.command_index < b.command_index; });
169 
170  /* Delete all the consumed signs, from last ID to first ID. */
171  std::sort(signs_to_delete.begin(), signs_to_delete.end(), [](SignID a, SignID b) { return a > b; });
172  for (SignID sign_id : signs_to_delete) {
173  delete Sign::Get(sign_id);
174  }
175  }
176 
177  SelectGameWindow(WindowDesc *desc) : Window(desc)
178  {
179  this->CreateNestedTree();
180  this->FinishInitNested(0);
181  this->OnInvalidateData();
182 
184 
185  this->cur_viewport_command_index = (size_t)-1;
186  this->cur_viewport_command_time = 0;
187  this->mouse_idle_time = 0;
188  this->mouse_idle_pos = _cursor.pos;
189  }
190 
191  void OnRealtimeTick(uint delta_ms) override
192  {
193  /* Move the main game viewport according to intro viewport commands. */
194 
195  if (intro_viewport_commands.empty()) return;
196 
197  bool suppress_panning = true;
198  if (this->mouse_idle_pos.x != _cursor.pos.x || this->mouse_idle_pos.y != _cursor.pos.y) {
199  this->mouse_idle_pos = _cursor.pos;
200  this->mouse_idle_time = 2000;
201  } else if (this->mouse_idle_time > delta_ms) {
202  this->mouse_idle_time -= delta_ms;
203  } else {
204  this->mouse_idle_time = 0;
205  suppress_panning = false;
206  }
207 
208  /* Determine whether to move to the next command or stay at current. */
209  bool changed_command = false;
210  if (this->cur_viewport_command_index >= intro_viewport_commands.size()) {
211  /* Reached last, rotate back to start of the list. */
212  this->cur_viewport_command_index = 0;
213  changed_command = true;
214  } else {
215  /* Check if current command has elapsed and switch to next. */
216  this->cur_viewport_command_time += delta_ms;
217  if (this->cur_viewport_command_time >= intro_viewport_commands[this->cur_viewport_command_index].delay) {
218  this->cur_viewport_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
219  this->cur_viewport_command_time = 0;
220  changed_command = true;
221  }
222  }
223 
226  Viewport *vp = mw->viewport;
227 
228  /* Early exit if the current command hasn't elapsed and isn't animated. */
229  if (!changed_command && !vc.pan_to_next && vc.vehicle == INVALID_VEHICLE) return;
230 
231  /* Suppress panning commands, while user interacts with GUIs. */
232  if (!changed_command && suppress_panning) return;
233 
234  /* Reset the zoom level. */
235  if (changed_command) FixTitleGameZoom(vc.zoom_adjust);
236 
237  /* Calculate current command position (updates followed vehicle coordinates). */
238  Point pos = vc.PositionForViewport(vp);
239 
240  /* Calculate panning (linear interpolation between current and next command position). */
241  if (vc.pan_to_next) {
242  size_t next_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
243  IntroGameViewportCommand &nvc = intro_viewport_commands[next_command_index];
244  Point pos2 = nvc.PositionForViewport(vp);
245  const double t = this->cur_viewport_command_time / (double)vc.delay;
246  pos.x = pos.x + (int)(t * (pos2.x - pos.x));
247  pos.y = pos.y + (int)(t * (pos2.y - pos.y));
248  }
249 
250  /* Update the viewport position. */
251  mw->viewport->dest_scrollpos_x = mw->viewport->scrollpos_x = pos.x;
252  mw->viewport->dest_scrollpos_y = mw->viewport->scrollpos_y = pos.y;
254  mw->SetDirty(); // Required during panning, otherwise logo graphics disappears
255 
256  /* If there is only one command, we just executed it and don't need to do any more */
258  }
259 
265  void OnInvalidateData(int data = 0, bool gui_scope = true) override
266  {
267  if (!gui_scope) return;
272  }
273 
274  void OnInit() override
275  {
276  bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion();
277  this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
278 
279  bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
280  this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
281  }
282 
283  void DrawWidget(const Rect &r, int widget) const override
284  {
285  switch (widget) {
286  case WID_SGI_BASESET:
288  DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_BASESET, TC_FROMSTRING, SA_CENTER);
289  break;
290 
291  case WID_SGI_TRANSLATION:
293  DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
294  break;
295  }
296  }
297 
298  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
299  {
300  StringID str = 0;
301  switch (widget) {
302  case WID_SGI_BASESET:
304  str = STR_INTRO_BASESET;
305  break;
306 
307  case WID_SGI_TRANSLATION:
309  str = STR_INTRO_TRANSLATION;
310  break;
311  }
312 
313  if (str != 0) {
314  int height = GetStringHeight(str, size->width);
315  if (height > 3 * FONT_HEIGHT_NORMAL) {
316  /* Don't let the window become too high. */
317  Dimension textdim = GetStringBoundingBox(str);
318  textdim.height *= 3;
319  textdim.width -= textdim.width / 2;
320  *size = maxdim(*size, textdim);
321  } else {
322  size->height = height + padding.height;
323  }
324  }
325  }
326 
327  void OnClick(Point pt, int widget, int click_count) override
328  {
329  /* Do not create a network server when you (just) have closed one of the game
330  * creation/load windows for the network server. */
332 
333  switch (widget) {
335  if (_ctrl_pressed) {
337  } else {
339  }
340  break;
341 
346 
348  if (!_network_available) {
349  ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
350  } else {
351  ShowNetworkGameWindow();
352  }
353  break;
354 
358  break;
359 
360  case WID_SGI_OPTIONS: ShowGameOptions(); break;
361  case WID_SGI_HIGHSCORE: ShowHighscoreTable(); break;
363  case WID_SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
365  if (!_network_available) {
366  ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
367  } else {
369  }
370  break;
373  case WID_SGI_EXIT: HandleExitGameRequest(); break;
374  }
375  }
376 };
377 
378 static const NWidgetPart _nested_select_game_widgets[] = {
379  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_INTRO_CAPTION, STR_NULL),
380  NWidget(WWT_PANEL, COLOUR_BROWN),
382 
383  /* 'New Game' and 'Load Game' buttons */
385  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GENERATE_GAME), SetMinimalSize(158, 12),
386  SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetPadding(0, 0, 0, 10), SetFill(1, 0),
387  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_LOAD_GAME), SetMinimalSize(158, 12),
388  SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetPadding(0, 10, 0, 0), SetFill(1, 0),
389  EndContainer(),
390 
392 
393  /* 'Play Scenario' and 'Play Heightmap' buttons */
395  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_SCENARIO), SetMinimalSize(158, 12),
396  SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetPadding(0, 0, 0, 10), SetFill(1, 0),
397  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_HEIGHTMAP), SetMinimalSize(158, 12),
398  SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_TOOLTIP_PLAY_HEIGHTMAP), SetPadding(0, 10, 0, 0), SetFill(1, 0),
399  EndContainer(),
400 
402 
403  /* 'Scenario Editor' and 'Multiplayer' buttons */
405  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EDIT_SCENARIO), SetMinimalSize(158, 12),
406  SetDataTip(STR_INTRO_SCENARIO_EDITOR, STR_INTRO_TOOLTIP_SCENARIO_EDITOR), SetPadding(0, 0, 0, 10), SetFill(1, 0),
407  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_PLAY_NETWORK), SetMinimalSize(158, 12),
408  SetDataTip(STR_INTRO_MULTIPLAYER, STR_INTRO_TOOLTIP_MULTIPLAYER), SetPadding(0, 10, 0, 0), SetFill(1, 0),
409  EndContainer(),
410 
412 
413  /* Climate selection buttons */
415  NWidget(NWID_SPACER), SetMinimalSize(10, 0), SetFill(1, 0),
417  SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
418  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
420  SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
421  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
423  SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
424  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
426  SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
427  NWidget(NWID_SPACER), SetMinimalSize(10, 0), SetFill(1, 0),
428  EndContainer(),
429 
433  NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_BASESET), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
434  EndContainer(),
435  EndContainer(),
438  NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_TRANSLATION), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
439  EndContainer(),
440  EndContainer(),
441 
442  /* 'Game Options' and 'Settings' buttons */
444  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_OPTIONS), SetMinimalSize(158, 12),
445  SetDataTip(STR_INTRO_GAME_OPTIONS, STR_INTRO_TOOLTIP_GAME_OPTIONS), SetPadding(0, 0, 0, 10), SetFill(1, 0),
447  SetDataTip(STR_INTRO_CONFIG_SETTINGS_TREE, STR_INTRO_TOOLTIP_CONFIG_SETTINGS_TREE), SetPadding(0, 10, 0, 0), SetFill(1, 0),
448  EndContainer(),
449 
451 
452  /* 'AI Settings' and 'Game Script Settings' buttons */
454  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_AI_SETTINGS), SetMinimalSize(158, 12),
455  SetDataTip(STR_INTRO_AI_SETTINGS, STR_INTRO_TOOLTIP_AI_SETTINGS), SetPadding(0, 0, 0, 10), SetFill(1, 0),
456  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GS_SETTINGS), SetMinimalSize(158, 12),
457  SetDataTip(STR_INTRO_GAMESCRIPT_SETTINGS, STR_INTRO_TOOLTIP_GAMESCRIPT_SETTINGS), SetPadding(0, 10, 0, 0), SetFill(1, 0),
458  EndContainer(),
459 
461 
462  /* 'Check Online Content' and 'NewGRF Settings' buttons */
465  SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), SetPadding(0, 0, 0, 10), SetFill(1, 0),
466  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_GRF_SETTINGS), SetMinimalSize(158, 12),
467  SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_INTRO_TOOLTIP_NEWGRF_SETTINGS), SetPadding(0, 10, 0, 0), SetFill(1, 0),
468  EndContainer(),
469 
471 
472  /* 'Highscore Table' button */
474  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_HIGHSCORE), SetMinimalSize(316, 12),
475  SetDataTip(STR_INTRO_HIGHSCORE, STR_INTRO_TOOLTIP_HIGHSCORE), SetPadding(0, 10, 0, 10), SetFill(1, 0),
476  EndContainer(),
477 
479 
480  /* 'Exit' button */
482  NWidget(NWID_SPACER), SetFill(1, 0),
483  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EXIT), SetMinimalSize(128, 12),
484  SetDataTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
485  NWidget(NWID_SPACER), SetFill(1, 0),
486  EndContainer(),
487 
489 
490  EndContainer(),
491 };
492 
493 static WindowDesc _select_game_desc(
494  WDP_CENTER, nullptr, 0, 0,
496  0,
497  _nested_select_game_widgets, lengthof(_nested_select_game_widgets)
498 );
499 
500 void ShowSelectGameWindow()
501 {
502  new SelectGameWindow(&_select_game_desc);
503 }
504 
505 static void AskExitGameCallback(Window *w, bool confirmed)
506 {
507  if (confirmed) _exit_game = true;
508 }
509 
510 void AskExitGame()
511 {
512  ShowQuery(
513  STR_QUIT_CAPTION,
514  STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD,
515  nullptr,
516  AskExitGameCallback
517  );
518 }
519 
520 
521 static void AskExitToGameMenuCallback(Window *w, bool confirmed)
522 {
523  if (confirmed) {
526  }
527 }
528 
529 void AskExitToGameMenu()
530 {
531  ShowQuery(
532  STR_ABANDON_GAME_CAPTION,
533  (_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY,
534  nullptr,
535  AskExitToGameMenuCallback
536  );
537 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:428
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:1999
network_content.h
LanguagePackHeader::missing
uint16 missing
number of missing strings.
Definition: language.h:40
IntroGameViewportCommand::vehicle
VehicleID vehicle
Vehicle to follow, or INVALID_VEHICLE if not following a vehicle.
Definition: intro_gui.cpp:63
IsInsideMM
static 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:230
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:51
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:337
IntroGameViewportCommand::pan_to_next
bool pan_to_next
If true, do a smooth pan from this position to the next.
Definition: intro_gui.cpp:66
Vehicle::y_pos
int32 y_pos
y coordinate.
Definition: vehicle_base.h:284
IntroGameViewportCommand::zoom_adjust
int zoom_adjust
Adjustment to zoom level from base zoom level.
Definition: intro_gui.cpp:65
Vehicle::x_pos
int32 x_pos
x coordinate.
Definition: vehicle_base.h:283
landscape_type.h
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1143
WID_SGI_TOYLAND_LANDSCAPE
@ WID_SGI_TOYLAND_LANDSCAPE
Select toyland landscape button.
Definition: intro_widget.h:24
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:328
WID_SGI_EXIT
@ WID_SGI_EXIT
Exit button.
Definition: intro_widget.h:36
IntroGameViewportCommand::delay
uint delay
Delay until next command.
Definition: intro_gui.cpp:64
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
WC_SELECT_GAME
@ WC_SELECT_GAME
Select game window; Window numbers:
Definition: window_type.h:435
Vehicle::z_pos
int32 z_pos
z coordinate.
Definition: vehicle_base.h:285
RemapCoords
static 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
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:255
IntroGameViewportCommand::command_index
int command_index
Sequence number of the command (order they are performed in).
Definition: intro_gui.cpp:61
ViewportData::scrollpos_y
int32 scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:195
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1775
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
WID_SGI_PLAY_SCENARIO
@ WID_SGI_PLAY_SCENARIO
Play scenario button.
Definition: intro_widget.h:17
SelectGameWindow
Definition: intro_gui.cpp:99
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:1126
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
ai_gui.hpp
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
vehicle_base.h
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:790
SelectGameWindow::cur_viewport_command_time
uint cur_viewport_command_time
Time spent (milliseconds) on current viewport command.
Definition: intro_gui.cpp:105
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2523
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
network_gui.h
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:224
fios.h
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition: genworld_gui.cpp:1090
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
GENERATE_NEW_SEED
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
Definition: genworld.h:24
genworld.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
textbuf_gui.h
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:377
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:789
WID_SGI_ARCTIC_LANDSCAPE
@ WID_SGI_ARCTIC_LANDSCAPE
Select arctic landscape button.
Definition: intro_widget.h:22
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:587
WID_SGI_HIGHSCORE
@ WID_SGI_HIGHSCORE
Highscore button.
Definition: intro_widget.h:30
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:102
SelectGameWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: intro_gui.cpp:327
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:469
WID_SGI_GRF_SETTINGS
@ WID_SGI_GRF_SETTINGS
NewGRF button.
Definition: intro_widget.h:32
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:335
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition: fileio_type.h:49
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:1078
WID_SGI_CONTENT_DOWNLOAD
@ WID_SGI_CONTENT_DOWNLOAD
Content Download button.
Definition: intro_widget.h:33
IntroGameViewportCommand
A viewport command for the main menu background (intro game).
Definition: intro_gui.cpp:47
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:249
game_gui.hpp
INVALID_VEHICLE
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:55
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
highscore.h
IntroGameViewportCommand::position
Point position
Calculated world coordinate to position viewport top-left at.
Definition: intro_gui.cpp:62
_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:174
WID_SGI_PLAY_NETWORK
@ WID_SGI_PLAY_NETWORK
Play network button.
Definition: intro_widget.h:20
GUISettings::missing_strings_threshold
byte missing_strings_threshold
the number of missing strings before showing the warning
Definition: settings_type.h:170
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
SelectGameWindow::ReadIntroGameViewportCommands
void ReadIntroGameViewportCommands()
Find and parse all viewport command signs.
Definition: intro_gui.cpp:113
_current_language
const LanguageMetadata * _current_language
The currently loaded language.
Definition: strings.cpp:47
safeguards.h
WID_SGI_LOAD_GAME
@ WID_SGI_LOAD_GAME
Load game button.
Definition: intro_widget.h:16
WID_SGI_TEMPERATE_LANDSCAPE
@ WID_SGI_TEMPERATE_LANDSCAPE
Select temperate landscape button.
Definition: intro_widget.h:21
WID_SGI_TRANSLATION_SELECTION
@ WID_SGI_TRANSLATION_SELECTION
Translation selection.
Definition: intro_widget.h:27
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
ViewportData::dest_scrollpos_y
int32 dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:197
language.h
stdafx.h
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:940
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
landscape.h
WID_SGI_TRANSLATION
@ WID_SGI_TRANSLATION
Translation errors.
Definition: intro_widget.h:28
WID_SGI_GS_SETTINGS
@ WID_SGI_GS_SETTINGS
Game Script button.
Definition: intro_widget.h:35
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition: game_gui.cpp:461
viewport_func.h
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:1099
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
WID_SGI_BASESET_SELECTION
@ WID_SGI_BASESET_SELECTION
Baseset selection.
Definition: intro_widget.h:25
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:715
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8 rank=-1)
Show the highscore table for a given difficulty.
Definition: highscore_gui.cpp:234
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:49
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
ShowQuery
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
Definition: misc_gui.cpp:1266
ViewportData::scrollpos_x
int32 scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:194
rev.h
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
SelectGameWindow::cur_viewport_command_index
size_t cur_viewport_command_index
Index of currently active viewport command.
Definition: intro_gui.cpp:103
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:386
WID_SGI_GENERATE_GAME
@ WID_SGI_GENERATE_GAME
Generate game button.
Definition: intro_widget.h:15
strings_func.h
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
SelectGameWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: intro_gui.cpp:283
geometry_func.hpp
IntroGameViewportCommand::align_v
AlignmentV align_v
Vertical alignment.
Definition: intro_gui.cpp:68
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
SetNewLandscapeType
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
Definition: genworld_gui.cpp:64
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
WID_SGI_AI_SETTINGS
@ WID_SGI_AI_SETTINGS
AI button.
Definition: intro_widget.h:34
UpdateViewportPosition
void UpdateViewportPosition(Window *w)
Update the viewport position being displayed.
Definition: viewport.cpp:1874
IntroGameViewportCommand::AlignmentH
AlignmentH
Horizontal alignment value.
Definition: intro_gui.cpp:49
FindWindowByClass
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Definition: window.cpp:1176
IntroGameViewportCommand::align_h
AlignmentH align_h
Horizontal alignment.
Definition: intro_gui.cpp:67
Sign
Definition: signs_base.h:22
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:20
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:44
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1791
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
WID_SGI_SETTINGS_OPTIONS
@ WID_SGI_SETTINGS_OPTIONS
Settings button.
Definition: intro_widget.h:31
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:24
SM_MENU
@ SM_MENU
Switch to game intro menu.
Definition: openttd.h:32
WID_SGI_PLAY_HEIGHTMAP
@ WID_SGI_PLAY_HEIGHTMAP
Play heightmap button.
Definition: intro_widget.h:18
IntroGameViewportCommand::AlignmentV
AlignmentV
Vertical alignment value.
Definition: intro_gui.cpp:55
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
network.h
IntroGameViewportCommand::PositionForViewport
Point PositionForViewport(const Viewport *vp)
Calculate effective position.
Definition: intro_gui.cpp:76
window_func.h
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:344
SelectGameWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: intro_gui.cpp:265
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
ViewportData::dest_scrollpos_x
int32 dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:196
SelectGameWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: intro_gui.cpp:191
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
gui.h
Window
Data structure for an opened window.
Definition: window_gui.h:213
Viewport::virtual_height
int virtual_height
height << zoom
Definition: viewport_type.h:31
_network_available
bool _network_available
is network mode available?
Definition: network.cpp:60
WID_SGI_EDIT_SCENARIO
@ WID_SGI_EDIT_SCENARIO
Edit scenario button.
Definition: intro_widget.h:19
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:911
intro_widget.h
WID_SGI_OPTIONS
@ WID_SGI_OPTIONS
Options button.
Definition: intro_widget.h:29
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
CursorVars::pos
Point pos
logical mouse position
Definition: gfx_type.h:117
SelectGameWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: intro_gui.cpp:274
SelectGameWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: intro_gui.cpp:298
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:91
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:382
_is_network_server
bool _is_network_server
Does this client wants to be a network-server?
Definition: network.cpp:62
SelectGameWindow::intro_viewport_commands
std::vector< IntroGameViewportCommand > intro_viewport_commands
Vector of viewport commands parsed.
Definition: intro_gui.cpp:101
signs_base.h
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:55
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:604
WID_SGI_BASESET
@ WID_SGI_BASESET
Baseset errors.
Definition: intro_widget.h:26
SignID
uint16 SignID
The type of the IDs of signs.
Definition: signs_type.h:14
_grfconfig_newgame
GRFConfig * _grfconfig_newgame
First item in list of default GRF set up.
Definition: newgrf_config.cpp:172
WID_SGI_TROPIC_LANDSCAPE
@ WID_SGI_TROPIC_LANDSCAPE
Select tropic landscape button.
Definition: intro_widget.h:23