OpenTTD
Data Structures | Typedefs | Enumerations | Functions | Variables
fios.h File Reference

Declarations for savegames operations. More...

#include "gfx_type.h"
#include "company_base.h"
#include "newgrf_config.h"
#include "network/core/tcp_content.h"

Go to the source code of this file.

Data Structures

struct  LoadCheckData
 Container for loading in mode SL_LOAD_CHECK. More...
 
struct  FiosItem
 Deals with finding savegames. More...
 
class  FileList
 List of file information. More...
 

Typedefs

typedef SmallMap< uint, CompanyProperties * > CompanyPropertiesMap
 

Enumerations

enum  FileSlots { CONFIG_SLOT = 0, SOUND_SLOT = 1, FIRST_GRF_SLOT = 2, MAX_FILE_SLOTS = 128 }
 
enum  SortingBits { SORT_ASCENDING = 0, SORT_DESCENDING = 1, SORT_BY_DATE = 0, SORT_BY_NAME = 2 }
 

Functions

void ShowSaveLoadDialog (AbstractFileType abstract_filetype, SaveLoadOperation fop)
 Launch save/load dialog in the given mode. More...
 
void FiosGetSavegameList (SaveLoadOperation fop, FileList &file_list)
 Get a list of savegames. More...
 
void FiosGetScenarioList (SaveLoadOperation fop, FileList &file_list)
 Get a list of scenarios. More...
 
void FiosGetHeightmapList (SaveLoadOperation fop, FileList &file_list)
 Get a list of heightmaps. More...
 
const char * FiosBrowseTo (const FiosItem *item)
 Browse to a new path based on the passed item, starting at #_fios_path. More...
 
StringID FiosGetDescText (const char **path, uint64 *total_free)
 Get descriptive texts. More...
 
bool FiosDelete (const char *name)
 Delete a file. More...
 
void FiosMakeHeightmapName (char *buf, const char *name, const char *last)
 Construct a filename for a height map. More...
 
void FiosMakeSavegameName (char *buf, const char *name, const char *last)
 Make a save game or scenario filename from a name. More...
 
FiosType FiosGetSavegameListCallback (SaveLoadOperation fop, const char *file, const char *ext, char *title, const char *last)
 Callback for FiosGetFileList. More...
 
int CDECL CompareFiosItems (const FiosItem *a, const FiosItem *b)
 Compare two FiosItem's. More...
 

Variables

LoadCheckData _load_check_data
 Data loaded from save during SL_LOAD_CHECK.
 
SortingBits _savegame_sort_order
 

Detailed Description

Declarations for savegames operations.

Definition in file fios.h.

Enumeration Type Documentation

◆ FileSlots

enum FileSlots
Enumerator
CONFIG_SLOT 

Slot used for the GRF scanning and such.

This slot is used for all temporary accesses to files when scanning/testing files, and thus cannot be used for files, which are continuously accessed during a game.

SOUND_SLOT 

Slot for the sound.

FIRST_GRF_SLOT 

First slot usable for (New)GRFs used during the game.

MAX_FILE_SLOTS 

Maximum number of slots.

Definition at line 82 of file fios.h.

Function Documentation

◆ CompareFiosItems()

int CDECL CompareFiosItems ( const FiosItem da,
const FiosItem db 
)

Compare two FiosItem's.

Used with sort when sorting the file list.

Parameters
daA pointer to the first FiosItem to compare.
dbA pointer to the second FiosItem to compare.
Returns
-1, 0 or 1, depending on how the two items should be sorted.

Definition at line 52 of file fios.cpp.

◆ FiosBrowseTo()

const char* FiosBrowseTo ( const FiosItem item)

Browse to a new path based on the passed item, starting at #_fios_path.

Parameters
*itemItem telling us what to do.
Returns
A filename w/path if we reached a file, otherwise NULL.

Definition at line 152 of file fios.cpp.

Referenced by DEF_CONSOLE_CMD().

◆ FiosDelete()

bool FiosDelete ( const char *  name)

Delete a file.

Parameters
nameFilename to delete.
Returns
Whether the file deletion was successful.

Definition at line 270 of file fios.cpp.

References FiosMakeSavegameName(), and lastof.

Referenced by DEF_CONSOLE_CMD(), and SaveLoadWindow::OnTimeout().

◆ FiosGetDescText()

StringID FiosGetDescText ( const char **  path,
uint64 *  total_free 
)

Get descriptive texts.

Returns the path and free space left on the device

Parameters
pathstring describing the path
total_freetotal free space in megabytes, optional (can be NULL)
Returns
StringID describing the path (free space or failure)

Definition at line 141 of file fios.cpp.

◆ FiosGetHeightmapList()

void FiosGetHeightmapList ( SaveLoadOperation  fop,
FileList file_list 
)

Get a list of heightmaps.

Parameters
fopPurpose of collecting the list.
file_listDestination of the found files.

Definition at line 619 of file fios.cpp.

◆ FiosGetSavegameList()

void FiosGetSavegameList ( SaveLoadOperation  fop,
FileList file_list 
)

Get a list of savegames.

Parameters
fopPurpose of collecting the list.
file_listDestination of the found files.
See also
FiosGetFileList

Definition at line 493 of file fios.cpp.

◆ FiosGetSavegameListCallback()

FiosType FiosGetSavegameListCallback ( SaveLoadOperation  fop,
const char *  file,
const char *  ext,
char *  title,
const char *  last 
)

Callback for FiosGetFileList.

It tells if a file is a savegame or not.

Parameters
fopPurpose of collecting the list.
fileName of the file to check.
extA pointer to the extension identifier inside file
titleBuffer if a callback wants to lookup the title of the file; NULL to skip the lookup
lastLast available byte in buffer (to prevent buffer overflows); not used when title == NULL
Returns
a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a savegame
See also
FiosGetFileList
FiosGetSavegameList

Definition at line 460 of file fios.cpp.

◆ FiosGetScenarioList()

void FiosGetScenarioList ( SaveLoadOperation  fop,
FileList file_list 
)

Get a list of scenarios.

Parameters
fopPurpose of collecting the list.
file_listDestination of the found files.
See also
FiosGetFileList

Definition at line 548 of file fios.cpp.

◆ FiosMakeHeightmapName()

void FiosMakeHeightmapName ( char *  buf,
const char *  name,
const char *  last 
)

Construct a filename for a height map.

Parameters
bufDestination buffer.
nameFilename.
lastLast element of buffer buf.

Definition at line 256 of file fios.cpp.

References FiosMakeFilename(), GetCurrentScreenshotExtension(), lastof, and strecpy().

Referenced by SaveLoadWindow::OnTimeout().

◆ FiosMakeSavegameName()

void FiosMakeSavegameName ( char *  buf,
const char *  name,
const char *  last 
)

Make a save game or scenario filename from a name.

Parameters
bufDestination buffer for saving the filename.
nameName of the file.
lastLast element of buffer buf.

Definition at line 243 of file fios.cpp.

Referenced by FiosDelete(), and SaveLoadWindow::OnTimeout().

◆ ShowSaveLoadDialog()

void ShowSaveLoadDialog ( AbstractFileType  abstract_filetype,
SaveLoadOperation  fop 
)

Launch save/load dialog in the given mode.

Parameters
abstract_filetypeKind of file to handle.
fopFile operation to perform (load or save).

Definition at line 768 of file fios_gui.cpp.

References _file_to_saveload, _save_dialog_desc, FileToSaveLoad::abstract_ftype, DeleteWindowById(), FT_HEIGHTMAP, SLO_SAVE, and WC_SAVELOAD.

Referenced by SelectGameWindow::OnClick().