The Battle for Wesnoth  1.15.1+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 /** @file */
16 
17 #pragma once
18 
19 #include "config.hpp"
20 #include "gettext.hpp"
21 #include "utils/make_enum.hpp"
22 #include "game_version.hpp"
23 
24 #include <boost/optional.hpp>
25 
27 {
29  mp_game_settings(const config& cfg);
30 
31  config to_config() const;
32 
33  // The items returned while configuring the game
34 
35  std::string name;
36  std::string password;
37  std::string hash;
38  std::string mp_era;
39  std::string mp_era_name;
40  std::string mp_scenario;
41  std::string mp_scenario_name;
42  std::string mp_campaign;
43  std::vector<std::string> active_mods;
44  std::map<std::string, std::string> side_users;
45 
46  int num_turns;
57  bool fog_game;
62 
63  MAKE_ENUM(SAVED_GAME_MODE,
64  (NONE, "no")
65  (MIDGAME, "midgame")
66  (SCENARIO_START, "scenaro_start")
67  )
68 
69  SAVED_GAME_MODE saved_game;
70 
71  // HACK: The Create Game dialog has special knowledge of these strings
72  // and the fact that they're placed in the default (wesnoth)
73  // textdomain by xgettext due to the absence of a GETTEXT_DOMAIN
74  // declaration in this file. See gui2::dialogs::mp_create_game::pre_show().
75  MAKE_ENUM(RANDOM_FACTION_MODE,
76  (DEFAULT, N_("Independent"))
77  (NO_MIRROR, N_("No Mirror"))
78  (NO_ALLY_MIRROR, N_("No Ally Mirror"))
79  )
80 
81  RANDOM_FACTION_MODE random_faction_mode;
82 
84 
86  {
87  boost::optional<version_info> version;
88  boost::optional<version_info> min_version;
89 
90  std::string name;
91 
92  explicit addon_version_info(const config &);
93  void write(config &) const;
94  };
95 
96  std::map<std::string, addon_version_info> addons; // the key is the addon_id
97 
98  /**
99  * Takes a config with addon metadata (id, name, version, min_version) and adds
100  * it as a requirement for this game. It also updates min_version if there was
101  * already an entry for this addon_id.
102  */
103  void update_addon_requirements(const config& addon_cfg);
104 };
boost::optional< version_info > version
std::string mp_scenario
std::string random_faction_mode()
Definition: game.cpp:494
Interfaces for manipulating version numbers of engine, add-ons, etc.
std::string mp_campaign
boost::optional< version_info > min_version
std::string mp_era_name
Definitions for the interface to Wesnoth Markup Language (WML).
std::string mp_scenario_name
config to_config() const
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
Definition: parser.cpp:762
std::vector< std::string > active_mods
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 ...
MAKE_ENUM(SAVED_GAME_MODE,(NONE, "no")(MIDGAME, "midgame")(SCENARIO_START, "scenaro_start")) SAVED_GAME_MODE saved_game
Default, unset return value.
Definition: retval.hpp:31
std::map< std::string, addon_version_info > addons
#define N_(String)
Definition: gettext.hpp:99
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:68
Defines the MAKE_ENUM macro.