fios.h
Go to the documentation of this file.00001
00002
00005 #ifndef FIOS_H
00006 #define FIOS_H
00007
00008 #include "strings_type.h"
00009
00010 enum {
00017 CONFIG_SLOT = 0,
00019 SOUND_SLOT = 1,
00021 FIRST_GRF_SLOT = 2,
00023 LAST_GRF_SLOT = 63,
00025 MAX_FILE_SLOTS = 64
00026 };
00027
00028 enum SaveLoadDialogMode{
00029 SLD_LOAD_GAME,
00030 SLD_LOAD_SCENARIO,
00031 SLD_SAVE_GAME,
00032 SLD_SAVE_SCENARIO,
00033 SLD_LOAD_HEIGHTMAP,
00034 SLD_NEW_GAME,
00035 };
00036
00037
00038 enum FileType {
00039 FT_NONE,
00040 FT_SAVEGAME,
00041 FT_SCENARIO,
00042 FT_HEIGHTMAP,
00043 };
00044
00045 enum FiosType {
00046 FIOS_TYPE_DRIVE = 0,
00047 FIOS_TYPE_PARENT = 1,
00048 FIOS_TYPE_DIR = 2,
00049 FIOS_TYPE_FILE = 3,
00050 FIOS_TYPE_OLDFILE = 4,
00051 FIOS_TYPE_SCENARIO = 5,
00052 FIOS_TYPE_OLD_SCENARIO = 6,
00053 FIOS_TYPE_DIRECT = 7,
00054 FIOS_TYPE_PNG = 8,
00055 FIOS_TYPE_BMP = 9,
00056 FIOS_TYPE_INVALID = 255,
00057 };
00058
00059
00060 struct FiosItem {
00061 byte type;
00062 uint64 mtime;
00063 char title[64];
00064 char name[256 - 12 - 64];
00065 };
00066
00067
00068 struct SmallFiosItem {
00069 int mode;
00070 FileType filetype;
00071 char name[MAX_PATH];
00072 char title[255];
00073 };
00074
00075
00076 extern FiosItem *_fios_list;
00077 extern int _fios_num;
00078 extern SmallFiosItem _file_to_saveload;
00079 extern SaveLoadDialogMode _saveload_mode;
00080
00081
00082 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
00083
00084
00085 FiosItem *FiosGetSavegameList(int mode);
00086
00087 FiosItem *FiosGetScenarioList(int mode);
00088
00089 FiosItem *FiosGetHeightmapList(int mode);
00090
00091 void FiosFreeSavegameList();
00092
00093 char *FiosBrowseTo(const FiosItem *item);
00094
00095 StringID FiosGetDescText(const char **path, uint32 *total_free);
00096
00097 bool FiosDelete(const char *name);
00098
00099 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
00100
00101 FiosItem *FiosAlloc();
00102
00103 byte FiosGetSavegameListCallback(int mode, const char *file, const char *ext, char *title);
00104
00105 int CDECL compare_FiosItems(const void *a, const void *b);
00106
00107
00108 #if defined(WIN32)
00109 #include <windows.h>
00110 struct DIR;
00111
00112 struct dirent {
00113 TCHAR *d_name;
00114
00115
00116
00117 DIR *dir;
00118 };
00119
00120 struct DIR {
00121 HANDLE hFind;
00122
00123
00124
00125 dirent ent;
00126 WIN32_FIND_DATA fd;
00127
00128
00129
00130 bool at_first_entry;
00131 };
00132
00133 DIR *opendir(const TCHAR *path);
00134 struct dirent *readdir(DIR *d);
00135 int closedir(DIR *d);
00136 #else
00137
00138 # include <sys/types.h>
00139 # include <dirent.h>
00140 #endif
00141
00149 static inline DIR *ttd_opendir(const char *path)
00150 {
00151 return opendir(OTTD2FS(path));
00152 }
00153
00154 #endif