The Battle for Wesnoth  1.19.5+dev
mp_create_game.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
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 
24 
25 
26 namespace gui2
27 {
28 class toggle_button;
29 class listbox;
30 class menu_button;
31 
32 namespace dialogs
33 {
34 
36 {
37  typedef std::pair<level_type::type, std::string> level_type_info;
38 
39 public:
40  mp_create_game(saved_game& state, bool local_mode);
41 
42  /** The execute function. See @ref modal_dialog for more information. */
44 
45 private:
46  virtual const std::string& window_id() const override;
47 
48  virtual void pre_show() override;
49 
50  virtual void post_show() override;
51 
53  std::unique_ptr<ng::configure_engine> config_engine_;
54  std::unique_ptr<mp_options_helper> options_manager_;
55 
58 
59  std::vector<level_type_info> level_types_;
60 
61  void update_games_list();
62  void display_games_of_type(level_type::type type, const std::string& level);
63 
65  void regenerate_random_map();
66 
67  /**
68  * All fields are also in the normal field vector, but they need to be
69  * manually controlled as well so add the pointers here as well.
70  */
71 
81 
90 
93 
95 
96  template<typename widget>
97  void on_filter_change(const std::string& id, bool do_select);
98 
99  void on_game_select();
100  void on_tab_select();
101  void on_era_select();
102  void on_mod_toggle(const std::string id, toggle_button* sender);
104 
105  std::vector<std::string> get_active_mods();
106  void set_active_mods(const std::vector<std::string>& val);
107 
108  void sync_with_depcheck();
109 
110  void show_description(const std::string& new_description);
111 
112  void update_details();
113  void update_map_settings();
114 
115  void reset_timer_settings();
116 
117  /**
118  * Dialog exit hook to bring up the difficulty dialog when starting a campaign.
119  * This only fires when the retval is OK (ie, creating a game), meaning it does not fire
120  * when loading a saved game.
121  */
122  bool dialog_exit_hook(window&);
123 
124  int convert_to_game_filtered_index(const unsigned int initial_index);
125 
126  void load_game_callback();
127 
129 };
130 
131 } // namespace dialogs
132 } // namespace gui2
Abstract base class for all modal dialogs.
std::unique_ptr< ng::configure_engine > config_engine_
bool dialog_exit_hook(window &)
Dialog exit hook to bring up the difficulty dialog when starting a campaign.
std::pair< level_type::type, std::string > level_type_info
void on_mod_toggle(const std::string id, toggle_button *sender)
void display_games_of_type(level_type::type type, const std::string &level)
virtual void post_show() override
Actions to be taken after the window has been shown.
void set_active_mods(const std::vector< std::string > &val)
void show_description(const std::string &new_description)
virtual void pre_show() override
Actions to be taken before showing the window.
mp_create_game(saved_game &state, bool local_mode)
std::unique_ptr< mp_options_helper > options_manager_
std::vector< level_type_info > level_types_
DEFINE_SIMPLE_EXECUTE_WRAPPER(mp_create_game)
The execute function.
ng::create_engine create_engine_
void on_filter_change(const std::string &id, bool do_select)
std::vector< std::string > get_active_mods()
virtual const std::string & window_id() const override
The ID of the window to build.
int convert_to_game_filtered_index(const unsigned int initial_index)
field_bool * use_map_settings_
All fields are also in the normal field vector, but they need to be manually controlled as well so ad...
Specialized field class for boolean.
Definition: field.hpp:488
Template class to implement the generic field implementation.
Definition: field.hpp:245
The listbox class.
Definition: listbox.hpp:43
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:61
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
Various uncategorised dialogs.
Generic file dialog.