[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src config.cpp config.hpp font.cpp game...
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src config.cpp config.hpp font.cpp game... |
Date: |
Mon, 18 Apr 2005 15:25:04 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 05/04/18 19:25:04
Modified files:
src : config.cpp config.hpp font.cpp game.cpp
game_events.cpp tstring.cpp tstring.hpp
Log message:
Fixed bug #12564 : cache being unnecessarily rebuilt on language change.
Made the cache be independant of language.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/config.cpp.diff?tr1=1.137&tr2=1.138&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/config.hpp.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.cpp.diff?tr1=1.135&tr2=1.136&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.231&tr2=1.232&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game_events.cpp.diff?tr1=1.143&tr2=1.144&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/tstring.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/tstring.hpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: wesnoth/src/config.cpp
diff -u wesnoth/src/config.cpp:1.137 wesnoth/src/config.cpp:1.138
--- wesnoth/src/config.cpp:1.137 Tue Apr 12 21:15:04 2005
+++ wesnoth/src/config.cpp Mon Apr 18 19:25:04 2005
@@ -1,4 +1,4 @@
-/* $Id: config.cpp,v 1.137 2005/04/12 21:15:04 ydirson Exp $ */
+/* $Id: config.cpp,v 1.138 2005/04/18 19:25:04 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -511,6 +511,20 @@
}
}
+void config::reset_translation() const
+{
+ for(string_map::const_iterator val = values.begin(); val !=
values.end(); ++val) {
+ val->second.reset_translation();
+ }
+
+ for(child_map::const_iterator list = children.begin(); list !=
children.end(); ++list) {
+ for(child_list::const_iterator child = list->second.begin();
+ child != list->second.end(); ++child) {
+ (*child)->reset_translation();
+ }
+ }
+}
+
bool operator==(const config& a, const config& b)
{
if (a.values != b.values)
Index: wesnoth/src/config.hpp
diff -u wesnoth/src/config.hpp:1.60 wesnoth/src/config.hpp:1.61
--- wesnoth/src/config.hpp:1.60 Sun Mar 27 23:06:16 2005
+++ wesnoth/src/config.hpp Mon Apr 18 19:25:04 2005
@@ -1,4 +1,4 @@
-/* $Id: config.hpp,v 1.60 2005/03/27 23:06:16 gruikya Exp $ */
+/* $Id: config.hpp,v 1.61 2005/04/18 19:25:04 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -124,6 +124,9 @@
//latter config object will clobber attributes in this one.
void append(const config& cfg);
+ //resets the translated values of all strings contained in this object
+ void reset_translation() const;
+
//all the attributes of this node.
string_map values;
Index: wesnoth/src/font.cpp
diff -u wesnoth/src/font.cpp:1.135 wesnoth/src/font.cpp:1.136
--- wesnoth/src/font.cpp:1.135 Sun Apr 17 21:37:43 2005
+++ wesnoth/src/font.cpp Mon Apr 18 19:25:04 2005
@@ -1,4 +1,4 @@
-/* $Id: font.cpp,v 1.135 2005/04/17 21:37:43 gruikya Exp $ */
+/* $Id: font.cpp,v 1.136 2005/04/18 19:25:04 gruikya Exp $ */
/* vim:set encoding=utf-8: */
/*
Copyright (C) 2003 by David White <address@hidden>
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.231 wesnoth/src/game.cpp:1.232
--- wesnoth/src/game.cpp:1.231 Sun Apr 17 18:53:10 2005
+++ wesnoth/src/game.cpp Mon Apr 18 19:25:04 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.231 2005/04/17 18:53:10 gruikya Exp $ */
+/* $Id: game.cpp,v 1.232 2005/04/18 19:25:04 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -260,7 +260,7 @@
void operator=(const game_controller&);
void read_game_cfg(preproc_map& defines, config& cfg, bool use_cache);
- void refresh_game_cfg();
+ void refresh_game_cfg(bool reset_translations=false);
void download_campaigns();
void upload_campaign(const std::string& campaign, network::connection
sock);
@@ -865,6 +865,7 @@
state_ = game_state();
state_.campaign_type = "tutorial";
state_.scenario = "tutorial";
+ defines_map_.clear();
defines_map_["TUTORIAL"] = preproc_define();
}
@@ -1239,6 +1240,7 @@
}
try {
+ defines_map_.clear();
defines_map_[state_.campaign_define] = preproc_define();
refresh_game_cfg();
@@ -1309,11 +1311,7 @@
::set_language(known_languages[res]);
preferences::set_language(known_languages[res].localename);
- //force a reload of configuration information
- const bool old_cache = use_caching_;
- use_caching_ = false;
- init_config();
- use_caching_ = old_cache;
+ refresh_game_cfg(true);
}
font::load_font_config();
@@ -1339,8 +1337,8 @@
str << "-" << i->first;
}
- std::string localename = get_locale().localename;
- str << "-lang_" << (localename.empty() ? "default" :
localename);
+ //std::string localename = get_locale().localename;
+ //str << "-lang_" << (localename.empty() ? "default" :
localename);
if(is_valid) {
const std::string& cache = get_cache_dir();
@@ -1413,15 +1411,19 @@
read(cfg, *stream);
}
-void game_controller::refresh_game_cfg()
+void game_controller::refresh_game_cfg(bool reset_translations)
{
try {
- if(old_defines_map_.empty() || defines_map_ !=
old_defines_map_) {
+ if(old_defines_map_.empty() || defines_map_ != old_defines_map_
|| reset_translations) {
units_data_.clear();
- game_config_.clear();
- read_game_cfg(defines_map_, game_config_, use_caching_);
+ if(!reset_translations) {
+ game_config_.clear();
+ read_game_cfg(defines_map_, game_config_,
use_caching_);
+ } else {
+ game_config_.reset_translation();
+ }
const config* const units = game_config_.child("units");
if(units != NULL) {
Index: wesnoth/src/game_events.cpp
diff -u wesnoth/src/game_events.cpp:1.143 wesnoth/src/game_events.cpp:1.144
--- wesnoth/src/game_events.cpp:1.143 Sun Apr 17 15:40:34 2005
+++ wesnoth/src/game_events.cpp Mon Apr 18 19:25:04 2005
@@ -1,4 +1,4 @@
-/* $Id: game_events.cpp,v 1.143 2005/04/17 15:40:34 gruikya Exp $ */
+/* $Id: game_events.cpp,v 1.144 2005/04/18 19:25:04 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -571,10 +571,10 @@
t_string win_string = cfg["victory_string"];
if(win_string.empty())
- win_string = _("Victory:");
+ win_string = t_string(N_("Victory:"), "wesnoth");
t_string lose_string = cfg["defeat_string"];
if(lose_string.empty())
- lose_string = _("Defeat:");
+ lose_string = t_string(N_("Defeat:"), "wesnoth");
t_string win_objectives;
t_string lose_objectives;
Index: wesnoth/src/tstring.cpp
diff -u wesnoth/src/tstring.cpp:1.6 wesnoth/src/tstring.cpp:1.7
--- wesnoth/src/tstring.cpp:1.6 Sun Apr 17 18:53:10 2005
+++ wesnoth/src/tstring.cpp Mon Apr 18 19:25:04 2005
@@ -1,4 +1,4 @@
-/* $Id: tstring.cpp,v 1.6 2005/04/17 18:53:10 gruikya Exp $ */
+/* $Id: tstring.cpp,v 1.7 2005/04/18 19:25:04 gruikya Exp $ */
/*
Copyright (C) 2004 by Philippe Plantier <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -480,6 +480,11 @@
return value_;
}
+void t_string::reset_translation() const
+{
+ translated_value_ = "";
+}
+
void t_string::add_textdomain(const std::string& name, const std::string& path)
{
LOG_CF << "Binding textdomain " << name << " to path " << path << "\n";
Index: wesnoth/src/tstring.hpp
diff -u wesnoth/src/tstring.hpp:1.5 wesnoth/src/tstring.hpp:1.6
--- wesnoth/src/tstring.hpp:1.5 Sun Apr 17 18:53:10 2005
+++ wesnoth/src/tstring.hpp Mon Apr 18 19:25:04 2005
@@ -1,4 +1,4 @@
-/* $Id: tstring.hpp,v 1.5 2005/04/17 18:53:10 gruikya Exp $ */
+/* $Id: tstring.hpp,v 1.6 2005/04/18 19:25:04 gruikya Exp $ */
/*
Copyright (C) 2004 by Philippe Plantier <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -80,6 +80,8 @@
const char* c_str() const;
const std::string& value() const;
+ void reset_translation() const;
+
static void add_textdomain(const std::string& name, const std::string&
path);
private:
bool translatable_;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src config.cpp config.hpp font.cpp game...,
Philippe Plantier <=