The Battle for Wesnoth  1.19.5+dev
game_load.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Jörg Hinrichs <joerg.hinrichs@alice-dsl.de>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
21 #include "save_index.hpp"
22 #include "savegame.hpp"
23 
24 #include <SDL2/SDL_keycode.h>
25 
26 namespace gui2
27 {
28 
29 namespace dialogs
30 {
31 
32 class game_load : public modal_dialog
33 {
34 public:
36 
37  static bool execute(const game_config_view& cache_config, savegame::load_game_metadata& data);
38 
39 private:
40  virtual void pre_show() override;
41 
42  virtual const std::string& window_id() const override;
43 
44  void set_save_dir_list(menu_button& dir_list);
45 
46  /** Update (both internally and visually) the list of games. */
47  void populate_game_list();
48 
49  void filter_text_changed(const std::string& text);
52  void handle_dir_select();
53 
54  /**
55  * Implementation detail of filter_text_changed and handle_dir_select
56  *
57  * @param text Current contents of the textbox
58  * @param force If true, recalculate even if the text is the same as last time
59  */
60  void apply_filter_text(const std::string& text, bool force);
61 
62  /** Part of display_savegame that might throw a config::error if the savegame data is corrupt. */
64  void display_savegame();
65  void evaluate_summary_string(std::stringstream& str, const config& cfg_summary);
66 
67  void key_press_callback(const SDL_Keycode key);
68 
69  std::string& filename_;
70  std::shared_ptr<savegame::save_index_class>& save_index_manager_;
71 
75 
77 
78  std::vector<savegame::save_info> games_;
80 
81  std::vector<std::string> last_words_;
82 };
83 } // namespace dialogs
84 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
A class grating read only view to a vector of config objects, viewed as one config with all children ...
void apply_filter_text(const std::string &text, bool force)
Implementation detail of filter_text_changed and handle_dir_select.
Definition: game_load.cpp:323
std::vector< std::string > last_words_
Definition: game_load.hpp:81
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.
Definition: game_load.cpp:179
field_bool * show_replay_
Definition: game_load.hpp:73
virtual void pre_show() override
Actions to be taken before showing the window.
Definition: game_load.cpp:93
game_load(const game_config_view &cache_config, savegame::load_game_metadata &data)
Definition: game_load.cpp:79
void key_press_callback(const SDL_Keycode key)
Definition: game_load.cpp:509
void evaluate_summary_string(std::stringstream &str, const config &cfg_summary)
Definition: game_load.cpp:355
void set_save_dir_list(menu_button &dir_list)
Definition: game_load.cpp:130
field_bool * cancel_orders_
Definition: game_load.hpp:74
const game_config_view & cache_config_
Definition: game_load.hpp:79
static bool execute(const game_config_view &cache_config, savegame::load_game_metadata &data)
Definition: game_load.cpp:58
std::shared_ptr< savegame::save_index_class > & save_index_manager_
Definition: game_load.hpp:70
std::string & filename_
Definition: game_load.hpp:69
std::vector< savegame::save_info > games_
Definition: game_load.hpp:78
void populate_game_list()
Update (both internally and visually) the list of games.
Definition: game_load.cpp:153
void filter_text_changed(const std::string &text)
Definition: game_load.cpp:318
virtual const std::string & window_id() const override
The ID of the window to build.
field_bool * change_difficulty_
Definition: game_load.hpp:72
Abstract base class for all modal dialogs.
Specialized field class for boolean.
Definition: field.hpp:488
Filename and modification date for a file list.
Definition: save_index.hpp:26
Various uncategorised dialogs.
Generic file dialog.
std::string_view data
Definition: picture.cpp:178