OpenTTD Source  12.0-beta2
fios.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef FIOS_H
11 #define FIOS_H
12 
13 #include "gfx_type.h"
14 #include "company_base.h"
15 #include "newgrf_config.h"
17 
18 
24 };
25 
27 
31 struct LoadCheckData {
32  bool checkable;
34  char *error_data;
35 
36  uint32 map_size_x, map_size_y;
37  Date current_date;
38 
39  GameSettings settings;
40 
42 
45 
48 
49  LoadCheckData() : error_data(nullptr), grfconfig(nullptr),
51  {
52  this->Clear();
53  }
54 
59  {
60  this->Clear();
61  }
62 
67  bool HasErrors()
68  {
69  return this->checkable && this->error != INVALID_STRING_ID;
70  }
71 
76  bool HasNewGrfs()
77  {
78  return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != nullptr;
79  }
80 
81  void Clear();
82 };
83 
85 
87 struct FiosItem {
88  FiosType type;
89  uint64 mtime;
90  char title[64];
91  char name[MAX_PATH];
92  bool operator< (const FiosItem &other) const;
93 };
94 
96 class FileList : public std::vector<FiosItem> {
97 public:
98  void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop);
99  const FiosItem *FindItem(const char *file);
100 };
101 
102 enum SortingBits {
103  SORT_ASCENDING = 0,
104  SORT_DESCENDING = 1,
105  SORT_BY_DATE = 0,
106  SORT_BY_NAME = 2
107 };
108 DECLARE_ENUM_AS_BIT_SET(SortingBits)
109 
110 /* Variables to display file lists */
111 extern SortingBits _savegame_sort_order;
112 
113 void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop);
114 
115 void FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list);
116 void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list);
117 void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list);
118 
119 const char *FiosBrowseTo(const FiosItem *item);
120 
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);
125 
126 FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const std::string &file, const char *ext, char *title, const char *last);
127 
132  FiosNumberedSaveName(const std::string &prefix);
133  std::string Filename();
134  std::string Extension();
135 private:
136  std::string prefix;
137  int number;
138 };
139 
140 #endif /* FIOS_H */
LoadCheckData::checkable
bool checkable
True if the savegame could be checked by SL_LOAD_CHECK. (Old savegames are not checkable....
Definition: fios.h:32
SLIWD_RESCAN_FILES
@ SLIWD_RESCAN_FILES
Rescan all files (when changed directory, ...)
Definition: fios.h:21
LoadCheckData::gamelog_action
struct LoggedAction * gamelog_action
Gamelog actions.
Definition: fios.h:46
company_base.h
FiosNumberedSaveName::FiosNumberedSaveName
FiosNumberedSaveName(const std::string &prefix)
Constructs FiosNumberedSaveName.
Definition: fios.cpp:754
SaveLoadOperation
SaveLoadOperation
Operation performed on the file.
Definition: fileio_type.h:47
_load_check_data
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Definition: fios_gui.cpp:38
LoadCheckData::grfconfig
GRFConfig * grfconfig
NewGrf configuration from save.
Definition: fios.h:43
FiosGetScenarioList
void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list)
Get a list of scenarios.
Definition: fios.cpp:547
LoadCheckData::HasErrors
bool HasErrors()
Check whether loading the game resulted in errors.
Definition: fios.h:67
FiosGetHeightmapList
void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list)
Get a list of heightmaps.
Definition: fios.cpp:608
newgrf_config.h
FiosGetDescText
StringID FiosGetDescText(const char **path, uint64 *total_free)
Get descriptive texts.
Definition: fios.cpp:139
FileList
List of file information.
Definition: fios.h:96
SmallMap< uint, CompanyProperties * >
LoadCheckData::~LoadCheckData
~LoadCheckData()
Don't leak memory at program exit.
Definition: fios.h:58
AbstractFileType
AbstractFileType
The different abstract types of files that the system knows about.
Definition: fileio_type.h:16
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:155
SLIWD_FILTER_CHANGES
@ SLIWD_FILTER_CHANGES
The filename filter has changed (via the editbox)
Definition: fios.h:23
tcp_content_type.h
LoadCheckData::error_data
char * error_data
Data to pass to SetDParamStr when displaying error.
Definition: fios.h:34
LoadCheckData::gamelog_actions
uint gamelog_actions
Number of gamelog actions.
Definition: fios.h:47
FileList::BuildFileList
void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Construct a file list with the given kind of files, for the stated purpose.
Definition: fios.cpp:72
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
FiosMakeHeightmapName
std::string FiosMakeHeightmapName(const char *name)
Construct a filename for a height map.
Definition: fios.cpp:243
FiosItem
Deals with finding savegames.
Definition: fios.h:87
FiosMakeSavegameName
std::string FiosMakeSavegameName(const char *name)
Make a save game or scenario filename from a name.
Definition: fios.cpp:231
FileList::FindItem
const FiosItem * FindItem(const char *file)
Find file information of a file by its name from the file list.
Definition: fios.cpp:104
GameSettings
All settings together for the game.
Definition: settings_type.h:574
SLIWD_SELECTION_CHANGES
@ SLIWD_SELECTION_CHANGES
File selection has changed (user click, ...)
Definition: fios.h:22
FiosDelete
bool FiosDelete(const char *name)
Delete a file.
Definition: fios.cpp:256
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:921
FiosGetSavegameList
void FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list)
Get a list of savegames.
Definition: fios.cpp:498
LoadCheckData::error
StringID error
Error message from loading. INVALID_STRING_ID if no error.
Definition: fios.h:33
LoadCheckData
Container for loading in mode SL_LOAD_CHECK.
Definition: fios.h:31
LoadCheckData::companies
CompanyPropertiesMap companies
Company information.
Definition: fios.h:41
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
FiosNumberedSaveName
A savegame name automatically numbered.
Definition: fios.h:131
LoadCheckData::Clear
void Clear()
Reset read data.
Definition: fios_gui.cpp:47
LoadCheckData::grf_compatibility
GRFListCompatibility grf_compatibility
Summary state of NewGrfs, whether missing files or only compatible found.
Definition: fios.h:44
FiosType
FiosType
Elements of a file system that are recognized.
Definition: fileio_type.h:67
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
FiosBrowseTo
const char * FiosBrowseTo(const FiosItem *item)
Browse to a new path based on the passed item, starting at #_fios_path.
Definition: fios.cpp:150
LoadCheckData::HasNewGrfs
bool HasNewGrfs()
Check whether the game uses any NewGrfs.
Definition: fios.h:76
FiosNumberedSaveName::Extension
std::string Extension()
Generate an extension for a savegame name.
Definition: fios.cpp:801
gfx_type.h
SaveLoadInvalidateWindowData
SaveLoadInvalidateWindowData
Special values for save-load window for the data parameter of InvalidateWindowData.
Definition: fios.h:20
FiosNumberedSaveName::Filename
std::string Filename()
Generate a savegame name and number according to _settings_client.gui.max_num_autosaves.
Definition: fios.cpp:791
GLC_NOT_FOUND
@ GLC_NOT_FOUND
At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
Definition: newgrf_config.h:55
GRFListCompatibility
GRFListCompatibility
Status of post-gameload GRF compatibility check.
Definition: newgrf_config.h:52
LoggedAction
Contains information about one logged action that caused at least one logged change.
Definition: gamelog_internal.h:80
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
FiosItem::operator<
bool operator<(const FiosItem &other) const
Compare two FiosItem's.
Definition: fios.cpp:54
FiosGetSavegameListCallback
FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const std::string &file, const char *ext, char *title, const char *last)
Callback for FiosGetFileList.
Definition: fios.cpp:465