OpenTTD
fios_gui.cpp
Go to the documentation of this file.
1 /* $Id: fios_gui.cpp 27893 2017-08-13 18:38:42Z frosch $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #include "stdafx.h"
13 #include "saveload/saveload.h"
14 #include "error.h"
15 #include "gui.h"
16 #include "gfx_func.h"
17 #include "command_func.h"
18 #include "network/network.h"
20 #include "strings_func.h"
21 #include "fileio_func.h"
22 #include "fios.h"
23 #include "window_func.h"
24 #include "tilehighlight_func.h"
25 #include "querystring_gui.h"
26 #include "engine_func.h"
27 #include "landscape_type.h"
28 #include "date_func.h"
29 #include "core/geometry_func.hpp"
30 #include "gamelog.h"
31 
32 #include "widgets/fios_widget.h"
33 
34 #include "table/sprites.h"
35 #include "table/strings.h"
36 
37 #include "safeguards.h"
38 
40 
41 static bool _fios_path_changed;
42 static bool _savegame_sort_dirty;
43 
44 
49 {
50  this->checkable = false;
51  this->error = INVALID_STRING_ID;
52  free(this->error_data);
53  this->error_data = NULL;
54 
55  this->map_size_x = this->map_size_y = 256; // Default for old savegames which do not store mapsize.
56  this->current_date = 0;
57  memset(&this->settings, 0, sizeof(this->settings));
58 
59  const CompanyPropertiesMap::iterator end = this->companies.End();
60  for (CompanyPropertiesMap::iterator it = this->companies.Begin(); it != end; it++) {
61  delete it->second;
62  }
63  companies.Clear();
64 
66  this->gamelog_action = NULL;
67  this->gamelog_actions = 0;
68 
70 }
71 
75  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
76  NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION),
77  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
78  EndContainer(),
79  NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
84  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
85  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
86  EndContainer(),
87  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
88  EndContainer(),
91  NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2),
92  SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
94  EndContainer(),
97  SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
98  EndContainer(),
99  EndContainer(),
100  EndContainer(),
101  NWidget(WWT_PANEL, COLOUR_GREY),
102  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1),
103  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_MISSING_NEWGRFS), SetDataTip(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON, STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
106  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_NEWGRF_INFO), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_NULL), SetFill(1, 0), SetResize(1, 0),
107  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
108  EndContainer(),
109  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
110  EndContainer(),
111  EndContainer(),
112  EndContainer(),
113 };
114 
118  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
119  NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION),
120  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
121  EndContainer(),
122  NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
126  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
127  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
128  EndContainer(),
129  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
130  EndContainer(),
133  NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2),
134  SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
136  EndContainer(),
138  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), SetFill(1, 0),
139  SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
140  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetResize(1, 0), SetFill(1, 0),
141  SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP),
142  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
143  EndContainer(),
144  EndContainer(),
145  EndContainer(),
146 };
147 
151  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
152  NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION),
153  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
154  EndContainer(),
155  NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
160  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
161  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
162  EndContainer(),
163  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
164  EndContainer(),
167  NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetPadding(2, 1, 0, 2),
168  SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
170  EndContainer(),
171  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_SAVE_OSK_TITLE), SetPadding(3, 2, 2, 2), SetFill(1, 0), SetResize(1, 0),
172  SetDataTip(STR_SAVELOAD_OSKTITLE, STR_SAVELOAD_EDITBOX_TOOLTIP),
173  EndContainer(),
175  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_DELETE_SELECTION), SetDataTip(STR_SAVELOAD_DELETE_BUTTON, STR_SAVELOAD_DELETE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
176  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SAVE_GAME), SetDataTip(STR_SAVELOAD_SAVE_BUTTON, STR_SAVELOAD_SAVE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
177  EndContainer(),
178  EndContainer(),
179  NWidget(WWT_PANEL, COLOUR_GREY),
180  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1),
182  NWidget(NWID_SPACER), SetResize(1, 0), SetFill(1, 1),
183  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
184  EndContainer(),
185  EndContainer(),
186  EndContainer(),
187 };
188 
190 static const TextColour _fios_colours[] = {
191  TC_LIGHT_BROWN, // DFT_OLD_GAME_FILE
192  TC_ORANGE, // DFT_GAME_FILE
193  TC_YELLOW, // DFT_HEIGHTMAP_BMP
194  TC_ORANGE, // DFT_HEIGHTMAP_PNG
195  TC_LIGHT_BLUE, // DFT_FIOS_DRIVE
196  TC_DARK_GREEN, // DFT_FIOS_PARENT
197  TC_DARK_GREEN, // DFT_FIOS_DIR
198  TC_ORANGE, // DFT_FIOS_DIRECT
199 };
200 
201 
206 static void SortSaveGameList(FileList &file_list)
207 {
208  uint sort_start = 0;
209  uint sort_end = 0;
210 
211  /* Directories are always above the files (FIOS_TYPE_DIR)
212  * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
213  * Only sort savegames/scenarios, not directories
214  */
215  for (const FiosItem *item = file_list.Begin(); item != file_list.End(); item++) {
216  switch (item->type) {
217  case FIOS_TYPE_DIR: sort_start++; break;
218  case FIOS_TYPE_PARENT: sort_start++; break;
219  case FIOS_TYPE_DRIVE: sort_end++; break;
220  default: break;
221  }
222  }
223 
224  uint s_amount = file_list.Length() - sort_start - sort_end;
225  QSortT(file_list.Get(sort_start), s_amount, CompareFiosItems);
226 }
227 
228 struct SaveLoadWindow : public Window {
229 private:
231  AbstractFileType abstract_filetype;
234  FiosItem o_dir;
236  Scrollbar *vscroll;
237 public:
238 
241  {
242  GenerateDefaultSaveName(this->filename_editbox.text.buf, &this->filename_editbox.text.buf[this->filename_editbox.text.max_bytes - 1]);
243  this->filename_editbox.text.UpdateSize();
244  }
245 
246  SaveLoadWindow(WindowDesc *desc, AbstractFileType abstract_filetype, SaveLoadOperation fop)
247  : Window(desc), filename_editbox(64), abstract_filetype(abstract_filetype), fop(fop)
248  {
249  assert(this->fop == SLO_SAVE || this->fop == SLO_LOAD);
250 
251  /* For saving, construct an initial file name. */
252  if (this->fop == SLO_SAVE) {
253  switch (this->abstract_filetype) {
254  case FT_SAVEGAME:
255  this->GenerateFileName();
256  break;
257 
258  case FT_SCENARIO:
259  case FT_HEIGHTMAP:
260  this->filename_editbox.text.Assign("UNNAMED");
261  break;
262 
263  default:
264  NOT_REACHED();
265  }
266  }
267  this->querystrings[WID_SL_SAVE_OSK_TITLE] = &this->filename_editbox;
268  this->filename_editbox.ok_button = WID_SL_SAVE_GAME;
269 
270  this->CreateNestedTree(true);
271  if (this->fop == SLO_LOAD && this->abstract_filetype == FT_SAVEGAME) {
272  this->GetWidget<NWidgetStacked>(WID_SL_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL);
273  }
274 
275  /* Select caption string of the window. */
276  StringID caption_string;
277  switch (this->abstract_filetype) {
278  case FT_SAVEGAME:
279  caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_CAPTION : STR_SAVELOAD_LOAD_CAPTION;
280  break;
281 
282  case FT_SCENARIO:
283  caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_SCENARIO : STR_SAVELOAD_LOAD_SCENARIO;
284  break;
285 
286  case FT_HEIGHTMAP:
287  caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_HEIGHTMAP : STR_SAVELOAD_LOAD_HEIGHTMAP;
288  break;
289 
290  default:
291  NOT_REACHED();
292  }
293  this->GetWidget<NWidgetCore>(WID_SL_CAPTION)->widget_data = caption_string;
294 
295  this->vscroll = this->GetScrollbar(WID_SL_SCROLLBAR);
296  this->FinishInitNested(0);
297 
298  this->LowerWidget(WID_SL_DRIVES_DIRECTORIES_LIST);
299 
300  /* pause is only used in single-player, non-editor mode, non-menu mode. It
301  * will be unpaused in the WE_DESTROY event handler. */
302  if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
304  }
305  SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
306 
307  this->OnInvalidateData(0);
308 
310 
311  /* Select the initial directory. */
312  o_dir.type = FIOS_TYPE_DIRECT;
313  switch (this->abstract_filetype) {
314  case FT_SAVEGAME:
315  FioGetDirectory(o_dir.name, lastof(o_dir.name), SAVE_DIR);
316  break;
317 
318  case FT_SCENARIO:
319  FioGetDirectory(o_dir.name, lastof(o_dir.name), SCENARIO_DIR);
320  break;
321 
322  case FT_HEIGHTMAP:
323  FioGetDirectory(o_dir.name, lastof(o_dir.name), HEIGHTMAP_DIR);
324  break;
325 
326  default:
327  strecpy(o_dir.name, _personal_dir, lastof(o_dir.name));
328  }
329 
330  /* Focus the edit box by default in the save windows */
331  if (this->fop == SLO_SAVE) this->SetFocusedWidget(WID_SL_SAVE_OSK_TITLE);
332  }
333 
334  virtual ~SaveLoadWindow()
335  {
336  /* pause is only used in single-player, non-editor mode, non menu mode */
337  if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
339  }
340  }
341 
342  virtual void DrawWidget(const Rect &r, int widget) const
343  {
344  switch (widget) {
345  case WID_SL_SORT_BYNAME:
346  case WID_SL_SORT_BYDATE:
347  if (((_savegame_sort_order & SORT_BY_NAME) != 0) == (widget == WID_SL_SORT_BYNAME)) {
348  this->DrawSortButtonState(widget, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
349  }
350  break;
351 
352  case WID_SL_BACKGROUND: {
353  static const char *path = NULL;
354  static StringID str = STR_ERROR_UNABLE_TO_READ_DRIVE;
355  static uint64 tot = 0;
356 
357  if (_fios_path_changed) {
358  str = FiosGetDescText(&path, &tot);
359  _fios_path_changed = false;
360  }
361 
362  if (str != STR_ERROR_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
364  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, path, TC_BLACK);
365  break;
366  }
367 
369  GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK);
370 
371  uint y = r.top + WD_FRAMERECT_TOP;
372  for (uint pos = this->vscroll->GetPosition(); pos < this->fios_items.Length(); pos++) {
373  const FiosItem *item = this->fios_items.Get(pos);
374 
375  if (item == this->selected) {
376  GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_DARK_BLUE);
377  }
378  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, item->title, _fios_colours[GetDetailedFileType(item->type)]);
379  y += this->resize.step_height;
380  if (y >= this->vscroll->GetCapacity() * this->resize.step_height + r.top + WD_FRAMERECT_TOP) break;
381  }
382  break;
383  }
384 
385  case WID_SL_DETAILS: {
388  DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL / 2 + WD_FRAMERECT_TOP, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
389 
390  if (this->selected == NULL) break;
391 
393  uint y_max = r.bottom - FONT_HEIGHT_NORMAL - WD_FRAMERECT_BOTTOM;
394 
395  if (y > y_max) break;
396  if (!_load_check_data.checkable) {
397  /* Old savegame, no information available */
398  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);
399  y += FONT_HEIGHT_NORMAL;
400  } else if (_load_check_data.error != INVALID_STRING_ID) {
401  /* Incompatible / broken savegame */
402  SetDParamStr(0, _load_check_data.error_data);
404  y, r.bottom - WD_FRAMERECT_BOTTOM, _load_check_data.error, TC_RED);
405  } else {
406  /* Mapsize */
407  SetDParam(0, _load_check_data.map_size_x);
408  SetDParam(1, _load_check_data.map_size_y);
409  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_MAP_SIZE);
410  y += FONT_HEIGHT_NORMAL;
411  if (y > y_max) break;
412 
413  /* Climate */
414  byte landscape = _load_check_data.settings.game_creation.landscape;
415  if (landscape < NUM_LANDSCAPE) {
416  SetDParam(0, STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE + landscape);
417  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANDSCAPE);
418  y += FONT_HEIGHT_NORMAL;
419  }
420 
421  y += WD_PAR_VSEP_NORMAL;
422  if (y > y_max) break;
423 
424  /* Start date (if available) */
425  if (_load_check_data.settings.game_creation.starting_year != 0) {
426  SetDParam(0, ConvertYMDToDate(_load_check_data.settings.game_creation.starting_year, 0, 1));
427  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_START_DATE);
428  y += FONT_HEIGHT_NORMAL;
429  }
430  if (y > y_max) break;
431 
432  /* Hide current date for scenarios */
433  if (this->abstract_filetype != FT_SCENARIO) {
434  /* Current date */
435  SetDParam(0, _load_check_data.current_date);
436  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CURRENT_DATE);
437  y += FONT_HEIGHT_NORMAL;
438  }
439 
440  /* Hide the NewGRF stuff when saving. We also hide the button. */
441  if (this->fop == SLO_LOAD && (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO)) {
442  y += WD_PAR_VSEP_NORMAL;
443  if (y > y_max) break;
444 
445  /* NewGrf compatibility */
446  SetDParam(0, _load_check_data.grfconfig == NULL ? STR_NEWGRF_LIST_NONE :
447  STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility);
448  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_GRFSTATUS);
449  y += FONT_HEIGHT_NORMAL;
450  }
451  if (y > y_max) break;
452 
453  /* Hide the company stuff for scenarios */
454  if (this->abstract_filetype != FT_SCENARIO) {
455  y += FONT_HEIGHT_NORMAL;
456  if (y > y_max) break;
457 
458  /* Companies / AIs */
459  CompanyPropertiesMap::const_iterator end = _load_check_data.companies.End();
460  for (CompanyPropertiesMap::const_iterator it = _load_check_data.companies.Begin(); it != end; it++) {
461  SetDParam(0, it->first + 1);
462  const CompanyProperties &c = *it->second;
463  if (c.name != NULL) {
464  SetDParam(1, STR_JUST_RAW_STRING);
465  SetDParamStr(2, c.name);
466  } else {
467  SetDParam(1, c.name_1);
468  SetDParam(2, c.name_2);
469  }
470  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_COMPANY_INDEX);
471  y += FONT_HEIGHT_NORMAL;
472  if (y > y_max) break;
473  }
474  }
475  }
476  break;
477  }
478  }
479  }
480 
481  virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
482  {
483  switch (widget) {
484  case WID_SL_BACKGROUND:
486  break;
487 
489  resize->height = FONT_HEIGHT_NORMAL;
490  size->height = resize->height * 10 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
491  break;
492  case WID_SL_SORT_BYNAME:
493  case WID_SL_SORT_BYDATE: {
494  Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
495  d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
496  d.height += padding.height;
497  *size = maxdim(*size, d);
498  break;
499  }
500  }
501  }
502 
503  virtual void OnPaint()
504  {
505  if (_savegame_sort_dirty) {
506  _savegame_sort_dirty = false;
507  SortSaveGameList(this->fios_items);
508  }
509 
510  this->vscroll->SetCount(this->fios_items.Length());
511  this->DrawWidgets();
512  }
513 
514  virtual void OnClick(Point pt, int widget, int click_count)
515  {
516  switch (widget) {
517  case WID_SL_SORT_BYNAME: // Sort save names by name
518  _savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
519  SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
520  _savegame_sort_dirty = true;
521  this->SetDirty();
522  break;
523 
524  case WID_SL_SORT_BYDATE: // Sort save names by date
525  _savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
526  SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
527  _savegame_sort_dirty = true;
528  this->SetDirty();
529  break;
530 
531  case WID_SL_HOME_BUTTON: // OpenTTD 'button', jumps to OpenTTD directory
532  FiosBrowseTo(&o_dir);
533  this->InvalidateData();
534  break;
535 
536  case WID_SL_LOAD_BUTTON:
537  if (this->selected != NULL && !_load_check_data.HasErrors()) {
538  const char *name = FiosBrowseTo(this->selected);
539  _file_to_saveload.SetMode(this->selected->type);
541  _file_to_saveload.SetTitle(this->selected->title);
542 
543  if (this->abstract_filetype == FT_HEIGHTMAP) {
544  delete this;
546 
547  } else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
548  _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
550  delete this;
551  }
552  }
553  break;
554 
555  case WID_SL_NEWGRF_INFO:
556  if (_load_check_data.HasNewGrfs()) {
557  ShowNewGRFSettings(false, false, false, &_load_check_data.grfconfig);
558  }
559  break;
560 
562  if (!_network_available) {
563  ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
564  } else if (_load_check_data.HasNewGrfs()) {
565 #if defined(ENABLE_NETWORK)
566  ShowMissingContentWindow(_load_check_data.grfconfig);
567 #endif
568  }
569  break;
570 
571  case WID_SL_DRIVES_DIRECTORIES_LIST: { // Click the listbox
572  int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WD_FRAMERECT_TOP);
573  if (y == INT_MAX) return;
574 
575  const FiosItem *file = this->fios_items.Get(y);
576 
577  const char *name = FiosBrowseTo(file);
578  if (name != NULL) {
579  if (click_count == 1) {
580  if (this->selected != file) {
581  this->selected = file;
582  _load_check_data.Clear();
583 
584  if (GetDetailedFileType(file->type) == DFT_GAME_FILE) {
585  /* Other detailed file types cannot be checked before. */
587  }
588 
589  this->InvalidateData(1);
590  }
591  if (this->fop == SLO_SAVE) {
592  /* Copy clicked name to editbox */
593  this->filename_editbox.text.Assign(file->title);
594  this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE);
595  }
596  } else if (!_load_check_data.HasErrors()) {
597  this->selected = file;
598  if (this->fop == SLO_LOAD) {
599  if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
600  this->OnClick(pt, WID_SL_LOAD_BUTTON, 1);
601  } else {
602  assert(this->abstract_filetype == FT_HEIGHTMAP);
603  _file_to_saveload.SetMode(file->type);
605  _file_to_saveload.SetTitle(file->title);
606 
607  delete this;
609  }
610  }
611  }
612  } else {
613  /* Changed directory, need refresh. */
614  this->InvalidateData();
615  }
616  break;
617  }
618 
620  if (!_network_available) {
621  ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
622  } else {
623 #if defined(ENABLE_NETWORK)
624  assert(this->fop == SLO_LOAD);
625  switch (this->abstract_filetype) {
626  default: NOT_REACHED();
629  }
630 #endif
631  }
632  break;
633 
634  case WID_SL_DELETE_SELECTION: // Delete
635  break;
636 
637  case WID_SL_SAVE_GAME: // Save game
638  /* Note, this is also called via the OSK; and we need to lower the button. */
639  this->HandleButtonClick(WID_SL_SAVE_GAME);
640  break;
641  }
642  }
643 
644  virtual EventState OnKeyPress(WChar key, uint16 keycode)
645  {
646  if (keycode == WKC_ESC) {
647  delete this;
648  return ES_HANDLED;
649  }
650 
651  return ES_NOT_HANDLED;
652  }
653 
654  virtual void OnTimeout()
655  {
656  /* Widgets WID_SL_DELETE_SELECTION and WID_SL_SAVE_GAME only exist when saving to a file. */
657  if (this->fop != SLO_SAVE) return;
658 
659  if (this->IsWidgetLowered(WID_SL_DELETE_SELECTION)) { // Delete button clicked
660  if (!FiosDelete(this->filename_editbox.text.buf)) {
661  ShowErrorMessage(STR_ERROR_UNABLE_TO_DELETE_FILE, INVALID_STRING_ID, WL_ERROR);
662  } else {
663  this->InvalidateData();
664  /* Reset file name to current date on successful delete */
665  if (this->abstract_filetype == FT_SAVEGAME) GenerateFileName();
666  }
667  } else if (this->IsWidgetLowered(WID_SL_SAVE_GAME)) { // Save button clicked
668  if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
670  FiosMakeSavegameName(_file_to_saveload.name, this->filename_editbox.text.buf, lastof(_file_to_saveload.name));
671  } else {
673  FiosMakeHeightmapName(_file_to_saveload.name, this->filename_editbox.text.buf, lastof(_file_to_saveload.name));
674  }
675 
676  /* In the editor set up the vehicle engines correctly (date might have changed) */
677  if (_game_mode == GM_EDITOR) StartupEngines();
678  }
679  }
680 
681  virtual void OnResize()
682  {
684  }
685 
691  virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
692  {
693  switch (data) {
694  case 0:
695  /* Rescan files */
696  this->selected = NULL;
697  _load_check_data.Clear();
698  if (!gui_scope) break;
699 
700  _fios_path_changed = true;
701  this->fios_items.BuildFileList(this->abstract_filetype, this->fop);
702  this->vscroll->SetCount(this->fios_items.Length());
703  this->selected = NULL;
704  _load_check_data.Clear();
705  FALLTHROUGH;
706 
707  case 1:
708  /* Selection changes */
709  if (!gui_scope) break;
710 
711  if (this->fop != SLO_LOAD) break;
712 
713  switch (this->abstract_filetype) {
714  case FT_HEIGHTMAP:
715  this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, this->selected == NULL || _load_check_data.HasErrors());
716  break;
717 
718  case FT_SAVEGAME:
719  case FT_SCENARIO: {
720  bool disabled = this->selected == NULL || _load_check_data.HasErrors();
722  disabled |= _load_check_data.HasNewGrfs() && _load_check_data.grf_compatibility == GLC_NOT_FOUND;
723  }
724  this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, disabled);
725  this->SetWidgetDisabledState(WID_SL_NEWGRF_INFO, !_load_check_data.HasNewGrfs());
726  this->SetWidgetDisabledState(WID_SL_MISSING_NEWGRFS,
727  !_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility == GLC_ALL_GOOD);
728  break;
729  }
730 
731  default:
732  NOT_REACHED();
733  }
734  break;
735  }
736  }
737 };
738 
741  WDP_CENTER, "load_game", 500, 294,
743  0,
744  _nested_load_dialog_widgets, lengthof(_nested_load_dialog_widgets)
745 );
746 
749  WDP_CENTER, "load_heightmap", 257, 320,
751  0,
752  _nested_load_heightmap_dialog_widgets, lengthof(_nested_load_heightmap_dialog_widgets)
753 );
754 
757  WDP_CENTER, "save_game", 500, 294,
759  0,
760  _nested_save_dialog_widgets, lengthof(_nested_save_dialog_widgets)
761 );
762 
769 {
771 
772  WindowDesc *sld;
773  if (fop == SLO_SAVE) {
774  sld = &_save_dialog_desc;
775  } else {
776  /* Dialogue for loading a file. */
777  sld = (abstract_filetype == FT_HEIGHTMAP) ? &_load_heightmap_dialog_desc : &_load_dialog_desc;
778  }
779 
780  _file_to_saveload.abstract_ftype = abstract_filetype;
781 
782  new SaveLoadWindow(sld, abstract_filetype, fop);
783 }
EventState
State of handling an event.
Definition: window_type.h:701
static const NWidgetPart _nested_load_heightmap_dialog_widgets[]
Load heightmap with content download.
Definition: fios_gui.cpp:116
Functions related to OTTD&#39;s strings.
AbstractFileType
The different abstract types of files that the system knows about.
Definition: fileio_type.h:18
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
static const TextColour _fios_colours[]
Text colours of DetailedFileType fios entries in the window.
Definition: fios_gui.cpp:190
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
virtual void OnPaint()
The window must be repainted.
Definition: fios_gui.cpp:503
bool _networking
are we in networking mode?
Definition: network.cpp:56
Button to open NewGgrf configuration.
Definition: fios_widget.h:31
Button to load game/scenario.
Definition: fios_widget.h:32
Horizontally center the text.
Definition: gfx_func.h:99
char * name
Name of the company if the user changed it.
Definition: company_base.h:56
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
Definition: gfx.cpp:112
Container for loading in mode SL_LOAD_CHECK.
Definition: fios.h:26
byte landscape
the landscape we&#39;re currently in
High level window description.
Definition: window_gui.h:168
void GenerateDefaultSaveName(char *buf, const char *last)
Fill the buffer with the default name for a savegame or screenshot.
Definition: saveload.cpp:2885
Saveload window; Window numbers:
Definition: window_type.h:139
All GRF needed by game are present.
Definition: newgrf_config.h:54
struct LoggedAction * gamelog_action
Gamelog actions.
Definition: fios.h:41
void SetName(const char *name)
Set the name of the file.
Definition: saveload.cpp:2948
Functions related to dates.
Scrollbar data structure.
Definition: widget_type.h:589
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
Load game, Play Scenario.
Definition: openttd.h:31
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
Horizontal container.
Definition: widget_type.h:75
The passed event is not handled.
Definition: window_type.h:703
Functions to be called to log possibly unsafe game events.
Types related to the fios widgets.
The content consists of a scenario.
Definition: tcp_content.h:31
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:272
Subdirectory of scenario for heightmaps.
Definition: fileio_type.h:115
void GenerateFileName()
Generate a default save filename.
Definition: fios_gui.cpp:240
a textbox for typing
Definition: widget_type.h:71
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:68
Pressed (inset) panel, most commonly used as combo box text area.
Definition: widget_type.h:51
Title textbox, only available for save operations.
Definition: fios_widget.h:26
void ShowNetworkContentListWindow(ContentVector *cv=NULL, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
FileList fios_items
Save game list.
Definition: fios_gui.cpp:233
void Clear()
Remove all items from the list.
GRFConfig * grfconfig
NewGrf configuration from save.
Definition: fios.h:38
const T * Begin() const
Get the pointer to the first item (const)
const FiosItem * Begin() const
Get a pointer to the first file information.
Definition: fios.h:132
Close box (at top-left of a window)
Definition: widget_type.h:69
Functions for Standard In/Out file operations.
DetailedFileType GetDetailedFileType(FiosType fios_type)
Extract the detailed file type from a FiosType.
Definition: fileio_type.h:102
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:50
uint32 name_2
Parameter of name_1.
Definition: company_base.h:54
Panel with game details.
Definition: fios_widget.h:30
Background of file selection.
Definition: fios_widget.h:21
const T * End() const
Get the pointer behind the last valid item (const)
File is being saved.
Definition: fileio_type.h:52
Deals with finding savegames.
Definition: fios.h:98
Save button, only available for save operations.
Definition: fios_widget.h:28
Load file for checking and/or preview.
Definition: fileio_type.h:50
StringID FiosGetDescText(const char **path, uint64 *total_free)
Get descriptive texts.
Definition: fios.cpp:141
bool _network_available
is network mode available?
Definition: network.cpp:58
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:670
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:910
Base for the GUIs that have an edit box in them.
Data structure for an opened window.
Definition: window_gui.h:271
Save game or scenario file.
Definition: fileio_type.h:33
bool checkable
True if the savegame could be checked by SL_LOAD_CHECK. (Old savegames are not checkable.)
Definition: fios.h:27
old or new savegame
Definition: fileio_type.h:20
old or new scenario
Definition: fileio_type.h:21
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:1046
static WindowDesc _load_dialog_desc(WDP_CENTER, "load_game", 500, 294, WC_SAVELOAD, WC_NONE, 0, _nested_load_dialog_widgets, lengthof(_nested_load_dialog_widgets))
Load game/scenario.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Definition: error_gui.cpp:378
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:279
Main window; Window numbers:
Definition: window_type.h:46
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
uint Length() const
Get the number of files in the list.
Definition: fios.h:123
Sort by name button.
Definition: fios_widget.h:18
Base directory for all scenarios.
Definition: fileio_type.h:114
const FiosItem * End() const
Get a pointer behind the last file information.
Definition: fios.h:141
void SetTitle(const char *title)
Set the title of the file.
Definition: saveload.cpp:2957
Functions/types related to saving and loading games.
Invisible widget that takes some space.
Definition: widget_type.h:79
void FiosMakeSavegameName(char *buf, const char *name, const char *last)
Make a save game or scenario filename from a name.
Definition: fios.cpp:243
Functions related to errors.
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX) ...
Definition: widget_type.h:65
Caption of the window.
Definition: fios_widget.h:17
Delete button, only available for save operations.
Definition: fios_widget.h:27
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1959
void GamelogFree(LoggedAction *gamelog_action, uint gamelog_actions)
Frees the memory allocated by a gamelog.
Definition: gamelog.cpp:71
Home button.
Definition: fios_widget.h:22
virtual EventState OnKeyPress(WChar key, uint16 keycode)
A key has been pressed.
Definition: fios_gui.cpp:644
Simple pair of data.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: fios_gui.cpp:342
Functions related to engines.
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
Sort descending.
Definition: window_gui.h:227
CompanyPropertiesMap companies
Company information.
Definition: fios.h:36
Statically loadable part of Company pool item.
Definition: company_base.h:53
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:180
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
Functions related to the gfx engine.
Data stored about a string that can be modified in the GUI.
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:76
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:389
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
A path without any base directory.
Definition: fileio_type.h:127
Definition of base types and functions in a cross-platform compatible way.
void Clear()
Reset read data.
Definition: fios_gui.cpp:48
void ShowHeightmapLoad()
Start with loading a heightmap.
A number of safeguards to prevent using unsafe methods.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:247
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
Geometry functions.
Simple depressed panel.
Definition: widget_type.h:50
Base directory for all savegames.
Definition: fileio_type.h:112
void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Construct a file list with the given kind of files, for the stated purpose.
Definition: fios.cpp:76
static void SortSaveGameList(FileList &file_list)
Sort the collected list save games prior to displaying it in the save/load gui.
Definition: fios_gui.cpp:206
const char * _personal_dir
custom directory for personal settings, saves, newgrf, etc.
Definition: fileio.cpp:1163
char * error_data
Data to pass to SetDParamStr when displaying error.
Definition: fios.h:29
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition: fios_gui.cpp:691
virtual void OnTimeout()
Called when this window&#39;s timeout has been reached.
Definition: fios_gui.cpp:654
const FiosItem * Get(uint index) const
Get a pointer to the indicated file information.
Definition: fios.h:150
Center the window.
Definition: window_gui.h:157
bool HasErrors()
Check whether loading the game resulted in errors.
Definition: fios.h:62
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
static WindowDesc _save_dialog_desc(WDP_CENTER, "save_game", 500, 294, WC_SAVELOAD, WC_NONE, 0, _nested_save_dialog_widgets, lengthof(_nested_save_dialog_widgets))
Save game/scenario.
virtual void OnResize()
Called after the window got resized.
Definition: fios_gui.cpp:681
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:499
Basic functions/variables used all over the place.
Part of the network protocol handling content distribution.
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
Definition: saveload.cpp:2790
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:527
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
File is being loaded.
Definition: fileio_type.h:51
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:658
StringID error
Error message from loading. INVALID_STRING_ID if no error.
Definition: fios.h:28
SaveLoadOperation fop
Type of file to select.
Definition: fios_gui.cpp:232
int CDECL CompareFiosItems(const FiosItem *da, const FiosItem *db)
Compare two FiosItem&#39;s.
Definition: fios.cpp:52
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:207
SaveLoadOperation
Operation performed on the file.
Definition: fileio_type.h:49
Save game.
Definition: openttd.h:33
void Assign(StringID string)
Render a string into the textbuffer.
Definition: textbuf.cpp:399
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:699
bool FiosDelete(const char *name)
Delete a file.
Definition: fios.cpp:270
void StartupEngines()
Start/initialise all our engines.
Definition: engine.cpp:688
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:40
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1137
static const uint8 PC_GREY
Grey palette colour.
Definition: gfx_func.h:209
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
Definition: gfx_func.h:226
Sort by date button.
Definition: fios_widget.h:19
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:768
void FiosMakeHeightmapName(char *buf, const char *name, const char *last)
Construct a filename for a height map.
Definition: fios.cpp:256
default
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:34
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Background of window.
Definition: fios_widget.h:20
GUISettings gui
settings related to the GUI
QueryString filename_editbox
Filename editbox.
Definition: fios_gui.cpp:230
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:336
Declarations for savegames operations.
Types related to the landscape.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Definition: fios_gui.cpp:39
The content consists of a heightmap.
Definition: tcp_content.h:32
StringID name_1
Name of the company if the user did not change it.
Definition: company_base.h:55
List of file information.
Definition: fios.h:106
At least one GRF couldn&#39;t be found (higher priority than GLC_COMPATIBLE)
Definition: newgrf_config.h:56
const char * FiosBrowseTo(const FiosItem *item)
Browse to a new path based on the passed item, starting at #_fios_path.
Definition: fios.cpp:152
Sort ascending.
Definition: window_gui.h:226
Vertical container.
Definition: widget_type.h:77
static const NWidgetPart _nested_load_dialog_widgets[]
Load game/scenario with optional content download.
Definition: fios_gui.cpp:73
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: depend.cpp:68
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:47
uint gamelog_actions
Number of gamelog actions.
Definition: fios.h:42
Functions related to commands.
char name[MAX_PATH]
Name of the file.
Definition: saveload.h:30
Coordinates of a point in 2D.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition: fios_gui.cpp:481
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
Definition: saveload.h:29
const FiosItem * selected
Selected game in fios_items, or NULL.
Definition: fios_gui.cpp:235
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
Definition: viewport.cpp:3166
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:622
Load scenario from scenario editor.
Definition: openttd.h:36
heightmap file
Definition: fileio_type.h:22
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game...
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:19
static WindowDesc _load_heightmap_dialog_desc(WDP_CENTER, "load_heightmap", 257, 320, WC_SAVELOAD, WC_NONE, 0, _nested_load_heightmap_dialog_widgets, lengthof(_nested_load_heightmap_dialog_widgets))
Load heightmap.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:114
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
Selection &#39;stack&#39; to &#39;hide&#39; the content download.
Definition: fios_widget.h:29
Button to find missing NewGRFs online.
Definition: fios_widget.h:33
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
bool HasNewGrfs()
Check whether the game uses any NewGrfs.
Definition: fios.h:71
GameCreationSettings game_creation
settings used during the creation of a game (map)
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget. ...
Definition: widget.cpp:1973
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Definition: viewport.cpp:3211
Specification of a rectangle with absolute coordinates of all edges.
Vertical scrollbar.
Definition: widget_type.h:84
void SetMode(FiosType ft)
Set the mode and file type of the file to save or load based on the type of file entry at the file sy...
Definition: saveload.cpp:2919
The passed event is handled.
Definition: window_type.h:702
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
A game paused for saving/loading.
Definition: openttd.h:60
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
Scrollbar of the file list.
Definition: fios_widget.h:24
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:80
GUI functions that shouldn&#39;t be here.
Errors (eg. saving/loading failed)
Definition: error.h:25
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
Definition: sort_func.hpp:28
uint32 WChar
Type for wide characters, i.e.
Definition: string_type.h:35
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: fios_gui.cpp:514
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1095
Dimensions (a width and height) of a rectangle in 2D.
GRFListCompatibility grf_compatibility
Summary state of NewGrfs, whether missing files or only compatible found.
Definition: fios.h:39
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:429
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
Year starting_year
starting date
This file contains all sprite-related enums and defines.
static const NWidgetPart _nested_save_dialog_widgets[]
Save game/scenario.
Definition: fios_gui.cpp:149
Save heightmap.
Definition: openttd.h:34
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:620
void UpdateSize()
Update Textbuf type with its actual physical character and screenlength Get the count of characters i...
Definition: textbuf.cpp:433
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:631
Content download button, only available for play scenario/heightmap.
Definition: fios_widget.h:25
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:201
pause the game
Definition: command_type.h:255