The Battle for Wesnoth  1.15.9+dev
mp_game_settings.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by Jörg Hinrichs
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 
17 #include "config.hpp"
18 #include "game_version.hpp"
19 #include "gettext.hpp"
20 #include "utils/make_enum.hpp"
21 #include <optional>
22 
24 {
26  mp_game_settings(const config& cfg);
27 
28  config to_config() const;
29 
30  // The items returned while configuring the game
31 
32  std::string name;
33  std::string password;
34  std::string hash;
35  std::string mp_era_name;
36  std::string mp_scenario;
37  std::string mp_scenario_name;
38  std::string mp_campaign;
39  std::map<std::string, std::string> side_users;
40 
41  int num_turns;
52  bool fog_game;
57 
58  MAKE_ENUM(SAVED_GAME_MODE,
59  (NONE, "no")
60  (MIDGAME, "midgame")
61  (SCENARIO_START, "scenaro_start")
62  )
63 
64  SAVED_GAME_MODE saved_game;
65 
66  // HACK: The Create Game dialog has special knowledge of these strings
67  // and the fact that they're placed in the default (wesnoth)
68  // textdomain by xgettext due to the absence of a GETTEXT_DOMAIN
69  // declaration in this file. See gui2::dialogs::mp_create_game::pre_show().
70  MAKE_ENUM(RANDOM_FACTION_MODE,
71  (DEFAULT, N_("Independent"))
72  (NO_MIRROR, N_("No Mirror"))
73  (NO_ALLY_MIRROR, N_("No Ally Mirror"))
74  )
75 
76  RANDOM_FACTION_MODE random_faction_mode;
77 
79 
81  {
82  std::string id;
83  std::string name;
84  std::string type;
85  };
86 
88  {
89  std::optional<version_info> version;
90  std::optional<version_info> min_version;
91  std::string name;
92  bool required;
93  std::vector<addon_content> content;
94 
95  explicit addon_version_info(const config &);
96  void write(config &) const;
97  };
98 
99  /** the key is the addon_id */
100  std::map<std::string, addon_version_info> addons;
101 
102  /**
103  * Takes a config with addon metadata (id, name, version, min_version) and adds
104  * it as a requirement for this game. It also updates min_version if there was
105  * already an entry for this addon_id.
106  */
107  void update_addon_requirements(const config& addon_cfg);
108 };
std::string mp_scenario
std::string random_faction_mode()
Definition: game.cpp:479
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:31
std::map< std::string, addon_version_info > addons
the key is the addon_id
#define N_(String)
Definition: gettext.hpp:100
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:60
Defines the MAKE_ENUM macro.
std::optional< version_info > min_version