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"
|
2010-06-13 14:15:36 +00:00
|
|
|
#include "core/smallmap_type.hpp"
|
2010-06-05 18:44:31 +00:00
|
|
|
#include "core/enum_type.hpp"
|
2010-06-05 19:02:29 +00:00
|
|
|
#include "gfx_type.h"
|
2010-06-13 14:14:20 +00:00
|
|
|
#include "date_type.h"
|
2010-06-13 14:14:37 +00:00
|
|
|
#include "settings_type.h"
|
2010-06-13 14:15:36 +00:00
|
|
|
#include "company_base.h"
|
2010-06-13 14:15:58 +00:00
|
|
|
#include "newgrf_config.h"
|
2008-01-13 01:21:35 +00:00
|
|
|
|
2010-06-13 14:13:23 +00:00
|
|
|
|
2010-06-13 14:15:36 +00:00
|
|
|
typedef SmallMap<uint, CompanyProperties *> CompanyPropertiesMap;
|
|
|
|
|
2010-06-13 14:13:23 +00:00
|
|
|
/**
|
|
|
|
* Container for loading in mode SL_LOAD_CHECK.
|
|
|
|
*/
|
|
|
|
struct LoadCheckData {
|
|
|
|
bool checkable; ///< True if the savegame could be checked by SL_LOAD_CHECK. (Old savegames are not checkable.)
|
|
|
|
StringID error; ///< Error message from loading. INVALID_STRING_ID if no error.
|
|
|
|
char *error_data; ///< Data to pass to SetDParamStr when displaying #error.
|
|
|
|
|
2010-06-13 14:13:49 +00:00
|
|
|
uint32 map_size_x, map_size_y;
|
2010-06-13 14:14:20 +00:00
|
|
|
Date current_date;
|
2010-06-13 14:13:49 +00:00
|
|
|
|
2010-06-13 14:14:37 +00:00
|
|
|
GameSettings settings;
|
|
|
|
|
2010-06-13 14:15:36 +00:00
|
|
|
CompanyPropertiesMap companies; ///< Company information.
|
|
|
|
|
2010-06-13 14:15:58 +00:00
|
|
|
GRFConfig *grfconfig; ///< NewGrf configuration from save.
|
|
|
|
GRFListCompatibility grf_compatibility; ///< Summary state of NewGrfs, whether missing files or only compatible found.
|
|
|
|
|
|
|
|
LoadCheckData() : error_data(NULL), grfconfig(NULL)
|
2010-06-13 14:13:23 +00:00
|
|
|
{
|
|
|
|
this->Clear();
|
|
|
|
}
|
|
|
|
|
2010-06-13 14:17:26 +00:00
|
|
|
/**
|
|
|
|
* Check whether loading the game resulted in errors.
|
|
|
|
* @return true if errors were encountered.
|
|
|
|
*/
|
|
|
|
bool HasErrors()
|
|
|
|
{
|
|
|
|
return this->checkable && this->error != INVALID_STRING_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether the game uses any NewGrfs.
|
|
|
|
* @return true if NewGrfs are used.
|
|
|
|
*/
|
|
|
|
bool HasNewGrfs()
|
|
|
|
{
|
|
|
|
return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-13 14:13:23 +00:00
|
|
|
void Clear();
|
|
|
|
};
|
|
|
|
|
|
|
|
extern LoadCheckData _load_check_data;
|
|
|
|
|
|
|
|
|
2010-05-13 09:44:44 +00:00
|
|
|
enum FileSlots {
|
2007-10-29 23:02:31 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
};
|
|
|
|
|
2010-02-10 17:37:47 +00:00
|
|
|
enum SaveLoadDialogMode {
|
2007-12-27 17:29:27 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2010-05-13 09:44:44 +00:00
|
|
|
enum SortingBits {
|
2008-05-29 09:54:47 +00:00
|
|
|
SORT_ASCENDING = 0,
|
|
|
|
SORT_DESCENDING = 1,
|
|
|
|
SORT_BY_DATE = 0,
|
|
|
|
SORT_BY_NAME = 2
|
|
|
|
};
|
2010-06-05 18:44:31 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(SortingBits)
|
2008-05-29 09:54:47 +00:00
|
|
|
|
2006-08-05 00:59:45 +00:00
|
|
|
/* Variables to display file lists */
|
2010-06-05 18:44:31 +00:00
|
|
|
extern SmallVector<FiosItem, 32> _fios_items;
|
2007-12-28 03:14:55 +00:00
|
|
|
extern SmallFiosItem _file_to_saveload;
|
2010-06-05 18:44:31 +00:00
|
|
|
extern SaveLoadDialogMode _saveload_mode;
|
|
|
|
extern SortingBits _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
|
|
|
|
2010-06-05 19:02:29 +00:00
|
|
|
/* FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
|
|
|
|
extern const TextColour _fios_colours[];
|
|
|
|
|
|
|
|
void BuildFileList();
|
|
|
|
void SetFiosType(const byte fiostype);
|
|
|
|
|
2006-08-04 23:41:13 +00:00
|
|
|
#endif /* FIOS_H */
|