Author: alink
Date: Sat Jul 12 21:00:11 2008
New Revision: 27947
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27947&view=rev
Log:
Fix broken hyperlinks to special attacks in gameplay sections of the help for
non-english languages.
Modified:
trunk/src/generate_report.cpp
trunk/src/help.cpp
trunk/src/unit_abilities.cpp
trunk/src/unit_types.hpp
Modified: trunk/src/generate_report.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/generate_report.cpp?rev=27947&r1=27946&r2=27947&view=diff
==============================================================================
--- trunk/src/generate_report.cpp (original)
+++ trunk/src/generate_report.cpp Sat Jul 12 21:00:11 2008
@@ -323,15 +323,15 @@
res.add_text(str,tooltip);
- const std::vector<std::string>& specials =
at_it->special_tooltips();
+ const std::vector<t_string>& specials =
at_it->special_tooltips();
if(! specials.empty()) {
- for(std::vector<std::string>::const_iterator
sp_it = specials.begin(); sp_it != specials.end(); ++sp_it) {
+ for(std::vector<t_string>::const_iterator sp_it
= specials.begin(); sp_it != specials.end(); ++sp_it) {
str << "<166,146,117> ";
- str << gettext(sp_it->c_str());
+ str << (*sp_it);
str<<"\n";
++sp_it;
- tooltip << gettext(sp_it->c_str());
+ tooltip << (*sp_it);
}
res.add_text(str,tooltip);
}
Modified: trunk/src/help.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/help.cpp?rev=27947&r1=27946&r2=27947&view=diff
==============================================================================
--- trunk/src/help.cpp (original)
+++ trunk/src/help.cpp Sat Jul 12 21:00:11 2008
@@ -976,7 +976,9 @@
if (generator == "abilities") {
res = generate_ability_topics(sort_generated);
} else if (generator == "weapon_specials") {
+ int t = SDL_GetTicks();
res = generate_weapon_special_topics(sort_generated);
+ std::cout << SDL_GetTicks() - t << " SPEC\n";
} else {
std::vector<std::string> parts = utils::split(generator, ':',
utils::STRIP_SPACES);
if (parts[0] == "units" && parts.size()>1) {
@@ -1049,66 +1051,73 @@
{
std::vector<topic> topics;
+
+ std::map<std::string, std::string> special_name;
std::map<std::string, std::string> special_description;
std::map<std::string, std::set<std::string> > special_units;
+
for(unit_type_data::unit_type_map::const_iterator i =
unit_type_data::types().begin();
i != unit_type_data::types().end(); i++) {
const unit_type &type = (*i).second;
// Only show the weapon special if we find it on a unit that
// detailed description should be shown about.
- if (description_type(type) == FULL_DESCRIPTION) {
- std::vector<attack_type> attacks = type.attacks();
- for (std::vector<attack_type>::const_iterator it =
attacks.begin();
- it != attacks.end(); it++) {
-
- std::vector<std::string> specials =
(*it).special_tooltips(true);
- std::vector<std::string>::iterator sp_it;
- for (sp_it = specials.begin(); sp_it !=
specials.end(); ++sp_it)
- {
- std::string special = *sp_it;
- ++sp_it;
-
- //some abilities like plague can be in
the form ability(argument)
- //make sure we cut off the argument
-
special.erase(std::find(special.begin(),special.end(),'('),special.end());
- if (special != "") {
- if
(special_description.find(special) == special_description.end()) {
- std::string description
= *sp_it;
- const size_t colon_pos
= description.find(':');
- if (colon_pos !=
std::string::npos) {
- // Remove the
first colon and the following newline.
-
description.erase(0, colon_pos + 2);
- }
-
special_description[special] = description;
- }
-
- if (!type.hide_help()) {
- //add a link in the
list of units having this special
- std::string type_name =
type.type_name();
- std::string ref_id =
unit_prefix + type.id();
- //we put the translated
name at the beginning of the hyperlink,
- //so the automatic
alphabetic sorting of std::set can use it
- std::string link =
"<ref>text='" + escape(type_name) + "' dst='" + escape(ref_id) + "'</ref>";
-
special_units[special].insert(link);
- }
+ if (description_type(type) != FULL_DESCRIPTION)
+ continue;
+
+ std::vector<attack_type> attacks = type.attacks();
+ for (std::vector<attack_type>::const_iterator it =
attacks.begin();
+ it != attacks.end(); it++) {
+
+ std::vector<t_string> specials =
(*it).special_tooltips(true);
+ for (std::vector<t_string>::iterator sp_it =
specials.begin();
+ sp_it != specials.end() && sp_it+1 !=
specials.end(); ++++sp_it)
+ {
+ // use untranslated name to have universal
topic id
+ const std::string special = sp_it->base_str();
+
+ //some abilities like plague can be in the form
ability(argument)
+ //make sure we cut off the argument
+ //NOTE: really? Seems to be used in id not name
+ //
special.erase(std::find(special.begin(),special.end(),'('),special.end());
+ if (special.empty())
+ continue;
+
+ if (special_description.find(special) ==
special_description.end()) {
+ special_name[special] = *(sp_it);
+ std::string description = *(sp_it+1);
+ const size_t colon_pos =
description.find(':');
+ if (colon_pos != std::string::npos) {
+ // Remove the first colon and
the following newline.
+ description.erase(0, colon_pos
+ 2);
}
+ special_description[special] =
description;
}
- }
- }
- }
-
- for (std::map<std::string, std::string>::iterator s =
special_description.begin(); s != special_description.end(); s++) {
- std::string name = utils::capitalize(gettext(s->first.c_str()));
+
+ if (!type.hide_help()) {
+ //add a link in the list of units
having this special
+ std::string type_name =
type.type_name();
+ std::string ref_id = unit_prefix +
type.id();
+ //we put the translated name at the
beginning of the hyperlink,
+ //so the automatic alphabetic sorting
of std::set can use it
+ std::string link = "<ref>text='" +
escape(type_name) + "' dst='" + escape(ref_id) + "'</ref>";
+ special_units[special].insert(link);
+ }
+ }
+ }
+ }
+
+ for (std::map<std::string, std::string>::iterator s =
special_name.begin();
+ s != special_name.end(); s++) {
std::string id = "weaponspecial_" + s->first;
std::stringstream text;
- text << s->second; //description
+ text << special_description[s->first];
text << "\n\n" << _("<header>text='Units having this special
attack'</header>") << "\n";
std::set<std::string>& units = special_units[s->first];
for (std::set<std::string>::iterator u = units.begin(); u !=
units.end();u++) {
text << (*u) << "\n";
}
- topics.push_back( topic(name, id, text.str()) );
+ topics.push_back( topic(s->second, id, text.str()) );
}
if (sort_generated)
@@ -1368,15 +1377,15 @@
// Show this attack's special, if it has any.
Cross
// reference it to the section describing the
// special.
- std::vector<std::string> specials =
attack_it->special_tooltips(true);
+ std::vector<t_string> specials =
attack_it->special_tooltips(true);
if(!specials.empty())
{
std::string lang_special = "";
- std::vector<std::string>::iterator
sp_it;
+ std::vector<t_string>::iterator sp_it;
for (sp_it = specials.begin(); sp_it !=
specials.end(); sp_it++) {
const std::string ref_id =
std::string("weaponspecial_")
- + (*sp_it);
- lang_special =
gettext(sp_it->c_str());
+ + sp_it->base_str();
+ lang_special = (*sp_it);
attack_ss << "<ref>dst='" <<
escape(ref_id)
<< "' text='"
<< escape(lang_special) << "'</ref>";
if((sp_it + 1) !=
specials.end() && (sp_it + 2) != specials.end())
Modified: trunk/src/unit_abilities.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_abilities.cpp?rev=27947&r1=27946&r2=27947&view=diff
==============================================================================
--- trunk/src/unit_abilities.cpp (original)
+++ trunk/src/unit_abilities.cpp Sat Jul 12 21:00:11 2008
@@ -563,10 +563,10 @@
}
return res;
}
-std::vector<std::string> attack_type::special_tooltips(bool force) const
+std::vector<t_string> attack_type::special_tooltips(bool force) const
{
// log_scope("special_tooltips");
- std::vector<std::string> res;
+ std::vector<t_string> res;
const config* specials = cfg_.child("specials");
if (!specials) return res;
@@ -576,13 +576,13 @@
for (config::child_list::const_iterator j = i->second.begin(),
j_end = i->second.end(); j != j_end; ++j) {
if (force || special_active(**j, true)) {
- std::string const &name = (**j)["name"];
+ t_string const &name = (**j)["name"];
if (!name.empty()) {
res.push_back(name);
res.push_back((**j)["description"]);
}
} else {
- std::string const &name =
(**j)["name_inactive"];
+ t_string const &name = (**j)["name_inactive"];
if (!name.empty()) {
res.push_back(name);
res.push_back((**j)["description_inactive"]);
Modified: trunk/src/unit_types.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.hpp?rev=27947&r1=27946&r2=27947&view=diff
==============================================================================
--- trunk/src/unit_types.hpp (original)
+++ trunk/src/unit_types.hpp Sat Jul 12 21:00:11 2008
@@ -54,7 +54,7 @@
bool get_special_bool(const std::string& special,bool force=false)
const;
unit_ability_list get_specials(const std::string& special) const;
- std::vector<std::string> special_tooltips(bool force=false) const;
+ std::vector<t_string> special_tooltips(bool force=false) const;
std::string weapon_specials(bool force=false) const;
void set_specials_context(const gamemap::location& aloc,const
gamemap::location& dloc,
const unit_map* unitmap,
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits