OpenTTD: src/fios.h File Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

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...
struct | SmallFiosItem
| Deals with the type of the savegame, independent of extension. More...

## Typedefs
typedef SmallMap< uint, CompanyProperties * > | CompanyPropertiesMap

## Enumerations
enum | FileSlots { CONFIG_SLOT = 0, SOUND_SLOT = 1, FIRST_GRF_SLOT = 2, LAST_GRF_SLOT = 63, MAX_FILE_SLOTS = 64 }
enum | SaveLoadDialogMode { SLD_LOAD_GAME, SLD_LOAD_SCENARIO, SLD_SAVE_GAME, SLD_SAVE_SCENARIO, SLD_LOAD_HEIGHTMAP, SLD_SAVE_HEIGHTMAP }
| Mode of the file dialogue window. More...
enum | FileType { FT_NONE, FT_SAVEGAME, FT_SCENARIO, FT_HEIGHTMAP }
| The different types of files that the system knows about. More...
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 }
enum | SortingBits { SORT_ASCENDING = 0, SORT_DESCENDING = 1, SORT_BY_DATE = 0, SORT_BY_NAME = 2 }

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

## Variables
LoadCheckData | _load_check_data
| Data loaded from save during SL_LOAD_CHECK.
SmallVector< FiosItem, 32 > | _fios_items
SmallFiosItem | _file_to_saveload
SaveLoadDialogMode | _saveload_mode
SortingBits | _savegame_sort_order
const TextColour | _fios_colours []
| Colours for fios types, indexed by #FiosType.

## Detailed Description

Declarations for savegames operations.

Definition in file fios.h.

## Enumeration Type Documentation

enum FileSlots

Enumerator:

  CONFIG_SLOT | 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".
  SOUND_SLOT | Slot for the sound.
  FIRST_GRF_SLOT | First slot usable for (New)GRFs used during the game.
  LAST_GRF_SLOT | Last slot usable for (New)GRFs used during the game.
  MAX_FILE_SLOTS | Maximum number of slots.

Definition at line 82 of file fios.h.

enum FileType

The different types of files that the system knows about.

Enumerator:

  FT_NONE | nothing to do
  FT_SAVEGAME | old or new savegame
  FT_SCENARIO | old or new scenario
  FT_HEIGHTMAP | heightmap file

Definition at line 111 of file fios.h.

enum SaveLoadDialogMode

Mode of the file dialogue window.

Enumerator:

  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.
  SLD_SAVE_HEIGHTMAP | Save a heightmap.

Definition at line 101 of file fios.h.

## Function Documentation

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

Compare two FiosItem's.

Used with sort when sorting the file list.

Parameters

  da | A pointer to the first FiosItem to compare.
  db | A pointer to the second FiosItem to compare.

Returns
  -1, 0 or 1, depending on how the two items should be sorted.

Definition at line 54 of file fios.cpp.

Referenced by FiosGetFileList().

const char* 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
  A filename w/path if we reached a file, otherwise `NULL`.

Definition at line 93 of file fios.cpp.

References seprintf(), and strecat().

Referenced by SaveLoadWindow::OnClick().

bool FiosDelete | ( | const char * | name | ) |

Delete a file.

Parameters

  name | Filename to delete.

Returns
  Whether the file deletion was successful.

Definition at line 210 of file fios.cpp.

References FiosMakeSavegameName(), and lastof.

Referenced by SaveLoadWindow::OnTimeout().

void FiosFreeSavegameList | ( |  | ) |

Free the list of savegames.

Definition at line 69 of file fios.cpp.

References SmallVector< T, S >::Clear(), and SmallVector< T, S >::Compact().

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

Get descriptive texts.

Returns the path and free space left on the device

Parameters

  path | string describing the path
  total_free | total free space in megabytes, optional (can be NULL)

Returns
  StringID describing the path (free space or failure)

Definition at line 82 of file fios.cpp.

Referenced by SaveLoadWindow::DrawWidget().

void FiosGetHeightmapList | ( | SaveLoadDialogMode | mode | ) |

Get a list of heightmaps.

Parameters

  mode | Save/load mode.

Definition at line 553 of file fios.cpp.

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

void FiosGetSavegameList | ( | SaveLoadDialogMode | mode | ) |

Get a list of savegames.

Parameters

  mode | Save/load mode.

See Also
  FiosGetFileList

Definition at line 430 of file fios.cpp.

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

FiosType FiosGetSavegameListCallback | ( | SaveLoadDialogMode | mode,
|  | 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

  mode | Save/load mode.
  file | Name of the file to check.
  ext | A pointer to the extension identifier inside file
  title | Buffer if a callback wants to lookup the title of the file; NULL to skip the lookup
  last | Last 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 398 of file fios.cpp.

References GetFileTitle(), SAVE_DIR, SLD_LOAD_GAME, and SLD_LOAD_SCENARIO.

Referenced by FiosGetSavegameList(), and openttd_main().

void FiosGetScenarioList | ( | SaveLoadDialogMode | mode | ) |

Get a list of scenarios.

Parameters

  mode | Save/load mode.

See Also
  FiosGetFileList

Definition at line 484 of file fios.cpp.

References FiosGetFileList(), FiosGetScenarioListCallback(), lastof, NO_DIRECTORY, SCENARIO_DIR, and SLD_LOAD_SCENARIO.

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

Construct a filename for a height map.

Parameters

  buf | Destination buffer.
  name | Filename.
  last | Last element of buffer buf.

Definition at line 196 of file fios.cpp.

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

Referenced by SaveLoadWindow::OnTimeout().

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

Make a save game or scenario filename from a name.

Parameters

  buf | Destination buffer for saving the filename.
  name | Name of the file.
  last | Last element of buffer buf.

Definition at line 183 of file fios.cpp.

References FiosMakeFilename().

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

void ShowSaveLoadDialog | ( | SaveLoadDialogMode | mode | ) |

Launch save/load dialog in the given mode.

Parameters

  mode | Save/load mode.

Definition at line 754 of file fios_gui.cpp.

References _load_dialog_desc, _load_heightmap_dialog_desc, _save_dialog_desc, DeleteWindowById(), SmallFiosItem::filetype, SLD_LOAD_HEIGHTMAP, SLD_SAVE_GAME, SLD_SAVE_HEIGHTMAP, SLD_SAVE_SCENARIO, and WC_SAVELOAD.

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

## Variable Documentation

const TextColour _fios_colours[]

Colours for fios types, indexed by #FiosType.

Definition at line 191 of file fios_gui.cpp.

Referenced by SaveLoadWindow::DrawWidget().