OpenTTD Source: src/fios_gui.cpp Source File

OpenTTD Source 14.0-beta1

fios_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 "saveload/saveload.h"
12 #include "error.h"
13 #include "gui.h"
14 #include "gfx_func.h"
15 #include "command_func.h"
16 #include "network/network.h"
17 #include "network/network_content.h"
18 #include "strings_func.h"
19 #include "fileio_func.h"
20 #include "fios.h"
21 #include "window_func.h"
22 #include "tilehighlight_func.h"
23 #include "querystring_gui.h"
24 #include "engine_func.h"
25 #include "landscape_type.h"
26 #include "timer/timer_game_calendar.h"
27 #include "core/geometry_func.hpp"
28 #include "gamelog.h"
29 #include "stringfilter_type.h"
30 #include "misc_cmd.h"
31 #include "gamelog_internal.h"
32
33 #include "widgets/fios_widget.h"
34
35 #include "table/sprites.h"
36 #include "table/strings.h"
37
38 #include "safeguards.h"
39
40 LoadCheckData _load_check_data;
41
42 static bool _fios_path_changed;
43 static bool _savegame_sort_dirty;
44
48 void LoadCheckData::Clear()
49 {
50 this->checkable = false;
51 this->error = INVALID_STRING_ID;
52 this->error_msg.clear();
53
54 this->map_size_x = this->map_size_y = 256; // Default for old savegames which do not store mapsize.
55 this->current_date = 0;
56 this->settings = {};
57
58 companies.clear();
59
60 this->gamelog.Reset();
61
62 ClearGRFConfigList(&this->grfconfig);
63 }
64
66 static constexpr NWidgetPart _nested_load_dialog_widgets[] = {
67 NWidget(NWID_HORIZONTAL),
68 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
69 NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION),
70 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
71 EndContainer(),
72 /* Current directory and free space */
73 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
74
75 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
76 /* Left side : filter box and available files */
77 NWidget(NWID_VERTICAL),
78 /* Filter box with label */
79 NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1),
80 NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect.top, 0, WidgetDimensions::unscaled.framerect.bottom, 0),
81 SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, 0),
82 NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL),
83 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
84 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
85 EndContainer(),
86 EndContainer(),
87 /* Sort buttons */
88 NWidget(NWID_HORIZONTAL),
89 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
90 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),
91 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),
92 EndContainer(),
93 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
94 EndContainer(),
95 /* Files */
96 NWidget(NWID_HORIZONTAL),
97 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND),
98 NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 2, 2, 2),
99 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
100 EndContainer(),
101 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
102 EndContainer(),
103 /* Online Content button */
104 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_SL_CONTENT_DOWNLOAD_SEL),
105 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0),
106 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
107 EndContainer(),
108 EndContainer(),
109
110 /* Right side : game details */
111 NWidget(NWID_VERTICAL),
112 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1),
113 EndContainer(),
114 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),
115 NWidget(NWID_HORIZONTAL),
116 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
117 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_NEWGRF_INFO), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_NULL), SetFill(1, 0), SetResize(1, 0),
118 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
119 EndContainer(),
120 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
121 EndContainer(),
122 EndContainer(),
123 EndContainer(),
124 };
125
127 static constexpr NWidgetPart _nested_load_heightmap_dialog_widgets[] = {
128 NWidget(NWID_HORIZONTAL),
129 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
130 NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION),
131 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
132 EndContainer(),
133 /* Current directory and free space */
134 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
135
136 /* Filter box with label */
137 NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1),
138 NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect.top, 0, WidgetDimensions::unscaled.framerect.bottom, 0),
139 SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, 0),
140 NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL),
141 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
142 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
143 EndContainer(),
144 EndContainer(),
145 /* Sort Buttons */
146 NWidget(NWID_HORIZONTAL),
147 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
148 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),
149 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),
150 EndContainer(),
151 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
152 EndContainer(),
153 /* Files */
154 NWidget(NWID_HORIZONTAL),
155 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND),
156 NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 2, 2, 2),
157 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
158 EndContainer(),
159 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
160 EndContainer(),
161 /* Online Content and Load button */
162 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
163 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), SetFill(1, 0),
164 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
165 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetResize(1, 0), SetFill(1, 0),
166 SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP),
167 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
168 EndContainer(),
169 };
170
172 static constexpr NWidgetPart _nested_save_dialog_widgets[] = {
173 NWidget(NWID_HORIZONTAL),
174 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
175 NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION),
176 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
177 EndContainer(),
178 /* Current directory and free space */
179 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
180 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
181 /* Left side : filter box and available files */
182 NWidget(NWID_VERTICAL),
183 /* Filter box with label */
184 NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1),
185 NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect.top, 0, WidgetDimensions::unscaled.framerect.bottom, 0),
186 SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, 0),
187 NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL),
188 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
189 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
190 EndContainer(),
191 EndContainer(),
192 /* Sort buttons */
193 NWidget(NWID_HORIZONTAL),
194 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
195 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),
196 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),
197 EndContainer(),
198 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
199 EndContainer(),
200 /* Files */
201 NWidget(NWID_HORIZONTAL),
202 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND),
203 NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetPadding(2, 2, 2, 2),
204 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
205 EndContainer(),
206 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
207 EndContainer(),
208 NWidget(WWT_PANEL, COLOUR_GREY),
209 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_SAVE_OSK_TITLE), SetPadding(2, 2, 2, 2), SetFill(1, 0), SetResize(1, 0),
210 SetDataTip(STR_SAVELOAD_OSKTITLE, STR_SAVELOAD_EDITBOX_TOOLTIP),
211 EndContainer(),
212 /* Save/delete buttons */
213 NWidget(NWID_HORIZONTAL),
214 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_DELETE_SELECTION), SetDataTip(STR_SAVELOAD_DELETE_BUTTON, STR_SAVELOAD_DELETE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
215 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SAVE_GAME), SetDataTip(STR_SAVELOAD_SAVE_BUTTON, STR_SAVELOAD_SAVE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
216 EndContainer(),
217 EndContainer(),
218
219 /* Right side : game details */
220 NWidget(NWID_VERTICAL),
221 NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1), EndContainer(),
222 NWidget(NWID_HORIZONTAL),
223 NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
224 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
225 EndContainer(),
226 EndContainer(),
227 EndContainer(),
228 };
229
231 static const TextColour _fios_colours[] = {
232 TC_LIGHT_BROWN, // DFT_OLD_GAME_FILE
233 TC_ORANGE, // DFT_GAME_FILE
234 TC_YELLOW, // DFT_HEIGHTMAP_BMP
235 TC_ORANGE, // DFT_HEIGHTMAP_PNG
236 TC_LIGHT_BLUE, // DFT_FIOS_DRIVE
237 TC_DARK_GREEN, // DFT_FIOS_PARENT
238 TC_DARK_GREEN, // DFT_FIOS_DIR
239 TC_ORANGE, // DFT_FIOS_DIRECT
240 };
241
242
247 static void SortSaveGameList(FileList &file_list)
248 {
249 size_t sort_start = 0;
250 size_t sort_end = 0;
251
252 /* Directories are always above the files (FIOS_TYPE_DIR)
253 * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
254 * Only sort savegames/scenarios, not directories
255 */
256 for (const auto &item : file_list) {
257 switch (item.type) {
258 case FIOS_TYPE_DIR: sort_start++; break;
259 case FIOS_TYPE_PARENT: sort_start++; break;
260 case FIOS_TYPE_DRIVE: sort_end++; break;
261 default: break;
262 }
263 }
264
265 std::sort(file_list.begin() + sort_start, file_list.end() - sort_end);
266 }
267
268 struct SaveLoadWindow : public Window {
269 private:
270 static const uint EDITBOX_MAX_SIZE = 50;
271
272 QueryString filename_editbox;
273 AbstractFileType abstract_filetype;
274 SaveLoadOperation fop;
275 FileList fios_items;
276 FiosItem o_dir;
277 const FiosItem *selected;
278 const FiosItem *highlighted;
279 Scrollbar *vscroll;
280
281 StringFilter string_filter;
282 QueryString filter_editbox;
283 std::vector<FiosItem *> display_list;
284
285 static void SaveGameConfirmationCallback(Window *, bool confirmed)
286 {
287 /* File name has already been written to _file_to_saveload */
288 if (confirmed) _switch_mode = SM_SAVE_GAME;
289 }
290
291 static void SaveHeightmapConfirmationCallback(Window *, bool confirmed)
292 {
293 /* File name has already been written to _file_to_saveload */
294 if (confirmed) _switch_mode = SM_SAVE_HEIGHTMAP;
295 }
296
297 public:
298
300 void GenerateFileName()
301 {
302 this->filename_editbox.text.Assign(GenerateDefaultSaveName());
303 }
304
305 SaveLoadWindow(WindowDesc *desc, AbstractFileType abstract_filetype, SaveLoadOperation fop)
306 : Window(desc), filename_editbox(64), abstract_filetype(abstract_filetype), fop(fop), filter_editbox(EDITBOX_MAX_SIZE)
307 {
308 assert(this->fop == SLO_SAVE || this->fop == SLO_LOAD);
309
310 /* For saving, construct an initial file name. */
311 if (this->fop == SLO_SAVE) {
312 switch (this->abstract_filetype) {
313 case FT_SAVEGAME:
314 this->GenerateFileName();
315 break;
316
317 case FT_SCENARIO:
318 case FT_HEIGHTMAP:
319 this->filename_editbox.text.Assign("UNNAMED");
320 break;
321
322 default:
323 NOT_REACHED();
324 }
325 }
326 this->querystrings[WID_SL_SAVE_OSK_TITLE] = &this->filename_editbox;
327 this->filename_editbox.ok_button = WID_SL_SAVE_GAME;
328
329 this->CreateNestedTree();
330 if (this->fop == SLO_LOAD && this->abstract_filetype == FT_SAVEGAME) {
331 this->GetWidget<NWidgetStacked>(WID_SL_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL);
332 }
333
334 /* Select caption string of the window. */
335 StringID caption_string;
336 switch (this->abstract_filetype) {
337 case FT_SAVEGAME:
338 caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_CAPTION : STR_SAVELOAD_LOAD_CAPTION;
339 break;
340
341 case FT_SCENARIO:
342 caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_SCENARIO : STR_SAVELOAD_LOAD_SCENARIO;
343 break;
344
345 case FT_HEIGHTMAP:
346 caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_HEIGHTMAP : STR_SAVELOAD_LOAD_HEIGHTMAP;
347 break;
348
349 default:
350 NOT_REACHED();
351 }
352 this->GetWidget<NWidgetCore>(WID_SL_CAPTION)->widget_data = caption_string;
353
354 this->vscroll = this->GetScrollbar(WID_SL_SCROLLBAR);
355 this->FinishInitNested(0);
356
357 this->LowerWidget(WID_SL_DRIVES_DIRECTORIES_LIST);
358 this->querystrings[WID_SL_FILTER] = &this->filter_editbox;
359 this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
360
361 /* pause is only used in single-player, non-editor mode, non-menu mode. It
362 * will be unpaused in the WE_DESTROY event handler. */
363 if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
364 Command<CMD_PAUSE>::Post(PM_PAUSED_SAVELOAD, true);
365 }
366 SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
367
368 this->OnInvalidateData(SLIWD_RESCAN_FILES);
369
370 ResetObjectToPlace();
371
372 /* Select the initial directory. */
373 o_dir.type = FIOS_TYPE_DIRECT;
374 switch (this->abstract_filetype) {
375 case FT_SAVEGAME:
376 o_dir.name = FioFindDirectory(SAVE_DIR);
377 break;
378
379 case FT_SCENARIO:
380 o_dir.name = FioFindDirectory(SCENARIO_DIR);
381 break;
382
383 case FT_HEIGHTMAP:
384 o_dir.name = FioFindDirectory(HEIGHTMAP_DIR);
385 break;
386
387 default:
388 o_dir.name = _personal_dir;
389 }
390
391 switch (this->fop) {
392 case SLO_SAVE:
393 /* Focus the edit box by default in the save window */
394 this->SetFocusedWidget(WID_SL_SAVE_OSK_TITLE);
395 break;
396
397 default:
398 this->SetFocusedWidget(WID_SL_FILTER);
399 }
400 }
401
402 void Close([[maybe_unused]] int data = 0) override
403 {
404 /* pause is only used in single-player, non-editor mode, non menu mode */
405 if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
406 Command<CMD_PAUSE>::Post(PM_PAUSED_SAVELOAD, false);
407 }
408 this->Window::Close();
409 }
410
411 void DrawWidget(const Rect &r, WidgetID widget) const override
412 {
413 switch (widget) {
414 case WID_SL_SORT_BYNAME:
415 case WID_SL_SORT_BYDATE:
416 if (((_savegame_sort_order & SORT_BY_NAME) != 0) == (widget == WID_SL_SORT_BYNAME)) {
417 this->DrawSortButtonState(widget, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
418 }
419 break;
420
421 case WID_SL_BACKGROUND: {
422 static std::string path;
423 static std::optional<uint64_t> free_space = std::nullopt;
424
425 if (_fios_path_changed) {
426 path = FiosGetCurrentPath();
427 free_space = FiosGetDiskFreeSpace(path);
428 _fios_path_changed = false;
429 }
430
431 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
432
433 if (free_space.has_value()) SetDParam(0, free_space.value());
434 DrawString(ir.left, ir.right, ir.top + GetCharacterHeight(FS_NORMAL), free_space.has_value() ? STR_SAVELOAD_BYTES_FREE : STR_ERROR_UNABLE_TO_READ_DRIVE);
435 DrawString(ir.left, ir.right, ir.top, path, TC_BLACK);
436 break;
437 }
438
439 case WID_SL_DRIVES_DIRECTORIES_LIST: {
440 const Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
441 GfxFillRect(br, PC_BLACK);
442
443 Rect tr = r.Shrink(WidgetDimensions::scaled.inset).WithHeight(this->resize.step_height);
444 uint scroll_pos = this->vscroll->GetPosition();
445 for (auto it = this->display_list.begin() + scroll_pos; it != this->display_list.end() && tr.top < br.bottom; ++it) {
446 const FiosItem *item = *it;
447
448 if (item == this->selected) {
449 GfxFillRect(br.left, tr.top, br.right, tr.bottom, PC_DARK_BLUE);
450 } else if (item == this->highlighted) {
451 GfxFillRect(br.left, tr.top, br.right, tr.bottom, PC_VERY_DARK_BLUE);
452 }
453 DrawString(tr, item->title, _fios_colours[GetDetailedFileType(item->type)]);
454 tr = tr.Translate(0, this->resize.step_height);
455 }
456 break;
457 }
458
459 case WID_SL_DETAILS:
460 this->DrawDetails(r);
461 break;
462 }
463 }
464
465 void DrawDetails(const Rect &r) const
466 {
467 /* Header panel */
468 int HEADER_HEIGHT = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical();
469
470 Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
471 Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
472 tr.top += HEADER_HEIGHT;
473
474 /* Create the nice grayish rectangle at the details top */
475 GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.bevel.left, WidgetDimensions::scaled.bevel.top, WidgetDimensions::scaled.bevel.right, 0), PC_GREY);
476 DrawString(hr.left, hr.right, hr.top, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
477
478 if (this->selected == nullptr) return;
479
480 /* Details panel */
481 tr.bottom -= GetCharacterHeight(FS_NORMAL) - 1;
482 if (tr.top > tr.bottom) return;
483
484 if (!_load_check_data.checkable) {
485 /* Old savegame, no information available */
486 DrawString(tr, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);
487 tr.top += GetCharacterHeight(FS_NORMAL);
488 } else if (_load_check_data.error != INVALID_STRING_ID) {
489 /* Incompatible / broken savegame */
490 SetDParamStr(0, _load_check_data.error_msg);
491 tr.top = DrawStringMultiLine(tr, _load_check_data.error, TC_RED);
492 } else {
493 /* Mapsize */
494 SetDParam(0, _load_check_data.map_size_x);
495 SetDParam(1, _load_check_data.map_size_y);
496 DrawString(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE);
497 tr.top += GetCharacterHeight(FS_NORMAL);
498 if (tr.top > tr.bottom) return;
499
500 /* Climate */
501 byte landscape = _load_check_data.settings.game_creation.landscape;
502 if (landscape < NUM_LANDSCAPE) {
503 SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + landscape);
504 DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE);
505 tr.top += GetCharacterHeight(FS_NORMAL);
506 }
507
508 tr.top += WidgetDimensions::scaled.vsep_normal;
509 if (tr.top > tr.bottom) return;
510
511 /* Start date (if available) */
512 if (_load_check_data.settings.game_creation.starting_year != 0) {
513 SetDParam(0, TimerGameCalendar::ConvertYMDToDate(_load_check_data.settings.game_creation.starting_year, 0, 1));
514 DrawString(tr, STR_NETWORK_SERVER_LIST_START_DATE);
515 tr.top += GetCharacterHeight(FS_NORMAL);
516 }
517 if (tr.top > tr.bottom) return;
518
519 /* Hide current date for scenarios */
520 if (this->abstract_filetype != FT_SCENARIO) {
521 /* Current date */
522 SetDParam(0, _load_check_data.current_date);
523 DrawString(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE);
524 tr.top += GetCharacterHeight(FS_NORMAL);
525 }
526
527 /* Hide the NewGRF stuff when saving. We also hide the button. */
528 if (this->fop == SLO_LOAD && (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO)) {
529 tr.top += WidgetDimensions::scaled.vsep_normal;
530 if (tr.top > tr.bottom) return;
531
532 /* NewGrf compatibility */
533 SetDParam(0, _load_check_data.grfconfig == nullptr ? STR_NEWGRF_LIST_NONE :
534 STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility);
535 DrawString(tr, STR_SAVELOAD_DETAIL_GRFSTATUS);
536 tr.top += GetCharacterHeight(FS_NORMAL);
537 }
538 if (tr.top > tr.bottom) return;
539
540 /* Hide the company stuff for scenarios */
541 if (this->abstract_filetype != FT_SCENARIO) {
542 tr.top += WidgetDimensions::scaled.vsep_wide;
543 if (tr.top > tr.bottom) return;
544
545 /* Companies / AIs */
546 for (auto &pair : _load_check_data.companies) {
547 SetDParam(0, pair.first + 1);
548 const CompanyProperties &c = *pair.second;
549 if (!c.name.empty()) {
550 SetDParam(1, STR_JUST_RAW_STRING);
551 SetDParamStr(2, c.name);
552 } else {
553 SetDParam(1, c.name_1);
554 SetDParam(2, c.name_2);
555 }
556 DrawString(tr, STR_SAVELOAD_DETAIL_COMPANY_INDEX);
557 tr.top += GetCharacterHeight(FS_NORMAL);
558 if (tr.top > tr.bottom) break;
559 }
560 }
561 }
562 }
563
564 void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
565 {
566 switch (widget) {
567 case WID_SL_BACKGROUND:
568 size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height;
569 break;
570
571 case WID_SL_DRIVES_DIRECTORIES_LIST:
572 resize->height = GetCharacterHeight(FS_NORMAL);
573 size->height = resize->height * 10 + padding.height;
574 break;
575 case WID_SL_SORT_BYNAME:
576 case WID_SL_SORT_BYDATE: {
577 Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
578 d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
579 d.height += padding.height;
580 *size = maxdim(*size, d);
581 break;
582 }
583 }
584 }
585
586 void OnPaint() override
587 {
588 if (_savegame_sort_dirty) {
589 _savegame_sort_dirty = false;
590 SortSaveGameList(this->fios_items);
591 this->OnInvalidateData(SLIWD_FILTER_CHANGES);
592 }
593
594 this->DrawWidgets();
595 }
596
597 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
598 {
599 switch (widget) {
600 case WID_SL_SORT_BYNAME: // Sort save names by name
601 _savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
602 SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
603 _savegame_sort_dirty = true;
604 this->SetDirty();
605 break;
606
607 case WID_SL_SORT_BYDATE: // Sort save names by date
608 _savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
609 SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
610 _savegame_sort_dirty = true;
611 this->SetDirty();
612 break;
613
614 case WID_SL_HOME_BUTTON: // OpenTTD 'button', jumps to OpenTTD directory
615 FiosBrowseTo(&o_dir);
616 this->InvalidateData(SLIWD_RESCAN_FILES);
617 break;
618
619 case WID_SL_LOAD_BUTTON: {
620 if (this->selected == nullptr || _load_check_data.HasErrors()) break;
621
622 _file_to_saveload.Set(*this->selected);
623
624 if (this->abstract_filetype == FT_HEIGHTMAP) {
625 this->Close();
626 ShowHeightmapLoad();
627 } else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
628 _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
629 ClearErrorMessages();
630 this->Close();
631 }
632 break;
633 }
634
635 case WID_SL_NEWGRF_INFO:
636 if (_load_check_data.HasNewGrfs()) {
637 ShowNewGRFSettings(false, false, false, &_load_check_data.grfconfig);
638 }
639 break;
640
641 case WID_SL_MISSING_NEWGRFS:
642 if (!_network_available) {
643 ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
644 } else if (_load_check_data.HasNewGrfs()) {
645 ShowMissingContentWindow(_load_check_data.grfconfig);
646 }
647 break;
648
649 case WID_SL_DRIVES_DIRECTORIES_LIST: { // Click the listbox
650 auto it = this->vscroll->GetScrolledItemFromWidget(this->display_list, pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top);
651 if (it == this->display_list.end()) return;
652
653 /* Get the corresponding non-filtered out item from the list */
654 const FiosItem *file = *it;
655
656 if (FiosBrowseTo(file)) {
657 /* Changed directory, need refresh. */
658 this->InvalidateData(SLIWD_RESCAN_FILES);
659 break;
660 }
661
662 if (click_count == 1) {
663 if (this->selected != file) {
664 this->selected = file;
665 _load_check_data.Clear();
666
667 if (GetDetailedFileType(file->type) == DFT_GAME_FILE) {
668 /* Other detailed file types cannot be checked before. */
669 SaveOrLoad(file->name, SLO_CHECK, DFT_GAME_FILE, NO_DIRECTORY, false);
670 }
671
672 this->InvalidateData(SLIWD_SELECTION_CHANGES);
673 }
674 if (this->fop == SLO_SAVE) {
675 /* Copy clicked name to editbox */
676 this->filename_editbox.text.Assign(file->title);
677 this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE);
678 }
679 } else if (!_load_check_data.HasErrors()) {
680 this->selected = file;
681 if (this->fop == SLO_LOAD) {
682 if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
683 this->OnClick(pt, WID_SL_LOAD_BUTTON, 1);
684 } else {
685 assert(this->abstract_filetype == FT_HEIGHTMAP);
686 _file_to_saveload.Set(*file);
687
688 this->Close();
689 ShowHeightmapLoad();
690 }
691 }
692 }
693 break;
694 }
695
696 case WID_SL_CONTENT_DOWNLOAD:
697 if (!_network_available) {
698 ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
699 } else {
700 assert(this->fop == SLO_LOAD);
701 switch (this->abstract_filetype) {
702 default: NOT_REACHED();
703 case FT_SCENARIO: ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_SCENARIO); break;
704 case FT_HEIGHTMAP: ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_HEIGHTMAP); break;
705 }
706 }
707 break;
708
709 case WID_SL_DELETE_SELECTION: // Delete
710 break;
711
712 case WID_SL_SAVE_GAME: // Save game
713 /* Note, this is also called via the OSK; and we need to lower the button. */
714 this->HandleButtonClick(WID_SL_SAVE_GAME);
715 break;
716 }
717 }
718
719 void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override
720 {
721 if (widget == WID_SL_DRIVES_DIRECTORIES_LIST) {
722 auto it = this->vscroll->GetScrolledItemFromWidget(this->display_list, pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top);
723 if (it == this->display_list.end()) return;
724
725 /* Get the corresponding non-filtered out item from the list */
726 const FiosItem *file = *it;
727
728 if (file != this->highlighted) {
729 this->highlighted = file;
730 this->SetWidgetDirty(WID_SL_DRIVES_DIRECTORIES_LIST);
731 }
732 } else if (this->highlighted != nullptr) {
733 this->highlighted = nullptr;
734 this->SetWidgetDirty(WID_SL_DRIVES_DIRECTORIES_LIST);
735 }
736 }
737
738 EventState OnKeyPress([[maybe_unused]] char32_t key, uint16_t keycode) override
739 {
740 if (keycode == WKC_ESC) {
741 this->Close();
742 return ES_HANDLED;
743 }
744
745 return ES_NOT_HANDLED;
746 }
747
748 void OnTimeout() override
749 {
750 /* Widgets WID_SL_DELETE_SELECTION and WID_SL_SAVE_GAME only exist when saving to a file. */
751 if (this->fop != SLO_SAVE) return;
752
753 if (this->IsWidgetLowered(WID_SL_DELETE_SELECTION)) { // Delete button clicked
754 if (!FiosDelete(this->filename_editbox.text.buf)) {
755 ShowErrorMessage(STR_ERROR_UNABLE_TO_DELETE_FILE, INVALID_STRING_ID, WL_ERROR);
756 } else {
757 this->InvalidateData(SLIWD_RESCAN_FILES);
758 /* Reset file name to current date on successful delete */
759 if (this->abstract_filetype == FT_SAVEGAME) GenerateFileName();
760 }
761 } else if (this->IsWidgetLowered(WID_SL_SAVE_GAME)) { // Save button clicked
762 if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
763 _file_to_saveload.name = FiosMakeSavegameName(this->filename_editbox.text.buf);
764 if (FioCheckFileExists(_file_to_saveload.name, Subdirectory::SAVE_DIR)) {
765 ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveGameConfirmationCallback);
766 } else {
767 _switch_mode = SM_SAVE_GAME;
768 }
769 } else {
770 _file_to_saveload.name = FiosMakeHeightmapName(this->filename_editbox.text.buf);
771 if (FioCheckFileExists(_file_to_saveload.name, Subdirectory::SAVE_DIR)) {
772 ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveHeightmapConfirmationCallback);
773 } else {
774 _switch_mode = SM_SAVE_HEIGHTMAP;
775 }
776 }
777
778 /* In the editor set up the vehicle engines correctly (date might have changed) */
779 if (_game_mode == GM_EDITOR) StartupEngines();
780 }
781 }
782
783 void OnResize() override
784 {
785 this->vscroll->SetCapacityFromWidget(this, WID_SL_DRIVES_DIRECTORIES_LIST);
786 }
787
788 void BuildDisplayList()
789 {
790 /* Filter changes */
791 this->display_list.clear();
792 this->display_list.reserve(this->fios_items.size());
793
794 if (this->string_filter.IsEmpty()) {
795 /* We don't filter anything out if the filter editbox is empty */
796 for (auto &it : this->fios_items) {
797 this->display_list.push_back(&it);
798 }
799 } else {
800 for (auto &it : this->fios_items) {
801 this->string_filter.ResetState();
802 this->string_filter.AddLine(it.title);
803 /* We set the vector to show this fios element as filtered depending on the result of the filter */
804 if (this->string_filter.GetState()) {
805 this->display_list.push_back(&it);
806 } else if (&it == this->selected) {
807 /* The selected element has been filtered out */
808 this->selected = nullptr;
809 this->OnInvalidateData(SLIWD_SELECTION_CHANGES);
810 }
811 }
812 }
813
814 this->vscroll->SetCount(this->display_list.size());
815 }
816
822 void OnInvalidateData(int data = 0, bool gui_scope = true) override
823 {
824 switch (data) {
825 case SLIWD_RESCAN_FILES:
826 /* Rescan files */
827 this->selected = nullptr;
828 _load_check_data.Clear();
829 if (!gui_scope) break;
830
831 _fios_path_changed = true;
832 this->fios_items.BuildFileList(this->abstract_filetype, this->fop, true);
833 this->selected = nullptr;
834 _load_check_data.Clear();
835
836 /* We reset the files filtered */
837 this->OnInvalidateData(SLIWD_FILTER_CHANGES);
838
839 [[fallthrough]];
840
841 case SLIWD_SELECTION_CHANGES:
842 /* Selection changes */
843 if (!gui_scope) break;
844
845 if (this->fop != SLO_LOAD) break;
846
847 switch (this->abstract_filetype) {
848 case FT_HEIGHTMAP:
849 this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, this->selected == nullptr || _load_check_data.HasErrors());
850 break;
851
852 case FT_SAVEGAME:
853 case FT_SCENARIO: {
854 bool disabled = this->selected == nullptr || _load_check_data.HasErrors();
855 if (!_settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
856 disabled |= _load_check_data.HasNewGrfs() && _load_check_data.grf_compatibility == GLC_NOT_FOUND;
857 }
858 this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, disabled);
859 this->SetWidgetDisabledState(WID_SL_NEWGRF_INFO, !_load_check_data.HasNewGrfs());
860 this->SetWidgetDisabledState(WID_SL_MISSING_NEWGRFS,
861 !_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility == GLC_ALL_GOOD);
862 break;
863 }
864
865 default:
866 NOT_REACHED();
867 }
868 break;
869
870 case SLIWD_FILTER_CHANGES:
871 this->BuildDisplayList();
872 break;
873 }
874 }
875
876 void OnEditboxChanged(WidgetID wid) override
877 {
878 if (wid == WID_SL_FILTER) {
879 this->string_filter.SetFilterTerm(this->filter_editbox.text.buf);
880 this->InvalidateData(SLIWD_FILTER_CHANGES);
881 }
882 }
883 };
884
886 static WindowDesc _load_dialog_desc(__FILE__, __LINE__,
887 WDP_CENTER, "load_game", 500, 294,
888 WC_SAVELOAD, WC_NONE,
889 0,
890 std::begin(_nested_load_dialog_widgets), std::end(_nested_load_dialog_widgets)
891 );
892
894 static WindowDesc _load_heightmap_dialog_desc(__FILE__, __LINE__,
895 WDP_CENTER, "load_heightmap", 257, 320,
896 WC_SAVELOAD, WC_NONE,
897 0,
898 std::begin(_nested_load_heightmap_dialog_widgets), std::end(_nested_load_heightmap_dialog_widgets)
899 );
900
902 static WindowDesc _save_dialog_desc(__FILE__, __LINE__,
903 WDP_CENTER, "save_game", 500, 294,
904 WC_SAVELOAD, WC_NONE,
905 0,
906 std::begin(_nested_save_dialog_widgets), std::end(_nested_save_dialog_widgets)
907 );
908
914 void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
915 {
916 CloseWindowById(WC_SAVELOAD, 0);
917
918 WindowDesc *sld;
919 if (fop == SLO_SAVE) {
920 sld = &_save_dialog_desc;
921 } else {
922 /* Dialogue for loading a file. */
923 sld = (abstract_filetype == FT_HEIGHTMAP) ? &_load_heightmap_dialog_desc : &_load_dialog_desc;
924 }
925
926 new SaveLoadWindow(sld, abstract_filetype, fop);
927 }
gamelog_internal.h
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:2023
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:739
network_content.h
WC_SAVELOAD
@ WC_SAVELOAD
Saveload window; Window numbers:
Definition: window_type.h:144
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:914
PC_DARK_BLUE
static const uint8_t PC_DARK_BLUE
Dark blue palette colour.
Definition: palette_func.h:75
LoadCheckData::checkable
bool checkable
True if the savegame could be checked by SL_LOAD_CHECK. (Old savegames are not checkable....
Definition: fios.h:34
FT_SCENARIO
@ FT_SCENARIO
old or new scenario
Definition: fileio_type.h:19
LoadCheckData::error_msg
std::string error_msg
Data to pass to SetDParamStr when displaying error.
Definition: fios.h:36
SAVE_DIR
@ SAVE_DIR
Base directory for all savegames.
Definition: fileio_type.h:110
QueryString::ok_button
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
Definition: querystring_gui.h:27
SaveLoadWindow::filename_editbox
QueryString filename_editbox
Filename editbox.
Definition: fios_gui.cpp:272
WID_SL_DELETE_SELECTION
@ WID_SL_DELETE_SELECTION
Delete button, only available for save operations.
Definition: fios_widget.h:26
SLIWD_RESCAN_FILES
@ SLIWD_RESCAN_FILES
Rescan all files (when changed directory, ...)
Definition: fios.h:23
querystring_gui.h
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:1227
landscape_type.h
SM_LOAD_GAME
@ SM_LOAD_GAME
Load game, Play Scenario.
Definition: openttd.h:32
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
_personal_dir
std::string _personal_dir
custom directory for personal settings, saves, newgrf, etc.
Definition: fileio.cpp:953
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Definition: error_gui.cpp:367
SaveLoadWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: fios_gui.cpp:748
SaveLoadWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: fios_gui.cpp:282
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
ClearGRFConfigList
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
Definition: newgrf_config.cpp:356
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:60
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:356
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:28
timer_game_calendar.h
_save_dialog_desc
static WindowDesc _save_dialog_desc(__FILE__, __LINE__, WDP_CENTER, "save_game", 500, 294, WC_SAVELOAD, WC_NONE, 0, std::begin(_nested_save_dialog_widgets), std::end(_nested_save_dialog_widgets))
Save game/scenario.
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:552
SaveOrLoad
SaveOrLoadResult SaveOrLoad(const std::string &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:3050
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
Textbuf::Assign
void Assign(StringID string)
Render a string into the textbuffer.
Definition: textbuf.cpp:405
SaveLoadOperation
SaveLoadOperation
Operation performed on the file.
Definition: fileio_type.h:47
SaveLoadWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: fios_gui.cpp:783
FileToSaveLoad::name
std::string name
Name of the file.
Definition: saveload.h:394
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1141
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
PC_VERY_DARK_BLUE
static const uint8_t PC_VERY_DARK_BLUE
Almost-black blue palette colour.
Definition: palette_func.h:74
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
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
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1048
SLO_CHECK
@ SLO_CHECK
Load file for checking and/or preview.
Definition: fileio_type.h:48
misc_cmd.h
ShowMissingContentWindow
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
Definition: newgrf_gui.cpp:1570
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
DFT_GAME_FILE
@ DFT_GAME_FILE
Save game or scenario file.
Definition: fileio_type.h:31
HEIGHTMAP_DIR
@ HEIGHTMAP_DIR
Subdirectory of scenario for heightmaps.
Definition: fileio_type.h:113
LoadCheckData::grfconfig
GRFConfig * grfconfig
NewGrf configuration from save.
Definition: fios.h:45
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:253
saveload.h
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2334
CompanyProperties::name
std::string name
Name of the company if the user changed it.
Definition: company_base.h:59
fileio_func.h
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
GetDetailedFileType
DetailedFileType GetDetailedFileType(FiosType fios_type)
Extract the detailed file type from a FiosType.
Definition: fileio_type.h:100
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:468
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
WID_SL_SAVE_GAME
@ WID_SL_SAVE_GAME
Save button, only available for save operations.
Definition: fios_widget.h:27
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:114
LoadCheckData::HasErrors
bool HasErrors()
Check whether loading the game resulted in errors.
Definition: fios.h:59
Gamelog::Reset
void Reset()
Resets and frees all memory allocated - used before loading or starting a new game.
Definition: gamelog.cpp:94
SM_LOAD_SCENARIO
@ SM_LOAD_SCENARIO
Load scenario from scenario editor.
Definition: openttd.h:37
gamelog.h
fios.h
StartupEngines
void StartupEngines()
Start/initialise all our engines.
Definition: engine.cpp:761
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:678
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
FiosGetCurrentPath
std::string FiosGetCurrentPath()
Get the current path/working directory.
Definition: fios.cpp:133
FileList
List of file information.
Definition: fios.h:88
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition: geometry_type.hpp:211
SaveLoadWindow::selected
const FiosItem * selected
Selected game in fios_items, or nullptr.
Definition: fios_gui.cpp:277
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
Scrollbar::GetPosition
uint16_t GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:720
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:619
WID_SL_CONTENT_DOWNLOAD_SEL
@ WID_SL_CONTENT_DOWNLOAD_SEL
Selection 'stack' to 'hide' the content download.
Definition: fios_widget.h:28
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
_nested_load_dialog_widgets
static constexpr NWidgetPart _nested_load_dialog_widgets[]
Load game/scenario with optional content download.
Definition: fios_gui.cpp:66
WID_SL_SORT_BYDATE
@ WID_SL_SORT_BYDATE
Sort by date button.
Definition: fios_widget.h:17
AbstractFileType
AbstractFileType
The different abstract types of files that the system knows about.
Definition: fileio_type.h:16
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
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
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
WID_SL_FILTER
@ WID_SL_FILTER
Filter list of files.
Definition: fios_widget.h:18
SLO_SAVE
@ SLO_SAVE
File is being saved.
Definition: fileio_type.h:50
FiosMakeHeightmapName
std::string FiosMakeHeightmapName(const char *name)
Construct a filename for a height map.
Definition: fios.cpp:234
tilehighlight_func.h
PM_PAUSED_SAVELOAD
@ PM_PAUSED_SAVELOAD
A game paused for saving/loading.
Definition: openttd.h:65
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
Rect::Translate
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
Definition: geometry_type.hpp:174
FiosDelete
bool FiosDelete(const char *name)
Delete a file.
Definition: fios.cpp:247
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:73
Window::HandleButtonClick
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:591
SM_SAVE_HEIGHTMAP
@ SM_SAVE_HEIGHTMAP
Save heightmap.
Definition: openttd.h:35
SLIWD_FILTER_CHANGES
@ SLIWD_FILTER_CHANGES
The filename filter has changed (via the editbox)
Definition: fios.h:25
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
SaveLoadWindow::display_list
std::vector< FiosItem * > display_list
Filtered display list.
Definition: fios_gui.cpp:283
_nested_save_dialog_widgets
static constexpr NWidgetPart _nested_save_dialog_widgets[]
Save game/scenario.
Definition: fios_gui.cpp:172
SaveLoadWindow::fop
SaveLoadOperation fop
Type of file to select.
Definition: fios_gui.cpp:274
WID_SL_DETAILS
@ WID_SL_DETAILS
Panel with game details.
Definition: fios_widget.h:29
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: timer_game_calendar.cpp:55
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:740
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:110
FiosItem
Deals with finding savegames.
Definition: fios.h:79
_nested_load_heightmap_dialog_widgets
static constexpr NWidgetPart _nested_load_heightmap_dialog_widgets[]
Load heightmap with content download.
Definition: fios_gui.cpp:127
CompanyProperties::name_2
uint32_t name_2
Parameter of name_1.
Definition: company_base.h:57
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
_load_dialog_desc
static WindowDesc _load_dialog_desc(__FILE__, __LINE__, WDP_CENTER, "load_game", 500, 294, WC_SAVELOAD, WC_NONE, 0, std::begin(_nested_load_dialog_widgets), std::end(_nested_load_dialog_widgets))
Load game/scenario.
safeguards.h
GenerateDefaultSaveName
std::string GenerateDefaultSaveName()
Get the default name for a savegame or screenshot.
Definition: saveload.cpp:3167
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:460
GameCreationSettings::starting_year
TimerGameCalendar::Year starting_year
starting date
Definition: settings_type.h:341
WID_SL_SCROLLBAR
@ WID_SL_SCROLLBAR
Scrollbar of the file list.
Definition: fios_widget.h:23
SCENARIO_DIR
@ SCENARIO_DIR
Base directory for all scenarios.
Definition: fileio_type.h:112
SLIWD_SELECTION_CHANGES
@ SLIWD_SELECTION_CHANGES
File selection has changed (user click, ...)
Definition: fios.h:24
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:59
HT_NONE
@ HT_NONE
default
Definition: tilehighlight_type.h:20
SaveLoadWindow::highlighted
const FiosItem * highlighted
Item in fios_items highlighted by mouse pointer, or nullptr.
Definition: fios_gui.cpp:278
SaveLoadWindow::string_filter
StringFilter string_filter
Filter for available games.
Definition: fios_gui.cpp:281
SaveLoadWindow::GenerateFileName
void GenerateFileName()
Generate a default save filename.
Definition: fios_gui.cpp:300
sprites.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
SaveLoadWindow::fios_items
FileList fios_items
Save game list.
Definition: fios_gui.cpp:275
Scrollbar::GetScrolledItemFromWidget
Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Return an iterator pointing to the element of a scrolled widget that a user clicked in.
Definition: widget_type.h:845
_load_check_data
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Definition: fios_gui.cpp:40
stdafx.h
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
SM_SAVE_GAME
@ SM_SAVE_GAME
Save game.
Definition: openttd.h:34
Window::SetFocusedWidget
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:487
GfxFillRect
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:113
ResizeInfo::step_height
uint step_height
Step-size of height resize changes.
Definition: window_gui.h:208
WID_SL_LOAD_BUTTON
@ WID_SL_LOAD_BUTTON
Button to load game/scenario.
Definition: fios_widget.h:31
WidgetDimensions::inset
RectPadding inset
Padding inside inset container.
Definition: window_gui.h:37
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3140
_fios_colours
static const TextColour _fios_colours[]
Text colours of DetailedFileType fios entries in the window.
Definition: fios_gui.cpp:231
WID_SL_FILE_BACKGROUND
@ WID_SL_FILE_BACKGROUND
Background of file selection.
Definition: fios_widget.h:20
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:339
LoadCheckData::error
StringID error
Error message from loading. INVALID_STRING_ID if no error.
Definition: fios.h:35
ShowHeightmapLoad
void ShowHeightmapLoad()
Start with loading a heightmap.
Definition: genworld_gui.cpp:1054
WID_SL_SORT_BYNAME
@ WID_SL_SORT_BYNAME
Sort by name button.
Definition: fios_widget.h:16
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
SaveLoadWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: fios_gui.cpp:586
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
SaveLoadWindow
Definition: fios_gui.cpp:268
LoadCheckData
Container for loading in mode SL_LOAD_CHECK.
Definition: fios.h:33
WID_SL_CAPTION
@ WID_SL_CAPTION
Caption of the window.
Definition: fios_widget.h:15
LoadCheckData::companies
CompanyPropertiesMap companies
Company information.
Definition: fios.h:43
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:491
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:48
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:111
Window::querystrings
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:314
SBS_DOWN
@ SBS_DOWN
Sort ascending.
Definition: window_gui.h:214
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
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
Window::DrawSortButtonState
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
Definition: widget.cpp:763
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
WidgetDimensions::vsep_wide
int vsep_wide
Wide vertical spacing.
Definition: window_gui.h:62
FioCheckFileExists
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
Definition: fileio.cpp:126
LoadCheckData::Clear
void Clear()
Reset read data.
Definition: fios_gui.cpp:48
WID_SL_BACKGROUND
@ WID_SL_BACKGROUND
Background of window.
Definition: fios_widget.h:19
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
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
FileToSaveLoad::Set
void Set(const FiosItem &item)
Set the title of the file.
Definition: saveload.cpp:3239
NO_DIRECTORY
@ NO_DIRECTORY
A path without any base directory.
Definition: fileio_type.h:126
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
geometry_func.hpp
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:60
WID_SL_SAVE_OSK_TITLE
@ WID_SL_SAVE_OSK_TITLE
Title textbox, only available for save operations.
Definition: fios_widget.h:25
_load_heightmap_dialog_desc
static WindowDesc _load_heightmap_dialog_desc(__FILE__, __LINE__, WDP_CENTER, "load_heightmap", 257, 320, WC_SAVELOAD, WC_NONE, 0, std::begin(_nested_load_heightmap_dialog_widgets), std::end(_nested_load_heightmap_dialog_widgets))
Load heightmap.
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:98
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:760
EventState
EventState
State of handling an event.
Definition: window_type.h:738
PC_GREY
static const uint8_t PC_GREY
Grey palette colour.
Definition: palette_func.h:57
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:71
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:20
SetDParamStr
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:352
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:51
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
LoadCheckData::grf_compatibility
GRFListCompatibility grf_compatibility
Summary state of NewGrfs, whether missing files or only compatible found.
Definition: fios.h:46
PC_BLACK
static const uint8_t PC_BLACK
Black palette colour.
Definition: palette_func.h:55
WWT_INSET
@ WWT_INSET
Pressed (inset) panel, most commonly used as combo box text area.
Definition: widget_type.h:53
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:26
WID_SL_CONTENT_DOWNLOAD
@ WID_SL_CONTENT_DOWNLOAD
Content download button, only available for play scenario/heightmap.
Definition: fios_widget.h:24
WID_SL_NEWGRF_INFO
@ WID_SL_NEWGRF_INFO
Button to open NewGgrf configuration.
Definition: fios_widget.h:30
FiosBrowseTo
bool FiosBrowseTo(const FiosItem *item)
Browse to a new path based on the passed item, starting at #_fios_path.
Definition: fios.cpp:143
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition: querystring_gui.h:24
fios_widget.h
network.h
CommandHelper
Definition: command_func.h:93
SaveLoadWindow::o_dir
FiosItem o_dir
Original dir (home dir for this browser)
Definition: fios_gui.cpp:276
window_func.h
LoadCheckData::gamelog
Gamelog gamelog
Gamelog actions.
Definition: fios.h:48
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
stringfilter_type.h
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
Window::SortButtonWidth
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:780
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:658
WidgetDimensions::bevel
RectPadding bevel
Bevel thickness, affected by "scaled bevels" game option.
Definition: window_gui.h:40
gui.h
SaveLoadWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: fios_gui.cpp:822
CONTENT_TYPE_SCENARIO
@ CONTENT_TYPE_SCENARIO
The content consists of a scenario.
Definition: tcp_content_type.h:24
WidgetDimensions::frametext
RectPadding frametext
Padding inside frame with text.
Definition: window_gui.h:43
WID_SL_DRIVES_DIRECTORIES_LIST
@ WID_SL_DRIVES_DIRECTORIES_LIST
Drives list.
Definition: fios_widget.h:22
LoadCheckData::HasNewGrfs
bool HasNewGrfs()
Check whether the game uses any NewGrfs.
Definition: fios.h:68
Window
Data structure for an opened window.
Definition: window_gui.h:267
SetObjectToPlace
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:3435
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
FiosMakeSavegameName
std::string FiosMakeSavegameName(const char *name)
Make a save game or scenario filename from a name.
Definition: fios.cpp:222
GLC_ALL_GOOD
@ GLC_ALL_GOOD
All GRF needed by game are present.
Definition: newgrf_config.h:53
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
SBS_UP
@ SBS_UP
Sort descending.
Definition: window_gui.h:215
_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
GUISettings::UserIsAllowedToChangeNewGRFs
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game.
Definition: settings_type.h:229
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
SortSaveGameList
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:247
CONTENT_TYPE_HEIGHTMAP
@ CONTENT_TYPE_HEIGHTMAP
The content consists of a heightmap.
Definition: tcp_content_type.h:25
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
GLC_NOT_FOUND
@ GLC_NOT_FOUND
At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
Definition: newgrf_config.h:55
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3483
WID_SL_MISSING_NEWGRFS
@ WID_SL_MISSING_NEWGRFS
Button to find missing NewGRFs online.
Definition: fios_widget.h:32
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:142
CompanyProperties
Statically loadable part of Company pool item.
Definition: company_base.h:56
WID_SL_HOME_BUTTON
@ WID_SL_HOME_BUTTON
Home button.
Definition: fios_widget.h:21
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
StringFilter
String filter and state.
Definition: stringfilter_type.h:30
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
CompanyProperties::name_1
StringID name_1
Name of the company if the user did not change it.
Definition: company_base.h:58
engine_func.h