OpenTTD Source 20260421-master-gc2fbc6fdeb
fios_gui.cpp File Reference

GUIs for loading/saving games, scenarios, heightmaps, ... More...

#include "stdafx.h"
#include "saveload/saveload.h"
#include "error.h"
#include "gui.h"
#include "gfx_func.h"
#include "command_func.h"
#include "network/network.h"
#include "network/network_content.h"
#include "strings_func.h"
#include "fileio_func.h"
#include "fios.h"
#include "window_func.h"
#include "tilehighlight_func.h"
#include "querystring_gui.h"
#include "engine_func.h"
#include "landscape_type.h"
#include "genworld.h"
#include "timer/timer_game_calendar.h"
#include "core/geometry_func.hpp"
#include "gamelog.h"
#include "stringfilter_type.h"
#include "misc_cmd.h"
#include "gamelog_internal.h"
#include "widgets/fios_widget.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  SaveLoadWindow

Enumerations

enum class  SavegameSorter : uint8_t { Date , Name }
 The available sorters for FiosItems. More...

Functions

bool FiosItemSorter (const FiosItem &a, const FiosItem &b)
 Sorts the FiosItems based on the savegame sorter and order.
static void SortSaveGameList (FileList &file_list)
 Sort the collected list save games prior to displaying it in the save/load gui.
void ShowSaveLoadDialog (AbstractFileType abstract_filetype, SaveLoadOperation fop)
 Launch save/load dialog in the given mode.

Variables

LoadCheckData _load_check_data
 Data loaded from save during SL_LOAD_CHECK.
static bool _fios_path_changed
static bool _savegame_sort_dirty
static SavegameSorter _savegame_sorter = SavegameSorter::Date
 Sorter for savegames.
static bool _savegame_sorter_ascending = false
 Sorter for savegames.
static constexpr std::initializer_list< NWidgetPart_nested_load_dialog_widgets
 Load game/scenario with optional content download.
static constexpr std::initializer_list< NWidgetPart_nested_load_heightmap_dialog_widgets
 Load heightmap with content download.
static constexpr std::initializer_list< NWidgetPart_nested_load_town_data_dialog_widgets
 Load town data.
static constexpr std::initializer_list< NWidgetPart_nested_save_dialog_widgets
 Save game/scenario.
static const EnumClassIndexContainer< std::array< TextColour, to_underlying(DetailedFileType::End)>, DetailedFileType_fios_colours
 Text colours of DetailedFileType fios entries in the window.
static WindowDesc _load_dialog_desc (WDP_CENTER, "load_game", 500, 294, WC_SAVELOAD, WC_NONE, {}, _nested_load_dialog_widgets)
 Load game/scenario.
static WindowDesc _load_heightmap_dialog_desc (WDP_CENTER, "load_heightmap", 257, 320, WC_SAVELOAD, WC_NONE, {}, _nested_load_heightmap_dialog_widgets)
 Load heightmap.
static WindowDesc _load_town_data_dialog_desc (WDP_CENTER, "load_town_data", 257, 320, WC_SAVELOAD, WC_NONE, {}, _nested_load_town_data_dialog_widgets)
 Load town data.
static WindowDesc _save_dialog_desc (WDP_CENTER, "save_game", 500, 294, WC_SAVELOAD, WC_NONE, {}, _nested_save_dialog_widgets)
 Save game/scenario.

Detailed Description

GUIs for loading/saving games, scenarios, heightmaps, ...

Definition in file fios_gui.cpp.

Enumeration Type Documentation

◆ SavegameSorter

enum class SavegameSorter : uint8_t
strong

The available sorters for FiosItems.

Enumerator
Date 

Sort by date.

Name 

Sort by name.

Definition at line 47 of file fios_gui.cpp.

Function Documentation

◆ FiosItemSorter()

bool FiosItemSorter ( const FiosItem & a,
const FiosItem & b )

Sorts the FiosItems based on the savegame sorter and order.

Comparison helper for the sorter, comparing a to b.

Parameters
aThe first element.
bThe second element.
Returns
true if the first element is less than the second element.

Definition at line 56 of file fios_gui.cpp.

References _savegame_sorter, _savegame_sorter_ascending, Date, FiosItemModificationDateSorter(), FiosItemNameSorter(), and Name.

Referenced by FiosGetFileList(), and SortSaveGameList().

◆ 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 1020 of file fios_gui.cpp.

References _load_dialog_desc, _load_heightmap_dialog_desc, _load_town_data_dialog_desc, _save_dialog_desc, CloseWindowById(), Heightmap, Save, TownData, and WC_SAVELOAD.

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

◆ SortSaveGameList()

void SortSaveGameList ( FileList & file_list)
static

Sort the collected list save games prior to displaying it in the save/load gui.

Parameters
[in,out]file_listList of save game files found in the directory.

Definition at line 322 of file fios_gui.cpp.

References FiosDirectory, FiosDrive, FiosItemSorter(), and FiosParent.

Referenced by SaveLoadWindow::OnPaint().

Variable Documentation

◆ _fios_colours

Initial value:
= {
TC_LIGHT_BROWN,
TC_ORANGE,
TC_YELLOW,
TC_ORANGE,
TC_LIGHT_BROWN,
TC_LIGHT_BLUE,
TC_DARK_GREEN,
TC_DARK_GREEN,
TC_ORANGE,
}

Text colours of DetailedFileType fios entries in the window.

Definition at line 306 of file fios_gui.cpp.

Referenced by SaveLoadWindow::DrawWidget().

◆ _fios_path_changed

bool _fios_path_changed
static

Definition at line 43 of file fios_gui.cpp.

◆ _load_check_data

◆ _nested_load_dialog_widgets

std::initializer_list<NWidgetPart> _nested_load_dialog_widgets
staticconstexpr

Load game/scenario with optional content download.

Definition at line 90 of file fios_gui.cpp.

◆ _nested_load_heightmap_dialog_widgets

std::initializer_list<NWidgetPart> _nested_load_heightmap_dialog_widgets
staticconstexpr

Load heightmap with content download.

Definition at line 153 of file fios_gui.cpp.

◆ _nested_load_town_data_dialog_widgets

std::initializer_list<NWidgetPart> _nested_load_town_data_dialog_widgets
staticconstexpr

Load town data.

Definition at line 200 of file fios_gui.cpp.

◆ _nested_save_dialog_widgets

std::initializer_list<NWidgetPart> _nested_save_dialog_widgets
staticconstexpr

Save game/scenario.

Definition at line 242 of file fios_gui.cpp.

◆ _savegame_sort_dirty

bool _savegame_sort_dirty
static

Definition at line 44 of file fios_gui.cpp.

◆ _savegame_sorter

SavegameSorter _savegame_sorter = SavegameSorter::Date
static

Sorter for savegames.

Definition at line 52 of file fios_gui.cpp.

Referenced by SaveLoadWindow::DrawWidget(), FiosItemSorter(), and SaveLoadWindow::OnClick().

◆ _savegame_sorter_ascending

bool _savegame_sorter_ascending = false
static

Sorter for savegames.

Definition at line 53 of file fios_gui.cpp.

Referenced by SaveLoadWindow::DrawWidget(), FiosItemSorter(), and SaveLoadWindow::OnClick().