-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
game_load.hpp
94 lines (74 loc) · 3.28 KB
/
game_load.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
Copyright (C) 2008 - 2018 by Jörg Hinrichs <joerg.hinrichs@alice-dsl.de>
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#pragma once
#include "gettext.hpp"
#include "gui/dialogs/modal_dialog.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/menu_button.hpp"
#include "save_index.hpp"
#include "savegame.hpp"
#include <SDL2/SDL_keycode.h>
namespace gui2
{
class text_box_base;
namespace dialogs
{
/**
* @ingroup GUIWindowDefinitionWML
*
* This shows the dialog to select and load a savegame file.
* Key |Type |Mandatory|Description
* ------------------|--------------|---------|-----------
* txtFilter | text |yes |The filter for the listbox items.
* savegame_list | @ref 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 | @ref minimap |yes |Minimap of the selected savegame.
* imgLeader | @ref image |yes |The image of the leader in the selected savegame.
* lblScenario | @ref label |yes |The name of the scenario of the selected savegame.
* lblSummary | @ref label |yes |Summary of the selected savegame.
*/
class game_load : public modal_dialog
{
public:
game_load(const game_config_view& cache_config, savegame::load_game_metadata& data);
static bool execute(const game_config_view& cache_config, savegame::load_game_metadata& data);
private:
/** Inherited from modal_dialog. */
virtual void pre_show(window& window) override;
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const override;
void set_save_dir_list(menu_button& dir_list);
/** Update (both internally and visually) the list of games. */
void populate_game_list();
void filter_text_changed(const std::string& text);
void browse_button_callback();
void delete_button_callback();
void handle_dir_select();
/** Part of display_savegame that might throw a config::error if the savegame data is corrupt. */
void display_savegame_internal(const savegame::save_info& game);
void display_savegame();
void evaluate_summary_string(std::stringstream& str, const config& cfg_summary);
void key_press_callback(const SDL_Keycode key);
std::string& filename_;
std::shared_ptr<savegame::save_index_class>& save_index_manager_;
field_bool* change_difficulty_;
field_bool* show_replay_;
field_bool* cancel_orders_;
config& summary_;
std::vector<savegame::save_info> games_;
const game_config_view& cache_config_;
std::vector<std::string> last_words_;
};
} // namespace dialogs
} // namespace gui2