fix bug 10352, anims are forgotten on save/load,
also add a test case of WML added anim in test scenario... just for fun
This commit is contained in:
parent
f8a960b1f6
commit
482b403172
6 changed files with 88 additions and 43 deletions
|
@ -44,6 +44,7 @@ Version 1.3.11+svn:
|
|||
shouldn't be uploaded on the addon server (it's useful if you use a svn
|
||||
checkout for example)
|
||||
* fixed some more possible utf-8 related terminations
|
||||
* fixed WML added anims being forgotten on save/load
|
||||
|
||||
Version 1.3.11:
|
||||
* campaigns
|
||||
|
|
|
@ -658,6 +658,48 @@ _s, _s, _s, _s, Aa, Aa, _s, _s, _s, _s
|
|||
[/unstore_unit]
|
||||
[/event]
|
||||
|
||||
[label]
|
||||
x,y=7,11
|
||||
text="test anim"
|
||||
[/label]
|
||||
|
||||
[event]
|
||||
name=moveto
|
||||
first_time_only=no
|
||||
[filter]
|
||||
x=7
|
||||
y=11
|
||||
[/filter]
|
||||
[object]
|
||||
[effect]
|
||||
apply_to=new_attack
|
||||
name=ruby of fire
|
||||
description= _ "ruby of fire"
|
||||
icon=attacks/fireball.png
|
||||
type=fire
|
||||
range=ranged
|
||||
[specials]
|
||||
{WEAPON_SPECIAL_MAGICAL}
|
||||
[/specials]
|
||||
damage=14
|
||||
number=4
|
||||
[/effect]
|
||||
|
||||
[effect]
|
||||
apply_to=new_animation
|
||||
[standing_anim]
|
||||
alpha=0.0~1.0
|
||||
|
||||
|
||||
[frame]
|
||||
begin=-2000
|
||||
end=0
|
||||
[/frame]
|
||||
[/standing_anim]
|
||||
[/effect]
|
||||
[/object]
|
||||
[/event]
|
||||
|
||||
|
||||
#capture connected villages near 13,2 for team 2
|
||||
[event]
|
||||
|
|
52
src/unit.cpp
52
src/unit.cpp
|
@ -1285,6 +1285,33 @@ void unit::read(const config& cfg, bool use_traits)
|
|||
if(cfg["ai_special"] == "guardian") {
|
||||
set_state("guardian","yes");
|
||||
}
|
||||
if(!type_set) {
|
||||
if(ut) {
|
||||
animations_ = ut->animations();
|
||||
} else {
|
||||
unit_animation::initialize_anims(animations_,cfg_,true);
|
||||
}
|
||||
} else {
|
||||
//load default anims
|
||||
unit_animation::initialize_anims(animations_,cfg_,true);
|
||||
}
|
||||
// Remove animations from private cfg, since they're not needed there now
|
||||
cfg_.clear_children("animation");
|
||||
|
||||
cfg_.clear_children("defend");
|
||||
cfg_.clear_children("teleport_anim");
|
||||
cfg_.clear_children("extra_anim");
|
||||
cfg_.clear_children("death");
|
||||
cfg_.clear_children("movement_anim");
|
||||
cfg_.clear_children("standing_anim");
|
||||
cfg_.clear_children("healing_anim");
|
||||
cfg_.clear_children("victory_anim");
|
||||
cfg_.clear_children("idle_anim");
|
||||
cfg_.clear_children("levelin_anim");
|
||||
cfg_.clear_children("levelout_anim");
|
||||
cfg_.clear_children("healed_anim");
|
||||
cfg_.clear_children("poison_anim");
|
||||
|
||||
if(!type_set) {
|
||||
backup_state();
|
||||
if(utils::string_bool(cfg_["random_traits"], true)) {
|
||||
|
@ -1325,31 +1352,6 @@ void unit::read(const config& cfg, bool use_traits)
|
|||
cfg_["generate_description"] = "";
|
||||
}
|
||||
|
||||
if(!type_set) {
|
||||
if(ut) {
|
||||
animations_ = ut->animations();
|
||||
cfg_.clear_children("animation");
|
||||
} else {
|
||||
unit_animation::initialize_anims(animations_,cfg_);
|
||||
}
|
||||
} else {
|
||||
// Remove animations from private cfg, since they're not needed there now
|
||||
cfg_.clear_children("animation");
|
||||
|
||||
cfg_.clear_children("defend");
|
||||
cfg_.clear_children("teleport_anim");
|
||||
cfg_.clear_children("extra_anim");
|
||||
cfg_.clear_children("death");
|
||||
cfg_.clear_children("movement_anim");
|
||||
cfg_.clear_children("standing_anim");
|
||||
cfg_.clear_children("healing_anim");
|
||||
cfg_.clear_children("victory_anim");
|
||||
cfg_.clear_children("idle_anim");
|
||||
cfg_.clear_children("levelin_anim");
|
||||
cfg_.clear_children("levelout_anim");
|
||||
cfg_.clear_children("healed_anim");
|
||||
cfg_.clear_children("poison_anim");
|
||||
}
|
||||
game_events::add_events(cfg_.get_children("event"),id_);
|
||||
cfg_.clear_children("event");
|
||||
// Make the default upkeep "full"
|
||||
|
|
|
@ -259,7 +259,7 @@ int unit_animation::matches(const game_display &disp,const gamemap::location& lo
|
|||
}
|
||||
|
||||
|
||||
void unit_animation::initialize_anims( std::vector<unit_animation> & animations, const config & cfg)
|
||||
void unit_animation::initialize_anims( std::vector<unit_animation> & animations, const config & cfg,bool with_default)
|
||||
{
|
||||
config expanded_cfg;
|
||||
config::child_list::const_iterator anim_itor;
|
||||
|
@ -269,7 +269,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
for(anim_itor = parsed_animations.begin(); anim_itor != parsed_animations.end(); ++anim_itor) {
|
||||
animations.push_back(unit_animation(**anim_itor));
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),300,"","",display::rgb(255,255,255),"0.0~0.3:100,0.3~0.0:200"),"selected",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),300,"","",display::rgb(255,255,255),"0.0~0.3:100,0.3~0.0:200"),"selected",unit_animation::DEFAULT_ANIM));
|
||||
|
||||
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"leading_anim");
|
||||
|
@ -280,7 +280,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"leading animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=leading flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),150),"leading",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),150),"leading",unit_animation::DEFAULT_ANIM));
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"recruit_anim");
|
||||
const config::child_list& recruit_anims = expanded_cfg.get_children("recruit_anim");
|
||||
for(anim_itor = recruit_anims.begin(); anim_itor != recruit_anims.end(); ++anim_itor) {
|
||||
|
@ -289,7 +289,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"recruit animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=recruited flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"0~1:600"),"recruited",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"0~1:600"),"recruited",unit_animation::DEFAULT_ANIM));
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"standing_anim");
|
||||
const config::child_list& standing_anims = expanded_cfg.get_children("standing_anim");
|
||||
for(anim_itor = standing_anims.begin(); anim_itor != standing_anims.end(); ++anim_itor) {
|
||||
|
@ -299,7 +299,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=standing flag\n";
|
||||
}
|
||||
// Always have a standing animation
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),0),"standing",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),0),"standing",unit_animation::DEFAULT_ANIM));
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"idle_anim");
|
||||
const config::child_list& idle_anims = expanded_cfg.get_children("idle_anim");
|
||||
for(anim_itor = idle_anims.begin(); anim_itor != idle_anims.end(); ++anim_itor) {
|
||||
|
@ -317,7 +317,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"levelin animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=levelin flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"1.0","",display::rgb(255,255,255),"1~0:600"),"levelin",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"1.0","",display::rgb(255,255,255),"1~0:600"),"levelin",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a levelin animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"levelout_anim");
|
||||
const config::child_list& levelout_anims = expanded_cfg.get_children("levelout_anim");
|
||||
|
@ -327,7 +327,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"levelout animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=levelout flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"1.0","",display::rgb(255,255,255),"0~1:600"),"levelout",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"1.0","",display::rgb(255,255,255),"0~1:600"),"levelout",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a levelout animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"healing_anim");
|
||||
const config::child_list& healing_anims = expanded_cfg.get_children("healing_anim");
|
||||
|
@ -338,7 +338,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"healing animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=healing flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),500),"healing",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),500),"healing",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a healing animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"healed_anim");
|
||||
const config::child_list& healed_anims = expanded_cfg.get_children("healed_anim");
|
||||
|
@ -349,7 +349,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"healed animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=healed flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),240,"1.0","",display::rgb(255,255,255),"0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30"),"healed",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),240,"1.0","",display::rgb(255,255,255),"0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30"),"healed",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a healed animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"poison_anim");
|
||||
const config::child_list& poison_anims = expanded_cfg.get_children("poison_anim");
|
||||
|
@ -360,7 +360,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"poison animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=poison flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),240,"1.0","",display::rgb(0,255,0),"0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30"),"poison",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),240,"1.0","",display::rgb(0,255,0),"0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30"),"poison",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a poison animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"movement_anim");
|
||||
const config::child_list& movement_anims = expanded_cfg.get_children("movement_anim");
|
||||
|
@ -370,7 +370,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"movement animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=movement flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),150),"movement",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),150),"movement",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a movement animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"defend");
|
||||
const config::child_list& defends = expanded_cfg.get_children("defend");
|
||||
|
@ -392,7 +392,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"defend animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=defend flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(-150,unit_frame(image::locator(cfg["image"]),300),"defend",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(-150,unit_frame(image::locator(cfg["image"]),300),"defend",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a defensive animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"attack_anim");
|
||||
const config::child_list& attack_anims = expanded_cfg.get_children("attack_anim");
|
||||
|
@ -413,7 +413,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"attack animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=attack flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(-150,unit_frame(image::locator(cfg["image"]),300),"attack",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(-150,unit_frame(image::locator(cfg["image"]),300),"attack",unit_animation::DEFAULT_ANIM));
|
||||
// always have an attack animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"death");
|
||||
const config::child_list& deaths = expanded_cfg.get_children("death");
|
||||
|
@ -429,7 +429,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"death animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=death flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"1~0:600"),"death",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),600,"1~0:600"),"death",unit_animation::DEFAULT_ANIM));
|
||||
if(!cfg["die_sound"].empty()) {
|
||||
animations.back().sub_anims_["_death_sound"] = crude_animation();
|
||||
animations.back().sub_anims_["_death_sound"].add_frame(1,unit_frame(image::locator(),1,"","",0,"","","","","",cfg["die_sound"]),true);
|
||||
|
@ -443,7 +443,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"victory animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=victory flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),1),"victory",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(0,unit_frame(image::locator(cfg["image"]),1),"victory",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a victory animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"extra_anim");
|
||||
const config::child_list& extra_anims = expanded_cfg.get_children("extra_anim");
|
||||
|
@ -461,7 +461,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"teleport animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=teleport flag\n";
|
||||
}
|
||||
animations.push_back(unit_animation(-20,unit_frame(image::locator(cfg["image"]),40),"teleport",unit_animation::DEFAULT_ANIM));
|
||||
if(with_default) animations.push_back(unit_animation(-20,unit_frame(image::locator(cfg["image"]),40),"teleport",unit_animation::DEFAULT_ANIM));
|
||||
// Always have a defensive animation
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class unit_animation
|
|||
public:
|
||||
typedef enum { MATCH_FAIL=-2 , DEFAULT_ANIM=-1};
|
||||
typedef enum { HIT, MISS, KILL, INVALID} hit_type;
|
||||
static void initialize_anims( std::vector<unit_animation> & animations, const config & cfg);
|
||||
static void initialize_anims( std::vector<unit_animation> & animations, const config & cfg,bool with_default = false);
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -721,7 +721,7 @@ const t_string& unit_type::unit_description() const
|
|||
|
||||
const std::vector<unit_animation>& unit_type::animations() const {
|
||||
if (animations_.empty()) {
|
||||
unit_animation::initialize_anims(animations_,cfg_);
|
||||
unit_animation::initialize_anims(animations_,cfg_,true);
|
||||
}
|
||||
return animations_;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue