wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src help.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src help.cpp
Date: Sat, 30 Oct 2004 17:45:18 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/10/30 21:39:48

Modified files:
        src            : help.cpp 

Log message:
        Also generate on the fly terrain help topics.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/help.cpp.diff?tr1=1.43&tr2=1.44&r1=text&r2=text

Patches:
Index: wesnoth/src/help.cpp
diff -u wesnoth/src/help.cpp:1.43 wesnoth/src/help.cpp:1.44
--- wesnoth/src/help.cpp:1.43   Sat Oct 30 20:20:53 2004
+++ wesnoth/src/help.cpp        Sat Oct 30 21:39:48 2004
@@ -849,6 +849,45 @@
        return NO_DESCRIPTION;
 }
 
+struct terrain_topic_generator: topic_generator
+{
+       terrain_topic_generator(terrain_type const &t): type(t) {}
+       terrain_type type;
+       virtual std::string operator()() const {
+               std::stringstream ss;
+               ss << "<img>src='terrain/" << type.symbol_image() << 
".png'</img>\n\n";
+               if (type.is_alias()) {
+                       const std::string aliased_terrains = type.type();
+                       std::stringstream alias_ss;
+                       for (std::string::const_iterator it = 
aliased_terrains.begin();
+                                it != aliased_terrains.end(); it++) {
+                               const gamemap::TERRAIN t = *it;
+                               const std::string &alias_name = 
map->get_terrain_info(t).name();
+                               alias_ss << "<ref>text='" << escape(alias_name) 
<< "' dst='"
+                                        << escape(std::string("terrain_") + t) 
<< "'</ref>";
+                               if (it + 2 == aliased_terrains.end())
+                                       alias_ss << " " << _("or") << " ";
+                               else if (it + 1 != aliased_terrains.end())
+                                       alias_ss << ", ";
+                       }
+                       string_map sm;
+                       sm["terrains"] = alias_ss.str();
+                       ss << 
config::interpolate_variables_into_string(string_table["terrain_acts_as"], &sm)
+                          << ".";
+                       if (aliased_terrains.size() > 1)
+                               ss << " " << 
string_table["best_terrain_chosen"] << ".";
+                       ss << "\n\n";
+               }
+               if (type.is_keep())
+                       ss << string_table["terrain_is_keep"] << ".\n\n";
+               if (type.is_castle())
+                       ss << string_table["terrain_is_castle"] << ".\n\n";
+               if (type.gives_healing())
+                       ss << string_table["terrain_gives_healing"] << ".\n\n";
+               return ss.str();
+       }
+};
+
 std::vector<topic> generate_terrains_topics() {
        std::vector<topic> res;
        std::vector<gamemap::TERRAIN> show_info_about;
@@ -872,45 +911,8 @@
        for (std::vector<gamemap::TERRAIN>::const_iterator terrain_it = 
show_info_about.begin();
                 terrain_it != show_info_about.end(); terrain_it++) {
                const terrain_type& info = map->get_terrain_info(*terrain_it);
-               //const std::string &name = string_table[info.name()];
                const std::string &name = info.name();
-               std::stringstream ss;
-               ss << "<img>src='terrain/" << info.symbol_image() << 
".png'</img>\n\n";
-               if (info.is_alias()) {
-                       const std::string aliased_terrains = info.type();
-                       std::stringstream alias_ss;
-                       for (std::string::const_iterator it = 
aliased_terrains.begin();
-                                it != aliased_terrains.end(); it++) {
-                               const gamemap::TERRAIN t = *it;
-                               const std::string &alias_name = 
map->get_terrain_info(t).name();
-                               alias_ss << "<ref>text='" << escape(alias_name) 
<< "' dst='"
-                                                << 
escape(std::string("terrain_") + t) << "'</ref>";
-                               if (it + 2 == aliased_terrains.end()) {
-                                       alias_ss << " " << _("or") << " ";
-                               }
-                               else if (it + 1 != aliased_terrains.end()) {
-                                       alias_ss << ", ";
-                               }
-                       }
-                       string_map sm;
-                       sm["terrains"] = alias_ss.str();
-                       ss << 
config::interpolate_variables_into_string(string_table["terrain_acts_as"], &sm)
-                          << ".";
-                       if (aliased_terrains.size() > 1) {
-                               ss << " " << 
string_table["best_terrain_chosen"] << ".";
-                       }
-                       ss << "\n\n";
-               }
-               if (info.is_keep()) {
-                       ss << string_table["terrain_is_keep"] << ".\n\n";
-               }
-               if (info.is_castle()) {
-                       ss << string_table["terrain_is_castle"] << ".\n\n";
-               }
-               if (info.gives_healing()) {
-                       ss << string_table["terrain_gives_healing"] << ".\n\n";
-               }
-               topic t(name, std::string("terrain_") + *terrain_it, ss.str());
+               topic t(name, std::string("terrain_") + *terrain_it, new 
terrain_topic_generator(info));
                res.push_back(t);
        }
        return res;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]