OpenTTD Source  20241120-master-g6d3adc6169
fios.h File Reference

Declarations for savegames operations. More...

#include "gfx_type.h"
#include "company_base.h"
#include "newgrf_config.h"
#include "gamelog.h"
#include "network/core/tcp_content_type.h"
#include "timer/timer_game_calendar.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...
 
struct  FiosNumberedSaveName
 A savegame name automatically numbered. More...
 

Typedefs

using CompanyPropertiesMap = std::map< uint, std::unique_ptr< CompanyProperties > >
 

Enumerations

enum  SaveLoadInvalidateWindowData { SLIWD_RESCAN_FILES , SLIWD_SELECTION_CHANGES , SLIWD_FILTER_CHANGES }
 Special values for save-load window for the data parameter of InvalidateWindowData. More...
 
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, bool show_dirs, FileList &file_list)
 Get a list of savegames. More...
 
void FiosGetScenarioList (SaveLoadOperation fop, bool show_dirs, FileList &file_list)
 Get a list of scenarios. More...
 
void FiosGetHeightmapList (SaveLoadOperation fop, bool show_dirs, FileList &file_list)
 Get a list of heightmaps. More...
 
void FiosGetTownDataList (SaveLoadOperation fop, bool show_dirs, FileList &file_list)
 Get a list of town data files. More...
 
bool FiosBrowseTo (const FiosItem *item)
 Browse to a new path based on the passed item, starting at #_fios_path. More...
 
std::string FiosGetCurrentPath ()
 Get the current path/working directory.
 
std::optional< uint64_t > FiosGetDiskFreeSpace (const std::string &path)
 
bool FiosDelete (const char *name)
 Delete a file. More...
 
std::string FiosMakeHeightmapName (const char *name)
 Construct a filename for a height map. More...
 
std::string FiosMakeSavegameName (const char *name)
 Make a save game or scenario filename from a name. More...
 
std::tuple< FiosType, std::string > FiosGetSavegameListCallback (SaveLoadOperation fop, const std::string &file, const std::string_view ext)
 Callback for FiosGetFileList. More...
 
std::tuple< FiosType, std::string > FiosGetScenarioListCallback (SaveLoadOperation fop, const std::string &file, const std::string_view ext)
 Callback for FiosGetFileList. More...
 
std::tuple< FiosType, std::string > FiosGetHeightmapListCallback (SaveLoadOperation fop, const std::string &file, const std::string_view ext)
 
void ScanScenarios ()
 Force a (re)scan of the scenarios.
 
const char * FindScenario (const ContentInfo *ci, bool md5sum)
 Find a given scenario based on its unique ID. 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

◆ SaveLoadInvalidateWindowData

Special values for save-load window for the data parameter of InvalidateWindowData.

Enumerator
SLIWD_RESCAN_FILES 

Rescan all files (when changed directory, ...)

SLIWD_SELECTION_CHANGES 

File selection has changed (user click, ...)

SLIWD_FILTER_CHANGES 

The filename filter has changed (via the editbox)

Definition at line 22 of file fios.h.

Function Documentation

◆ FindScenario()

const char* FindScenario ( const ContentInfo ci,
bool  md5sum 
)

Find a given scenario based on its unique ID.

Parameters
ciThe content info to compare it to.
md5sumWhether to look at the md5sum or the id.
Returns
The filename of the file, else nullptr.

Definition at line 690 of file fios.cpp.

References _scanner, ContentInfo::md5sum, ScenarioScanner::Scan(), and ContentInfo::unique_id.

Referenced by HasScenario().

◆ FiosBrowseTo()

bool 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
true when the path got changed.

Definition at line 143 of file fios.cpp.

◆ FiosDelete()

bool FiosDelete ( const char *  name)

Delete a file.

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

Definition at line 248 of file fios.cpp.

References FioRemove(), and FiosMakeSavegameName().

Referenced by SaveLoadWindow::OnTimeout().

◆ FiosGetHeightmapList()

void FiosGetHeightmapList ( SaveLoadOperation  fop,
bool  show_dirs,
FileList file_list 
)

Get a list of heightmaps.

Parameters
fopPurpose of collecting the list.
show_dirsWhether to show directories.
file_listDestination of the found files.

Definition at line 549 of file fios.cpp.

Referenced by FileList::BuildFileList().

◆ FiosGetSavegameList()

void FiosGetSavegameList ( SaveLoadOperation  fop,
bool  show_dirs,
FileList file_list 
)

Get a list of savegames.

Parameters
fopPurpose of collecting the list.
show_dirsWhether to show directories.
file_listDestination of the found files.
See also
FiosGetFileList

Definition at line 442 of file fios.cpp.

Referenced by FileList::BuildFileList().

◆ FiosGetSavegameListCallback()

std::tuple<FiosType, std::string> FiosGetSavegameListCallback ( SaveLoadOperation  fop,
const std::string &  file,
const std::string_view  ext 
)

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
Returns
a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a savegame, and the title of the file (if any).
See also
FiosGetFileList
FiosGetSavegameList

Definition at line 413 of file fios.cpp.

References StrEqualsIgnoreCase().

◆ FiosGetScenarioList()

void FiosGetScenarioList ( SaveLoadOperation  fop,
bool  show_dirs,
FileList file_list 
)

Get a list of scenarios.

Parameters
fopPurpose of collecting the list.
show_dirsWhether to show directories.
file_listDestination of the found files.
See also
FiosGetFileList

Definition at line 489 of file fios.cpp.

Referenced by FileList::BuildFileList().

◆ FiosGetScenarioListCallback()

std::tuple<FiosType, std::string> FiosGetScenarioListCallback ( SaveLoadOperation  fop,
const std::string &  file,
const std::string_view  ext 
)

Callback for FiosGetFileList.

It tells if a file is a scenario or not.

Parameters
fopPurpose of collecting the list.
fileName of the file to check.
extA pointer to the extension identifier inside file
Returns
a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a scenario and the title of the file (if any).
See also
FiosGetFileList
FiosGetScenarioList

Definition at line 462 of file fios.cpp.

References StrEqualsIgnoreCase().

◆ FiosGetTownDataList()

void FiosGetTownDataList ( SaveLoadOperation  fop,
bool  show_dirs,
FileList file_list 
)

Get a list of town data files.

Parameters
fopPurpose of collecting the list.
show_dirsWhether to show directories.
file_listDestination of the found files.

Definition at line 585 of file fios.cpp.

Referenced by FileList::BuildFileList().

◆ FiosMakeHeightmapName()

std::string FiosMakeHeightmapName ( const char *  name)

Construct a filename for a height map.

Parameters
nameFilename.
Returns
The completed filename.

Definition at line 235 of file fios.cpp.

References FiosMakeFilename(), and GetCurrentScreenshotExtension().

Referenced by SaveLoadWindow::OnTimeout().

◆ FiosMakeSavegameName()

std::string FiosMakeSavegameName ( const char *  name)

Make a save game or scenario filename from a name.

Parameters
nameName of the file.
Returns
The completed filename.

Definition at line 223 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 986 of file fios_gui.cpp.

References _load_dialog_desc, _load_heightmap_dialog_desc, _load_town_data_dialog_desc, _save_dialog_desc, CloseWindowById(), FT_HEIGHTMAP, FT_TOWN_DATA, SLO_SAVE, and WC_SAVELOAD.