disable turbo on idle,standing and select animation...

...(hacky method, will clean in 1.5)
This commit is contained in:
Jérémy Rosen 2008-02-20 22:22:22 +00:00
parent 3744029e19
commit ada3514023
3 changed files with 12 additions and 5 deletions

View file

@ -1597,6 +1597,8 @@ void unit::set_selecting(const game_display &disp,const gamemap::location& loc)
void unit::start_animation(const int start_time, const gamemap::location &loc,const unit_animation * animation,bool with_bars,bool cycles,const std::string text, const Uint32 text_color,STATE state)
{
const game_display * disp = game_display::get_singleton();
// everything except standing select and idle
const bool accelerate = (state != STATE_FORGET && state != STATE_STANDING);
if(!animation) {
set_standing(loc,with_bars);
return ;
@ -1607,7 +1609,7 @@ void unit::start_animation(const int start_time, const gamemap::location &loc,co
if(anim_) delete anim_;
anim_ = new unit_animation(*animation);
const int real_start_time = start_time == INT_MAX ? anim_->get_begin_time() : start_time;
anim_->start_animation(real_start_time,loc, loc.get_direction(facing_), cycles,text,text_color);
anim_->start_animation(real_start_time,loc, loc.get_direction(facing_), cycles,text,text_color,accelerate);
frame_begin_time_ = anim_->get_begin_time() -1;
if (disp->idle_anim()) {
next_idling_ = get_current_animation_tick()

View file

@ -297,9 +297,8 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
animation_base.back().event_.clear();
}
}
if(animation_base.empty()) {
// always provide a base
animation_base.push_back(unit_animation(0,unit_frame(default_image,600),"",unit_animation::DEFAULT_ANIM));
}
animations.push_back(unit_animation(0,unit_frame(default_image,1),"_disabled_",0));
for(itor = animation_base.begin() ; itor != animation_base.end() ; itor++ ) {
@ -307,6 +306,10 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
// provide all default anims
animations.push_back(*itor);
tmp_anim = *itor;
tmp_anim.event_ = utils::split("standing");
animations.push_back(tmp_anim);
tmp_anim = *itor;
tmp_anim.unit_anim_.override(0,"","0.0~0.3:100,0.3~0.0:200",display::rgb(255,255,255));
tmp_anim.event_ = utils::split("selected");
@ -727,8 +730,9 @@ int unit_animation::get_begin_time() const
return result;
}
void unit_animation::start_animation(int start_time,const gamemap::location &src, const gamemap::location &dst, bool cycles, const std::string text, const Uint32 text_color)
void unit_animation::start_animation(int start_time,const gamemap::location &src, const gamemap::location &dst, bool cycles, const std::string text, const Uint32 text_color,const bool accelerate)
{
unit_anim_.accelerate = accelerate;
unit_anim_.start_animation(start_time, src, dst, cycles);
if(!text.empty()) {
crude_animation crude_build;
@ -738,6 +742,7 @@ void unit_animation::start_animation(int start_time,const gamemap::location &src
}
std::map<std::string,crude_animation>::iterator anim_itor =sub_anims_.begin();
for( /*null*/; anim_itor != sub_anims_.end() ; anim_itor++) {
anim_itor->second.accelerate = accelerate;
anim_itor->second.start_animation(start_time,src,dst,cycles);
}
}

View file

@ -51,7 +51,7 @@ class unit_animation
int time_to_tick(int animation_time) const { return unit_anim_.time_to_tick(animation_time); };
int get_animation_time() const{ return unit_anim_.get_animation_time() ; };
int get_animation_time_potential() const{ return unit_anim_.get_animation_time_potential() ; };
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);
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);
const int get_current_frame_begin_time() const{ return unit_anim_.get_current_frame_begin_time() ; };
void redraw();