The Battle for Wesnoth  1.19.5+dev
addon_utils.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Copyright (C) 2013 - 2015 by Iris Morelle <shadowm2006@gmail.com>
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 <string>
20 #include <map>
21 #include "game_version.hpp"
22 
23 class config;
24 
25 namespace campaignd {
26 
27 /**
28  * Markup characters recognized by GUI1 code.
29  *
30  * These must be the same as the constants defined in marked-up_text.cpp.
31  */
32 extern const std::string illegal_markup_chars;
33 
34 inline bool is_text_markup_char(char c)
35 {
36  return illegal_markup_chars.find(c) != std::string::npos;
37 }
38 
39 /**
40  * Format a feedback URL for an add-on.
41  *
42  * @param format The format string for the URL, presumably obtained
43  * from the add-ons server identification.
44  *
45  * @param params The URL format parameters table.
46  *
47  * @return A string containing a feedback URL or an empty string if that
48  * is not possible (e.g. empty or invalid @a format, empty
49  * @a params table, or a result that is identical in content to
50  * the @a format suggesting that the @a params table contains
51  * incorrect data).
52  */
53 std::string format_addon_feedback_url(const std::string& format, const config& params);
54 
55 void support_translation(config& addon, const std::string& locale_id);
56 
57 /**
58  * Scans an add-on archive directory for translations.
59  *
60  * Any subdirectories of @a base_dir containing a subdirectory named
61  * 'LC_MESSAGES' are assumed to be translation dirs. The names of the
62  * subdirectories thus located are recorded into the @a addon WML node in
63  * [translation] children nodes like the following (comments included for
64  * documentation purposes):
65  *
66  * @verbatim
67  * [translation]
68  * language="es" # translations/es/LC_MESSAGES/
69  * [/translation]
70  * [translation]
71  * language="ja" # translations/ja/LC_MESSAGES/
72  * [/translation]
73  * @endverbatim
74  */
75 void find_translations(const config& base_dir, config& addon);
76 
77 /**
78  * Adds a COPYING.txt file with the full text of the GNU GPL to an add-on.
79  *
80  * This only has an effect if the add-on archive @a cfg does not already
81  * contain an equivalent file ('copying.txt', 'COPYING', etc.).
82  */
83 void add_license(config& cfg);
84 
85 std::map<version_info, config> get_version_map(config& addon);
86 
87 bool data_apply_removelist(config& data, const config& removelist);
88 void data_apply_addlist(config& data, const config& addlist);
89 
90 }
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
Interfaces for manipulating version numbers of engine, add-ons, etc.
std::string format_addon_feedback_url(const std::string &format, const config &params)
Format a feedback URL for an add-on.
Definition: addon_utils.cpp:64
void data_apply_addlist(config &data, const config &addlist)
const std::string illegal_markup_chars
Markup characters recognized by GUI1 code.
Definition: addon_utils.cpp:62
void find_translations(const config &base_dir, config &addon)
Scans an add-on archive directory for translations.
bool data_apply_removelist(config &data, const config &removelist)
bool is_text_markup_char(char c)
Definition: addon_utils.hpp:34
void support_translation(config &addon, const std::string &locale_id)
Definition: addon_utils.cpp:94
std::map< version_info, config > get_version_map(config &addon)
void add_license(config &cfg)
Adds a COPYING.txt file with the full text of the GNU GPL to an add-on.
std::string_view data
Definition: picture.cpp:178
mock_char c