mail[Wesnoth-commits] r13946 - in /trunk/src: halo.hpp unit.cpp unit_display.cpp unit_frame.cpp unit_frame.hpp unit_types.cpp


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

Header


Content

Posted by jeremy . rosen on October 14, 2006 - 01:08:
Author: boucman
Date: Sat Oct 14 01:07:34 2006
New Revision: 13946

URL: http://svn.gna.org/viewcvs/wesnoth?rev=13946&view=rev
Log:
better use of image::locator for units. This will be improved to be used in 
halos at a later stage, porting to 1.2 will be done on the performance 
branch...

Modified:
    trunk/src/halo.hpp
    trunk/src/unit.cpp
    trunk/src/unit_display.cpp
    trunk/src/unit_frame.cpp
    trunk/src/unit_frame.hpp
    trunk/src/unit_types.cpp

Modified: trunk/src/halo.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/halo.hpp?rev=13946&r1=13945&r2=13946&view=diff
==============================================================================
--- trunk/src/halo.hpp (original)
+++ trunk/src/halo.hpp Sat Oct 14 01:07:34 2006
@@ -16,6 +16,7 @@
 
 class display;
 #include "animated.hpp"
+#include "image.hpp"
 
 #include <string>
 

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=13946&r1=13945&r2=13946&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sat Oct 14 01:07:34 2006
@@ -1623,7 +1623,7 @@
 
        // add a blink on damage effect
        int anim_time = anim_->get_last_frame_time();
-       const std::string my_image = anim_->get_last_frame().image();
+       const image::locator my_image = anim_->get_last_frame().image();
        if(damage) {
                
anim_->add_frame(anim_time,unit_frame(my_image,anim_time,anim_time+100,"1.0","",display::rgb(255,0,0),"0.5:50,0.0:50"));
                anim_time+=100;
@@ -1777,7 +1777,7 @@
                anim_ = NULL;
        }
        anim_ =  new 
death_animation(die_animation(disp,loc,fighting_animation::KILL,attack,secondary_attack));
-       std::string tmp_image = anim_->get_last_frame().image();
+       image::locator tmp_image = anim_->get_last_frame().image();
        int anim_time =anim_->get_last_frame_time();
        
anim_->add_frame(0,unit_frame(tmp_image,anim_time,anim_time+600,"1~0:600"));
        anim_->add_frame(anim_time+600);
@@ -1867,13 +1867,13 @@
        const double submerge = is_flying() ? 0.0 : 
map.get_terrain_info(terrain).unit_submerge() * disp.zoom();
        const int height_adjust = is_flying() ? 0 : 
int(map.get_terrain_info(terrain).unit_height_adjust() * disp.zoom());
 
-       std::string image_name;
        unit_frame current_frame;
        if(anim_->animation_finished()) current_frame = 
anim_->get_last_frame();
        else if(anim_->get_first_frame_time() > anim_->get_animation_time()) 
current_frame = anim_->get_first_frame();
        else current_frame = anim_->get_current_frame();
 
-       image_name = current_frame.image();
+       image::locator loc;
+       loc = current_frame.image();
        double tmp_offset = current_frame.offset(anim_->get_animation_time());
        if(tmp_offset == -20.0) tmp_offset = offset_;
        const int x = int(tmp_offset*xdst + (1.0-tmp_offset)*xsrc);
@@ -1902,20 +1902,9 @@
                                        halo::HREVERSE);
                }
        }
-       if(image_name.empty()) {
-               image_name = absolute_image();
-       }
-       image::locator  loc;
-
-#ifdef LOW_MEM
-       loc = image::locator(image_name);
-#else
-       if(flag_rgb().size()){
-               loc = image::locator(image_name,team_rgb_range(),flag_rgb());
-       }else{
-               loc = image::locator(image_name);
-       }
-#endif
+       if(loc.is_void()) {
+               loc = absolute_image();
+       }
 
        surface image(image::get_image(loc,
                                
utils::string_bool(get_state("stoned"))?image::GREYED : 
image::UNSCALED,image::ADJUST_COLOUR,
@@ -1923,6 +1912,11 @@
        if(image ==NULL) {
                image = still_image();
        }
+#ifndef LOW_MEM
+       if(flag_rgb().size()){
+               image = recolor_image(image,team_rgb_range(),flag_rgb());
+       }
+#endif
        if(facing_ == gamemap::location::NORTH_WEST || facing_ == 
gamemap::location::SOUTH_WEST) {
                image.assign(image::reverse_image(image));
        }

Modified: trunk/src/unit_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_display.cpp?rev=13946&r1=13945&r2=13946&view=diff
==============================================================================
--- trunk/src/unit_display.cpp (original)
+++ trunk/src/unit_display.cpp Sat Oct 14 01:07:34 2006
@@ -308,7 +308,7 @@
                        const int posx = int(pos*xdst + (1.0-pos)*xsrc);
                        const int posy = int(pos*ydst + (1.0-pos)*ysrc);
 
-                       std::string missile_image= missile_frame.image();
+                       image::locator missile_image= missile_frame.image();
                        const int d = disp.hex_size() / 2;
                        if(vertical_dir) {
                                missile_image = missile_frame.image();
@@ -330,7 +330,7 @@
                        }
                        missile_frame_halo = halo::add(posx+d,
                                        posy+d,
-                                       missile_image,
+                                       missile_image.get_filename(),
                                        orientation);
 
                }

Modified: trunk/src/unit_frame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.cpp?rev=13946&r1=13945&r2=13946&view=diff
==============================================================================
--- trunk/src/unit_frame.cpp (original)
+++ trunk/src/unit_frame.cpp Sat Oct 14 01:07:34 2006
@@ -198,12 +198,12 @@
 }
 
 
-unit_frame::unit_frame(const std::string& str, int begin,int end,
+unit_frame::unit_frame(const image::locator& image, int begin,int end,
                const std::string& highlight, const std::string& offset,
                Uint32 blend_color, const std::string& blend_rate,
                const std::string& in_halo, const std::string& halox, const 
std::string& haloy,
-               const std::string & diag) :
-        image_(str),image_diagonal_(diag),
+               const image::locator & diag) :
+        image_(image),image_diagonal_(diag),
        halo_(in_halo,end_time_ - begin_time_),
        halo_x_(halox,end_time_ - begin_time_),
        halo_y_(haloy,end_time_ - begin_time_),
@@ -225,8 +225,8 @@
 
 unit_frame::unit_frame(const config& cfg)
 {
-       image_ = cfg["image"];
-       image_diagonal_ = cfg["image_diagonal"];
+       image_ = image::locator(cfg["image"]);
+       image_diagonal_ = image::locator(cfg["image_diagonal"]);
        sound_ = cfg["sound"];
        begin_time_ = atoi(cfg["begin"].c_str());
        end_time_ = atoi(cfg["end"].c_str());

Modified: trunk/src/unit_frame.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.hpp?rev=13946&r1=13945&r2=13946&view=diff
==============================================================================
--- trunk/src/unit_frame.hpp (original)
+++ trunk/src/unit_frame.hpp Sat Oct 14 01:07:34 2006
@@ -17,6 +17,7 @@
 #include "map.hpp"
 #include "config.hpp"
 #include "util.hpp"
+#include "image.hpp"
 #include "serialization/string_utils.hpp"
 
 #include <string>
@@ -57,16 +58,16 @@
        public:
        // constructors
                unit_frame();
-               explicit unit_frame(const std::string& str, int begin=0,int 
end=1,
+               explicit unit_frame(const image::locator& image, int 
begin=0,int end=1,
                                const std::string& highlight="1.0",const 
std::string& offset="",
                                Uint32 blend_color = 0, const std::string& 
blend_rate = "0",
                                const std::string & in_halo = "",
                                const std::string & halox = "",const 
std::string & haloy = "",
-                               const std::string & diag ="");
+                               const image::locator & diag ="");
                explicit unit_frame(const config& cfg);
 
-               std::string image() const { return image_ ;}
-               std::string image_diagonal() const { return image_diagonal_ ; 
}
+               image::locator image() const { return image_ ;}
+               image::locator image_diagonal() const { return 
image_diagonal_ ; }
                const std::string &halo(int current_time) const;
                std::string sound() const { return sound_ ; };
                int halo_x(int current_time) const;
@@ -78,8 +79,8 @@
                fixed_t highlight_ratio(int current_time) const;
                double offset(int current_time) const;
        private:
-               std::string image_;
-               std::string image_diagonal_;
+               image::locator image_;
+               image::locator image_diagonal_;
                progressive_string halo_;
 
                std::string sound_;

Modified: trunk/src/unit_types.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.cpp?rev=13946&r1=13945&r2=13946&view=diff
==============================================================================
--- trunk/src/unit_types.cpp (original)
+++ trunk/src/unit_types.cpp Sat Oct 14 01:07:34 2006
@@ -849,7 +849,7 @@
                
healing_animations_.push_back(healing_animation(**healing_anim));
        }
        if(healing_animations_.empty()) {
-               
healing_animations_.push_back(healing_animation(unit_frame(cfg["image_healing"],0,1,"1.0","",0,"",cfg["image_halo_healing"])));
+               
healing_animations_.push_back(healing_animation(unit_frame(image::locator(cfg["image_healing"]),0,1,"1.0","",0,"",cfg["image_halo_healing"])));
                // always have a healing animation
        }
 




Related Messages


Powered by MHonArc, Updated Sat Oct 14 02:00:11 2006