2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file fios.h Declarations for savegames operations */
14 #include "company_base.h"
15 #include "newgrf_config.h"
16 #include "network/core/tcp_content_type.h"
19 /** Special values for save-load window for the data parameter of #InvalidateWindowData. */
20 enum SaveLoadInvalidateWindowData
{
21 SLIWD_RESCAN_FILES
, ///< Rescan all files (when changed directory, ...)
22 SLIWD_SELECTION_CHANGES
, ///< File selection has changed (user click, ...)
23 SLIWD_FILTER_CHANGES
, ///< The filename filter has changed (via the editbox)
26 typedef SmallMap
<uint
, CompanyProperties
*> CompanyPropertiesMap
;
29 * Container for loading in mode SL_LOAD_CHECK.
31 struct LoadCheckData
{
32 bool checkable
; ///< True if the savegame could be checked by SL_LOAD_CHECK. (Old savegames are not checkable.)
33 StringID error
; ///< Error message from loading. INVALID_STRING_ID if no error.
34 char *error_data
; ///< Data to pass to SetDParamStr when displaying #error.
36 uint32 map_size_x
, map_size_y
;
39 GameSettings settings
;
41 CompanyPropertiesMap companies
; ///< Company information.
43 GRFConfig
*grfconfig
; ///< NewGrf configuration from save.
44 GRFListCompatibility grf_compatibility
; ///< Summary state of NewGrfs, whether missing files or only compatible found.
46 struct LoggedAction
*gamelog_action
; ///< Gamelog actions
47 uint gamelog_actions
; ///< Number of gamelog actions
49 LoadCheckData() : error_data(nullptr), grfconfig(nullptr),
50 grf_compatibility(GLC_NOT_FOUND
), gamelog_action(nullptr), gamelog_actions(0)
56 * Don't leak memory at program exit
64 * Check whether loading the game resulted in errors.
65 * @return true if errors were encountered.
69 return this->checkable
&& this->error
!= INVALID_STRING_ID
;
73 * Check whether the game uses any NewGrfs.
74 * @return true if NewGrfs are used.
78 return this->checkable
&& this->error
== INVALID_STRING_ID
&& this->grfconfig
!= nullptr;
84 extern LoadCheckData _load_check_data
;
86 /** Deals with finding savegames */
92 bool operator< (const FiosItem
&other
) const;
95 /** List of file information. */
96 class FileList
: public std::vector
<FiosItem
> {
98 void BuildFileList(AbstractFileType abstract_filetype
, SaveLoadOperation fop
);
99 const FiosItem
*FindItem(const char *file
);
108 DECLARE_ENUM_AS_BIT_SET(SortingBits
)
110 /* Variables to display file lists */
111 extern SortingBits _savegame_sort_order
;
113 void ShowSaveLoadDialog(AbstractFileType abstract_filetype
, SaveLoadOperation fop
);
115 void FiosGetSavegameList(SaveLoadOperation fop
, FileList
&file_list
);
116 void FiosGetScenarioList(SaveLoadOperation fop
, FileList
&file_list
);
117 void FiosGetHeightmapList(SaveLoadOperation fop
, FileList
&file_list
);
119 const char *FiosBrowseTo(const FiosItem
*item
);
121 StringID
FiosGetDescText(const char **path
, uint64
*total_free
);
122 bool FiosDelete(const char *name
);
123 std::string
FiosMakeHeightmapName(const char *name
);
124 std::string
FiosMakeSavegameName(const char *name
);
126 FiosType
FiosGetSavegameListCallback(SaveLoadOperation fop
, const std::string
&file
, const char *ext
, char *title
, const char *last
);
129 * A savegame name automatically numbered.
131 struct FiosNumberedSaveName
{
132 FiosNumberedSaveName(const std::string
&prefix
);
133 std::string
Filename();
134 std::string
Extension();