The Battle for Wesnoth  1.17.21+dev
mp_create_game.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2023
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 #include "mp_game_settings.hpp"
25 
26 class config;
27 
28 namespace gui2
29 {
30 class toggle_button;
31 class listbox;
32 class menu_button;
33 
34 namespace dialogs
35 {
36 
38 {
39  typedef std::pair<level_type::type, std::string> level_type_info;
40 
41 public:
42  mp_create_game(saved_game& state, bool local_mode);
43 
44  /** The execute function. See @ref modal_dialog for more information. */
46 
47 private:
48  virtual const std::string& window_id() const override;
49 
50  virtual void pre_show(window& window) override;
51 
52  virtual void post_show(window& window) override;
53 
55  std::unique_ptr<ng::configure_engine> config_engine_;
56  std::unique_ptr<mp_options_helper> options_manager_;
57 
60 
61  std::vector<level_type_info> level_types_;
62 
63  void update_games_list();
64  void display_games_of_type(level_type::type type, const std::string& level);
65 
67  void regenerate_random_map();
68 
69  /**
70  * All fields are also in the normal field vector, but they need to be
71  * manually controlled as well so add the pointers here as well.
72  */
73 
83 
92 
95 
97 
98  template<typename widget>
99  void on_filter_change(const std::string& id, bool do_select);
100 
101  void on_game_select();
102  void on_tab_select();
103  void on_era_select();
104  void on_mod_toggle(const int index, toggle_button* sender);
106 
107  std::vector<std::string> get_active_mods();
108  void set_active_mods(const std::vector<std::string>& val);
109 
110  void sync_with_depcheck();
111 
112  void show_description(const std::string& new_description);
113 
114  void update_details();
115  void update_map_settings();
116 
117  void reset_timer_settings();
118 
119  /**
120  * Dialog exit hook to bring up the difficulty dialog when starting a campaign.
121  * This only fires when the retval is OK (ie, creating a game), meaning it does not fire
122  * when loading a saved game.
123  */
124  bool dialog_exit_hook(window&);
125 
126  int convert_to_game_filtered_index(const unsigned int initial_index);
127 
128  void load_game_callback();
129 
131 };
132 
133 } // namespace dialogs
134 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
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 display_games_of_type(level_type::type type, const std::string &level)
void set_active_mods(const std::vector< std::string > &val)
void show_description(const std::string &new_description)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
mp_create_game(saved_game &state, bool local_mode)
std::unique_ptr< mp_options_helper > options_manager_
std::vector< level_type_info > level_types_
void on_mod_toggle(const int index, toggle_button *sender)
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:489
Template class to implement the generic field implementation.
Definition: field.hpp:246
The listbox class.
Definition: listbox.hpp:46
A menu_button is a styled_widget to choose an element from a list of elements.
Definition: menu_button.hpp:62
Class for a toggle button.
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:67
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
Various uncategorised dialogs.
Generic file dialog.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:72