The Battle for Wesnoth  1.15.13+dev
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
gui2::dialogs::game_load Class Reference

This shows the dialog to select and load a savegame file. More...

#include <game_load.hpp>

Inheritance diagram for gui2::dialogs::game_load:

Public Member Functions

 game_load (const game_config_view &cache_config, savegame::load_game_metadata &data)
 
- Public Member Functions inherited from gui2::dialogs::modal_dialog
 modal_dialog ()
 
virtual ~modal_dialog ()
 
bool show (const unsigned auto_close_time=0)
 Shows the window. More...
 
windowget_window () const
 Returns a pointer to the dialog's window. More...
 
int get_retval () const
 Returns the cached window exit code. More...
 
void set_retval (int retval)
 Convenience wrapper to set the window's exit code. More...
 
void set_always_save_fields (const bool always_save_fields)
 
void set_restore (const bool restore)
 
void set_allow_plugin_skip (const bool allow_plugin_skip)
 
void set_show_even_without_video (const bool show_even_without_video)
 

Static Public Member Functions

static bool execute (const game_config_view &cache_config, savegame::load_game_metadata &data)
 

Private Member Functions

virtual void pre_show (window &window) override
 Actions to be taken before showing the window. More...
 
virtual const std::string & window_id () const override
 The id of the window to build. More...
 
void set_save_dir_list (menu_button &dir_list)
 
void populate_game_list ()
 Update (both internally and visually) the list of games. More...
 
void filter_text_changed (const std::string &text)
 
void browse_button_callback ()
 
void delete_button_callback ()
 
void handle_dir_select ()
 
void display_savegame_internal (const savegame::save_info &game)
 Part of display_savegame that might throw a config::error if the savegame data is corrupt. More...
 
void display_savegame ()
 
void evaluate_summary_string (std::stringstream &str, const config &cfg_summary)
 
void key_press_callback (const SDL_Keycode key)
 

Private Attributes

std::string & filename_
 
std::shared_ptr< savegame::save_index_class > & save_index_manager_
 
field_boolchange_difficulty_
 
field_boolshow_replay_
 
field_boolcancel_orders_
 
configsummary_
 
std::vector< savegame::save_infogames_
 
const game_config_viewcache_config_
 
std::vector< std::string > last_words_
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::dialogs::modal_dialog
field_boolregister_bool (const std::string &id, const bool mandatory, const std::function< bool()> callback_load_value=nullptr, const std::function< void(bool)> callback_save_value=nullptr, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
 Creates a new boolean field. More...
 
field_boolregister_bool (const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
 Creates a new boolean field. More...
 
field_integerregister_integer (const std::string &id, const bool mandatory, const std::function< int()> callback_load_value=nullptr, const std::function< void(int)> callback_save_value=nullptr)
 Creates a new integer field. More...
 
field_integerregister_integer (const std::string &id, const bool mandatory, int &linked_variable)
 Creates a new integer field. More...
 
field_textregister_text (const std::string &id, const bool mandatory, const std::function< std::string()> callback_load_value=nullptr, const std::function< void(const std::string &)> callback_save_value=nullptr, const bool capture_focus=false)
 Creates a new text field. More...
 
field_textregister_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false)
 Creates a new text field. More...
 
field_labelregister_label (const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false)
 Registers a new styled_widget as a label. More...
 
field_labelregister_image (const std::string &id, const bool mandatory, const std::string &filename)
 Registers a new styled_widget as image. More...
 
- Protected Attributes inherited from gui2::dialogs::modal_dialog
std::unique_ptr< windowwindow_
 The window object build for this dialog. More...
 

Detailed Description

This shows the dialog to select and load a savegame file.

Key Type MandatoryDescription
txtFilter text yes The filter for the listbox items.
savegame_list listbox yes List of savegames.
filename control yes Name of the savegame.
date control no Date the savegame was created.
preview_pane widget yes Container widget or grid that contains the items for a preview. The visible status of this container depends on whether or not something is selected.
minimap minimap yes Minimap of the selected savegame.
imgLeader image yes The image of the leader in the selected savegame.
lblScenario label yes The name of the scenario of the selected savegame.
lblSummary label yes Summary of the selected savegame.

Definition at line 48 of file game_load.hpp.

Constructor & Destructor Documentation

◆ game_load()

gui2::dialogs::game_load::game_load ( const game_config_view cache_config,
savegame::load_game_metadata data 
)

Definition at line 82 of file game_load.cpp.

Member Function Documentation

◆ browse_button_callback()

void gui2::dialogs::game_load::browse_button_callback ( )
private

Definition at line 452 of file game_load.cpp.

References desktop::open_object(), and save_index_manager_.

Referenced by pre_show().

◆ delete_button_callback()

void gui2::dialogs::game_load::delete_button_callback ( )
private

◆ display_savegame()

void gui2::dialogs::game_load::display_savegame ( )
private

◆ display_savegame_internal()

void gui2::dialogs::game_load::display_savegame_internal ( const savegame::save_info game)
private

◆ evaluate_summary_string()

void gui2::dialogs::game_load::evaluate_summary_string ( std::stringstream &  str,
const config cfg_summary 
)
private

◆ execute()

bool gui2::dialogs::game_load::execute ( const game_config_view cache_config,
savegame::load_game_metadata data 
)
static

◆ filter_text_changed()

void gui2::dialogs::game_load::filter_text_changed ( const std::string &  text)
private

◆ handle_dir_select()

void gui2::dialogs::game_load::handle_dir_select ( )
private

◆ key_press_callback()

void gui2::dialogs::game_load::key_press_callback ( const SDL_Keycode  key)
private

◆ populate_game_list()

void gui2::dialogs::game_load::populate_game_list ( )
private

Update (both internally and visually) the list of games.

Definition at line 155 of file game_load.cpp.

References gui2::listbox::add_row(), gui2::listbox::clear(), utils::ellipsis_truncate(), games_, gui2::dialogs::modal_dialog::get_window(), and save_index_manager_.

Referenced by handle_dir_select(), and pre_show().

◆ pre_show()

void gui2::dialogs::game_load::pre_show ( window window)
overrideprivatevirtual

◆ set_save_dir_list()

void gui2::dialogs::game_load::set_save_dir_list ( menu_button dir_list)
private

◆ window_id()

virtual const std::string& gui2::dialogs::game_load::window_id ( ) const
overrideprivatevirtual

The id of the window to build.

Implements gui2::dialogs::modal_dialog.

Member Data Documentation

◆ cache_config_

const game_config_view& gui2::dialogs::game_load::cache_config_
private

Definition at line 87 of file game_load.hpp.

Referenced by evaluate_summary_string().

◆ cancel_orders_

field_bool* gui2::dialogs::game_load::cancel_orders_
private

Definition at line 82 of file game_load.hpp.

Referenced by display_savegame(), and display_savegame_internal().

◆ change_difficulty_

field_bool* gui2::dialogs::game_load::change_difficulty_
private

Definition at line 80 of file game_load.hpp.

Referenced by display_savegame(), and display_savegame_internal().

◆ filename_

std::string& gui2::dialogs::game_load::filename_
private

Definition at line 77 of file game_load.hpp.

Referenced by display_savegame_internal().

◆ games_

std::vector<savegame::save_info> gui2::dialogs::game_load::games_
private

◆ last_words_

std::vector<std::string> gui2::dialogs::game_load::last_words_
private

Definition at line 89 of file game_load.hpp.

Referenced by filter_text_changed().

◆ save_index_manager_

std::shared_ptr<savegame::save_index_class>& gui2::dialogs::game_load::save_index_manager_
private

◆ show_replay_

field_bool* gui2::dialogs::game_load::show_replay_
private

Definition at line 81 of file game_load.hpp.

Referenced by display_savegame(), and display_savegame_internal().

◆ summary_

config& gui2::dialogs::game_load::summary_
private

Definition at line 84 of file game_load.hpp.

Referenced by display_savegame_internal().


The documentation for this class was generated from the following files: