26 #define ERR_AC LOG_STREAM(err , log_addons_client)
27 #define LOG_AC LOG_STREAM(info, log_addons_client)
30 const std::string fallback_addon_icon =
"misc/blank-hex.png";
32 void resolve_deps_recursive(
const addons_list& addons,
const std::string& base_id, std::set<std::string>& dest)
34 addons_list::const_iterator it = addons.find(base_id);
35 if(it == addons.end()) {
36 LOG_AC <<
"resolve_deps_recursive(): " << base_id <<
" not in add-ons list\n";
40 const std::vector<std::string>& base_deps = it->second.depends;
42 if(base_deps.empty()) {
48 LOG_AC << dep <<
" depends upon itself; breaking circular dependency\n";
50 }
else if(dest.find(dep) != dest.end()) {
51 LOG_AC << dep <<
" already in dependency tree; breaking circular dependency\n";
57 resolve_deps_recursive(addons, dep, dest);
64 this->
id = cfg[
"name"].str();
65 this->
title = cfg[
"title"].str();
67 this->
icon = cfg[
"icon"].str();
68 this->
version = cfg[
"version"].str();
69 this->
author = cfg[
"author"].str();
70 this->
size = cfg[
"size"];
77 for(
const config& locale : locales) {
78 this->locales.push_back(locale[
"language"].str());
81 this->
core = cfg[
"core"].str();
85 this->
updated = cfg[
"timestamp"].to_time_t();
86 this->
created = cfg[
"original_timestamp"].to_time_t();
92 cfg[
"title"] = this->
title;
94 cfg[
"icon"] = this->
icon;
96 cfg[
"author"] = this->
author;
97 cfg[
"size"] = this->
size;
103 cfg.
add_child(
"translation")[
"language"] = locale_id;
106 cfg[
"core"] = this->
core;
110 cfg[
"timestamp"] = this->
updated;
111 cfg[
"original_timestamp"] = this->
created;
117 cfg[
"uploads"] = this->
uploads;
119 cfg[
"title"] = this->
title;
121 cfg[
"core"] = this->
core;
126 if(this->
title.empty()) {
138 ERR_AC <<
"add-on '" <<
id <<
"' doesn't have an icon path set" << std::endl;
139 ret = fallback_addon_icon;
142 ERR_AC <<
"add-on '" <<
id <<
"' has an icon which cannot be found: '" << ret <<
"'" << std::endl;
145 else if(ret.find(
"units/") != std::string::npos && ret.find_first_of(
'~') == std::string::npos) {
147 LOG_AC <<
"add-on '" <<
id <<
"' uses a unit baseframe as icon without TC/RC specifications\n";
148 ret +=
"~RC(magenta>red)";
158 return _(
"addon_type^Campaign");
160 return _(
"addon_type^Scenario");
162 return _(
"addon_type^SP/MP Campaign");
164 return _(
"addon_type^MP era");
166 return _(
"addon_type^MP faction");
168 return _(
"addon_type^MP map-pack");
170 return _(
"addon_type^MP scenario");
172 return _(
"addon_type^MP campaign");
174 return _(
"addon_type^MP modification");
176 return _(
"addon_type^Core");
178 return _(
"addon_type^Resources");
180 return _(
"addon_type^Other");
182 return _(
"addon_type^(unknown)");
188 std::set<std::string> deps;
189 resolve_deps_recursive(addons, this->
id, deps);
191 if(deps.find(this->id) != deps.end()) {
192 LOG_AC << this->
id <<
" depends upon itself; breaking circular dependency\n";
193 deps.erase(this->
id);
208 for(
const config& addon_cfg : addon_cfgs) {
210 if(dest.find(
id) != dest.end()) {
211 ERR_AC <<
"add-ons list has multiple entries for '" <<
id <<
"', not good; ignoring them" << std::endl;
214 dest[
id].read(addon_cfg);
215 dest[
id].order = order++;
child_itors child_range(const std::string &key)
std::string si_string(double input, bool base2, std::string unit)
Convert into a string with an SI-postfix.
void read_addons_list(const config &cfg, addons_list &dest)
GLuint GLdouble GLdouble GLint GLint order
an add-on that fits in no other category
GLuint GLuint GLsizei GLenum type
std::string size_display_string(double size)
Get a human-readable representation of the specified byte count.
static lg::log_domain log_addons_client("addons-client")
Definitions for the interface to Wesnoth Markup Language (WML).
std::pair< const_child_iterator, const_child_iterator > const_child_itors
void write_minimal(config &cfg) const
Write only minimal WML used for state tracking (_info.cfg) files.
bool exists(const image::locator &i_locator)
returns true if the given image actually exists, without loading it.
static UNUSEDNOWARN std::string _(const char *str)
std::string display_title() const
Get a title or automatic title for display.
std::map< std::string, addon_info > addons_list
config & add_child(const std::string &key)
Modification of the game for MP.
ADDON_TYPE get_addon_type(const std::string &str)
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::string str() const
Serializes the version number into string form.
Miscellaneous content/media (unit packs, terrain packs, music packs, etc.).
std::string display_icon() const
Get an icon path fixed for display (e.g.
void read(const config &cfg)
std::vector< std::string > locales
std::string display_type() const
Get an add-on type identifier for display in the user's language.
Multiplayer plain (no WML) map pack.
std::string replace(std::string str, const std::string &src, const std::string &dst)
Replace all instances of src in str with dst.
void write(config &cfg) const
std::string make_addon_title(const std::string &id)
Replaces underscores to dress up file or dirnames as add-on titles.
std::vector< std::string > depends
Standard logging facilities (interface).
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
std::string get_addon_type_string(ADDON_TYPE type)
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
std::set< std::string > resolve_dependencies(const addons_list &addons) const
Resolve an add-on's dependency tree in a recursive fashion.