34 return cfg[
"healed_sound"].
empty() ?
"heal.wav" : cfg[
"healed_sound"].str();
55 std::vector<config::const_all_children_iterator>
children;
65 branches.back().attributes.merge_attributes(cfg);
75 bool previously_hits_set =
false;
76 bool previously_direction_set =
false;
77 bool previously_terrain_set =
false;
78 bool previously_value_set =
false;
79 bool previously_value_2nd_set =
false;
81 const std::string s_cfg_hits = cfg[
"hits"];
82 const std::string s_cfg_direction = cfg[
"direction"];
83 const std::string s_cfg_terrain = cfg[
"terrain_types"];
84 const std::string s_cfg_value = cfg[
"value"];
85 const std::string s_cfg_value_2nd = cfg[
"value_2nd"];
88 const std::string s_branch_hits = branch.attributes[
"hits"];
89 const std::string s_branch_direction = branch.attributes[
"direction"];
90 const std::string s_branch_terrain = branch.attributes[
"terrain_types"];
91 const std::string s_branch_value = branch.attributes[
"value"];
92 const std::string s_branch_value_2nd = branch.attributes[
"value_second"];
94 if(!s_branch_hits.empty() && s_branch_hits == s_cfg_hits) {
95 previously_hits_set =
true;
98 if(!s_branch_direction.empty() && s_branch_direction == s_cfg_direction) {
99 previously_direction_set =
true;
102 if(!s_branch_terrain.empty() && s_branch_terrain == s_cfg_terrain) {
103 previously_terrain_set =
true;
106 if(!s_branch_value.empty() && s_branch_value == s_cfg_value) {
107 previously_value_set =
true;
110 if(!s_branch_value_2nd.empty() && s_branch_value_2nd == s_cfg_value_2nd) {
111 previously_value_2nd_set =
true;
118 const std::string s_branch_hits = (*iter).attributes[
"hits"];
119 const std::string s_branch_direction = (*iter).attributes[
"direction"];
120 const std::string s_branch_terrain = (*iter).attributes[
"terrain_types"];
121 const std::string s_branch_value = (*iter).attributes[
"value"];
122 const std::string s_branch_value_2nd = (*iter).attributes[
"value_second"];
124 const bool hits_match = (previously_hits_set && s_branch_hits != s_cfg_hits);
125 const bool direction_match = (previously_direction_set && s_branch_direction != s_cfg_direction);
126 const bool terrain_match = (previously_terrain_set && s_branch_terrain != s_cfg_terrain);
127 const bool value_match = (previously_value_set && s_branch_value != s_cfg_value);
128 const bool value_2nd_match = (previously_value_2nd_set && s_branch_value_2nd != s_cfg_value_2nd);
130 if((!previously_hits_set || hits_match) &&
131 (!previously_direction_set || direction_match) &&
132 (!previously_terrain_set || terrain_match) &&
133 (!previously_value_set || value_match) &&
134 (!previously_value_2nd_set || value_2nd_match) &&
135 (hits_match || direction_match || terrain_match || value_match || value_2nd_match))
139 (*iter).attributes.merge_attributes(cfg);
147 const std::string s_branch_hits = (*iter).attributes[
"hits"];
148 const std::string s_branch_direction = (*iter).attributes[
"direction"];
149 const std::string s_branch_terrain = (*iter).attributes[
"terrain_types"];
150 const std::string s_branch_value = (*iter).attributes[
"value"];
151 const std::string s_branch_value_2nd = (*iter).attributes[
"value_second"];
153 const bool hits_match = (previously_hits_set && s_branch_hits == s_cfg_hits);
154 const bool direction_match = (previously_direction_set && s_branch_direction == s_cfg_direction);
155 const bool terrain_match = (previously_terrain_set && s_branch_terrain == s_cfg_terrain);
156 const bool value_match = (previously_value_set && s_branch_value == s_cfg_value);
157 const bool value_2nd_match = (previously_value_2nd_set && s_branch_value_2nd == s_cfg_value_2nd);
159 if((!previously_hits_set || hits_match) &&
160 (!previously_direction_set || direction_match) &&
161 (!previously_terrain_set || terrain_match) &&
162 (!previously_value_set || value_match) &&
163 (!previously_value_2nd_set || value_2nd_match) &&
164 (hits_match || direction_match || terrain_match || value_match || value_2nd_match))
186 std::list<animation_cursor> anim_cursors;
187 anim_cursors.emplace_back(anim_cfg);
189 while(!anim_cursors.empty()) {
193 if(ac.
itors.empty()) {
198 anim_cursors.pop_back();
202 if(ac.
itors.front().key !=
"if") {
208 ac.
itors.pop_front();
216 anim_cursors.emplace_back(ac.
itors.front().cfg, &ac);
217 ac.
itors.pop_front();
219 }
while (!ac.
itors.empty() && ac.
itors.front().key ==
"else");
230 std::cout <<
"--branch--\n" << ab.attributes;
232 std::cout <<
"--branchcfg--\n" << ci->cfg;
239 assert(anim_cursors.size() == 1);
251 return expanded_animations;
258 , secondary_unit_filter_()
261 , base_score_(variation)
264 , primary_attack_filter_()
265 , secondary_attack_filter_()
269 , unit_anim_(start_time,builder)
272 , invalidated_(false)
273 , play_offscreen_(true)
282 , secondary_unit_filter_()
284 , frequency_(cfg[
"frequency"])
285 , base_score_(cfg[
"base_score"])
288 , primary_attack_filter_()
289 , secondary_attack_filter_()
293 , unit_anim_(cfg,frame_string)
296 , invalidated_(false)
297 , play_offscreen_(true)
303 if(fr.key == frame_string) {
307 if(fr.key.find(
"_frame", fr.key.size() - 6) == std::string::npos) {
320 const std::vector<std::string>& my_directions =
utils::split(cfg[
"direction"]);
321 for(
const auto& direction : my_directions) {
346 value_.push_back(atoi(v.c_str()));
350 if(
h ==
"yes" ||
h == strike_result::hit) {
351 hits_.push_back(strike_result::type::hit);
354 if(
h ==
"no" ||
h == strike_result::miss) {
355 hits_.push_back(strike_result::type::miss);
358 if(
h ==
"yes" ||
h == strike_result::kill ) {
359 hits_.push_back(strike_result::type::kill);
363 for(
const auto& v2 :
utils::split(cfg[
"value_second"])) {
364 value2_.push_back(atoi(v2.c_str()));
385 if(!event.empty() && !
event_.empty()) {
467 if(!attack->matches_filter(iter))
return MATCH_FAIL;
478 if(!second_attack->matches_filter(iter))
return MATCH_FAIL;
489 std::vector<unit_animation> animation_base;
490 for(
const auto& anim : animations) {
491 if(std::find(anim.event_.begin(), anim.event_.end(),
"default") != anim.event_.end()) {
492 animation_base.push_back(anim);
494 animation_base.back().event_.clear();
498 const std::string default_image = cfg[
"image"];
500 if(animation_base.empty()) {
506 frame_builder().
image(default_image).duration(300).blend(
"0.0~0.3:100,0.3~0.0:200", {255,255,255}),
507 "_disabled_selected_", 0));
509 for(
const auto& base : animation_base) {
510 animations.push_back(base);
511 animations.back().event_ = {
"standing" };
512 animations.back().play_offscreen_ =
false;
514 animations.push_back(base);
515 animations.back().event_ = {
"_ghosted_" };
516 animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),
particle::UNSET,
"0.9",
"", {0,0,0},
"",
"",
"~GS()");
518 animations.push_back(base);
519 animations.back().event_ = {
"_disabled_ghosted_" };
520 animations.back().unit_anim_.override(0, 1,
particle::UNSET,
"0.4",
"", {0,0,0},
"",
"",
"~GS()");
522 animations.push_back(base);
523 animations.back().event_ = {
"selected" };
524 animations.back().unit_anim_.override(0, 300,
particle::UNSET,
"",
"0.0~0.3:100,0.3~0.0:200", {255,255,255});
526 animations.push_back(base);
527 animations.back().event_ = {
"recruited" };
530 animations.push_back(base);
531 animations.back().event_ = {
"levelin" };
532 animations.back().unit_anim_.override(0, 600,
particle::NO_CYCLE,
"",
"1~0:600", {255,255,255});
534 animations.push_back(base);
535 animations.back().event_ = {
"levelout" };
536 animations.back().unit_anim_.override(0, 600,
particle::NO_CYCLE,
"",
"0~1:600,1", {255,255,255});
538 animations.push_back(base);
539 animations.back().event_ = {
"pre_movement" };
542 animations.push_back(base);
543 animations.back().event_ = {
"post_movement" };
546 animations.push_back(base);
547 animations.back().event_ = {
"movement" };
548 animations.back().unit_anim_.override(0, 200,
551 animations.push_back(base);
552 animations.back().event_ = {
"defend" };
553 animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),
555 animations.back().hits_.push_back(strike_result::type::hit);
556 animations.back().hits_.push_back(strike_result::type::kill);
558 animations.push_back(base);
559 animations.back().event_ = {
"defend" };
561 animations.push_back(base);
562 animations.back().event_ = {
"attack" };
563 animations.back().unit_anim_.override(-150, 300,
particle::NO_CYCLE,
"",
"", {0,0,0},
"0~0.6:150,0.6~0:150", std::to_string(
display::LAYER_UNIT_MOVE_DEFAULT-
display::LAYER_UNIT_FIRST));
564 animations.back().primary_attack_filter_.emplace_back(
"range",
"melee");
566 animations.push_back(base);
567 animations.back().event_ = {
"attack" };
569 animations.back().primary_attack_filter_.emplace_back(
"range",
"ranged");
571 animations.push_back(base);
572 animations.back().event_ = {
"death" };
574 animations.back().sub_anims_[
"_death_sound"] =
particle();
575 animations.back().sub_anims_[
"_death_sound"].add_frame(1,
frame_builder().
sound(cfg[
"die_sound"]),
true);
577 animations.push_back(base);
578 animations.back().event_ = {
"victory" };
579 animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),
particle::CYCLE);
581 animations.push_back(base);
583 animations.back().event_ = {
"pre_teleport" };
585 animations.push_back(base);
587 animations.back().event_ = {
"post_teleport" };
589 animations.push_back(base);
590 animations.back().event_ = {
"healing" };
592 animations.push_back(base);
593 animations.back().event_ = {
"healed" };
594 animations.back().unit_anim_.override(0, 300,
particle::NO_CYCLE,
"",
"0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30", {255,255,255});
598 animations.back().sub_anims_[
"_healed_sound"].add_frame(1,
frame_builder().
sound(healed_sound),
true);
600 animations.push_back(base);
601 animations.back().event_ = {
"poisoned" };
602 animations.back().unit_anim_.override(0, 300,
particle::NO_CYCLE,
"",
"0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30", {0,255,0});
603 animations.back().sub_anims_[
"_poison_sound"] =
particle();
609 const config& cfg,
char const* tag_name,
char const* apply_to,
611 bool offscreen =
true)
615 anim[
"apply_to"] = apply_to;
619 if(v.
empty()) v =
false;
625 animations.emplace_back(anim);
632 animations.emplace_back(ab.merge());
650 anim[
"apply_to"] =
"standing";
651 anim[
"cycles"] =
true;
655 std::string sub_frame_name = ci->key;
656 std::size_t pos = sub_frame_name.find(
"_frame");
657 if(pos != std::string::npos) {
658 anim[sub_frame_name.substr(0, pos) +
"_cycles"] =
true;
662 if(anim[
"layer"].empty()) {
663 anim[
"layer"] = default_layer;
666 if(anim[
"offscreen"].empty()) {
667 anim[
"offscreen"] =
false;
670 animations.emplace_back(anim);
676 anim[
"apply_to"] =
"default";
677 anim[
"cycles"] =
true;
680 std::string sub_frame_name = ci->key;
681 std::size_t pos = sub_frame_name.find(
"_frame");
682 if(pos != std::string::npos) {
683 anim[sub_frame_name.substr(0, pos) +
"_cycles"] =
true;
687 if(anim[
"layer"].empty()) {
688 anim[
"layer"] = default_layer;
691 if(anim[
"offscreen"].empty()) {
692 anim[
"offscreen"] =
false;
695 animations.emplace_back(anim);
700 anim[
"apply_to"] =
"healing";
701 anim[
"value"] = anim[
"damage"];
703 if(anim[
"layer"].empty()) {
704 anim[
"layer"] = default_layer;
707 animations.emplace_back(anim);
712 anim[
"apply_to"] =
"healed";
713 anim[
"value"] = anim[
"healing"];
715 if(anim[
"layer"].empty()) {
716 anim[
"layer"] = default_layer;
719 animations.emplace_back(anim);
720 animations.back().sub_anims_[
"_healed_sound"] =
particle();
723 animations.back().sub_anims_[
"_healed_sound"].add_frame(1,
frame_builder().
sound(healed_sound),
true);
728 anim[
"apply_to"] =
"poisoned";
729 anim[
"value"] = anim[
"damage"];
731 if(anim[
"layer"].empty()) {
732 anim[
"layer"] = default_layer;
735 animations.emplace_back(anim);
736 animations.back().sub_anims_[
"_poison_sound"] =
particle();
744 anim[
"apply_to"] =
"movement";
746 if(anim[
"offset"].empty()) {
747 anim[
"offset"] =
"0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,0~1:200,";
750 if(anim[
"layer"].empty()) {
751 anim[
"layer"] = move_layer;
754 animations.emplace_back(anim);
761 anim[
"apply_to"] =
"defend";
763 if(anim[
"layer"].empty()) {
764 anim[
"layer"] = default_layer;
767 if(!anim[
"damage"].empty() && anim[
"value"].empty()) {
768 anim[
"value"] = anim[
"damage"];
771 if(anim[
"hits"].empty()) {
772 anim[
"hits"] =
false;
773 animations.emplace_back(anim);
774 animations.back().base_score_--;
777 animations.emplace_back(anim);
778 animations.back().base_score_--;
780 image::locator image_loc = animations.back().get_last_frame().end_parameters().image;
784 .blend(
"0.0,0.5:75,0.0:75,0.5:75,0.0", {255,0,0}));
786 for(
const std::string& hit_type :
utils::split(anim[
"hits"])) {
788 tmp[
"hits"] = hit_type;
790 animations.emplace_back(tmp);
792 image::locator image_loc = animations.back().get_last_frame().end_parameters().image;
793 if(hit_type ==
"yes" || hit_type == strike_result::hit || hit_type == strike_result::kill) {
797 .blend(
"0.0,0.5:75,0.0:75,0.5:75,0.0", {255,0,0}));
808 anim[
"apply_to"] =
"attack";
810 if(anim[
"layer"].empty()) {
811 anim[
"layer"] = move_layer;
815 if(anim[
"offset"].empty() && missile_fs.
empty()) {
816 anim[
"offset"] =
"0~0.6,0.6~0";
819 if(!missile_fs.empty()) {
820 if(anim[
"missile_offset"].empty()) {
821 anim[
"missile_offset"] =
"0~0.8";
824 if(anim[
"missile_layer"].empty()) {
825 anim[
"missile_layer"] = missile_layer;
835 animations.emplace_back(anim);
840 anim[
"apply_to"] =
"death";
842 if(anim[
"layer"].empty()) {
843 anim[
"layer"] = default_layer;
846 animations.emplace_back(anim);
847 image::locator image_loc = animations.back().get_last_frame().end_parameters().image;
852 .highlight(
"1~0:600"));
854 if(!cfg[
"die_sound"].empty()) {
855 animations.back().sub_anims_[
"_death_sound"] =
particle();
856 animations.back().sub_anims_[
"_death_sound"].add_frame(1,
frame_builder().
sound(cfg[
"die_sound"]),
true);
864 anim[
"apply_to"] = anim[
"flag"];
866 if(anim[
"layer"].empty()) {
867 anim[
"layer"] = default_layer;
870 animations.emplace_back(anim);
875 if(anim[
"layer"].empty()) {
876 anim[
"layer"] = default_layer;
879 anim[
"apply_to"] =
"pre_teleport";
880 animations.emplace_back(anim);
881 animations.back().unit_anim_.set_end_time(0);
883 anim[
"apply_to"] =
"post_teleport";
884 animations.emplace_back(anim);
885 animations.back().unit_anim_.remove_frames_until(0);
892 ,
const std::string& highlight
893 ,
const std::string& blend_ratio
895 ,
const std::string& offset
896 ,
const std::string& layer
897 ,
const std::string& modifiers)
919 if(parameters_.need_update())
return true;
933 , last_frame_begin_time_(0)
939 if(!range.empty() && cfg[frame_string +
"start_time"].
empty()) {
940 for(
const config& frame : range) {
947 for(
const config& frame : range) {
952 cycles_ = cfg[frame_string +
"cycles"].to_bool(
false);
964 if(anim.second.need_update())
return true;
979 if(anim.second.need_minimal_update())
return true;
989 if(!anim.second.animation_finished())
return false;
999 if(!anim.second.animation_finished_potential())
return false;
1010 anim.second.update_last_draw_time(acceleration);
1018 result = std::max<int>(result, anim.second.get_end_time());
1028 result = std::min<int>(result, anim.second.get_begin_time());
1037 ,
const std::string& text
1039 ,
const bool accelerate)
1056 anim.second.start_animation(start_time);
1071 anim.second.pause_animation();
1080 anim.second.restart_animation();
1094 anim.second.redraw(value,
src_,
dst_, halo_man);
1103 anim.second.clear_halo();
1115 if(complete_redraw) {
1121 std::set<map_location> tmp = anim.second.get_overlaped_hex(value,
src_,
dst_);
1131 if(complete_redraw) {
1153 std::ostringstream outstream;
1155 return outstream.str();
1161 outstream <<
"[" << events_string <<
"]\n";
1163 outstream <<
"\tstart_time=" << u_animation.
get_begin_time() <<
'\n';
1165 if(u_animation.
hits_.size() > 0) {
1166 std::vector<std::string> hits;
1168 outstream <<
"\thits=" <<
utils::join(hits) <<
'\n';
1172 std::vector<std::string> dirs;
1174 outstream <<
"\tdirections=" <<
utils::join(dirs) <<
'\n';
1184 outstream <<
"[filter]\n";
1186 outstream << cfg.
debug();
1189 outstream <<
"[/filter]\n";
1193 outstream <<
"[filter_second]\n";
1195 outstream << cfg.
debug();
1198 outstream <<
"[/filter_second]\n";
1202 outstream <<
"[filter_attack]\n";
1204 outstream << cfg.
debug();
1207 outstream <<
"[/filter_attack]\n";
1211 outstream <<
"[filter_second_attack]\n";
1213 outstream << cfg.
debug();
1216 outstream <<
"[/filter_second_attack]\n";
1220 outstream <<
"\t[frame]\n";
1222 outstream <<
"\t\t" << frame_string <<
"\n";
1224 outstream <<
"\t[/frame]\n";
1227 for(std::pair<std::string, unit_animation::particle>
p : u_animation.
sub_anims_) {
1228 for(std::size_t
i = 0;
i <
p.second.get_frames_count();
i++) {
1229 std::string sub_frame_name =
p.first;
1230 std::size_t pos = sub_frame_name.find(
"_frame");
1231 if(pos != std::string::npos) sub_frame_name = sub_frame_name.substr(0, pos);
1233 outstream <<
"\t" << sub_frame_name <<
"_start_time=" <<
p.second.get_begin_time() <<
'\n';
1234 outstream <<
"\t[" <<
p.first <<
"]\n";
1236 for(
const std::string& frame_string :
p.second.get_frame(
i).debug_strings()) {
1237 outstream <<
"\t\t" << frame_string <<
'\n';
1240 outstream <<
"\t[/" <<
p.first <<
"]\n";
1244 outstream <<
"[/" << events_string <<
"]\n";
1250 const unit_frame& current_frame = get_current_frame();
1257 if(animation_time > get_current_frame_end_time()) in_scope_of_frame =
false;
1266 current_frame.
redraw(get_current_frame_time(),
true, in_scope_of_frame, src, dst, halo_id_, halo_man, default_val, value);
1268 current_frame.
redraw(get_current_frame_time(),
false, in_scope_of_frame, src, dst, halo_id_, halo_man, default_val, value);
1279 const unit_frame& current_frame = get_current_frame();
1281 return current_frame.
get_overlaped_hex(get_current_frame_time(), src, dst, default_val,value);
1292 parameters_.override(get_animation_duration());
1298 ,
const std::string& event
1303 ,
const std::string& text
1310 if(!animated_unit)
return;
1313 tmp.
my_unit = std::move(animated_unit);
1318 tmp.
animation = tmp.
my_unit->anim_comp().choose_animation(src, event, dst, value, hit_type, attack, second_attack, value2);
1323 animated_units_.push_back(std::move(tmp));
1330 ,
const std::string& text
1333 if(!animated_unit)
return;
1336 tmp.
my_unit = std::move(animated_unit);
1346 animated_units_.push_back(std::move(tmp));
1350 ,
const std::string& event
1359 return (animated_unit && animated_unit->anim_comp().choose_animation(src, event, dst, value, hit_type, attack, second_attack, value2));
1363 ,
const std::string& event
1368 ,
const std::string& text
1375 if(!animated_unit)
return;
1377 if(animated_unit->anim_comp().get_animation() &&
1378 !animated_unit->anim_comp().get_animation()->animation_finished_potential() &&
1379 animated_unit->anim_comp().get_animation()->matches(
1390 animated_units_.push_back(std::move(tmp));
1392 add_animation(animated_unit,event,src,dst,value,with_bars,text,text_color,hit_type,attack,second_attack,value2);
1398 int begin_time = INT_MAX;
1400 for(
const auto& anim : animated_units_) {
1401 if(anim.my_unit->anim_comp().get_animation()) {
1402 if(anim.animation) {
1403 begin_time = std::min<int>(begin_time, anim.animation->get_begin_time());
1405 begin_time = std::min<int>(begin_time, anim.my_unit->anim_comp().get_animation()->get_begin_time());
1410 for(
auto& anim : animated_units_) {
1411 if(anim.animation) {
1412 anim.my_unit->anim_comp().start_animation(begin_time, anim.animation, anim.with_bars, anim.text, anim.text_color);
1413 anim.animation =
nullptr;
1415 anim.my_unit->anim_comp().get_animation()->update_parameters(anim.src, anim.src.get_direction(anim.my_unit->facing()));
1422 bool finished =
true;
1423 for(
const auto& anim : animated_units_) {
1424 finished &= anim.my_unit->anim_comp().get_animation()->animation_finished_potential();
1432 if(animated_units_.empty()) {
1437 animated_units_[0].my_unit->anim_comp().get_animation()->set_max_animation_time(animation_time);
1444 int end_tick = animated_units_[0].my_unit->anim_comp().get_animation()->time_to_tick(animation_time);
1445 while(SDL_GetTicks() <
unsigned(end_tick - std::min(
int(20 / speed), 20))) {
1450 end_tick = animated_units_[0].my_unit->anim_comp().get_animation()->time_to_tick(animation_time);
1454 SDL_Delay(std::max<int>(0, end_tick - SDL_GetTicks() + 5));
1458 animated_units_[0].my_unit->anim_comp().get_animation()->set_max_animation_time(0);
1465 bool finished =
false;
1472 for(
const auto& anim : animated_units_) {
1473 finished &= anim.my_unit->anim_comp().get_animation()->animation_finished_potential();
1480 if(animated_units_.empty()) {
1483 return animated_units_[0].my_unit->anim_comp().get_animation()->get_animation_time() ;
1488 if(animated_units_.empty()) {
1491 return animated_units_[0].my_unit->anim_comp().get_animation()->get_animation_time_potential() ;
1496 int end_time = INT_MIN;
1497 for(
const auto& anim : animated_units_) {
1498 if(anim.my_unit->anim_comp().get_animation()) {
1499 end_time = std::max<int>(end_time, anim.my_unit->anim_comp().get_animation()->get_end_time());
1508 for(
const auto& anim : animated_units_) {
1509 if(anim.my_unit->anim_comp().get_animation()) {
1510 anim.my_unit->anim_comp().get_animation()->pause_animation();
1517 for(
const auto& anim : animated_units_) {
1518 if(anim.my_unit->anim_comp().get_animation()) {
1519 anim.my_unit->anim_comp().get_animation()->restart_animation();
1526 for(
const auto& anim : animated_units_) {
1527 anim.my_unit->anim_comp().set_standing();
void new_animation_frame()
std::list< animation_branch > animation_branches
static void prepare_single_animation(const config &anim_cfg, animation_branches &expanded_anims)
static std::string get_heal_sound(const config &cfg)
static animation_branches prepare_animation(const config &cfg, const std::string &animation_tag)
static void add_simple_anim(std::vector< unit_animation > &animations, const config &cfg, char const *tag_name, char const *apply_to, display::drawing_layer layer=display::LAYER_UNIT_DEFAULT, bool offscreen=true)
const T & get_frame(std::size_t n) const
void set_end_time(int ending_time)
bool animation_finished_potential() const
int get_begin_time() const
void update_last_draw_time(double acceleration=0)
void start_animation(int start_time, bool cycles=false)
Starts an animation cycle.
int get_animation_duration() const
const unit_frame & get_last_frame() const
void set_begin_time(int new_begin_time)
bool animation_finished() const
Returns true if the current animation was finished.
std::size_t get_frames_count() const
void add_frame(int duration, const unit_frame &value, bool force_change=false)
Adds a frame to an animation.
Variant for storing WML attributes.
bool empty() const
Tests for an attribute that either was never set or was set to "".
A config object defines a single node in a WML file, with access to child nodes.
boost::iterator_range< const_all_children_iterator > const_all_children_itors
config & add_child_at(config_key_type key, const config &val, std::size_t index)
const_all_children_itors all_children_range() const
In-order iteration over all children.
child_itors child_range(config_key_type key)
std::string debug() const
boost::iterator_range< const_child_iterator > const_child_itors
config & add_child(config_key_type key)
virtual void play_slice(bool is_delay_enabled=true)
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
const unit_map & get_units() const
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
drawing_layer
The layers to render something on.
@ LAYER_UNIT_FIRST
Reserve layers to be selected for WML.
@ LAYER_UNIT_MISSILE_DEFAULT
default layer for missile frames
@ LAYER_UNIT_DEFAULT
default layer for drawing units
@ LAYER_UNIT_MOVE_DEFAULT
default layer for drawing moving units
double turbo_speed() const
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
const gamemap & get_map() const
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
static display * get_singleton()
Returns the display object if a display object exists.
Keep most parameters in a separate class to simplify the handling of the large number of parameters b...
void override(int duration, const std::string &highlight="", const std::string &blend_ratio="", color_t blend_color={0, 0, 0}, const std::string &offset="", const std::string &layer="", const std::string &modifiers="")
bool does_not_change() const
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Generic locator abstracting the location of an image.
const std::string & get_filename() const
const std::string & get_modifications() const
static rng & default_instance()
void start_animation(int start_time)
std::set< map_location > get_overlaped_hex(const frame_parameters &value, const map_location &src, const map_location &dst)
frame_parsed_parameters parameters_
bool need_minimal_update() const
void override(int start_time, int duration, const cycle_state cycles, const std::string &highlight="", const std::string &blend_ratio="", color_t blend_color={0, 0, 0}, const std::string &offset="", const std::string &layer="", const std::string &modifiers="")
particle(int start_time=0, const frame_builder &builder=frame_builder())
void redraw(const frame_parameters &value, const map_location &src, const map_location &dst, halo::manager &halo_man)
bool invalidate(frame_parameters &value)
std::vector< config > primary_attack_filter_
std::vector< int > value2_
bool need_minimal_update() const
void start_animation(int start_time, const map_location &src=map_location::null_location(), const map_location &dst=map_location::null_location(), const std::string &text="", const color_t text_color={0, 0, 0}, const bool accelerate=true)
int get_animation_time() const
bool animation_finished_potential() const
std::vector< config > secondary_unit_filter_
void add_frame(int duration, const unit_frame &value, bool force_change=false)
int matches(const map_location &loc, const map_location &second_loc, unit_const_ptr my_unit, const std::string &event="", const int value=0, strike_result::type hit=strike_result::type::invalid, const_attack_ptr attack=nullptr, const_attack_ptr second_attack=nullptr, int value2=0) const
t_translation::ter_list terrain_types_
std::vector< std::string > event_
int get_current_frame_begin_time() const
std::vector< int > value_
std::string debug() const
void update_last_draw_time()
std::map< std::string, particle > sub_anims_
void update_parameters(const map_location &src, const map_location &dst)
int get_begin_time() const
void redraw(frame_parameters &value, halo::manager &halo_man)
std::set< map_location > overlaped_hex_
std::vector< map_location::DIRECTION > directions_
friend std::ostream & operator<<(std::ostream &outstream, const unit_animation &u_animation)
static void fill_initial_animations(std::vector< unit_animation > &animations, const config &cfg)
std::vector< config > secondary_attack_filter_
std::vector< config > unit_filter_
static void add_anims(std::vector< unit_animation > &animations, const config &cfg)
std::vector< strike_result::type > hits_
bool animation_finished() const
void replace_anim_if_invalid(unit_const_ptr animated_unit, const std::string &event, const map_location &src=map_location::null_location(), const map_location &dst=map_location::null_location(), const int value=0, bool with_bars=false, const std::string &text="", const color_t text_color={0, 0, 0}, const strike_result::type hit_type=strike_result::type::invalid, const_attack_ptr attack=nullptr, const_attack_ptr second_attack=nullptr, int value2=0)
void wait_until(int animation_time) const
int get_animation_time() const
bool has_animation(unit_const_ptr animated_unit, const std::string &event, const map_location &src=map_location::null_location(), const map_location &dst=map_location::null_location(), const int value=0, const strike_result::type hit_type=strike_result::type::invalid, const_attack_ptr attack=nullptr, const_attack_ptr second_attack=nullptr, int value2=0) const
has_animation : return an boolean value if animated unit present and have animation specified,...
void wait_for_end() const
void add_animation(unit_const_ptr animated_unit, const unit_animation *animation, const map_location &src=map_location::null_location(), bool with_bars=false, const std::string &text="", const color_t text_color={0, 0, 0})
int get_animation_time_potential() const
Describes a unit's animation sequence.
void redraw(const int frame_time, bool on_start_time, bool in_scope_of_frame, const map_location &src, const map_location &dst, halo::handle &halo_id, halo::manager &halo_man, const frame_parameters &animation_val, const frame_parameters &engine_val) const
bool does_not_change() const
std::vector< std::string > debug_strings() const
std::set< map_location > get_overlaped_hex(const int frame_time, const map_location &src, const map_location &dst, const frame_parameters &animation_val, const frame_parameters &engine_val) const
unit_iterator find(std::size_t id)
This class represents a single unit of a specific type.
A variable-expanding proxy for the config class.
Functions to load and save images from/to disk.
play_controller * controller
Audio output for sound and music.
bool terrain_matches(const terrain_code &src, const terrain_code &dest)
Tests whether a specific terrain matches an expression, for matching rules see above.
ter_list read_list(std::string_view str, const ter_layer filler)
Reads a list of terrains from a string, when reading the.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::vector< std::string > split(const config_attribute_value &val)
std::shared_ptr< const unit > unit_const_ptr
std::shared_ptr< const attack_type > const_attack_ptr
std::vector< config::const_all_children_iterator > children
animation_branches branches
animation_cursor(const config &cfg)
animation_cursor(const config &cfg, animation_cursor *p)
config::const_all_children_itors itors
animation_cursor * parent
The basic class for representing 8-bit RGB or RGBA colour values.
All parameters from a frame at a given instant.
boost::tribool primary_frame
Encapsulates the map of the game.
static DIRECTION parse_direction(const std::string &str)
DIRECTION
Valid directions which can be moved in our hexagonal world.
static std::string write_direction(DIRECTION dir)
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.
const unit_animation * animation