Commit c1374ba032 for some reason reverted
commits 4a44369d8a and
91cbc9aff1.
This commit is contained in:
Ignacio R. Morelle 2014-02-19 23:10:39 -03:00
parent c1374ba032
commit b7848663bd
11 changed files with 43 additions and 16 deletions

View file

@ -7,7 +7,8 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=Default
id=Default
name= _ "theme^Default"
description= _ "Default theme."
#define DEFAULT_FONT_NORMAL

View file

@ -7,7 +7,8 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=editor
id=editor
name= _ "theme^Editor"
hidden=yes
#define DEFAULT_EDITOR_FONT_NORMAL

View file

@ -5,7 +5,7 @@
#
[theme]
name=null
id=null
hidden=yes
[resolution]
width=1

View file

@ -18,7 +18,8 @@
{themes/macros.cfg}
[theme]
name=Pandora
id=Pandora
name= _ "theme^Pandora"
description= _ "800x480 theme optimized for Pandora devices."
[resolution]

View file

@ -7,7 +7,8 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=UnitBox
id=UnitBox
name= _ "theme^UnitBox"
description= _ "Experimental work-in-progress replacement for the default theme."
#define DEFAULT_FONT_NORMAL

View file

@ -7,7 +7,8 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=Widescreen
id=Widescreen
name= _ "theme^Widescreen"
description= _ "Experimental theme optimized for widescreen resolutions."
#define DEFAULT_FONT_NORMAL

View file

@ -331,12 +331,20 @@ const config& controller_base::get_theme(const config& game_config, std::string
{
if (theme_name.empty()) theme_name = preferences::theme();
if (const config &c = game_config.find_child("theme", "name", theme_name))
if (const config &c = game_config.find_child("theme", "id", theme_name))
return c;
// Themes created for version 1.11.9 and earlier use name= for
// untranslatable ids.
// TODO: remove support for this in 1.13.x (1.13.2?).
if (const config &c = game_config.find_child("theme", "name", theme_name)) {
ERR_DP << "Theme '" << theme_name << "' uses [theme] name= instead of id= to specify its id; this usage is deprecated and will be removed in version 1.13.x.\n";
return c;
}
ERR_DP << "Theme '" << theme_name << "' not found. Trying the default theme.\n";
if (const config &c = game_config.find_child("theme", "name", "Default"))
if (const config &c = game_config.find_child("theme", "id", "Default"))
return c;
ERR_DP << "Default theme not found.\n";

View file

@ -1445,7 +1445,7 @@ bool show_theme_dialog(display& disp)
gui2::ttheme_list dlg(themes);
for(size_t k = 0; k < themes.size(); ++k) {
if(themes[k].name == preferences::theme()) {
if(themes[k].id == preferences::theme()) {
dlg.set_selected_index(static_cast<int>(k));
}
}
@ -1454,7 +1454,7 @@ bool show_theme_dialog(display& disp)
const int action = dlg.selected_index();
if(action >= 0){
preferences::set_theme(themes[action].name);
preferences::set_theme(themes[action].id);
// FIXME: it would be preferable for the new theme to take effect
// immediately.
return 1;

View file

@ -69,7 +69,12 @@ void ttheme_list::pre_show(CVideo& /*video*/, twindow& window)
std::map<std::string, string_map> data;
string_map column;
column["label"] = t.name;
std::string theme_name = t.name;
if(theme_name.empty()) {
theme_name = t.id;
}
column["label"] = theme_name;
data.insert(std::make_pair("name", column));
column["label"] = t.description;
data.insert(std::make_pair("description", column));

View file

@ -915,9 +915,16 @@ void theme::set_known_themes(const config* cfg)
BOOST_FOREACH(const config &thm, cfg->child_range("theme"))
{
std::string thm_name = thm["name"];
if (!thm["hidden"].to_bool(false))
known_themes[thm_name] = thm;
std::string thm_id = thm["id"];
if (thm_id.empty() && thm.has_attribute("name")) {
thm_id = thm["name"].str();
ERR_DP << "Theme '" << thm_id << "' uses [theme] name= instead of id= to specify its id; this usage is deprecated and will be removed in version 1.13.x.\n";
}
if (!thm["hidden"].to_bool(false)) {
known_themes[thm_id] = thm;
}
}
}
@ -930,7 +937,8 @@ std::vector<theme_info> theme::get_known_themes()
++i)
{
res.push_back(theme_info());
res.back().name = i->first;
res.back().id = i->first;
res.back().name = i->second["name"].t_str();
res.back().description = i->second["description"].t_str();
}

View file

@ -28,7 +28,8 @@ typedef struct { size_t x1,y1,x2,y2; } _rect;
struct theme_info
{
std::string name;
std::string id;
t_string name;
t_string description;
};