The Battle for Wesnoth  1.19.10+dev
mp_create_game.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2025
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 
23 
24 
25 namespace gui2
26 {
27 class toggle_button;
28 class listbox;
29 class menu_button;
30 
31 namespace dialogs
32 {
33 
35 {
36  typedef std::pair<level_type::type, std::string> level_type_info;
37 
38 public:
39  mp_create_game(saved_game& state, bool local_mode);
40 
41  /** The execute function. See @ref modal_dialog for more information. */
43 
44  /**
45  * @a presets needs to be a copy!
46  * Otherwise you'll get segfaults when clicking the Join button since it results in the configs getting reloaded.
47  */
48  static void quick_mp_setup(saved_game& state, const config presets);
49 
50 private:
51  virtual const std::string& window_id() const override;
52 
53  virtual void pre_show() override;
54 
55  virtual void post_show() override;
56 
58  std::unique_ptr<mp_options_helper> options_manager_;
59 
62 
63  std::vector<level_type_info> level_types_;
64 
65  void update_games_list();
66  void display_games_of_type(level_type::type type, const std::string& level);
67 
69  void regenerate_random_map();
70 
71  /**
72  * All fields are also in the normal field vector, but they need to be
73  * manually controlled as well so add the pointers here as well.
74  */
75 
85 
94 
97 
99 
100  template<typename widget>
101  void on_filter_change(const std::string& id, bool do_select);
102 
103  void on_game_select();
104  void on_tab_select();
105  void on_era_select();
106  void on_mod_toggle(const std::string& id, toggle_button* sender);
108 
109  std::vector<std::string> get_active_mods();
110  void set_active_mods(const std::vector<std::string>& val);
111 
112  void sync_with_depcheck();
113 
114  void show_description(const std::string& new_description);
115 
116  void update_details();
117  void update_map_settings();
118 
119  void reset_timer_settings();
120 
121  /**
122  * Dialog exit hook to bring up the difficulty dialog when starting a campaign.
123  * This only fires when the retval is OK (ie, creating a game), meaning it does not fire
124  * when loading a saved game.
125  */
126  bool dialog_exit_hook();
127 
128  int convert_to_game_filtered_index(const unsigned int initial_index);
129 
130  void load_game_callback();
131 
133 };
134 
135 } // namespace dialogs
136 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
Abstract base class for all modal dialogs.
std::pair< level_type::type, std::string > level_type_info
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.
void on_mod_toggle(const std::string &id, toggle_button *sender)
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)
static void quick_mp_setup(saved_game &state, const config presets)
presets needs to be a copy! Otherwise you'll get segfaults when clicking the Join button since it res...
std::vector< std::string > get_active_mods()
virtual const std::string & window_id() const override
The ID of the window to build.
bool dialog_exit_hook()
Dialog exit hook to bring up the difficulty dialog when starting a campaign.
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:41
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
Various uncategorised dialogs.
Generic file dialog.