AnimationWML: fix code for halos in additional shorter frames persisting on screen.

This commit is contained in:
David Mikos 2013-10-12 00:35:20 +10:30
parent 36e8d558d5
commit bd4ce5d11c
4 changed files with 26 additions and 7 deletions

View file

@ -130,6 +130,8 @@ Version 1.11.6+dev:
This is useful for batch testing.
* Animation WML: Fix sound start time in additional frames without
requiring a duration 1 frame workaround.
* Animation WML: Fix halo in additional frame persisting without blank
hex workaround at start and end if a shorter frame.
* Fixed crash on delete of last save
Version 1.11.6:

View file

@ -959,13 +959,24 @@ bool unit_animation::invalidate(frame_parameters& value)
void unit_animation::particule::redraw(const frame_parameters& value,const map_location &src, const map_location &dst)
{
const unit_frame& current_frame= get_current_frame();
const int relative_frame_time = get_animation_time() -get_begin_time(); //relative to first frame of all relevant animation blocks
const frame_parameters default_val = parameters_.parameters(relative_frame_time);
if(get_current_frame_begin_time() != last_frame_begin_time_ && relative_frame_time >=0) {
const int animation_time = get_animation_time();
const frame_parameters default_val = parameters_.parameters(animation_time -get_begin_time());
// everything is relative to the first frame in an attack/defense/etc. block.
// so we need to check if this particular frame is due to be shown at this time
bool in_scope_of_frame = (animation_time >= get_current_frame_begin_time() ? true: false);
if (animation_time > get_current_frame_end_time()) in_scope_of_frame = false;
// sometimes even if the frame is not due to be shown, a frame image still must be shown.
// i.e. in a defense animation that is shorter than an attack animation.
// the halos should not persist though and use the 'in_scope_of_frame' variable.
// for sound frames we want the first time variable set only after the frame has started.
if(get_current_frame_begin_time() != last_frame_begin_time_ && animation_time >= get_current_frame_begin_time()) {
last_frame_begin_time_ = get_current_frame_begin_time();
current_frame.redraw(get_current_frame_time(),true,src,dst,&halo_id_,default_val,value);
current_frame.redraw(get_current_frame_time(),true,in_scope_of_frame,src,dst,&halo_id_,default_val,value);
} else {
current_frame.redraw(get_current_frame_time(),false,src,dst,&halo_id_,default_val,value);
current_frame.redraw(get_current_frame_time(),false,in_scope_of_frame,src,dst,&halo_id_,default_val,value);
}
}
void unit_animation::particule::clear_halo()

View file

@ -554,7 +554,7 @@ void frame_parsed_parameters::override( int duration
}
void unit_frame::redraw(const int frame_time,bool first_time,const map_location & src,const map_location & dst,int*halo_id,const frame_parameters & animation_val,const frame_parameters & engine_val)const
void unit_frame::redraw(const int frame_time,bool first_time,bool in_scope_of_frame,const map_location & src,const map_location & dst,int*halo_id,const frame_parameters & animation_val,const frame_parameters & engine_val)const
{
const int xsrc = game_display::get_singleton()->get_location_x(src);
const int ysrc = game_display::get_singleton()->get_location_y(src);
@ -624,8 +624,14 @@ void unit_frame::redraw(const int frame_time,bool first_time,const map_location
ftofxp(current_data.highlight_ratio), current_data.blend_with,
current_data.blend_ratio,current_data.submerge,!facing_north);
}
halo::remove(*halo_id);
*halo_id = halo::NO_HALO;
if (!in_scope_of_frame) { //check after frame as first/last frame image used in defense/attack anims
return;
}
if(!current_data.halo.empty()) {
halo::ORIENTATION orientation;
switch(direction)

View file

@ -202,7 +202,7 @@ class unit_frame {
public:
// Constructors
unit_frame(const frame_builder& builder=frame_builder()):builder_(builder){};
void redraw(const int frame_time,bool first_time,const map_location & src,const map_location & dst,int*halo_id,const frame_parameters & animation_val,const frame_parameters & engine_val)const;
void redraw(const int frame_time,bool first_time,bool in_scope_of_frame,const map_location & src,const map_location & dst,int*halo_id,const frame_parameters & animation_val,const frame_parameters & engine_val)const;
const frame_parameters merge_parameters(int current_time,const frame_parameters & animation_val,const frame_parameters & engine_val=frame_parameters()) const;
const frame_parameters parameters(int current_time) const {return builder_.parameters(current_time);};
const frame_parameters end_parameters() const {return builder_.parameters(duration());};