Make select anim works exactly like idle anim (in background of inputs)

This fix a severe UI blocking if you move a unit playing its select anim
It will be easy to adapt when fire&forget anims will be ready
Also start to play the unit-select sound before starting the select anim
This commit is contained in:
Ali El Gariani 2007-11-03 17:54:59 +00:00
parent 11f66f24c3
commit e420426838
3 changed files with 10 additions and 3 deletions

View File

@ -1220,8 +1220,8 @@ void mouse_handler::left_click(const SDL_MouseButtonEvent& event, const bool bro
paths::route route = get_route(u, go_to, current_team());
gui_->set_route(&route);
}
unit_display::unit_selected(u->first);
sound::play_UI_sound("select-unit.wav");
u->second.set_selecting(*gui_, u->first);
game_events::fire("select",hex);
} else {
unit_movement_resetter move_reset(u->second);

View File

@ -1611,6 +1611,12 @@ void unit::set_idling(const game_display &disp,const gamemap::location& loc)
start_animation(disp,loc,choose_animation(disp,loc,"idling"),true);
}
void unit::set_selecting(const game_display &disp,const gamemap::location& loc)
{
state_ = STATE_SELECTING;
start_animation(disp,loc,choose_animation(disp,loc,"selected"),true);
}
void unit::start_animation(const game_display &disp, const gamemap::location &loc,const unit_animation * animation,bool with_bars,bool cycles)
{
if(!animation) {

View File

@ -124,7 +124,7 @@ public:
void new_level();
//! Called on every draw
void refresh(const game_display& disp,const gamemap::location& loc) {
if (state_ == STATE_IDLING && anim_ && anim_->animation_would_finish()) {
if ((state_ == STATE_IDLING || state_ == STATE_SELECTING) && anim_ && anim_->animation_would_finish()) {
set_standing(disp, loc);
return;
}
@ -190,6 +190,7 @@ public:
void set_victorious(const game_display &disp,const gamemap::location& loc,const attack_type* attack,const attack_type* secondary_attack);
void set_poisoned(const game_display& disp,const gamemap::location& loc,int damage);
void set_idling(const game_display& disp,const gamemap::location& loc);
void set_selecting(const game_display& disp,const gamemap::location& loc);
void restart_animation(const game_display& disp,int start_time, bool cycles = false);
const unit_animation* get_animation() const { return anim_;};
void set_offset(double offset){offset_ = offset;}
@ -248,7 +249,7 @@ public:
STATE_LEVELIN, STATE_LEVELOUT,
STATE_DYING, STATE_EXTRA, STATE_TELEPORT,
STATE_RECRUITED, STATE_HEALED, STATE_POISONED,
STATE_IDLEIN, STATE_IDLING, STATE_VICTORIOUS};
STATE_IDLING, STATE_SELECTING, STATE_VICTORIOUS};
void start_animation(const game_display &disp, const gamemap::location &loc,const unit_animation* animation, bool with_bars,bool cycles=false);
//! The name of the file to game_display (used in menus).