Author: boucman
Date: Fri Apr 4 20:25:27 2008
New Revision: 25547
URL: http://svn.gna.org/viewcvs/wesnoth?rev=25547&view=rev
Log:
sub frames of animations now handle their own invalidation. They are not
limited in placement or size anymore. Not that the main unit frame still has
the limitation. Please don't abuse this feature since i'll remove the
limitation to the main frame eventually
Modified:
trunk/src/display.cpp
trunk/src/display.hpp
trunk/src/unit.cpp
trunk/src/unit_animation.cpp
trunk/src/unit_animation.hpp
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=25547&r1=25546&r2=25547&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Fri Apr 4 20:25:27 2008
@@ -2014,3 +2014,17 @@
reportSurfaces_[report_num].assign(NULL);
}
}
+
+void display::invalidate_rectangle(const gamemap::location& first_corner,
const gamemap::location& second_corner) {
+ const SDL_Rect& rect = map_area();
+ for (int x = minimum<int>(first_corner.x,second_corner.x); x <=
maximum<int>(first_corner.x,second_corner.x);x++) {
+ for (int y = minimum<int>(first_corner.y,second_corner.y); y <=
maximum<int>(first_corner.y,second_corner.y);y++) {
+ invalidate(gamemap::location(x,y));
+ }
+ }
+}
+
+void display::invalidate_zone(const int x1,const int y1, const int x2, const
int y2) {
+ const SDL_Rect& rect = map_area();
+ invalidate_rectangle(pixel_position_to_hex(x1 - rect.x, y1 -
rect.y),pixel_position_to_hex(x2 - rect.x, y2 - rect.y));
+};
Modified: trunk/src/display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=25547&r1=25546&r2=25547&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Fri Apr 4 20:25:27 2008
@@ -190,6 +190,8 @@
// Will be overridden in the display subclass
virtual void invalidate(const gamemap::location& loc)
{invalidated_.insert(loc);};
+ virtual void invalidate_rectangle(const gamemap::location&
first_corner, const gamemap::location& second_corner) ;
+ virtual void invalidate_zone(const int x1,const int y1, const int x2,
const int y2);
virtual void draw_minimap_units() {};
const gamemap& get_map()const { return map_;}
Modified: trunk/src/unit.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=25547&r1=25546&r2=25547&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Fri Apr 4 20:25:27 2008
@@ -2010,6 +2010,7 @@
over.insert(arr[i]);
}
}
+ if(get_animation()) get_animation()->invalidate();
return over;
}
Modified: trunk/src/unit_animation.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.cpp?rev=25547&r1=25546&r2=25547&view=diff
==============================================================================
--- trunk/src/unit_animation.cpp (original)
+++ trunk/src/unit_animation.cpp Fri Apr 4 20:25:27 2008
@@ -708,6 +708,14 @@
anim_itor->second.redraw();
}
}
+void unit_animation::invalidate() const
+{
+
+ std::map<std::string,particule>::const_iterator anim_itor
=sub_anims_.begin();
+ for( /*null*/; anim_itor != sub_anims_.end() ; anim_itor++) {
+ anim_itor->second.invalidate();
+ }
+}
void unit_animation::particule::redraw()
{
const unit_frame& current_frame= get_current_frame();
@@ -718,6 +726,12 @@
} else {
current_frame.redraw(get_current_frame_time(),false,src_,dst_,&halo_id_,default_val);
}
+}
+void unit_animation::particule::invalidate() const
+{
+ const unit_frame& current_frame= get_current_frame();
+ const frame_parameters default_val =
parameters_.parameters(get_animation_time() -get_begin_time());
+
current_frame.invalidate(get_current_frame_time(),src_,dst_,default_val);
}
unit_animation::particule::~particule()
Modified: trunk/src/unit_animation.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.hpp?rev=25547&r1=25546&r2=25547&view=diff
==============================================================================
--- trunk/src/unit_animation.hpp (original)
+++ trunk/src/unit_animation.hpp Fri Apr 4 20:25:27 2008
@@ -54,6 +54,7 @@
void start_animation(int start_time,const gamemap::location
&src = gamemap::location::null_location, const gamemap::location &dst =
gamemap::location::null_location , bool cycles=false, const std::string
text="", const Uint32 text_color=0,const bool accelerate = true);
int get_current_frame_begin_time() const{ return
unit_anim_.get_current_frame_begin_time() ; };
void redraw();
+ void invalidate( ) const;
friend class unit;
protected:
@@ -80,6 +81,7 @@
bool need_update() const;
void override(int start_time,const std::string
highlight="", const std::string blend_ratio ="",Uint32 blend_color = 0,const
std::string offset="");
void redraw( );
+ void invalidate( ) const;
void start_animation(int start_time,const
gamemap::location& src,const gamemap::location& dst, bool cycles=false);
const frame_parameters parameters(const
frame_parameters & default_val) const { return
get_current_frame().parameters(get_current_frame_time(),parameters_.parameters(get_animation_time()-get_begin_time(),default_val));
};
bool accelerate;
Modified: trunk/src/unit_frame.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.cpp?rev=25547&r1=25546&r2=25547&view=diff
==============================================================================
--- trunk/src/unit_frame.cpp (original)
+++ trunk/src/unit_frame.cpp Fri Apr 4 20:25:27 2008
@@ -405,3 +405,37 @@
}
}
}
+void unit_frame::invalidate(const int frame_time,const gamemap::location &
src,const gamemap::location & dst,const frame_parameters & default_val) const
+{
+ const int xsrc = game_display::get_singleton()->get_location_x(src);
+ const int ysrc = game_display::get_singleton()->get_location_y(src);
+ const int xdst = game_display::get_singleton()->get_location_x(dst);
+ const int ydst = game_display::get_singleton()->get_location_y(dst);
+ const gamemap::location::DIRECTION direction =
src.get_relative_dir(dst);
+
+ const frame_parameters current_data =
builder_.parameters(frame_time,default_val);
+ double tmp_offset = current_data.offset;
+ int d2 = game_display::get_singleton()->hex_size() / 2;
+
+ image::locator image_loc;
+ if(direction != gamemap::location::NORTH && direction !=
gamemap::location::SOUTH) {
+ image_loc = current_data.image_diagonal;
+ }
+ if(image_loc.is_void() || image_loc.get_filename() == "") { // invalid
diag image, or not diagonal
+ image_loc = current_data.image;
+ }
+
+ surface image;
+ if(!image_loc.is_void() && image_loc.get_filename() != "") { // invalid
diag image, or not diagonal
+ image=image::get_image(image_loc,
+ image::SCALED_TO_ZOOM,
+ false
+ );
+ }
+ const int x = static_cast<int>(tmp_offset * xdst + (1.0-tmp_offset) *
xsrc)+current_data.x;
+ const int y = static_cast<int>(tmp_offset * ydst + (1.0-tmp_offset) *
ysrc)+current_data.x;
+ if (image != NULL) {
+
game_display::get_singleton()->invalidate_zone(x,y,x+image->w,y+image->h);
+
+ }
+}
Modified: trunk/src/unit_frame.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.hpp?rev=25547&r1=25546&r2=25547&view=diff
==============================================================================
--- trunk/src/unit_frame.hpp (original)
+++ trunk/src/unit_frame.hpp Fri Apr 4 20:25:27 2008
@@ -174,6 +174,7 @@
int duration() const { return builder_.duration();};
bool does_not_change() const{ return
builder_.does_not_change();};
bool need_update() const{ return builder_.need_update();};
+ void invalidate(const int frame_time,const gamemap::location &
src,const gamemap::location & dst,const frame_parameters & default_val) const;
private:
frame_builder builder_;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits