annotate src/fios_gui.cpp @ 17649:2b51d78fc404 draft

(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
author frosch <frosch@openttd.org>
date Wed, 04 May 2011 17:45:16 +0000
parents fcaf21b1f9fa
children c2a2cda37d1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
2
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
3 /*
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
4 * This file is part of OpenTTD.
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
8 */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
9
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
10 /** @file fios_gui.cpp GUIs for loading/saving games, scenarios, heightmaps, ... */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
11
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
12 #include "stdafx.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
13 #include "saveload/saveload.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
14 #include "gui.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
15 #include "gfx_func.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
16 #include "command_func.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
17 #include "network/network.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
18 #include "network/network_content.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
19 #include "strings_func.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
20 #include "fileio_func.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
21 #include "fios.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
22 #include "window_func.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
23 #include "tilehighlight_func.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
24 #include "querystring_gui.h"
15298
1028938fd078 (svn r19937) -Codechange: Move some fios related prototypes to fios.h
frosch <frosch@openttd.org>
parents: 15282
diff changeset
25 #include "engine_func.h"
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
26 #include "landscape_type.h"
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
27 #include "date_func.h"
16435
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
28 #include "core/geometry_func.hpp"
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
29
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
30 #include "table/sprites.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
31 #include "table/strings.h"
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
32
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
33 SaveLoadDialogMode _saveload_mode;
15334
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
34 LoadCheckData _load_check_data; ///< Data loaded from save during SL_LOAD_CHECK.
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
35
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
36 static bool _fios_path_changed;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
37 static bool _savegame_sort_dirty;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
38
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
39
15334
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
40 /**
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
41 * Reset read data.
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
42 */
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
43 void LoadCheckData::Clear()
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
44 {
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
45 this->checkable = false;
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
46 this->error = INVALID_STRING_ID;
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
47 free(this->error_data);
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
48 this->error_data = NULL;
15335
3d75c6abc840 (svn r19976) -Add: Read mapsize during SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15334
diff changeset
49
3d75c6abc840 (svn r19976) -Add: Read mapsize during SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15334
diff changeset
50 this->map_size_x = this->map_size_y = 256; // Default for old savegames which do not store mapsize.
15336
3e790f032a7c (svn r19977) -Add: Read current date during SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15335
diff changeset
51 this->current_date = 0;
15337
c37904846c25 (svn r19978) -Add: Read settings during SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15336
diff changeset
52 memset(&this->settings, 0, sizeof(this->settings));
15339
3a3570b1fd4c (svn r19980) -Add: Load some general data from savegames on SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15337
diff changeset
53
3a3570b1fd4c (svn r19980) -Add: Load some general data from savegames on SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15337
diff changeset
54 const CompanyPropertiesMap::iterator end = this->companies.End();
3a3570b1fd4c (svn r19980) -Add: Load some general data from savegames on SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15337
diff changeset
55 for (CompanyPropertiesMap::iterator it = this->companies.Begin(); it != end; it++) {
3a3570b1fd4c (svn r19980) -Add: Load some general data from savegames on SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15337
diff changeset
56 delete it->second;
3a3570b1fd4c (svn r19980) -Add: Load some general data from savegames on SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15337
diff changeset
57 }
3a3570b1fd4c (svn r19980) -Add: Load some general data from savegames on SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15337
diff changeset
58 companies.Clear();
15340
7113e55b1216 (svn r19981) -Add: Read NewGRF configuration during SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15339
diff changeset
59
7113e55b1216 (svn r19981) -Add: Read NewGRF configuration during SL_LOAD_CHECK.
frosch <frosch@openttd.org>
parents: 15339
diff changeset
60 ClearGRFConfigList(&this->grfconfig);
15334
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
61 }
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
62
09680603c66b (svn r19975) -Add: SL_LOAD_CHECK mode for partial reading of savegames.
frosch <frosch@openttd.org>
parents: 15325
diff changeset
63
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
64 enum SaveLoadWindowWidgets {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
65 SLWW_WINDOWTITLE,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
66 SLWW_SORT_BYNAME,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
67 SLWW_SORT_BYDATE,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
68 SLWW_BACKGROUND,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
69 SLWW_FILE_BACKGROUND,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
70 SLWW_HOME_BUTTON,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
71 SLWW_DRIVES_DIRECTORIES_LIST,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
72 SLWW_SCROLLBAR,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
73 SLWW_CONTENT_DOWNLOAD, ///< only available for play scenario/heightmap (content download)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
74 SLWW_SAVE_OSK_TITLE, ///< only available for save operations
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
75 SLWW_DELETE_SELECTION, ///< same in here
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
76 SLWW_SAVE_GAME, ///< not to mention in here too
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
77 SLWW_CONTENT_DOWNLOAD_SEL, ///< Selection 'stack' to 'hide' the content download
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
78 SLWW_DETAILS, ///< Panel with game details
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
79 SLWW_NEWGRF_INFO, ///< Button to open NewGgrf configuration
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
80 SLWW_LOAD_BUTTON, ///< Button to load game/scenario
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
81 };
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
82
15342
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
83 /** Load game/scenario with optional content download */
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
84 static const NWidgetPart _nested_load_dialog_widgets[] = {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
85 NWidget(NWID_HORIZONTAL),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
86 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
87 NWidget(WWT_CAPTION, COLOUR_GREY, SLWW_WINDOWTITLE),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
88 EndContainer(),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
89 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
90 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
91 NWidget(NWID_VERTICAL),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
92 NWidget(NWID_HORIZONTAL),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
93 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
94 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
95 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
96 EndContainer(),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
97 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, SLWW_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
15341
bbb2b959f4a1 (svn r19982) -Codechange: Shuffle some widget positions in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15340
diff changeset
98 EndContainer(),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
99 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_FILE_BACKGROUND),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
100 NWidget(NWID_HORIZONTAL),
15341
bbb2b959f4a1 (svn r19982) -Codechange: Shuffle some widget positions in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15340
diff changeset
101 NWidget(WWT_INSET, COLOUR_GREY, SLWW_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2),
15778
4f4c3160cca8 (svn r20452) -Codechange: Remove NWidgetCore::FindScrollbar() and associate scrollbar explicitly using a NWidgetPart via SetScrollbar().
frosch <frosch@openttd.org>
parents: 15626
diff changeset
102 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(SLWW_SCROLLBAR), EndContainer(),
15787
6c4bec3b8401 (svn r20461) -Codechange: Replace WWT_HSCROLLBAR, WWT_SCROLLBAR and WWT_SCROLL2BAR with NWID_HSCROLLBAR and NWID_VSCROLLBAR.
frosch <frosch@openttd.org>
parents: 15779
diff changeset
103 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, SLWW_SCROLLBAR),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
104 EndContainer(),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
105 NWidget(NWID_SELECTION, INVALID_COLOUR, SLWW_CONTENT_DOWNLOAD_SEL),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
106 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_CONTENT_DOWNLOAD), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
107 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
108 EndContainer(),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
109 EndContainer(),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
110 EndContainer(),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
111 NWidget(WWT_PANEL, COLOUR_GREY),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
112 NWidget(WWT_EMPTY, INVALID_COLOUR, SLWW_DETAILS), SetResize(1, 1), SetFill(1, 1),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
113 NWidget(NWID_HORIZONTAL),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
114 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
115 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_NEWGRF_INFO), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_NULL), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
116 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_LOAD_BUTTON), SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
15341
bbb2b959f4a1 (svn r19982) -Codechange: Shuffle some widget positions in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15340
diff changeset
117 EndContainer(),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
118 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
119 EndContainer(),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
120 EndContainer(),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
121 EndContainer(),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
122 };
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
123
15342
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
124 /** Load heightmap with content download */
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
125 static const NWidgetPart _nested_load_heightmap_dialog_widgets[] = {
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
126 NWidget(NWID_HORIZONTAL),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
127 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
128 NWidget(WWT_CAPTION, COLOUR_GREY, SLWW_WINDOWTITLE),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
129 EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
130 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
131 NWidget(NWID_VERTICAL),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
132 NWidget(NWID_HORIZONTAL),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
133 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
134 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
135 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
136 EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
137 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, SLWW_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
138 EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
139 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_FILE_BACKGROUND),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
140 NWidget(NWID_HORIZONTAL),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
141 NWidget(WWT_INSET, COLOUR_GREY, SLWW_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2),
15778
4f4c3160cca8 (svn r20452) -Codechange: Remove NWidgetCore::FindScrollbar() and associate scrollbar explicitly using a NWidgetPart via SetScrollbar().
frosch <frosch@openttd.org>
parents: 15626
diff changeset
142 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(SLWW_SCROLLBAR), EndContainer(),
15787
6c4bec3b8401 (svn r20461) -Codechange: Replace WWT_HSCROLLBAR, WWT_SCROLLBAR and WWT_SCROLL2BAR with NWID_HSCROLLBAR and NWID_VSCROLLBAR.
frosch <frosch@openttd.org>
parents: 15779
diff changeset
143 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, SLWW_SCROLLBAR),
15342
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
144 EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
145 NWidget(NWID_HORIZONTAL),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
146 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_CONTENT_DOWNLOAD), SetResize(1, 0),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
147 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
148 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
149 EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
150 EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
151 EndContainer(),
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
152 };
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
153
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
154 /** Save game/scenario */
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
155 static const NWidgetPart _nested_save_dialog_widgets[] = {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
156 NWidget(NWID_HORIZONTAL),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
157 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
158 NWidget(WWT_CAPTION, COLOUR_GREY, SLWW_WINDOWTITLE),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
159 EndContainer(),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
160 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
161 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
162 NWidget(NWID_VERTICAL),
15341
bbb2b959f4a1 (svn r19982) -Codechange: Shuffle some widget positions in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15340
diff changeset
163 NWidget(NWID_HORIZONTAL),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
164 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
165 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
166 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
167 EndContainer(),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
168 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, SLWW_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
169 EndContainer(),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
170 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_FILE_BACKGROUND),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
171 NWidget(NWID_HORIZONTAL),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
172 NWidget(WWT_INSET, COLOUR_GREY, SLWW_DRIVES_DIRECTORIES_LIST), SetPadding(2, 1, 0, 2),
15778
4f4c3160cca8 (svn r20452) -Codechange: Remove NWidgetCore::FindScrollbar() and associate scrollbar explicitly using a NWidgetPart via SetScrollbar().
frosch <frosch@openttd.org>
parents: 15626
diff changeset
173 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(SLWW_SCROLLBAR), EndContainer(),
15787
6c4bec3b8401 (svn r20461) -Codechange: Replace WWT_HSCROLLBAR, WWT_SCROLLBAR and WWT_SCROLL2BAR with NWID_HSCROLLBAR and NWID_VSCROLLBAR.
frosch <frosch@openttd.org>
parents: 15779
diff changeset
174 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, SLWW_SCROLLBAR),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
175 EndContainer(),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
176 NWidget(WWT_EDITBOX, COLOUR_GREY, SLWW_SAVE_OSK_TITLE), SetPadding(3, 2, 2, 2), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
177 SetDataTip(STR_SAVELOAD_OSKTITLE, STR_SAVELOAD_EDITBOX_TOOLTIP),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
178 EndContainer(),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
179 NWidget(NWID_HORIZONTAL),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
180 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_DELETE_SELECTION), SetDataTip(STR_SAVELOAD_DELETE_BUTTON, STR_SAVELOAD_DELETE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
181 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SAVE_GAME), SetDataTip(STR_SAVELOAD_SAVE_BUTTON, STR_SAVELOAD_SAVE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
182 EndContainer(),
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
183 EndContainer(),
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
184 NWidget(WWT_PANEL, COLOUR_GREY),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
185 NWidget(WWT_EMPTY, INVALID_COLOUR, SLWW_DETAILS), SetResize(1, 1), SetFill(1, 1),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
186 NWidget(NWID_HORIZONTAL),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
187 NWidget(NWID_SPACER), SetResize(1, 0), SetFill(1, 1),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
188 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
189 EndContainer(),
15341
bbb2b959f4a1 (svn r19982) -Codechange: Shuffle some widget positions in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15340
diff changeset
190 EndContainer(),
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
191 EndContainer(),
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
192 };
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
193
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
194 /* Colours for fios types */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
195 const TextColour _fios_colours[] = {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
196 TC_LIGHT_BLUE, TC_DARK_GREEN, TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
197 TC_ORANGE, TC_LIGHT_BROWN, TC_ORANGE, TC_ORANGE, TC_YELLOW
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
198 };
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
199
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
200 void BuildFileList()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
201 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
202 _fios_path_changed = true;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
203 FiosFreeSavegameList();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
204
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
205 switch (_saveload_mode) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
206 case SLD_LOAD_SCENARIO:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
207 case SLD_SAVE_SCENARIO:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
208 FiosGetScenarioList(_saveload_mode); break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
209 case SLD_LOAD_HEIGHTMAP:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
210 FiosGetHeightmapList(_saveload_mode); break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
211
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
212 default: FiosGetSavegameList(_saveload_mode); break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
213 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
214 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
215
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
216 static void MakeSortedSaveGameList()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
217 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
218 uint sort_start = 0;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
219 uint sort_end = 0;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
220
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
221 /* Directories are always above the files (FIOS_TYPE_DIR)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
222 * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
223 * Only sort savegames/scenarios, not directories
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
224 */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
225 for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
226 switch (item->type) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
227 case FIOS_TYPE_DIR: sort_start++; break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
228 case FIOS_TYPE_PARENT: sort_start++; break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
229 case FIOS_TYPE_DRIVE: sort_end++; break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
230 default: break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
231 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
232 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
233
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
234 uint s_amount = _fios_items.Length() - sort_start - sort_end;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
235 QSortT(_fios_items.Get(sort_start), s_amount, CompareFiosItems);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
236 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
237
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
238 struct SaveLoadWindow : public QueryStringBaseWindow {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
239 private:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
240 FiosItem o_dir;
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
241 const FiosItem *selected;
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
242 Scrollbar *vscroll;
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
243 public:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
244
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
245 void GenerateFileName()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
246 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
247 GenerateDefaultSaveName(this->edit_str_buf, &this->edit_str_buf[this->edit_str_size - 1]);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
248 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
249
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
250 SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(64)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
251 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
252 static const StringID saveload_captions[] = {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
253 STR_SAVELOAD_LOAD_CAPTION,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
254 STR_SAVELOAD_LOAD_SCENARIO,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
255 STR_SAVELOAD_SAVE_CAPTION,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
256 STR_SAVELOAD_SAVE_SCENARIO,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
257 STR_SAVELOAD_LOAD_HEIGHTMAP,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
258 };
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
259 assert((uint)mode < lengthof(saveload_captions));
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
260
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
261 /* Use an array to define what will be the current file type being handled
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
262 * by current file mode */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
263 switch (mode) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
264 case SLD_SAVE_GAME: this->GenerateFileName(); break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
265 case SLD_SAVE_SCENARIO: strecpy(this->edit_str_buf, "UNNAMED", &this->edit_str_buf[edit_str_size - 1]); break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
266 default: break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
267 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
268
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
269 this->afilter = CS_ALPHANUMERAL;
17581
fcaf21b1f9fa (svn r22345) -Change: Remove pixel limiter for text buffers.
terkhen <terkhen@openttd.org>
parents: 17494
diff changeset
270 InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size);
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
271
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
272 this->CreateNestedTree(desc, true);
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
273 if (mode == SLD_LOAD_GAME) this->GetWidget<NWidgetStacked>(SLWW_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
274 this->GetWidget<NWidgetCore>(SLWW_WINDOWTITLE)->widget_data = saveload_captions[mode];
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
275 this->vscroll = this->GetScrollbar(SLWW_SCROLLBAR);
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
276
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
277 this->FinishInitNested(desc, 0);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
278
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
279 this->LowerWidget(SLWW_DRIVES_DIRECTORIES_LIST);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
280
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
281 /* pause is only used in single-player, non-editor mode, non-menu mode. It
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
282 * will be unpaused in the WE_DESTROY event handler. */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
283 if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
284 DoCommandP(0, PM_PAUSED_SAVELOAD, 1, CMD_PAUSE);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
285 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
286 SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
287
15325
84cad5d4ab8d (svn r19966) -Codechange: Use InvalidateData() in saveload GUI when appropiate.
frosch <frosch@openttd.org>
parents: 15298
diff changeset
288 this->OnInvalidateData(0);
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
289
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
290 ResetObjectToPlace();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
291
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
292 o_dir.type = FIOS_TYPE_DIRECT;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
293 switch (_saveload_mode) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
294 case SLD_SAVE_GAME:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
295 case SLD_LOAD_GAME:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
296 FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
297 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
298
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
299 case SLD_SAVE_SCENARIO:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
300 case SLD_LOAD_SCENARIO:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
301 FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
302 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
303
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
304 case SLD_LOAD_HEIGHTMAP:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
305 FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
306 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
307
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
308 default:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
309 strecpy(o_dir.name, _personal_dir, lastof(o_dir.name));
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
310 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
311
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
312 /* Focus the edit box by default in the save windows */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
313 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
314 this->SetFocusedWidget(SLWW_SAVE_OSK_TITLE);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
315 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
316 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
317
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
318 virtual ~SaveLoadWindow()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
319 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
320 /* pause is only used in single-player, non-editor mode, non menu mode */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
321 if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
322 DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
323 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
324 FiosFreeSavegameList();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
325 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
326
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
327 virtual void DrawWidget(const Rect &r, int widget) const
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
328 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
329 switch (widget) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
330 case SLWW_SORT_BYNAME:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
331 case SLWW_SORT_BYDATE:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
332 if (((_savegame_sort_order & SORT_BY_NAME) != 0) == (widget == SLWW_SORT_BYNAME)) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
333 this->DrawSortButtonState(widget, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
334 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
335 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
336
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
337 case SLWW_BACKGROUND: {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
338 static const char *path = NULL;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
339 static StringID str = STR_ERROR_UNABLE_TO_READ_DRIVE;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
340 static uint64 tot = 0;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
341
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
342 if (_fios_path_changed) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
343 str = FiosGetDescText(&path, &tot);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
344 _fios_path_changed = false;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
345 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
346
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
347 if (str != STR_ERROR_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
348 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP, str);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
349 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, path, TC_BLACK);
15618
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
350 break;
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
351 }
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
352
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
353 case SLWW_DRIVES_DIRECTORIES_LIST: {
17649
2b51d78fc404 (svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents: 17581
diff changeset
354 GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, GREY_SCALE(1));
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
355
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
356 uint y = r.top + WD_FRAMERECT_TOP;
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
357 for (uint pos = this->vscroll->GetPosition(); pos < _fios_items.Length(); pos++) {
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
358 const FiosItem *item = _fios_items.Get(pos);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
359
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
360 if (item == this->selected) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
361 GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, 156);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
362 }
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
363 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, item->title, _fios_colours[item->type]);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
364 y += this->resize.step_height;
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
365 if (y >= this->vscroll->GetCapacity() * this->resize.step_height + r.top + WD_FRAMERECT_TOP) break;
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
366 }
15618
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
367 break;
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
368 }
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
369
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
370 case SLWW_DETAILS: {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
371 GfxFillRect(r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP,
17649
2b51d78fc404 (svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents: 17581
diff changeset
372 r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL * 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, GREY_SCALE(10));
15400
821c26b30fd9 (svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents: 15343
diff changeset
373 DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL / 2 + WD_FRAMERECT_TOP, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
374
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
375 if (this->selected == NULL) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
376
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
377 uint y = r.top + FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
378 uint y_max = r.bottom - FONT_HEIGHT_NORMAL - WD_FRAMERECT_BOTTOM;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
379
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
380 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
381 if (!_load_check_data.checkable) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
382 /* Old savegame, no information available */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
383 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
384 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
385 } else if (_load_check_data.error != INVALID_STRING_ID) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
386 /* Incompatible / broken savegame */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
387 SetDParamStr(0, _load_check_data.error_data);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
388 y = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT,
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
389 y, r.bottom - WD_FRAMERECT_BOTTOM, _load_check_data.error, TC_RED);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
390 } else {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
391 /* Mapsize */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
392 SetDParam(0, _load_check_data.map_size_x);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
393 SetDParam(1, _load_check_data.map_size_y);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
394 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_MAP_SIZE);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
395 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
396 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
397
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
398 /* Climate */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
399 byte landscape = _load_check_data.settings.game_creation.landscape;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
400 if (landscape < NUM_LANDSCAPE) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
401 SetDParam(0, STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE + landscape);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
402 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANDSCAPE);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
403 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
404 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
405
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
406 y += WD_PAR_VSEP_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
407 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
408
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
409 /* Start date (if available) */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
410 if (_load_check_data.settings.game_creation.starting_year != 0) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
411 SetDParam(0, ConvertYMDToDate(_load_check_data.settings.game_creation.starting_year, 0, 1));
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
412 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_START_DATE);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
413 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
414 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
415 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
416
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
417 /* Hide current date for scenarios */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
418 if (_saveload_mode != SLD_LOAD_SCENARIO && _saveload_mode != SLD_SAVE_SCENARIO) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
419 /* Current date */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
420 SetDParam(0, _load_check_data.current_date);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
421 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CURRENT_DATE);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
422 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
423 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
424
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
425 /* Hide the NewGRF stuff when saving. We also hide the button. */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
426 if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
427 y += WD_PAR_VSEP_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
428 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
429
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
430 /* NewGrf compatibility */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
431 SetDParam(0, _load_check_data.grfconfig == NULL ? STR_NEWGRF_LIST_NONE :
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
432 STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
433 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_GRFSTATUS);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
434 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
435 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
436 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
437
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
438 /* Hide the company stuff for scenarios */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
439 if (_saveload_mode != SLD_LOAD_SCENARIO && _saveload_mode != SLD_SAVE_SCENARIO) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
440 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
441 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
442
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
443 /* Companies / AIs */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
444 CompanyPropertiesMap::const_iterator end = _load_check_data.companies.End();
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
445 for (CompanyPropertiesMap::const_iterator it = _load_check_data.companies.Begin(); it != end; it++) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
446 SetDParam(0, it->first + 1);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
447 const CompanyProperties &c = *it->second;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
448 if (c.name != NULL) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
449 SetDParam(1, STR_JUST_RAW_STRING);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
450 SetDParamStr(2, c.name);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
451 } else {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
452 SetDParam(1, c.name_1);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
453 SetDParam(2, c.name_2);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
454 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
455 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_COMPANY_INDEX);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
456 y += FONT_HEIGHT_NORMAL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
457 if (y > y_max) break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
458 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
459 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
460 }
15618
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
461 break;
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
462 }
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
463 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
464 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
465
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
466 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
467 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
468 switch (widget) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
469 case SLWW_BACKGROUND:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
470 size->height = 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
471 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
472
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
473 case SLWW_DRIVES_DIRECTORIES_LIST:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
474 resize->height = FONT_HEIGHT_NORMAL;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
475 size->height = resize->height * 10 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
476 break;
16435
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
477 case SLWW_SORT_BYNAME:
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
478 case SLWW_SORT_BYDATE: {
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
479 Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
480 d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
481 d.height += padding.height;
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
482 *size = maxdim(*size, d);
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
483 break;
2a6157d1bc63 (svn r21151) -Fix [FS#4221]: Sort arrow wasn't accounted for in two windows causing it to be overwritten by the "sort by" string
rubidium <rubidium@openttd.org>
parents: 16400
diff changeset
484 }
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
485 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
486 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
487
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
488 virtual void OnPaint()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
489 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
490 if (_savegame_sort_dirty) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
491 _savegame_sort_dirty = false;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
492 MakeSortedSaveGameList();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
493 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
494
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
495 this->vscroll->SetCount(_fios_items.Length());
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
496 this->DrawWidgets();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
497
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
498 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
499 this->DrawEditBox(SLWW_SAVE_OSK_TITLE);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
500 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
501 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
502
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
503 virtual void OnClick(Point pt, int widget, int click_count)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
504 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
505 switch (widget) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
506 case SLWW_SORT_BYNAME: // Sort save names by name
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
507 _savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
508 SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
509 _savegame_sort_dirty = true;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
510 this->SetDirty();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
511 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
512
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
513 case SLWW_SORT_BYDATE: // Sort save names by date
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
514 _savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
515 SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
516 _savegame_sort_dirty = true;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
517 this->SetDirty();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
518 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
519
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
520 case SLWW_HOME_BUTTON: // OpenTTD 'button', jumps to OpenTTD directory
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
521 FiosBrowseTo(&o_dir);
15325
84cad5d4ab8d (svn r19966) -Codechange: Use InvalidateData() in saveload GUI when appropiate.
frosch <frosch@openttd.org>
parents: 15298
diff changeset
522 this->InvalidateData();
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
523 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
524
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
525 case SLWW_LOAD_BUTTON:
16400
e14d2cd5ca74 (svn r21116) -Add [FS#3012]: Reduce the chances to accidentially break savegames with NewGRFs
planetmaker <planetmaker@openttd.org>
parents: 15787
diff changeset
526 if (this->selected != NULL && !_load_check_data.HasErrors() && (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs())) {
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
527 _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
528
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
529 const char *name = FiosBrowseTo(this->selected);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
530 SetFiosType(this->selected->type);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
531
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
532 strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
533 strecpy(_file_to_saveload.title, this->selected->title, lastof(_file_to_saveload.title));
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
534
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
535 delete this;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
536 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
537 break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
538
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
539 case SLWW_NEWGRF_INFO:
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
540 if (_load_check_data.HasNewGrfs()) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
541 ShowNewGRFSettings(false, false, false, &_load_check_data.grfconfig);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
542 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
543 break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
544
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
545 case SLWW_DRIVES_DIRECTORIES_LIST: { // Click the listbox
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
546 int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, SLWW_DRIVES_DIRECTORIES_LIST, WD_FRAMERECT_TOP);
15563
011c8bee59d1 (svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
alberth <alberth@openttd.org>
parents: 15400
diff changeset
547 if (y == INT_MAX) return;
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
548
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
549 const FiosItem *file = _fios_items.Get(y);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
550
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
551 const char *name = FiosBrowseTo(file);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
552 if (name != NULL) {
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
553 if (click_count == 1) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
554 if (this->selected != file) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
555 this->selected = file;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
556 _load_check_data.Clear();
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
557
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
558 if (file->type == FIOS_TYPE_FILE || file->type == FIOS_TYPE_SCENARIO) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
559 SaveOrLoad(name, SL_LOAD_CHECK, NO_DIRECTORY, false);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
560 }
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
561
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
562 this->InvalidateData(1);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
563 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
564 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
565 /* Copy clicked name to editbox */
16675
4df98a0bd2ce (svn r21406) -Codechange: rename some textbuf related names to make them a bit more descriptive
rubidium <rubidium@openttd.org>
parents: 16435
diff changeset
566 ttd_strlcpy(this->text.buf, file->title, this->text.max_bytes);
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
567 UpdateTextBufferSize(&this->text);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
568 this->SetWidgetDirty(SLWW_SAVE_OSK_TITLE);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
569 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
570 } else if (!_load_check_data.HasErrors()) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
571 this->selected = file;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
572 if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
573 this->OnClick(pt, SLWW_LOAD_BUTTON, 1);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
574 } else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
575 SetFiosType(file->type);
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
576 strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
577 strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
578
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
579 delete this;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
580 ShowHeightmapLoad();
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
581 }
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
582 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
583 } else {
15325
84cad5d4ab8d (svn r19966) -Codechange: Use InvalidateData() in saveload GUI when appropiate.
frosch <frosch@openttd.org>
parents: 15298
diff changeset
584 /* Changed directory, need refresh. */
84cad5d4ab8d (svn r19966) -Codechange: Use InvalidateData() in saveload GUI when appropiate.
frosch <frosch@openttd.org>
parents: 15298
diff changeset
585 this->InvalidateData();
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
586 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
587 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
588 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
589
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
590 case SLWW_CONTENT_DOWNLOAD:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
591 if (!_network_available) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
592 ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
593 } else {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
594 #if defined(ENABLE_NETWORK)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
595 switch (_saveload_mode) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
596 default: NOT_REACHED();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
597 case SLD_LOAD_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
598 case SLD_LOAD_HEIGHTMAP: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_HEIGHTMAP); break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
599 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
600 #endif
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
601 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
602 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
603
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
604 case SLWW_DELETE_SELECTION: case SLWW_SAVE_GAME: // Delete, Save game
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
605 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
606 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
607 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
608
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
609 virtual void OnMouseLoop()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
610 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
611 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
612 this->HandleEditBox(SLWW_SAVE_OSK_TITLE);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
613 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
614 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
615
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
616 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
617 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
618 if (keycode == WKC_ESC) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
619 delete this;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
620 return ES_HANDLED;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
621 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
622
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
623 EventState state = ES_NOT_HANDLED;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
624 if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
625 this->HandleEditBoxKey(SLWW_SAVE_OSK_TITLE, key, keycode, state) == HEBR_CONFIRM) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
626 this->HandleButtonClick(SLWW_SAVE_GAME);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
627 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
628
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
629 return state;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
630 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
631
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
632 virtual void OnTimeout()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
633 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
634 /* This test protects against using widgets 11 and 12 which are only available
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
635 * in those two saveload mode */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
636 if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) return;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
637
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
638 if (this->IsWidgetLowered(SLWW_DELETE_SELECTION)) { // Delete button clicked
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
639 if (!FiosDelete(this->text.buf)) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
640 ShowErrorMessage(STR_ERROR_UNABLE_TO_DELETE_FILE, INVALID_STRING_ID, WL_ERROR);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
641 } else {
15325
84cad5d4ab8d (svn r19966) -Codechange: Use InvalidateData() in saveload GUI when appropiate.
frosch <frosch@openttd.org>
parents: 15298
diff changeset
642 this->InvalidateData();
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
643 /* Reset file name to current date on successful delete */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
644 if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
645 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
646
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
647 UpdateTextBufferSize(&this->text);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
648 } else if (this->IsWidgetLowered(SLWW_SAVE_GAME)) { // Save button clicked
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
649 _switch_mode = SM_SAVE;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
650 FiosMakeSavegameName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name));
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
651
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
652 /* In the editor set up the vehicle engines correctly (date might have changed) */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
653 if (_game_mode == GM_EDITOR) StartupEngines();
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
654 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
655 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
656
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
657 virtual void OnResize()
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
658 {
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
659 this->vscroll->SetCapacityFromWidget(this, SLWW_DRIVES_DIRECTORIES_LIST);
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
660 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
661
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17157
diff changeset
662 /**
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17157
diff changeset
663 * Some data on this window has become invalid.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17157
diff changeset
664 * @param data Information about the changed data.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17157
diff changeset
665 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17157
diff changeset
666 */
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17157
diff changeset
667 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
668 {
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
669 switch (data) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
670 case 0:
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
671 /* Rescan files */
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
672 this->selected = NULL;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
673 _load_check_data.Clear();
17494
24022375538e (svn r22249) -Codechange: Process some more invalidation of IDs during command scope.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
674 if (!gui_scope) break;
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
675 BuildFileList();
15626
33d3500b2a62 (svn r20289) -Codechange: Unify fall through coding style.
terkhen <terkhen@openttd.org>
parents: 15623
diff changeset
676 /* FALL THROUGH */
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
677 case 1:
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
678 /* Selection changes */
17494
24022375538e (svn r22249) -Codechange: Process some more invalidation of IDs during command scope.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
679 if (!gui_scope) break;
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
680 if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
681 this->SetWidgetDisabledState(SLWW_LOAD_BUTTON,
16400
e14d2cd5ca74 (svn r21116) -Add [FS#3012]: Reduce the chances to accidentially break savegames with NewGRFs
planetmaker <planetmaker@openttd.org>
parents: 15787
diff changeset
682 this->selected == NULL || _load_check_data.HasErrors() || !(_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()));
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
683 this->SetWidgetDisabledState(SLWW_NEWGRF_INFO,
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
684 !_load_check_data.HasNewGrfs());
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
685 }
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
686 break;
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
687 }
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
688 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
689 };
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
690
15342
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
691 /** Load game/scenario */
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
692 static const WindowDesc _load_dialog_desc(
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
693 WDP_CENTER, 500, 294,
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
694 WC_SAVELOAD, WC_NONE,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
695 WDF_UNCLICK_BUTTONS,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
696 _nested_load_dialog_widgets, lengthof(_nested_load_dialog_widgets)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
697 );
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
698
15342
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
699 /** Load heightmap */
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
700 static const WindowDesc _load_heightmap_dialog_desc(
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
701 WDP_CENTER, 257, 320,
15342
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
702 WC_SAVELOAD, WC_NONE,
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
703 WDF_UNCLICK_BUTTONS,
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
704 _nested_load_heightmap_dialog_widgets, lengthof(_nested_load_heightmap_dialog_widgets)
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
705 );
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
706
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
707 /** Save game/scenario */
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
708 static const WindowDesc _save_dialog_desc(
15343
51659ba5ab27 (svn r19984) -Feature: Show some savegame details when selecting items in saveload GUIs.
frosch <frosch@openttd.org>
parents: 15342
diff changeset
709 WDP_CENTER, 500, 294,
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
710 WC_SAVELOAD, WC_NONE,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
711 WDF_UNCLICK_BUTTONS,
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
712 _nested_save_dialog_widgets, lengthof(_nested_save_dialog_widgets)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
713 );
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
714
15620
f8e9a3f0c140 (svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents: 15618
diff changeset
715 /**
f8e9a3f0c140 (svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents: 15618
diff changeset
716 * These values are used to convert the file/operations mode into a corresponding file type.
15623
c62577640878 (svn r20286) -Codechange: Unify end of doxygen comments.
frosch <frosch@openttd.org>
parents: 15620
diff changeset
717 * So each entry, as expressed by the related comment, is based on the enum
c62577640878 (svn r20286) -Codechange: Unify end of doxygen comments.
frosch <frosch@openttd.org>
parents: 15620
diff changeset
718 */
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
719 static const FileType _file_modetotype[] = {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
720 FT_SAVEGAME, ///< used for SLD_LOAD_GAME
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
721 FT_SCENARIO, ///< used for SLD_LOAD_SCENARIO
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
722 FT_SAVEGAME, ///< used for SLD_SAVE_GAME
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
723 FT_SCENARIO, ///< used for SLD_SAVE_SCENARIO
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
724 FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
725 };
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
726
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
727 void ShowSaveLoadDialog(SaveLoadDialogMode mode)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
728 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
729 DeleteWindowById(WC_SAVELOAD, 0);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
730
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
731 const WindowDesc *sld;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
732 switch (mode) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
733 case SLD_SAVE_GAME:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
734 case SLD_SAVE_SCENARIO:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
735 sld = &_save_dialog_desc; break;
15342
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
736 case SLD_LOAD_HEIGHTMAP:
f239c675c8dd (svn r19983) -Add: Separate nested widget array for load heightmap GUI.
frosch <frosch@openttd.org>
parents: 15341
diff changeset
737 sld = &_load_heightmap_dialog_desc; break;
15282
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
738 default:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
739 sld = &_load_dialog_desc; break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
740 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
741
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
742 _saveload_mode = mode;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
743 _file_to_saveload.filetype = _file_modetotype[mode];
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
744
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
745 new SaveLoadWindow(sld, mode);
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
746 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
747
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
748 void SetFiosType(const byte fiostype)
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
749 {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
750 switch (fiostype) {
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
751 case FIOS_TYPE_FILE:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
752 case FIOS_TYPE_SCENARIO:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
753 _file_to_saveload.mode = SL_LOAD;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
754 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
755
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
756 case FIOS_TYPE_OLDFILE:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
757 case FIOS_TYPE_OLD_SCENARIO:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
758 _file_to_saveload.mode = SL_OLD_LOAD;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
759 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
760
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
761 #ifdef WITH_PNG
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
762 case FIOS_TYPE_PNG:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
763 _file_to_saveload.mode = SL_PNG;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
764 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
765 #endif /* WITH_PNG */
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
766
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
767 case FIOS_TYPE_BMP:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
768 _file_to_saveload.mode = SL_BMP;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
769 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
770
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
771 default:
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
772 _file_to_saveload.mode = SL_INVALID;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
773 break;
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
774 }
4e9378affc1f (svn r19917) -Codechange: Split save/load GUI to separate file.
frosch <frosch@openttd.org>
parents:
diff changeset
775 }