OpenTTD Source: src/fios_gui.cpp Source File

OpenTTD Source 13.1

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