Darkvater@4218: /* $Id$ */ Darkvater@4218: belugas@6179: /** @file fios.h Declarations for savegames operations */ belugas@6179: Darkvater@4218: #ifndef FIOS_H Darkvater@4218: #define FIOS_H Darkvater@4218: rubidium@8264: #include "strings_type.h" skidd13@9555: #include "core/smallvec_type.hpp" rubidium@8264: rubidium@7805: enum { rubidium@7805: /** rubidium@7805: * Slot used for the GRF scanning and such. This slot cannot be reused rubidium@7805: * as it will otherwise cause issues when pressing "rescan directories". rubidium@7805: * It can furthermore not be larger than LAST_GRF_SLOT as that complicates rubidium@7805: * the testing for "too much NewGRFs". rubidium@7805: */ rubidium@7805: CONFIG_SLOT = 0, rubidium@7805: /** Slot for the sound. */ rubidium@7805: SOUND_SLOT = 1, rubidium@7805: /** First slot useable for (New)GRFs used during the game. */ rubidium@7805: FIRST_GRF_SLOT = 2, rubidium@7805: /** Last slot useable for (New)GRFs used during the game. */ rubidium@7805: LAST_GRF_SLOT = 63, rubidium@7805: /** Maximum number of slots. */ rubidium@7805: MAX_FILE_SLOTS = 64 rubidium@7805: }; rubidium@7805: belugas@8149: enum SaveLoadDialogMode{ belugas@8149: SLD_LOAD_GAME, belugas@8149: SLD_LOAD_SCENARIO, belugas@8149: SLD_SAVE_GAME, belugas@8149: SLD_SAVE_SCENARIO, belugas@8149: SLD_LOAD_HEIGHTMAP, belugas@8149: SLD_NEW_GAME, belugas@8149: }; belugas@8149: belugas@8152: /* The different types of files been handled by the system */ belugas@8152: enum FileType { belugas@8152: FT_NONE, ///< nothing to do belugas@8152: FT_SAVEGAME, ///< old or new savegame belugas@8152: FT_SCENARIO, ///< old or new scenario belugas@8152: FT_HEIGHTMAP, ///< heightmap file belugas@8152: }; belugas@8152: peter1138@9031: enum FiosType { peter1138@9031: FIOS_TYPE_DRIVE, peter1138@9031: FIOS_TYPE_PARENT, peter1138@9031: FIOS_TYPE_DIR, peter1138@9031: FIOS_TYPE_FILE, peter1138@9031: FIOS_TYPE_OLDFILE, peter1138@9031: FIOS_TYPE_SCENARIO, peter1138@9031: FIOS_TYPE_OLD_SCENARIO, peter1138@9031: FIOS_TYPE_DIRECT, peter1138@9031: FIOS_TYPE_PNG, peter1138@9031: FIOS_TYPE_BMP, peter1138@9031: FIOS_TYPE_INVALID = 255, Darkvater@4223: }; Darkvater@4223: belugas@8151: /* Deals with finding savegames */ belugas@8151: struct FiosItem { peter1138@9031: FiosType type; belugas@8151: uint64 mtime; belugas@8151: char title[64]; belugas@8151: char name[256 - 12 - 64]; belugas@8151: }; belugas@8151: belugas@8151: /* Deals with the type of the savegame, independent of extension */ belugas@8151: struct SmallFiosItem { belugas@8151: int mode; ///< savegame/scenario type (old, new) belugas@8152: FileType filetype; ///< what type of file are we dealing with belugas@8151: char name[MAX_PATH]; ///< name belugas@8151: char title[255]; ///< internal name of the game belugas@8151: }; belugas@8151: rubidium@9409: enum { rubidium@9409: SORT_ASCENDING = 0, rubidium@9409: SORT_DESCENDING = 1, rubidium@9409: SORT_BY_DATE = 0, rubidium@9409: SORT_BY_NAME = 2 rubidium@9409: }; rubidium@9409: Darkvater@4223: /* Variables to display file lists */ skidd13@9441: extern SmallVector _fios_items; ///< defined in fios.cpp belugas@8151: extern SmallFiosItem _file_to_saveload; belugas@8149: extern SaveLoadDialogMode _saveload_mode; ///< defined in misc_gui.cpp rubidium@9409: extern byte _savegame_sort_order; belugas@8149: belugas@8149: /* Launch save/load dialog */ belugas@8149: void ShowSaveLoadDialog(SaveLoadDialogMode mode); Darkvater@4223: belugas@6179: /* Get a list of savegames */ skidd13@9441: void FiosGetSavegameList(SaveLoadDialogMode mode); belugas@6179: /* Get a list of scenarios */ skidd13@9441: void FiosGetScenarioList(SaveLoadDialogMode mode); belugas@6179: /* Get a list of Heightmaps */ skidd13@9441: void FiosGetHeightmapList(SaveLoadDialogMode mode); belugas@6179: /* Free the list of savegames */ rubidium@6247: void FiosFreeSavegameList(); belugas@6179: /* Browse to. Returns a filename w/path if we reached a file. */ Darkvater@4223: char *FiosBrowseTo(const FiosItem *item); belugas@6179: /* Return path, free space and stringID */ Darkvater@4223: StringID FiosGetDescText(const char **path, uint32 *total_free); belugas@6179: /* Delete a name */ Darkvater@4223: bool FiosDelete(const char *name); belugas@6179: /* Make a filename from a name */ Darkvater@4223: void FiosMakeSavegameName(char *buf, const char *name, size_t size); smatz@9730: /* Determines type of savegame (or tells it is not a savegame) */ smatz@9730: FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title); Darkvater@4223: Darkvater@4223: int CDECL compare_FiosItems(const void *a, const void *b); Darkvater@4223: Darkvater@4218: #endif /* FIOS_H */