The Battle for Wesnoth  1.19.7+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::dialogs
27 {
28 class game_load : public modal_dialog
29 {
30 public:
32 
33  static bool execute(const game_config_view& cache_config, savegame::load_game_metadata& data);
34 
35 private:
36  virtual void pre_show() override;
37 
38  virtual const std::string& window_id() const override;
39 
40  void set_save_dir_list(menu_button& dir_list);
41 
42  /** Update (both internally and visually) the list of games. */
43  void populate_game_list();
44 
47  void handle_dir_select();
48 
49  /**
50  * Hides saves not matching the given filter.
51  *
52  * @param text Current contents of the textbox
53  */
54  void apply_filter_text(const std::string& text);
55 
56  /** Part of display_savegame that might throw a config::error if the savegame data is corrupt. */
58  void display_savegame();
59  void evaluate_summary_string(std::stringstream& str, const config& cfg_summary);
60 
61  void key_press_callback(const SDL_Keycode key);
62 
63  std::string& filename_;
64  std::shared_ptr<savegame::save_index_class>& save_index_manager_;
65 
69 
71 
72  std::vector<savegame::save_info> games_;
74 };
75 
76 } // namespace gui2::dialogs
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 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:181
void apply_filter_text(const std::string &text)
Hides saves not matching the given filter.
Definition: game_load.cpp:320
field_bool * show_replay_
Definition: game_load.hpp:67
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:80
void key_press_callback(const SDL_Keycode key)
Definition: game_load.cpp:480
void evaluate_summary_string(std::stringstream &str, const config &cfg_summary)
Definition: game_load.cpp:326
void set_save_dir_list(menu_button &dir_list)
Definition: game_load.cpp:132
field_bool * cancel_orders_
Definition: game_load.hpp:68
const game_config_view & cache_config_
Definition: game_load.hpp:73
static bool execute(const game_config_view &cache_config, savegame::load_game_metadata &data)
Definition: game_load.cpp:59
std::shared_ptr< savegame::save_index_class > & save_index_manager_
Definition: game_load.hpp:64
std::string & filename_
Definition: game_load.hpp:63
std::vector< savegame::save_info > games_
Definition: game_load.hpp:72
void populate_game_list()
Update (both internally and visually) the list of games.
Definition: game_load.cpp:155
virtual const std::string & window_id() const override
The ID of the window to build.
field_bool * change_difficulty_
Definition: game_load.hpp:66
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
std::string_view data
Definition: picture.cpp:178