OpenTTD Source: src/fios.h File Reference

OpenTTD Source 15.3

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

## 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.

## Typedef Documentation

## ◆ CompanyPropertiesMap

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

Definition at line 28 of file fios.h.

## Enumeration Type Documentation

## ◆ SaveLoadInvalidateWindowData

enum SaveLoadInvalidateWindowData : uint8_t

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.

## ◆ SortingBits

enum SortingBits : uint8_t

Definition at line 93 of file fios.h.

## Function Documentation

## ◆ FindScenario()

std::optional< std::string_view > FindScenario | ( | const ContentInfo & | ci,
|  | bool | md5sum
| ) |  |

Find a given scenario based on its unique ID.

Parameters

  ci | The content info to compare it to.
  md5sum | Whether to look at the md5sum or the id.

Returns
  The filename of the file, else `std::nullopt`.

Definition at line 664 of file fios.cpp.

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

Referenced by ContentInfo::GetTextfile(), and HasScenario().

## ◆ FiosBrowseTo()

bool FiosBrowseTo | ( | const FiosItem * | item | ) |

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

Parameters

  *item | Item telling us what to do.

Returns
  `true` when the path got changed.

Definition at line 142 of file fios.cpp.

References FiosType::detailed, DFT_FIOS_DIR, DFT_FIOS_DIRECT, DFT_FIOS_DRIVE, DFT_FIOS_PARENT, and DFT_INVALID.

Referenced by SaveLoadWindow::OnClick().

## ◆ FiosGetCurrentPath()

std::string FiosGetCurrentPath | ( |  | ) |

Get the current path/working directory.

Definition at line 132 of file fios.cpp.

Referenced by SaveLoadWindow::DrawWidget().

## ◆ FiosGetDiskFreeSpace()

std::optional< uint64_t > FiosGetDiskFreeSpace | ( | const std::string & | path | ) |

Definition at line 70 of file unix.cpp.

## ◆ FiosGetHeightmapList()

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

Get a list of heightmaps.

Parameters

  fop | Purpose of collecting the list.
  show_dirs | Whether to show directories.
  file_list | Destination of the found files.

Definition at line 528 of file fios.cpp.

References FiosGetFileList(), HEIGHTMAP_DIR, and NO_DIRECTORY.

Referenced by FileList::BuildFileList().

## ◆ FiosGetHeightmapListCallback()

std::tuple< FiosType, std::string > FiosGetHeightmapListCallback | ( | SaveLoadOperation | fop,
|  | std::string_view | file,
|  | std::string_view | ext
| ) |  |

Definition at line 482 of file fios.cpp.

## ◆ FiosGetSavegameList()

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

Get a list of savegames.

Parameters

  fop | Purpose of collecting the list.
  show_dirs | Whether to show directories.
  file_list | Destination of the found files.

See also
  FiosGetFileList

Definition at line 421 of file fios.cpp.

References FiosGetFileList(), FiosGetSavegameListCallback(), NO_DIRECTORY, and SAVE_DIR.

Referenced by FileList::BuildFileList().

## ◆ FiosGetSavegameListCallback()

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

Callback for FiosGetFileList.

It tells if a file is a savegame or not.

Parameters

  fop | Purpose of collecting the list.
  file | Name of the file to check.
  ext | A 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 392 of file fios.cpp.

References GetFileTitle(), SAVE_DIR, SLO_LOAD, and StrEqualsIgnoreCase().

Referenced by FiosGetSavegameList(), and openttd_main().

## ◆ FiosGetScenarioList()

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

Get a list of scenarios.

Parameters

  fop | Purpose of collecting the list.
  show_dirs | Whether to show directories.
  file_list | Destination of the found files.

See also
  FiosGetFileList

Definition at line 468 of file fios.cpp.

References FiosGetFileList(), FiosGetScenarioListCallback(), NO_DIRECTORY, SCENARIO_DIR, and SLO_LOAD.

Referenced by FileList::BuildFileList().

## ◆ FiosGetScenarioListCallback()

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

Callback for FiosGetFileList.

It tells if a file is a scenario or not.

Parameters

  fop | Purpose of collecting the list.
  file | Name of the file to check.
  ext | A 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 441 of file fios.cpp.

References GetFileTitle(), SCENARIO_DIR, SLO_LOAD, and StrEqualsIgnoreCase().

Referenced by FiosGetScenarioList(), and openttd_main().

## ◆ FiosGetTownDataList()

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

Get a list of town data files.

Parameters

  fop | Purpose of collecting the list.
  show_dirs | Whether to show directories.
  file_list | Destination of the found files.

Definition at line 564 of file fios.cpp.

References FiosGetFileList(), FiosGetTownDataListCallback(), HEIGHTMAP_DIR, and NO_DIRECTORY.

Referenced by FileList::BuildFileList().

## ◆ FiosMakeHeightmapName()

std::string FiosMakeHeightmapName | ( | std::string_view | name | ) |

Construct a filename for a height map.

Parameters

  name | Filename.

Returns
  The completed filename.

Definition at line 228 of file fios.cpp.

References FiosMakeFilename(), and GetCurrentScreenshotExtension().

Referenced by SaveLoadWindow::OnTimeout().

## ◆ FiosMakeSavegameName()

std::string FiosMakeSavegameName | ( | std::string_view | name | ) |

Make a save game or scenario filename from a name.

Parameters

  name | Name of the file.

Returns
  The completed filename.

Definition at line 216 of file fios.cpp.

References FiosMakeFilename().

Referenced by SaveLoadWindow::OnTimeout().

## ◆ ScanScenarios()

void ScanScenarios | ( |  | ) |

Force a (re)scan of the scenarios.

Definition at line 692 of file fios.cpp.

References _scanner, and ScenarioScanner::Scan().

Referenced by NetworkContentDownloadStatusWindow::Close().

## ◆ ShowSaveLoadDialog()

void ShowSaveLoadDialog | ( | AbstractFileType | abstract_filetype,
|  | SaveLoadOperation | fop
| ) |  |

Launch save/load dialog in the given mode.

Parameters

  abstract_filetype | Kind of file to handle.
  fop | File operation to perform (load or save).

Definition at line 1000 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.

Referenced by MenuClickSaveLoad(), SelectGameWindow::OnClick(), NetworkStartServerWindow::OnClick(), FoundTownWindow::OnClick(), and MainToolbarWindow::OnHotkey().

## Variable Documentation

## ◆ _load_check_data

LoadCheckData _load_check_data
| extern

Data loaded from save during SL_LOAD_CHECK.

Definition at line 41 of file fios_gui.cpp.

Referenced by DoLoad(), PLYRChunkHandler::LoadCheck(), GLOGChunkHandler::LoadCheck(), MAPSChunkHandler::LoadCheck(), DATEChunkHandler::LoadCheck(), NGRFChunkHandler::LoadCheck(), PATSChunkHandler::LoadCheck(), SaveLoadWindow::OnClick(), SaveLoadWindow::OnInvalidateData(), openttd_main(), and SlError().

## ◆ _savegame_sort_order

SortingBits _savegame_sort_order
| extern

Definition at line 33 of file fios.cpp.