34 return cfg[
"healed_sound"].
empty() ?
"heal.wav" : cfg[
"healed_sound"].str();
50 std::vector<config::const_all_children_iterator>
children;
60 branches.back().attributes.merge_attributes(cfg);
70 bool previously_hits_set =
false;
71 bool previously_direction_set =
false;
72 bool previously_terrain_set =
false;
73 bool previously_value_set =
false;
74 bool previously_value_2nd_set =
false;
76 const std::string s_cfg_hits = cfg[
"hits"];
77 const std::string s_cfg_direction = cfg[
"direction"];
78 const std::string s_cfg_terrain = cfg[
"terrain_types"];
79 const std::string s_cfg_value = cfg[
"value"];
80 const std::string s_cfg_value_2nd = cfg[
"value_2nd"];
83 const std::string s_branch_hits = branch.attributes[
"hits"];
84 const std::string s_branch_direction = branch.attributes[
"direction"];
85 const std::string s_branch_terrain = branch.attributes[
"terrain_types"];
86 const std::string s_branch_value = branch.attributes[
"value"];
87 const std::string s_branch_value_2nd = branch.attributes[
"value_second"];
89 if(!s_branch_hits.empty() && s_branch_hits == s_cfg_hits) {
90 previously_hits_set =
true;
93 if(!s_branch_direction.empty() && s_branch_direction == s_cfg_direction) {
94 previously_direction_set =
true;
97 if(!s_branch_terrain.empty() && s_branch_terrain == s_cfg_terrain) {
98 previously_terrain_set =
true;
101 if(!s_branch_value.empty() && s_branch_value == s_cfg_value) {
102 previously_value_set =
true;
105 if(!s_branch_value_2nd.empty() && s_branch_value_2nd == s_cfg_value_2nd) {
106 previously_value_2nd_set =
true;
113 const std::string s_branch_hits = (*iter).attributes[
"hits"];
114 const std::string s_branch_direction = (*iter).attributes[
"direction"];
115 const std::string s_branch_terrain = (*iter).attributes[
"terrain_types"];
116 const std::string s_branch_value = (*iter).attributes[
"value"];
117 const std::string s_branch_value_2nd = (*iter).attributes[
"value_second"];
119 const bool hits_match = (previously_hits_set && s_branch_hits != s_cfg_hits);
120 const bool direction_match = (previously_direction_set && s_branch_direction != s_cfg_direction);
121 const bool terrain_match = (previously_terrain_set && s_branch_terrain != s_cfg_terrain);
122 const bool value_match = (previously_value_set && s_branch_value != s_cfg_value);
123 const bool value_2nd_match = (previously_value_2nd_set && s_branch_value_2nd != s_cfg_value_2nd);
125 if((!previously_hits_set || hits_match) &&
126 (!previously_direction_set || direction_match) &&
127 (!previously_terrain_set || terrain_match) &&
128 (!previously_value_set || value_match) &&
129 (!previously_value_2nd_set || value_2nd_match) &&
130 (hits_match || direction_match || terrain_match || value_match || value_2nd_match))
134 (*iter).attributes.merge_attributes(cfg);
142 const std::string s_branch_hits = (*iter).attributes[
"hits"];
143 const std::string s_branch_direction = (*iter).attributes[
"direction"];
144 const std::string s_branch_terrain = (*iter).attributes[
"terrain_types"];
145 const std::string s_branch_value = (*iter).attributes[
"value"];
146 const std::string s_branch_value_2nd = (*iter).attributes[
"value_second"];
148 const bool hits_match = (previously_hits_set && s_branch_hits == s_cfg_hits);
149 const bool direction_match = (previously_direction_set && s_branch_direction == s_cfg_direction);
150 const bool terrain_match = (previously_terrain_set && s_branch_terrain == s_cfg_terrain);
151 const bool value_match = (previously_value_set && s_branch_value == s_cfg_value);
152 const bool value_2nd_match = (previously_value_2nd_set && s_branch_value_2nd == s_cfg_value_2nd);
154 if((!previously_hits_set || hits_match) &&
155 (!previously_direction_set || direction_match) &&
156 (!previously_terrain_set || terrain_match) &&
157 (!previously_value_set || value_match) &&
158 (!previously_value_2nd_set || value_2nd_match) &&
159 (hits_match || direction_match || terrain_match || value_match || value_2nd_match))
181 std::list<animation_cursor> anim_cursors;
182 anim_cursors.emplace_back(anim_cfg);
184 while(!anim_cursors.empty()) {
188 if(ac.
itors.empty()) {
193 anim_cursors.pop_back();
197 if(ac.
itors.front().key !=
"if") {
203 ac.
itors.pop_front();
211 anim_cursors.emplace_back(ac.
itors.front().cfg, &ac);
212 ac.
itors.pop_front();
214 }
while (!ac.
itors.empty() && ac.
itors.front().key ==
"else");
225 std::cout <<
"--branch--\n" << ab.attributes;
227 std::cout <<
"--branchcfg--\n" << ci->cfg;
234 assert(anim_cursors.size() == 1);
246 return expanded_animations;
253 , secondary_unit_filter_()
256 , base_score_(variation)
259 , primary_attack_filter_()
260 , secondary_attack_filter_()
264 , unit_anim_(start_time,builder)
267 , invalidated_(false)
268 , play_offscreen_(true)
277 , secondary_unit_filter_()
279 , frequency_(cfg[
"frequency"].to_int())
280 , base_score_(cfg[
"base_score"].to_int())
283 , primary_attack_filter_()
284 , secondary_attack_filter_()
288 , unit_anim_(cfg,frame_string)
291 , invalidated_(false)
292 , play_offscreen_(true)
298 if(key == frame_string) {
302 if(key.find(
"_frame", key.size() - 6) == std::string::npos) {
315 const std::vector<std::string>& my_directions =
utils::split(cfg[
"direction"]);
316 for(
const auto& direction : my_directions) {
341 value_.push_back(atoi(v.c_str()));
345 if(
h ==
"yes" ||
h == strike_result::hit) {
346 hits_.push_back(strike_result::type::hit);
349 if(
h ==
"no" ||
h == strike_result::miss) {
350 hits_.push_back(strike_result::type::miss);
353 if(
h ==
"yes" ||
h == strike_result::kill ) {
354 hits_.push_back(strike_result::type::kill);
358 for(
const auto& v2 :
utils::split(cfg[
"value_second"])) {
359 value2_.push_back(atoi(v2.c_str()));
380 if(!event.empty() && !
event_.empty()) {
462 if(!attack->matches_filter(iter))
return MATCH_FAIL;
473 if(!second_attack->matches_filter(iter))
return MATCH_FAIL;
484 std::vector<unit_animation> animation_base;
485 for(
const auto& anim : animations) {
486 if(std::find(anim.event_.begin(), anim.event_.end(),
"default") != anim.event_.end()) {
487 animation_base.push_back(anim);
489 animation_base.back().event_.clear();
493 const std::string default_image = cfg[
"image"];
495 if(animation_base.empty()) {
501 frame_builder().
image(default_image).duration(300).blend(
"0.0~0.3:100,0.3~0.0:200", {255,255,255}),
502 "_disabled_selected_", 0));
504 for(
const auto& base : animation_base) {
505 animations.push_back(base);
506 animations.back().event_ = {
"standing" };
507 animations.back().play_offscreen_ =
false;
509 animations.push_back(base);
510 animations.back().event_ = {
"_ghosted_" };
511 animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),
particle::UNSET,
"0.9",
"", {0,0,0},
"",
"",
"~GS()");
513 animations.push_back(base);
514 animations.back().event_ = {
"_disabled_ghosted_" };
515 animations.back().unit_anim_.override(0, 1,
particle::UNSET,
"0.4",
"", {0,0,0},
"",
"",
"~GS()");
517 animations.push_back(base);
518 animations.back().event_ = {
"selected" };
519 animations.back().unit_anim_.override(0, 300,
particle::UNSET,
"",
"0.0~0.3:100,0.3~0.0:200", {255,255,255});
521 animations.push_back(base);
522 animations.back().event_ = {
"recruited" };
525 animations.push_back(base);
526 animations.back().event_ = {
"levelin" };
527 animations.back().unit_anim_.override(0, 600,
particle::NO_CYCLE,
"",
"1~0:600", {255,255,255});
529 animations.push_back(base);
530 animations.back().event_ = {
"levelout" };
531 animations.back().unit_anim_.override(0, 600,
particle::NO_CYCLE,
"",
"0~1:600,1", {255,255,255});
533 animations.push_back(base);
534 animations.back().event_ = {
"pre_movement" };
537 animations.push_back(base);
538 animations.back().event_ = {
"post_movement" };
541 animations.push_back(base);
542 animations.back().event_ = {
"movement" };
543 animations.back().unit_anim_.override(0, 200,
546 animations.push_back(base);
547 animations.back().event_ = {
"defend" };
548 animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),
550 animations.back().hits_.push_back(strike_result::type::hit);
551 animations.back().hits_.push_back(strike_result::type::kill);
553 animations.push_back(base);
554 animations.back().event_ = {
"defend" };
556 animations.push_back(base);
557 animations.back().event_ = {
"attack" };
558 animations.back().unit_anim_.override(-150, 300,
particle::NO_CYCLE,
"",
"", {0,0,0},
"0~0.6:150,0.6~0:150", std::to_string(
get_abs_frame_layer(
drawing_layer::unit_move_default)));
559 animations.back().primary_attack_filter_.emplace_back(
"range",
"melee");
561 animations.push_back(base);
562 animations.back().event_ = {
"attack" };
564 animations.back().primary_attack_filter_.emplace_back(
"range",
"ranged");
566 animations.push_back(base);
567 animations.back().event_ = {
"death" };
569 animations.back().sub_anims_[
"_death_sound"] =
particle();
570 animations.back().sub_anims_[
"_death_sound"].add_frame(1,
frame_builder().
sound(cfg[
"die_sound"]),
true);
572 animations.push_back(base);
573 animations.back().event_ = {
"victory" };
574 animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),
particle::CYCLE);
576 animations.push_back(base);
578 animations.back().event_ = {
"pre_teleport" };
580 animations.push_back(base);
582 animations.back().event_ = {
"post_teleport" };
584 animations.push_back(base);
585 animations.back().event_ = {
"healing" };
587 animations.push_back(base);
588 animations.back().event_ = {
"healed" };
589 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});
593 animations.back().sub_anims_[
"_healed_sound"].add_frame(1,
frame_builder().
sound(healed_sound),
true);
595 animations.push_back(base);
596 animations.back().event_ = {
"poisoned" };
597 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});
598 animations.back().sub_anims_[
"_poison_sound"] =
particle();
604 const config& cfg,
char const* tag_name,
char const* apply_to,
606 bool offscreen =
true)
610 anim[
"apply_to"] = apply_to;
614 if(v.
empty()) v =
false;
620 animations.emplace_back(anim);
627 animations.emplace_back(ab.merge());
645 anim[
"apply_to"] =
"standing";
646 anim[
"cycles"] =
true;
650 std::string sub_frame_name = ci->key;
651 std::size_t pos = sub_frame_name.find(
"_frame");
652 if(pos != std::string::npos) {
653 anim[sub_frame_name.substr(0, pos) +
"_cycles"] =
true;
657 if(anim[
"layer"].empty()) {
658 anim[
"layer"] = default_layer;
661 if(anim[
"offscreen"].empty()) {
662 anim[
"offscreen"] =
false;
665 animations.emplace_back(anim);
671 anim[
"apply_to"] =
"default";
672 anim[
"cycles"] =
true;
675 std::string sub_frame_name = ci->key;
676 std::size_t pos = sub_frame_name.find(
"_frame");
677 if(pos != std::string::npos) {
678 anim[sub_frame_name.substr(0, pos) +
"_cycles"] =
true;
682 if(anim[
"layer"].empty()) {
683 anim[
"layer"] = default_layer;
686 if(anim[
"offscreen"].empty()) {
687 anim[
"offscreen"] =
false;
690 animations.emplace_back(anim);
695 anim[
"apply_to"] =
"healing";
696 anim[
"value"] = anim[
"damage"];
698 if(anim[
"layer"].empty()) {
699 anim[
"layer"] = default_layer;
702 animations.emplace_back(anim);
707 anim[
"apply_to"] =
"healed";
708 anim[
"value"] = anim[
"healing"];
710 if(anim[
"layer"].empty()) {
711 anim[
"layer"] = default_layer;
714 animations.emplace_back(anim);
715 animations.back().sub_anims_[
"_healed_sound"] =
particle();
718 animations.back().sub_anims_[
"_healed_sound"].add_frame(1,
frame_builder().
sound(healed_sound),
true);
723 anim[
"apply_to"] =
"poisoned";
724 anim[
"value"] = anim[
"damage"];
726 if(anim[
"layer"].empty()) {
727 anim[
"layer"] = default_layer;
730 animations.emplace_back(anim);
731 animations.back().sub_anims_[
"_poison_sound"] =
particle();
739 anim[
"apply_to"] =
"movement";
741 if(anim[
"offset"].empty()) {
742 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,";
745 if(anim[
"layer"].empty()) {
746 anim[
"layer"] = move_layer;
749 animations.emplace_back(anim);
756 anim[
"apply_to"] =
"defend";
758 if(anim[
"layer"].empty()) {
759 anim[
"layer"] = default_layer;
762 if(!anim[
"damage"].empty() && anim[
"value"].empty()) {
763 anim[
"value"] = anim[
"damage"];
766 if(anim[
"hits"].empty()) {
767 anim[
"hits"] =
false;
768 animations.emplace_back(anim);
769 animations.back().base_score_--;
772 animations.emplace_back(anim);
773 animations.back().base_score_--;
775 image::locator image_loc = animations.back().get_last_frame().end_parameters().image;
779 .blend(
"0.0,0.5:75,0.0:75,0.5:75,0.0", {255,0,0}));
781 for(
const std::string& hit_type :
utils::split(anim[
"hits"])) {
783 tmp[
"hits"] = hit_type;
785 animations.emplace_back(tmp);
787 image::locator image_loc = animations.back().get_last_frame().end_parameters().image;
788 if(hit_type ==
"yes" || hit_type == strike_result::hit || hit_type == strike_result::kill) {
792 .blend(
"0.0,0.5:75,0.0:75,0.5:75,0.0", {255,0,0}));
803 anim[
"apply_to"] =
"attack";
805 if(anim[
"layer"].empty()) {
806 anim[
"layer"] = move_layer;
810 if(anim[
"offset"].empty() && missile_fs.
empty()) {
811 anim[
"offset"] =
"0~0.6,0.6~0";
814 if(!missile_fs.empty()) {
815 if(anim[
"missile_offset"].empty()) {
816 anim[
"missile_offset"] =
"0~0.8";
819 if(anim[
"missile_layer"].empty()) {
820 anim[
"missile_layer"] = missile_layer;
830 animations.emplace_back(anim);
835 anim[
"apply_to"] =
"death";
837 if(anim[
"layer"].empty()) {
838 anim[
"layer"] = default_layer;
841 animations.emplace_back(anim);
842 image::locator image_loc = animations.back().get_last_frame().end_parameters().image;
847 .highlight(
"1~0:600"));
849 if(!cfg[
"die_sound"].empty()) {
850 animations.back().sub_anims_[
"_death_sound"] =
particle();
851 animations.back().sub_anims_[
"_death_sound"].add_frame(1,
frame_builder().
sound(cfg[
"die_sound"]),
true);
859 anim[
"apply_to"] = anim[
"flag"];
861 if(anim[
"layer"].empty()) {
862 anim[
"layer"] = default_layer;
865 animations.emplace_back(anim);
870 if(anim[
"layer"].empty()) {
871 anim[
"layer"] = default_layer;
874 anim[
"apply_to"] =
"pre_teleport";
875 animations.emplace_back(anim);
876 animations.back().unit_anim_.set_end_time(0);
878 anim[
"apply_to"] =
"post_teleport";
879 animations.emplace_back(anim);
880 animations.back().unit_anim_.remove_frames_until(0);
887 ,
const std::string& highlight
888 ,
const std::string& blend_ratio
890 ,
const std::string& offset
891 ,
const std::string& layer
892 ,
const std::string& modifiers)
914 if(parameters_.need_update())
return true;
928 , last_frame_begin_time_(0)
934 if(!range.empty() && cfg[frame_string +
"start_time"].
empty()) {
935 for(
const config& frame : range) {
942 for(
const config& frame : range) {
947 cycles_ = cfg[frame_string +
"cycles"].to_bool(
false);
959 if(anim.second.need_update())
return true;
974 if(anim.second.need_minimal_update())
return true;
984 if(!anim.second.animation_finished())
return false;
994 if(!anim.second.animation_finished_potential())
return false;
1005 anim.second.update_last_draw_time(acceleration);
1013 result = std::max<int>(result, anim.second.get_end_time());
1023 result = std::min<int>(result, anim.second.get_begin_time());
1032 ,
const std::string& text
1034 ,
const bool accelerate)
1051 anim.second.start_animation(start_time);
1066 anim.second.pause_animation();
1075 anim.second.restart_animation();
1089 anim.second.redraw(value,
src_,
dst_, halo_man);
1098 anim.second.clear_halo();
1110 if(complete_redraw) {
1116 std::set<map_location> tmp = anim.second.get_overlaped_hex(value,
src_,
dst_);
1126 if(complete_redraw) {
1148 std::ostringstream outstream;
1150 return outstream.str();
1156 outstream <<
"[" << events_string <<
"]\n";
1158 outstream <<
"\tstart_time=" << u_animation.
get_begin_time() <<
'\n';
1160 if(u_animation.
hits_.size() > 0) {
1161 std::vector<std::string> hits;
1163 outstream <<
"\thits=" <<
utils::join(hits) <<
'\n';
1167 std::vector<std::string> dirs;
1169 outstream <<
"\tdirections=" <<
utils::join(dirs) <<
'\n';
1179 outstream <<
"[filter]\n";
1181 outstream << cfg.
debug();
1184 outstream <<
"[/filter]\n";
1188 outstream <<
"[filter_second]\n";
1190 outstream << cfg.
debug();
1193 outstream <<
"[/filter_second]\n";
1197 outstream <<
"[filter_attack]\n";
1199 outstream << cfg.
debug();
1202 outstream <<
"[/filter_attack]\n";
1206 outstream <<
"[filter_second_attack]\n";
1208 outstream << cfg.
debug();
1211 outstream <<
"[/filter_second_attack]\n";
1215 outstream <<
"\t[frame]\n";
1217 outstream <<
"\t\t" << frame_string <<
"\n";
1219 outstream <<
"\t[/frame]\n";
1222 for(std::pair<std::string, unit_animation::particle>
p : u_animation.
sub_anims_) {
1223 for(std::size_t
i = 0;
i <
p.second.get_frames_count();
i++) {
1224 std::string sub_frame_name =
p.first;
1225 std::size_t pos = sub_frame_name.find(
"_frame");
1226 if(pos != std::string::npos) sub_frame_name = sub_frame_name.substr(0, pos);
1228 outstream <<
"\t" << sub_frame_name <<
"_start_time=" <<
p.second.get_begin_time() <<
'\n';
1229 outstream <<
"\t[" <<
p.first <<
"]\n";
1231 for(
const std::string& frame_string :
p.second.get_frame(
i).debug_strings()) {
1232 outstream <<
"\t\t" << frame_string <<
'\n';
1235 outstream <<
"\t[/" <<
p.first <<
"]\n";
1239 outstream <<
"[/" << events_string <<
"]\n";
1245 const unit_frame& current_frame = get_current_frame();
1252 if(animation_time > get_current_frame_end_time()) in_scope_of_frame =
false;
1261 current_frame.
redraw(get_current_frame_time(),
true, in_scope_of_frame,
src,
dst, halo_id_, halo_man, default_val, value);
1263 current_frame.
redraw(get_current_frame_time(),
false, in_scope_of_frame,
src,
dst, halo_id_, halo_man, default_val, value);
1274 const unit_frame& current_frame = get_current_frame();
1287 parameters_.override(get_animation_duration());
1293 ,
const std::string& event
1298 ,
const std::string& text
1305 if(!animated_unit)
return;
1308 animated_unit->anim_comp().choose_animation(
src, event,
dst, value, hit_type, attack, second_attack, value2);
1311 start_time_ = std::max<int>(start_time_, anim->
get_begin_time());
1312 animated_units_.AGGREGATE_EMPLACE(std::move(animated_unit), anim, text, text_color,
src, with_bars);
1319 ,
const std::string& text
1322 if(!animated_unit || !anim)
return;
1324 start_time_ = std::max<int>(start_time_, anim->
get_begin_time());
1325 animated_units_.AGGREGATE_EMPLACE(std::move(animated_unit), anim, text, text_color,
src, with_bars);
1329 ,
const std::string& event
1338 return (animated_unit && animated_unit->anim_comp().choose_animation(
src, event,
dst, value, hit_type, attack, second_attack, value2));
1342 ,
const std::string& event
1347 ,
const std::string& text
1354 if(!animated_unit)
return;
1356 if(animated_unit->anim_comp().get_animation() &&
1357 !animated_unit->anim_comp().get_animation()->animation_finished_potential() &&
1358 animated_unit->anim_comp().get_animation()->matches(
1361 animated_units_.AGGREGATE_EMPLACE(animated_unit,
nullptr, text, text_color,
src, with_bars);
1363 add_animation(animated_unit,event,
src,
dst,value,with_bars,text,text_color,hit_type,attack,second_attack,value2);
1369 int begin_time = std::numeric_limits<int>::max();
1371 for(
const auto& anim : animated_units_) {
1372 if(anim.my_unit->anim_comp().get_animation()) {
1373 if(anim.animation) {
1374 begin_time = std::min<int>(begin_time, anim.animation->get_begin_time());
1376 begin_time = std::min<int>(begin_time, anim.my_unit->anim_comp().get_animation()->get_begin_time());
1381 for(
auto& anim : animated_units_) {
1382 if(anim.animation) {
1383 anim.my_unit->anim_comp().start_animation(begin_time, anim.animation, anim.with_bars, anim.text, anim.text_color);
1384 anim.animation =
nullptr;
1386 anim.my_unit->anim_comp().get_animation()->update_parameters(anim.src, anim.src.get_direction(anim.my_unit->facing()));
1393 bool finished =
true;
1394 for(
const auto& anim : animated_units_) {
1395 finished &= anim.my_unit->anim_comp().get_animation()->animation_finished_potential();
1403 if(animated_units_.empty()) {
1408 animated_units_[0].my_unit->anim_comp().get_animation()->set_max_animation_time(animation_time);
1415 int end_tick = animated_units_[0].my_unit->anim_comp().get_animation()->time_to_tick(animation_time);
1416 while(SDL_GetTicks() <
unsigned(end_tick - std::min(
int(20 / speed), 20))) {
1421 end_tick = animated_units_[0].my_unit->anim_comp().get_animation()->time_to_tick(animation_time);
1425 SDL_Delay(std::max<int>(0, end_tick - SDL_GetTicks() + 5));
1429 animated_units_[0].my_unit->anim_comp().get_animation()->set_max_animation_time(0);
1436 bool finished =
false;
1443 for(
const auto& anim : animated_units_) {
1444 finished &= anim.my_unit->anim_comp().get_animation()->animation_finished_potential();
1451 if(animated_units_.empty()) {
1454 return animated_units_[0].my_unit->anim_comp().get_animation()->get_animation_time() ;
1459 if(animated_units_.empty()) {
1462 return animated_units_[0].my_unit->anim_comp().get_animation()->get_animation_time_potential() ;
1467 int end_time = std::numeric_limits<int>::min();
1468 for(
const auto& anim : animated_units_) {
1469 if(anim.my_unit->anim_comp().get_animation()) {
1470 end_time = std::max<int>(end_time, anim.my_unit->anim_comp().get_animation()->get_end_time());
1479 for(
const auto& anim : animated_units_) {
1480 if(anim.my_unit->anim_comp().get_animation()) {
1481 anim.my_unit->anim_comp().get_animation()->pause_animation();
1488 for(
const auto& anim : animated_units_) {
1489 if(anim.my_unit->anim_comp().get_animation()) {
1490 anim.my_unit->anim_comp().get_animation()->restart_animation();
1497 for(
const auto& anim : animated_units_) {
1498 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 void add_simple_anim(std::vector< unit_animation > &animations, const config &cfg, char const *tag_name, char const *apply_to, drawing_layer layer=drawing_layer::unit_default, bool offscreen=true)
static animation_branches prepare_animation(const config &cfg, const std::string &animation_tag)
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
auto all_children_view() const
In-order iteration over all children.
config & add_child_at(config_key_type key, const config &val, std::size_t index)
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)
virtual const gamemap & map() const =0
virtual const unit_map & units() const =0
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
double turbo_speed() const
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
const display_context & context() const
static display * get_singleton()
Returns the display object if a display object exists.
Easily build frame parameters with the serialized constructors.
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< map_location::direction > directions_
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_
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.
map_display and display: classes which take care of displaying the map and game-data on the screen.
@ unit_missile_default
Default layer for missile frames.
@ unit_default
Default layer for drawing units.
@ unit_move_default
Default layer for drawing moving units.
constexpr int get_abs_frame_layer(drawing_layer layer)
Functions to load and save images from/to disk.
play_controller * controller
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
rect dst
Location on the final composed sheet.
rect src
Non-transparent portion of the surface to compose.
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 std::string write_direction(direction dir)
direction
Valid directions which can be moved in our hexagonal world.
static direction parse_direction(const std::string &str)
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.