OpenTTD: src/fileio_type.h Source File

OpenTTD

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

- File List
- Globals

fileio_type.h
Go to the documentation of this file.
1 /* $Id: fileio_type.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 FILEIO_TYPE_H
13 #define FILEIO_TYPE_H
14
15 #include "core/enum_type.hpp"
16
18 enum AbstractFileType {
19 FT_NONE,
20 FT_SAVEGAME,
21 FT_SCENARIO,
22 FT_HEIGHTMAP,
23
24 FT_INVALID = 7,
25 FT_NUMBITS = 3,
26 FT_MASK = (1 << FT_NUMBITS) - 1,
27 };
28
30 enum DetailedFileType {
31 /* Save game and scenario files. */
32 DFT_OLD_GAME_FILE,
33 DFT_GAME_FILE,
34
35 /* Heightmap files. */
36 DFT_HEIGHTMAP_BMP,
37 DFT_HEIGHTMAP_PNG,
38
39 /* fios 'files' */
40 DFT_FIOS_DRIVE,
41 DFT_FIOS_PARENT,
42 DFT_FIOS_DIR,
43 DFT_FIOS_DIRECT,
44
45 DFT_INVALID = 255,
46 };
47
49 enum SaveLoadOperation {
50 SLO_CHECK,
51 SLO_LOAD,
52 SLO_SAVE,
53
54 SLO_INVALID,
55 };
56
62 #define MAKE_FIOS_TYPE(abstract, detailed) ((abstract) | ((detailed) << FT_NUMBITS))
63
69 enum FiosType {
70 FIOS_TYPE_DRIVE = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DRIVE),
71 FIOS_TYPE_PARENT = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_PARENT),
72 FIOS_TYPE_DIR = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DIR),
73 FIOS_TYPE_DIRECT = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DIRECT),
74
75 FIOS_TYPE_FILE = MAKE_FIOS_TYPE(FT_SAVEGAME, DFT_GAME_FILE),
76 FIOS_TYPE_OLDFILE = MAKE_FIOS_TYPE(FT_SAVEGAME, DFT_OLD_GAME_FILE),
77 FIOS_TYPE_SCENARIO = MAKE_FIOS_TYPE(FT_SCENARIO, DFT_GAME_FILE),
78 FIOS_TYPE_OLD_SCENARIO = MAKE_FIOS_TYPE(FT_SCENARIO, DFT_OLD_GAME_FILE),
79 FIOS_TYPE_PNG = MAKE_FIOS_TYPE(FT_HEIGHTMAP, DFT_HEIGHTMAP_PNG),
80 FIOS_TYPE_BMP = MAKE_FIOS_TYPE(FT_HEIGHTMAP, DFT_HEIGHTMAP_BMP),
81
82 FIOS_TYPE_INVALID = MAKE_FIOS_TYPE(FT_INVALID, DFT_INVALID),
83 };
84
85 #undef MAKE_FIOS_TYPE
86
92 inline AbstractFileType GetAbstractFileType(FiosType fios_type)
93 {
94 return static_cast<AbstractFileType>(fios_type & FT_MASK);
95 }
96
102 inline DetailedFileType GetDetailedFileType(FiosType fios_type)
103 {
104 return static_cast<DetailedFileType>(fios_type >> FT_NUMBITS);
105 }
106
110 enum Subdirectory {
111 BASE_DIR,
112 SAVE_DIR,
113 AUTOSAVE_DIR,
114 SCENARIO_DIR,
115 HEIGHTMAP_DIR,
116 OLD_GM_DIR,
117 OLD_DATA_DIR,
118 BASESET_DIR,
119 NEWGRF_DIR,
120 LANG_DIR,
121 AI_DIR,
122 AI_LIBRARY_DIR,
123 GAME_DIR,
124 GAME_LIBRARY_DIR,
125 SCREENSHOT_DIR,
126 NUM_SUBDIRS,
127 NO_DIRECTORY,
128 };
129
133 enum Searchpath {
134 SP_FIRST_DIR,
135 SP_WORKING_DIR = SP_FIRST_DIR,
136 #if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
137 SP_PERSONAL_DIR_XDG,
138 #endif
139 SP_PERSONAL_DIR,
140 SP_SHARED_DIR,
141 SP_BINARY_DIR,
142 SP_INSTALLATION_DIR,
143 SP_APPLICATION_BUNDLE_DIR,
144 SP_AUTODOWNLOAD_DIR,
145 NUM_SEARCHPATHS
146 };
147
148 DECLARE_POSTFIX_INCREMENT(Searchpath)
149
150 #endif /* FILEIO_TYPE_H */