mail[Wesnoth-commits] r33934 - in /trunk/src: display.cpp display.hpp unit_animation.cpp unit_frame.cpp unit_frame.hpp


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

Header


Content

Posted by jeremy . rosen on March 20, 2009 - 20:16:
Author: boucman
Date: Fri Mar 20 20:16:10 2009
New Revision: 33934

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33934&view=rev
Log:
apply patch 1134, code half. WML half will come later, and once both are 
ready and heavily tested, we can backport to 1.6

Modified:
    trunk/src/display.cpp
    trunk/src/display.hpp
    trunk/src/unit_animation.cpp
    trunk/src/unit_frame.cpp
    trunk/src/unit_frame.hpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=33934&r1=33933&r2=33934&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Fri Mar 20 20:16:10 2009
@@ -2327,6 +2327,14 @@
        return false;
 }
 
+bool display::hex_need_update(const map_location& loc) const
+{
+       if(invalidateAll_)
+               return true;
+
+       return invalidated_.find(loc) != invalidated_.end();
+}
+
 void display::invalidate_animations() {
        if (preferences::animate_map()) {
                rect_of_hexes hexes = get_visible_hexes();

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=33934&r1=33933&r2=33934&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Fri Mar 20 20:16:10 2009
@@ -275,6 +275,9 @@
 
        /** check if an hexes under the rectangle is invalidated */
        bool rectangle_need_update(const SDL_Rect& rect) const;
+
+       /** check if an hex is invalidated */
+       bool hex_need_update(const map_location& loc) const;
 
        /**
         * Function to invalidate animated terrains which may have changed.

Modified: trunk/src/unit_animation.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.cpp?rev=33934&r1=33933&r2=33934&view=diff
==============================================================================
--- trunk/src/unit_animation.cpp (original)
+++ trunk/src/unit_animation.cpp Fri Mar 20 20:16:10 2009
@@ -314,7 +314,8 @@
        if( animation_base.empty() )
                
animation_base.push_back(unit_animation(0,frame_builder().image(default_image).duration(1),"",unit_animation::DEFAULT_ANIM));
 
-       
animations.push_back(unit_animation(0,frame_builder().image(default_image).duration(1),"_disabled_",0));
+       //the default standing anim when disbabled use the main in_hex key
+       
animations.push_back(unit_animation(0,frame_builder().image(default_image).duration(1).in_hex(cfg["in_hex"]),"_disabled_",0));
        
animations.push_back(unit_animation(0,frame_builder().image(default_image).duration(1).
                                        
blend("0.0~0.3:100,0.3~0.0:200",display::rgb(255,255,255)),"_disabled_selected_",0));
        for(itor = animation_base.begin() ; itor != animation_base.end() ; 
itor++ ) {

Modified: trunk/src/unit_frame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.cpp?rev=33934&r1=33933&r2=33934&view=diff
==============================================================================
--- trunk/src/unit_frame.cpp (original)
+++ trunk/src/unit_frame.cpp Fri Mar 20 20:16:10 2009
@@ -174,7 +174,8 @@
        submerge_(""),
        x_(""),
        y_(""),
-       drawing_layer_("")
+       drawing_layer_(""),
+       in_hex_(false)
 {
        
image(image::locator(cfg[frame_string+"image"]),cfg[frame_string+"image_mod"]);
        
image_diagonal(image::locator(cfg[frame_string+"image_diagonal"]),cfg[frame_string+"image_mod"]);
@@ -205,7 +206,7 @@
        x(cfg[frame_string+"x"]);
        y(cfg[frame_string+"y"]);
        drawing_layer(cfg[frame_string+"layer"]);
-
+       in_hex(cfg[frame_string+"in_hex"]);
 }
 
 const frame_parameters frame_builder::parameters(int current_time) const
@@ -230,6 +231,7 @@
        result.x = x_.get_current_element(current_time);
        result.y = y_.get_current_element(current_time);
        result.drawing_layer = 
drawing_layer_.get_current_element(current_time,display::LAYER_UNIT_DEFAULT-display::LAYER_UNIT_FIRST);
+       result.in_hex = in_hex_;
        return result;
 }
 frame_builder & frame_builder::image(const image::locator image ,const 
std::string & image_mod)
@@ -318,6 +320,12 @@
        drawing_layer_=progressive_int(drawing_layer,duration_);
        return *this;
 }
+frame_builder & frame_builder::in_hex(const std::string& in_hex)
+{
+       in_hex_= utils::string_bool(in_hex);
+       return *this;
+}
+
 bool frame_builder::does_not_change() const
 {
        return halo_.does_not_change() &&
@@ -490,14 +498,22 @@
        if (image != NULL) {
                const int x = static_cast<int>(tmp_offset * xdst + 
(1.0-tmp_offset) * xsrc)+current_data.x+d2-(image->w/2);
                const int y = static_cast<int>(tmp_offset * ydst + 
(1.0-tmp_offset) * ysrc)+current_data.y+d2-(image->h/2);
+               const SDL_Rect r = {x,y,image->w,image->h};
+               // check if the unit fit in a hex
+               bool in_hex = current_data.in_hex && r.x==xsrc && r.y==ysrc
+                               && r.w==disp->hex_size() && 
r.h==disp->hex_size();
+               // check if our underlying hexes are invalidated
+               bool rect_need_update = in_hex ?
+                               disp->hex_need_update(src) : 
disp->rectangle_need_update(r);
                // if we need to update ourselve because we changed, 
invalidate our hexes
                // and return whether or not our hexs was invalidated
-               const SDL_Rect r = {x,y,image->w,image->h};
-               if(force || need_update() || disp->rectangle_need_update(r)){
+               if(force || need_update() || rect_need_update) {
                        // invalidate ouself to be called at redraw time
                        result |= disp->invalidate(src);
-                       // invalidate all hex we plan to overwrite
-                       result |= 
disp->invalidate_visible_locations_in_rect(r);
+                       if(in_hex == false) {
+                               // invalidate all hexes we plan to overwrite
+                               result |= 
disp->invalidate_visible_locations_in_rect(r);
+                       }
                }
        } else {
                // we have no "redraw surface" but we still need to 
invalidate our own hex
@@ -600,6 +616,8 @@
        result.drawing_layer = current_val.drawing_layer !=  
display::LAYER_UNIT_DEFAULT-display::LAYER_UNIT_FIRST?
                current_val.drawing_layer:animation_val.drawing_layer;
 
+       assert(!engine_val.in_hex);
+       result.in_hex = current_val.in_hex ? current_val.in_hex : 
animation_val.in_hex;
 #ifdef LOW_MEM
        if(primary) {
                result.image= engine_val.image;

Modified: trunk/src/unit_frame.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.hpp?rev=33934&r1=33933&r2=33934&view=diff
==============================================================================
--- trunk/src/unit_frame.hpp (original)
+++ trunk/src/unit_frame.hpp Fri Mar 20 20:16:10 2009
@@ -85,7 +85,8 @@
        submerge(0.0),
        x(0),
        y(0),
-       drawing_layer(display::LAYER_UNIT_DEFAULT-display::LAYER_UNIT_FIRST)
+       drawing_layer(display::LAYER_UNIT_DEFAULT-display::LAYER_UNIT_FIRST),
+       in_hex(false)
        {};
 
        image::locator image;
@@ -107,6 +108,7 @@
        int x;
        int y;
        int drawing_layer;
+       bool in_hex;
 } ;
 /**
  * keep most parameters in a separate class to simplify handling of large
@@ -134,7 +136,8 @@
                submerge_(""),
                x_(""),
                y_(""),
-               
drawing_layer_(lexical_cast<std::string>(display::LAYER_UNIT_DEFAULT-display::LAYER_UNIT_FIRST))
+               
drawing_layer_(lexical_cast<std::string>(display::LAYER_UNIT_DEFAULT-display::LAYER_UNIT_FIRST)),
+               in_hex_(false)
        {};
                frame_builder(const config& cfg,const std::string 
&frame_string = "");
                /** allow easy chained modifications will raised assert if 
used after initialization */
@@ -151,6 +154,7 @@
                frame_builder & x(const std::string& x);
                frame_builder & y(const std::string& y);
                frame_builder & drawing_layer(const std::string& 
drawing_layer);
+               frame_builder & in_hex(const std::string& in_hex);
                /** getters for the different parameters */
                const frame_parameters parameters(int current_time) const ;
 
@@ -178,7 +182,7 @@
                progressive_int x_;
                progressive_int y_;
                progressive_int drawing_layer_;
-
+               bool in_hex_;
 };
 
 /** Describe a unit's animation sequence. */




Related Messages


Powered by MHonArc, Updated Fri Mar 20 20:20:23 2009