The Battle for Wesnoth  1.17.0-dev
mp_game_settings.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2021
3  by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
4  Copyright (C) 2003 by David White <dave@whitevine.net>
5  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY.
13 
14  See the COPYING file for more details.
15 */
16 
17 #pragma once
18 
19 #include "config.hpp"
20 #include "game_version.hpp"
21 #include "gettext.hpp"
22 #include "utils/make_enum.hpp"
23 #include <optional>
24 
26 {
28  mp_game_settings(const config& cfg);
29 
30  config to_config() const;
31 
32  // The items returned while configuring the game
33 
34  std::string name;
35  std::string password;
36  std::string hash;
37  std::string mp_era_name;
38  std::string mp_scenario;
39  std::string mp_scenario_name;
40  std::string mp_campaign;
41  std::map<std::string, std::string> side_users;
42 
43  int num_turns;
54  bool fog_game;
59 
60  MAKE_ENUM(SAVED_GAME_MODE,
61  (NONE, "no")
62  (MIDGAME, "midgame")
63  (SCENARIO_START, "scenaro_start")
64  )
65 
66  SAVED_GAME_MODE saved_game;
67 
68  // HACK: The Create Game dialog has special knowledge of these strings
69  // and the fact that they're placed in the default (wesnoth)
70  // textdomain by xgettext due to the absence of a GETTEXT_DOMAIN
71  // declaration in this file. See gui2::dialogs::mp_create_game::pre_show().
72  MAKE_ENUM(RANDOM_FACTION_MODE,
73  (DEFAULT, N_("Independent"))
74  (NO_MIRROR, N_("No Mirror"))
75  (NO_ALLY_MIRROR, N_("No Ally Mirror"))
76  )
77 
78  RANDOM_FACTION_MODE random_faction_mode;
79 
81 
83  {
84  std::string id;
85  std::string name;
86  std::string type;
87  };
88 
90  {
91  std::optional<version_info> version;
92  std::optional<version_info> min_version;
93  std::string name;
94  bool required;
95  std::vector<addon_content> content;
96 
97  explicit addon_version_info(const config &);
98  void write(config &) const;
99  };
100 
101  /** the key is the addon_id */
102  std::map<std::string, addon_version_info> addons;
103 
104  /**
105  * Takes a config with addon metadata (id, name, version, min_version) and adds
106  * it as a requirement for this game. It also updates min_version if there was
107  * already an entry for this addon_id.
108  */
109  void update_addon_requirements(const config& addon_cfg);
110 };
std::string mp_scenario
std::string random_faction_mode()
Definition: game.cpp:485
Interfaces for manipulating version numbers of engine, add-ons, etc.
std::string mp_campaign
std::string mp_era_name
Definitions for the interface to Wesnoth Markup Language (WML).
std::string mp_scenario_name
config to_config() const
void update_addon_requirements(const config &addon_cfg)
Takes a config with addon metadata (id, name, version, min_version) and adds it as a requirement for ...
std::vector< addon_content > content
MAKE_ENUM(SAVED_GAME_MODE,(NONE, "no")(MIDGAME, "midgame")(SCENARIO_START, "scenaro_start")) SAVED_GAME_MODE saved_game
std::optional< version_info > version
Default, unset return value.
Definition: retval.hpp:32
std::map< std::string, addon_version_info > addons
the key is the addon_id
#define N_(String)
Definition: gettext.hpp:101
std::map< std::string, std::string > side_users
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
Defines the MAKE_ENUM macro.
std::optional< version_info > min_version