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
|
|
|
|
|
2010-06-05 19:02:29 +00:00
|
|
|
#include "gfx_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"
|
2012-08-20 21:01:40 +00:00
|
|
|
#include "network/core/tcp_content.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.
|
|
|
|
|
2011-10-30 13:47:45 +00:00
|
|
|
struct LoggedAction *gamelog_action; ///< Gamelog actions
|
|
|
|
uint gamelog_actions; ///< Number of gamelog actions
|
|
|
|
|
2013-11-23 13:12:19 +00:00
|
|
|
LoadCheckData() : error_data(NULL), grfconfig(NULL),
|
|
|
|
grf_compatibility(GLC_NOT_FOUND), gamelog_action(NULL), gamelog_actions(0)
|
2010-06-13 14:13:23 +00:00
|
|
|
{
|
|
|
|
this->Clear();
|
|
|
|
}
|
|
|
|
|
2010-09-06 15:47:11 +00:00
|
|
|
/**
|
|
|
|
* Don't leak memory at program exit
|
|
|
|
*/
|
|
|
|
~LoadCheckData()
|
|
|
|
{
|
|
|
|
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,
|
2013-01-08 22:46:42 +00:00
|
|
|
/** First slot usable for (New)GRFs used during the game. */
|
2007-10-29 23:02:31 +00:00
|
|
|
FIRST_GRF_SLOT = 2,
|
2013-01-08 22:46:42 +00:00
|
|
|
/** Last slot usable for (New)GRFs used during the game. */
|
2007-10-29 23:02:31 +00:00
|
|
|
LAST_GRF_SLOT = 63,
|
|
|
|
/** Maximum number of slots. */
|
|
|
|
MAX_FILE_SLOTS = 64
|
|
|
|
};
|
|
|
|
|
2011-05-27 21:20:07 +00:00
|
|
|
/** Mode of the file dialogue window. */
|
2010-02-10 17:37:47 +00:00
|
|
|
enum SaveLoadDialogMode {
|
2011-05-27 21:20:07 +00:00
|
|
|
SLD_LOAD_GAME, ///< Load a game.
|
|
|
|
SLD_LOAD_SCENARIO, ///< Load a scenario.
|
|
|
|
SLD_SAVE_GAME, ///< Save a game.
|
|
|
|
SLD_SAVE_SCENARIO, ///< Save a scenario.
|
|
|
|
SLD_LOAD_HEIGHTMAP, ///< Load a heightmap.
|
2011-05-28 13:55:59 +00:00
|
|
|
SLD_SAVE_HEIGHTMAP, ///< Save a heightmap.
|
2007-12-27 17:29:27 +00:00
|
|
|
};
|
|
|
|
|
2011-05-27 21:20:07 +00:00
|
|
|
/** The different types of files that the system knows about. */
|
2007-12-28 04:20:56 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2011-05-27 21:20:07 +00:00
|
|
|
/** Deals with finding savegames */
|
2007-12-28 03:14:55 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2011-05-27 21:20:07 +00:00
|
|
|
/** Deals with the type of the savegame, independent of extension */
|
2007-12-28 03:14:55 +00:00
|
|
|
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
|
|
|
|
|
|
|
void ShowSaveLoadDialog(SaveLoadDialogMode mode);
|
2006-08-05 00:59:45 +00:00
|
|
|
|
2008-06-02 14:19:27 +00:00
|
|
|
void FiosGetSavegameList(SaveLoadDialogMode mode);
|
|
|
|
void FiosGetScenarioList(SaveLoadDialogMode mode);
|
|
|
|
void FiosGetHeightmapList(SaveLoadDialogMode mode);
|
2011-05-27 21:20:07 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void FiosFreeSavegameList();
|
2009-03-04 00:13:52 +00:00
|
|
|
const char *FiosBrowseTo(const FiosItem *item);
|
2011-05-27 21:20:07 +00:00
|
|
|
|
2009-01-16 12:59:47 +00:00
|
|
|
StringID FiosGetDescText(const char **path, uint64 *total_free);
|
2006-08-05 00:59:45 +00:00
|
|
|
bool FiosDelete(const char *name);
|
2014-04-23 21:23:21 +00:00
|
|
|
void FiosMakeHeightmapName(char *buf, const char *name, const char *last);
|
|
|
|
void FiosMakeSavegameName(char *buf, const char *name, const char *last);
|
2011-05-27 21:20:07 +00:00
|
|
|
|
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
|
|
|
extern const TextColour _fios_colours[];
|
|
|
|
|
|
|
|
void BuildFileList();
|
|
|
|
void SetFiosType(const byte fiostype);
|
|
|
|
|
2006-08-04 23:41:13 +00:00
|
|
|
#endif /* FIOS_H */
|