2006-08-04 23:41:13 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/** @file fios.h Declarations for savegames operations */
|
|
|
|
|
2006-08-04 23:41:13 +00:00
|
|
|
#ifndef FIOS_H
|
|
|
|
#define FIOS_H
|
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "strings_type.h"
|
2008-06-19 10:19:02 +00:00
|
|
|
#include "core/smallvec_type.hpp"
|
2008-01-13 01:21:35 +00:00
|
|
|
|
2007-10-29 23:02:31 +00:00
|
|
|
enum {
|
|
|
|
/**
|
|
|
|
* Slot used for the GRF scanning and such. This slot cannot be reused
|
|
|
|
* as it will otherwise cause issues when pressing "rescan directories".
|
|
|
|
* It can furthermore not be larger than LAST_GRF_SLOT as that complicates
|
|
|
|
* the testing for "too much NewGRFs".
|
|
|
|
*/
|
|
|
|
CONFIG_SLOT = 0,
|
|
|
|
/** Slot for the sound. */
|
|
|
|
SOUND_SLOT = 1,
|
|
|
|
/** First slot useable for (New)GRFs used during the game. */
|
|
|
|
FIRST_GRF_SLOT = 2,
|
|
|
|
/** Last slot useable for (New)GRFs used during the game. */
|
|
|
|
LAST_GRF_SLOT = 63,
|
|
|
|
/** Maximum number of slots. */
|
|
|
|
MAX_FILE_SLOTS = 64
|
|
|
|
};
|
|
|
|
|
2007-12-27 17:29:27 +00:00
|
|
|
enum SaveLoadDialogMode{
|
|
|
|
SLD_LOAD_GAME,
|
|
|
|
SLD_LOAD_SCENARIO,
|
|
|
|
SLD_SAVE_GAME,
|
|
|
|
SLD_SAVE_SCENARIO,
|
|
|
|
SLD_LOAD_HEIGHTMAP,
|
|
|
|
SLD_NEW_GAME,
|
|
|
|
};
|
|
|
|
|
2007-12-28 04:20:56 +00:00
|
|
|
/* The different types of files been handled by the system */
|
|
|
|
enum FileType {
|
|
|
|
FT_NONE, ///< nothing to do
|
|
|
|
FT_SAVEGAME, ///< old or new savegame
|
|
|
|
FT_SCENARIO, ///< old or new scenario
|
|
|
|
FT_HEIGHTMAP, ///< heightmap file
|
|
|
|
};
|
|
|
|
|
2008-04-23 12:03:47 +00:00
|
|
|
enum FiosType {
|
|
|
|
FIOS_TYPE_DRIVE,
|
|
|
|
FIOS_TYPE_PARENT,
|
|
|
|
FIOS_TYPE_DIR,
|
|
|
|
FIOS_TYPE_FILE,
|
|
|
|
FIOS_TYPE_OLDFILE,
|
|
|
|
FIOS_TYPE_SCENARIO,
|
|
|
|
FIOS_TYPE_OLD_SCENARIO,
|
|
|
|
FIOS_TYPE_DIRECT,
|
|
|
|
FIOS_TYPE_PNG,
|
|
|
|
FIOS_TYPE_BMP,
|
|
|
|
FIOS_TYPE_INVALID = 255,
|
2006-08-05 00:59:45 +00:00
|
|
|
};
|
|
|
|
|
2007-12-28 03:14:55 +00:00
|
|
|
/* Deals with finding savegames */
|
|
|
|
struct FiosItem {
|
2008-04-23 12:03:47 +00:00
|
|
|
FiosType type;
|
2007-12-28 03:14:55 +00:00
|
|
|
uint64 mtime;
|
|
|
|
char title[64];
|
2009-03-04 01:09:48 +00:00
|
|
|
char name[MAX_PATH];
|
2007-12-28 03:14:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Deals with the type of the savegame, independent of extension */
|
|
|
|
struct SmallFiosItem {
|
|
|
|
int mode; ///< savegame/scenario type (old, new)
|
2007-12-28 04:20:56 +00:00
|
|
|
FileType filetype; ///< what type of file are we dealing with
|
2007-12-28 03:14:55 +00:00
|
|
|
char name[MAX_PATH]; ///< name
|
|
|
|
char title[255]; ///< internal name of the game
|
|
|
|
};
|
|
|
|
|
2008-05-29 09:54:47 +00:00
|
|
|
enum {
|
|
|
|
SORT_ASCENDING = 0,
|
|
|
|
SORT_DESCENDING = 1,
|
|
|
|
SORT_BY_DATE = 0,
|
|
|
|
SORT_BY_NAME = 2
|
|
|
|
};
|
|
|
|
|
2006-08-05 00:59:45 +00:00
|
|
|
/* Variables to display file lists */
|
2008-06-02 14:19:27 +00:00
|
|
|
extern SmallVector<FiosItem, 32> _fios_items; ///< defined in fios.cpp
|
2007-12-28 03:14:55 +00:00
|
|
|
extern SmallFiosItem _file_to_saveload;
|
2007-12-27 17:29:27 +00:00
|
|
|
extern SaveLoadDialogMode _saveload_mode; ///< defined in misc_gui.cpp
|
2008-05-29 09:54:47 +00:00
|
|
|
extern byte _savegame_sort_order;
|
2007-12-27 17:29:27 +00:00
|
|
|
|
|
|
|
/* Launch save/load dialog */
|
|
|
|
void ShowSaveLoadDialog(SaveLoadDialogMode mode);
|
2006-08-05 00:59:45 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Get a list of savegames */
|
2008-06-02 14:19:27 +00:00
|
|
|
void FiosGetSavegameList(SaveLoadDialogMode mode);
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Get a list of scenarios */
|
2008-06-02 14:19:27 +00:00
|
|
|
void FiosGetScenarioList(SaveLoadDialogMode mode);
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Get a list of Heightmaps */
|
2008-06-02 14:19:27 +00:00
|
|
|
void FiosGetHeightmapList(SaveLoadDialogMode mode);
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Free the list of savegames */
|
2007-03-07 11:47:46 +00:00
|
|
|
void FiosFreeSavegameList();
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Browse to. Returns a filename w/path if we reached a file. */
|
2009-03-04 00:13:52 +00:00
|
|
|
const char *FiosBrowseTo(const FiosItem *item);
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Return path, free space and stringID */
|
2009-01-16 12:59:47 +00:00
|
|
|
StringID FiosGetDescText(const char **path, uint64 *total_free);
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Delete a name */
|
2006-08-05 00:59:45 +00:00
|
|
|
bool FiosDelete(const char *name);
|
2007-03-01 01:24:44 +00:00
|
|
|
/* Make a filename from a name */
|
2006-08-05 00:59:45 +00:00
|
|
|
void FiosMakeSavegameName(char *buf, const char *name, size_t size);
|
2008-07-28 15:31:11 +00:00
|
|
|
/* Determines type of savegame (or tells it is not a savegame) */
|
2009-01-18 22:44:53 +00:00
|
|
|
FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last);
|
2006-08-05 00:59:45 +00:00
|
|
|
|
2009-09-13 17:39:33 +00:00
|
|
|
int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
|
2006-08-05 00:59:45 +00:00
|
|
|
|
2006-08-04 23:41:13 +00:00
|
|
|
#endif /* FIOS_H */
|