The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
game_config_manager_tests.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2008 - 2025
3 by Pauli Nieminen <paniemin@cc.hut.fi>
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#define GETTEXT_DOMAIN "wesnoth-test"
17
19
20#include "config.hpp"
21#include "game_config_view.hpp"
22#include "config_cache.hpp"
23#include "filesystem.hpp"
24#include "font/font_config.hpp"
25#include "game_config.hpp"
26#include "gettext.hpp"
30#include "language.hpp"
31#include "units/types.hpp"
32#include "utils/general.hpp"
33
34#include "gui/gui.hpp"
35
36#include <clocale>
37
38namespace test_utils {
39
46
48 static void check_manager()
49 {
50 if(manager)
51 return;
53 }
54 public:
56 : cfg_()
61 {
62#ifdef _WIN32
63 setlocale(LC_ALL, "English");
64#else
65 std::setlocale(LC_ALL, "C");
66#endif
67 const std::string& intl_dir = filesystem::get_intl_dir();
68 translation::bind_textdomain("wesnoth", intl_dir.c_str(), "UTF-8");
69 translation::bind_textdomain("wesnoth-lib", intl_dir.c_str(), "UTF-8");
71
73 gui2::init();
74 gui2::switch_theme("default");
79 const std::vector<language_def>& languages = get_languages();
80 auto English = utils::ranges::find(languages, "en_US", &language_def::localename);
81 ::set_language(*English);
82
84
86 const hotkey::scope_changer hk_scope{hotkey::scope_game, false};
87
91 }
92
94 {
96 return manager->get_config();
97 }
98
100 {
101 return cfg_;
102 }
103 };
104
105
107
112
117
118}
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
config & mandatory_child(std::string_view key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
Definition config.cpp:362
void add_define(const std::string &define)
Add a entry to preproc defines map.
static config_cache & instance()
Get reference to the singleton object.
config get_config(const std::string &path, abstract_validator *validator=nullptr)
Gets a config object from given path.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
game_config_view merged_children_view(std::string_view key) const
this class is initialized once at game start put all initialization and wipe code in the methods here...
filesystem::binary_paths_manager paths_manager_
void set_config(const game_config_view &cfg)
Resets all data based on the provided config.
Definition types.cpp:1067
Definitions for the interface to Wesnoth Markup Language (WML).
Declarations for File-IO.
std::vector< language_def > get_languages(bool all)
Return a list of available translations.
Definition language.cpp:159
void init_textdomains(const game_config_view &cfg)
Initializes the list of textdomains from a configuration object.
Definition language.cpp:339
bool load_language_list()
Definition language.cpp:138
void set_language(const language_def &locale)
Definition language.cpp:259
std::string get_intl_dir()
bool load_font_config()
std::string path
void load_config(const config &v)
void init()
Initializes the GUI subsystems.
Definition gui.cpp:108
void switch_theme(const std::string &theme_id)
Set and activate the given gui2 theme.
Definition gui.cpp:149
constexpr uint32_t scope_game
void load_default_hotkeys(const game_config_view &cfg)
Registers all hotkeys present in this config.
const config & get_test_config_ref()
void bind_textdomain(const char *domain, const char *directory, const char *)
Definition gettext.cpp:479
void set_default_textdomain(const char *domain)
Definition gettext.cpp:487
auto find(Container &container, const Value &value, const Projection &projection={})
Definition general.hpp:213
The paths manager is responsible for recording the various paths that binary files may be located at.
void set_paths(const game_config_view &cfg)
std::string localename
Definition language.hpp:32
unit_type_data unit_types
Definition types.cpp:1499