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 26489 2014-04-23 21:23:21Z rubidium $ */
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 enum SaveLoadDialogMode {
102 SLD_LOAD_GAME,
103 SLD_LOAD_SCENARIO,
104 SLD_SAVE_GAME,
105 SLD_SAVE_SCENARIO,
106 SLD_LOAD_HEIGHTMAP,
107 SLD_SAVE_HEIGHTMAP,
108 };
109
111 enum FileType {
112 FT_NONE,
113 FT_SAVEGAME,
114 FT_SCENARIO,
115 FT_HEIGHTMAP,
116 };
117
118 enum FiosType {
119 FIOS_TYPE_DRIVE,
120 FIOS_TYPE_PARENT,
121 FIOS_TYPE_DIR,
122 FIOS_TYPE_FILE,
123 FIOS_TYPE_OLDFILE,
124 FIOS_TYPE_SCENARIO,
125 FIOS_TYPE_OLD_SCENARIO,
126 FIOS_TYPE_DIRECT,
127 FIOS_TYPE_PNG,
128 FIOS_TYPE_BMP,
129 FIOS_TYPE_INVALID = 255,
130 };
131
133 struct FiosItem {
134 FiosType type;
135 uint64 mtime;
136 char title[64];
137 char name[MAX_PATH];
138 };
139
141 struct SmallFiosItem {
142 int mode;
143 FileType filetype;
144 char name[MAX_PATH];
145 char title[255];
146 };
147
148 enum SortingBits {
149 SORT_ASCENDING = 0,
150 SORT_DESCENDING = 1,
151 SORT_BY_DATE = 0,
152 SORT_BY_NAME = 2
153 };
154 DECLARE_ENUM_AS_BIT_SET(SortingBits)
155
156 /* Variables to display file lists */
157 extern SmallVector<FiosItem, 32> _fios_items;
158 extern SmallFiosItem _file_to_saveload;
159 extern SaveLoadDialogMode _saveload_mode;
160 extern SortingBits _savegame_sort_order;
161
162 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
163
164 void FiosGetSavegameList(SaveLoadDialogMode mode);
165 void FiosGetScenarioList(SaveLoadDialogMode mode);
166 void FiosGetHeightmapList(SaveLoadDialogMode mode);
167
168 void FiosFreeSavegameList();
169 const char *FiosBrowseTo(const FiosItem *item);
170
171 StringID FiosGetDescText(const char **path, uint64 *total_free);
172 bool FiosDelete(const char *name);
173 void FiosMakeHeightmapName(char *buf, const char *name, const char *last);
174 void FiosMakeSavegameName(char *buf, const char *name, const char *last);
175
176 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last);
177
178 int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
179
180 extern const TextColour _fios_colours[];
181
182 void BuildFileList();
183 void SetFiosType(const byte fiostype);
184
185 #endif /* FIOS_H */