Author: alink
Date: Wed Apr 15 14:47:09 2009
New Revision: 34937

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34937&view=rev
Log:
Add new WML feature allowing to hide mainline units in help.
This will help to prevent double entries when campaign use similar names. 
It could also be used to simplify the help of campaign not using some types.
Syntax is [+units] [hide_help] types=Thief,Rogue..

Modified:
    trunk/src/unit_types.cpp
    trunk/src/unit_types.hpp

Modified: trunk/src/unit_types.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.cpp?rev=34937&r1=34936&r2=34937&view=diff
==============================================================================
--- trunk/src/unit_types.cpp (original)
+++ trunk/src/unit_types.cpp Wed Apr 15 14:47:09 2009
@@ -1046,6 +1046,10 @@
        return race_->id();
 }
 
+bool unit_type::hide_help() const {
+       return (hide_help_ || 
unit_type_data::types().hide_types().count(id_)>0);
+}
+
 // Allow storing "advances from" info for convenience in Help.
 void unit_type::add_advancesfrom(const std::string& unit_id)
 {
@@ -1171,6 +1175,12 @@
        }
 
        build_all(unit_type::CREATED);
+
+       if (const config &hide = cfg.child("hide_help")) {
+               std::vector<std::string> hide_types_list =
+                               utils::split(hide["types"]);
+               hide_types_.insert(hide_types_list.begin(), 
hide_types_list.end());
+       }
 }
 
 bool unit_type_data::unit_type_map_wrapper::unit_type_exists(const 
std::string& key) const

Modified: trunk/src/unit_types.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.hpp?rev=34937&r1=34936&r2=34937&view=diff
==============================================================================
--- trunk/src/unit_types.hpp (original)
+++ trunk/src/unit_types.hpp Wed Apr 15 14:47:09 2009
@@ -261,7 +261,7 @@
        const std::vector<unit_race::GENDER>& genders() const { return 
genders_; }
 
        const std::string& race() const;
-       bool hide_help() const { return hide_help_; }
+       bool hide_help() const;
 
     enum BUILD_STATUS {NOT_BUILT, CREATED, HELP_INDEX, WITHOUT_ANIMATIONS, 
FULL};
 
@@ -358,6 +358,8 @@
 
             void build_all(unit_type::BUILD_STATUS status) const;
 
+            const std::set<std::string>& hide_types() const {return 
hide_types_;}
+
         private:
             unit_type_map_wrapper();
                        unit_type_map_wrapper(const unit_type_map_wrapper &);
@@ -380,6 +382,9 @@
             mutable unit_type_map dummy_unit_map_;
             movement_type_map movement_types_;
             race_map races_;
+
+                       std::set<std::string> hide_types_;
+
             const config* unit_cfg_;
        };
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to