OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

fios.h
Go to the documentation of this file.
1 /* $Id: fios.h 27653 2016-09-04 16:06:50Z alberth $ */
2
3 /*
4 * This file is part of OpenTTD.
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.
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.
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/>.
8 */
9
12 #ifndef FIOS_H
13 #define FIOS_H
14
15 #include "gfx_type.h"
16 #include "company_base.h"
17 #include "newgrf_config.h"
18 #include "network/core/tcp_content.h"
19
20
21 typedef SmallMap<uint, CompanyProperties *> CompanyPropertiesMap;
22
26 struct LoadCheckData {
27 bool checkable;
28 StringID error;
29 char *error_data;
30
31 uint32 map_size_x, map_size_y;
32 Date current_date;
33
34 GameSettings settings;
35
36 CompanyPropertiesMap companies;
37
38 GRFConfig *grfconfig;
39 GRFListCompatibility grf_compatibility;
40
41 struct LoggedAction *gamelog_action;
42 uint gamelog_actions;
43
44 LoadCheckData() : error_data(NULL), grfconfig(NULL),
45 grf_compatibility(GLC_NOT_FOUND), gamelog_action(NULL), gamelog_actions(0)
46 {
47 this->Clear();
48 }
49
53 ~LoadCheckData()
54 {
55 this->Clear();
56 }
57
62 bool HasErrors()
63 {
64 return this->checkable && this->error != INVALID_STRING_ID;
65 }
66
71 bool HasNewGrfs()
72 {
73 return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != NULL;
74 }
75
76 void Clear();
77 };
78
79 extern LoadCheckData _load_check_data;
80
81
82 enum FileSlots {
89 CONFIG_SLOT = 0,
91 SOUND_SLOT = 1,
93 FIRST_GRF_SLOT = 2,
95 LAST_GRF_SLOT = 63,
97 MAX_FILE_SLOTS = 64
98 };
99
101 struct FiosItem {
102 FiosType type;
103 uint64 mtime;
104 char title[64];
105 char name[MAX_PATH];
106 };
107
109 class FileList {
110 public:
111 ~FileList();
112
117 inline FiosItem *Append()
118 {
119 return this->files.Append();
120 }
121
126 inline uint Length() const
127 {
128 return this->files.Length();
129 }
130
135 inline const FiosItem *Begin() const
136 {
137 return this->files.Begin();
138 }
139
144 inline const FiosItem *End() const
145 {
146 return this->files.End();
147 }
148
153 inline const FiosItem *Get(uint index) const
154 {
155 return this->files.Get(index);
156 }
157
162 inline FiosItem *Get(uint index)
163 {
164 return this->files.Get(index);
165 }
166
167 inline const FiosItem &operator[](uint index) const
168 {
169 return this->files[index];
170 }
171
176 inline FiosItem &operator[](uint index)
177 {
178 return this->files[index];
179 }
180
182 inline void Clear()
183 {
184 this->files.Clear();
185 }
186
188 inline void Compact()
189 {
190 this->files.Compact();
191 }
192
193 void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop);
194 const FiosItem *FindItem(const char *file);
195
196 SmallVector<FiosItem, 32> files;
197 };
198
199 enum SortingBits {
200 SORT_ASCENDING = 0,
201 SORT_DESCENDING = 1,
202 SORT_BY_DATE = 0,
203 SORT_BY_NAME = 2
204 };
205 DECLARE_ENUM_AS_BIT_SET(SortingBits)
206
207 /* Variables to display file lists */
208 extern SortingBits _savegame_sort_order;
209
210 void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop);
211
212 void FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list);
213 void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list);
214 void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list);
215
216 const char *FiosBrowseTo(const FiosItem *item);
217
218 StringID FiosGetDescText(const char **path, uint64 *total_free);
219 bool FiosDelete(const char *name);
220 void FiosMakeHeightmapName(char *buf, const char *name, const char *last);
221 void FiosMakeSavegameName(char *buf, const char *name, const char *last);
222
223 FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const char *file, const char *ext, char *title, const char *last);
224
225 int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
226
227 #endif /* FIOS_H */