mail[Wesnoth-commits] r10265 - in /trunk/src: unit.cpp unit.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by wesnoth on February 23, 2006 - 17:26:
Author: xan
Date: Thu Feb 23 17:25:32 2006
New Revision: 10265

URL: http://svn.gna.org/viewcvs/wesnoth?rev=10265&view=rev
Log:
added 'image' key to single unit wml.

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

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=10265&r1=10264&r2=10265&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Thu Feb 23 17:25:32 2006
@@ -71,7 +71,7 @@
        state_(STATE_NORMAL),
        moves_(0), user_end_turn_(false), facingLeft_(true),
        resting_(false), hold_position_(false), recruit_(false),
-       guardian_(false), upkeep_(UPKEEP_FREE),anim_(NULL),
+       guardian_(false), upkeep_(UPKEEP_FREE),anim_(NULL),user_image_(""),
        unit_halo_(0),unit_anim_halo_(0)
 {
        read(data,cfg);
@@ -105,7 +105,7 @@
               attacks_(type_->attacks()),
               backupAttacks_(type_->attacks()),
                guardian_(false), upkeep_(UPKEEP_FULL_PRICE),
-               unrenamable_(false),anim_(NULL),unit_halo_(0),
+               unrenamable_(false),anim_(NULL),unit_halo_(0),user_image_(""),
               unit_anim_halo_(0)
 {
        //dummy units used by the 'move_unit_fake' command don't need to have 
a side.
@@ -147,7 +147,7 @@
        modifications_(u.modifications_),
        traitsDescription_(u.traitsDescription_),
        guardian_(false), upkeep_(u.upkeep_),
-       unrenamable_(u.unrenamable_),anim_(NULL),unit_halo_(0),
+       
unrenamable_(u.unrenamable_),anim_(NULL),unit_halo_(0),user_image_(u.user_image_),
        unit_anim_halo_(0)
 {
        validate_side(side_);
@@ -805,6 +805,7 @@
        if(cfg["generate_description"] == "yes") {
                description_ = type_->generate_description();
        }
+       user_image_ = cfg["image"];
 
        underlying_description_ = cfg["description"];
        if(description_.empty()) {
@@ -934,6 +935,7 @@
        cfg["user_description"] = description_;
        cfg["description"] = underlying_description_;
        cfg["unit_description"] = custom_unit_description_;
+       cfg["image"] = user_image_;
 
        cfg["traits_description"] = traitsDescription_;
 
@@ -1003,7 +1005,11 @@
 const std::string& unit::image() const
 {
        switch(state_) {
-               case STATE_NORMAL: return type_->image();
+               case STATE_NORMAL:
+                       if(! user_image_.empty()) {
+                               return user_image_;
+                       }
+                       return type_->image();
                case STATE_WALKING: 
                case STATE_DEFENDING: {
                        const std::string& res = 
anim_->get_current_frame().image;

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=10265&r1=10264&r2=10265&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Thu Feb 23 17:25:32 2006
@@ -254,6 +254,7 @@
        bool unrenamable_;
 
        unit_animation *anim_;
+       std::string user_image_;
 
        void reset_modifications();
        void apply_modifications();




Related Messages


Powered by MHonArc, Updated Thu Feb 23 19:20:27 2006