The Battle for Wesnoth  1.15.1+dev
game_load.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2018 by Jörg Hinrichs <joerg.hinrichs@alice-dsl.de>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
19 #include "savegame.hpp"
20 #include "save_index.hpp"
21 #include "gettext.hpp"
22 
23 #include <SDL2/SDL_keycode.h>
24 
25 namespace gui2
26 {
27 class text_box_base;
28 
29 namespace dialogs
30 {
31 
32 class game_load : public modal_dialog
33 {
34 public:
35  game_load(const config& cache_config, savegame::load_game_metadata& data);
36 
37  static bool execute(const config& cache_config, savegame::load_game_metadata& data)
38  {
39  if(savegame::get_saves_list().empty()) {
40  gui2::show_transient_message(_("No Saved Games"), _("There are no save files to load"));
41  return false;
42  }
43 
44  return game_load(cache_config, data).show();
45  }
46 
47 private:
48  /** Inherited from modal_dialog. */
49  virtual void pre_show(window& window) override;
50 
51  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
52  virtual const std::string& window_id() const override;
53 
54  void filter_text_changed(text_box_base* textbox, const std::string& text);
55  void delete_button_callback(window& window);
56 
57  void display_savegame_internal(window& window);
58  void display_savegame(window& window);
59  void evaluate_summary_string(std::stringstream& str, const config& cfg_summary);
60 
61  void key_press_callback(window& window, const SDL_Keycode key);
62 
63  std::string& filename_;
64 
68 
70 
71  std::vector<savegame::save_info> games_;
73 
74  std::vector<std::string> last_words_;
75 };
76 } // namespace dialogs
77 } // namespace gui2
Abstract base class for text items.
field_bool * change_difficulty_
Definition: game_load.hpp:65
void display_savegame(window &window)
Definition: game_load.cpp:258
Specialized field class for boolean.
Definition: field.hpp:544
std::vector< save_info > get_saves_list(const std::string *dir, const std::string *filter)
Get a list of available saves.
Definition: save_index.cpp:190
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
void delete_button_callback(window &window)
Definition: game_load.cpp:436
static bool execute(const config &cache_config, savegame::load_game_metadata &data)
Definition: game_load.hpp:37
std::vector< std::string > last_words_
Definition: game_load.hpp:74
Generic file dialog.
Definition: field-fwd.hpp:22
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:91
game_load(const config &cache_config, savegame::load_game_metadata &data)
Definition: game_load.cpp:98
std::vector< savegame::save_info > games_
Definition: game_load.hpp:71
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
Various uncategorised dialogs.
void key_press_callback(window &window, const SDL_Keycode key)
Definition: game_load.cpp:467
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Definition: game_load.cpp:110
const config & cache_config_
Definition: game_load.hpp:72
field_bool * show_replay_
Definition: game_load.hpp:66
field_bool * cancel_orders_
Definition: game_load.hpp:67
void filter_text_changed(text_box_base *textbox, const std::string &text)
Definition: game_load.cpp:286
std::string & filename_
Definition: game_load.hpp:63
void display_savegame_internal(window &window)
Definition: game_load.cpp:162
Abstract base class for all modal dialogs.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
void evaluate_summary_string(std::stringstream &str, const config &cfg_summary)
Definition: game_load.cpp:339