more reorganisation of unit animation initialisation,

...preparation work for bug fixing
This commit is contained in:
Jérémy Rosen 2008-02-02 10:39:38 +00:00
parent 793b94b23b
commit 42f62e9ecc
4 changed files with 7 additions and 8 deletions

View file

@ -1356,12 +1356,10 @@ void unit::read(const config& cfg, bool use_traits, game_state* state)
if(ut) {
animations_ = ut->animations();
} else {
unit_animation::fill_initial_animations(animations_,image::locator(cfg_["image"]));
unit_animation::add_anims(animations_,cfg_);
unit_animation::fill_initial_animations(animations_,cfg_);
}
} else {
unit_animation::fill_initial_animations(animations_,image::locator(cfg_["image"]));
unit_animation::add_anims(animations_,cfg_);
unit_animation::fill_initial_animations(animations_,cfg_);
}
// Remove animations from private cfg, since they're not needed there now
cfg_.clear_children("animation");

View file

@ -284,8 +284,9 @@ int unit_animation::matches(const game_display &disp,const gamemap::location& lo
}
void unit_animation::fill_initial_animations( std::vector<unit_animation> & animations,image::locator default_image)
void unit_animation::fill_initial_animations( std::vector<unit_animation> & animations, const config & cfg)
{
const image::locator default_image = image::locator(cfg["image"]);
animations.push_back(unit_animation(0,unit_frame(default_image,300),"",unit_animation::DEFAULT_ANIM));
animations.push_back(unit_animation(0,unit_frame(default_image,300,"","",display::rgb(255,255,255),"0.0~0.3:100,0.3~0.0:200"),"selected",unit_animation::DEFAULT_ANIM));
animations.push_back(unit_animation(0,unit_frame(default_image,150),"leading",unit_animation::DEFAULT_ANIM));
@ -304,6 +305,7 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
animations.push_back(unit_animation(0,unit_frame(default_image,1),"victory",unit_animation::DEFAULT_ANIM));
animations.push_back(unit_animation(-150,unit_frame(default_image,150,"1~0"),"pre_teleport",unit_animation::DEFAULT_ANIM));
animations.push_back(unit_animation(0,unit_frame(default_image,150,"0~1"),"post_teleport",unit_animation::DEFAULT_ANIM));
add_anims(animations,cfg);
}
void unit_animation::add_anims( std::vector<unit_animation> & animations, const config & cfg)
{

View file

@ -33,7 +33,7 @@ class unit_animation
public:
typedef enum { MATCH_FAIL=-2 , DEFAULT_ANIM=-1};
typedef enum { HIT, MISS, KILL, INVALID} hit_type;
static void fill_initial_animations( std::vector<unit_animation> & animations,image::locator default_image);
static void fill_initial_animations( std::vector<unit_animation> & animations, const config & cfg);
static void add_anims( std::vector<unit_animation> & animations, const config & cfg);
int matches(const game_display &disp,const gamemap::location& loc,const unit* my_unit,const std::string & event="",const int value=0,hit_type hit=INVALID,const attack_type* attack=NULL,const attack_type* second_attack = NULL, int swing_num =0) const;

View file

@ -737,8 +737,7 @@ const t_string& unit_type::unit_description() const
const std::vector<unit_animation>& unit_type::animations() const {
if (animations_.empty()) {
unit_animation::fill_initial_animations(animations_,image::locator(cfg_["image"]));
unit_animation::add_anims(animations_,cfg_);
unit_animation::fill_initial_animations(animations_,cfg_);
}
return animations_;