Animation tool now lets you cycle through different sequence/transform 'forms' and shows you which one you're viewing.
This commit is contained in:
parent
07b2102f59
commit
4356b1535e
5 changed files with 170 additions and 56 deletions
33
animate2.cpp
33
animate2.cpp
|
|
@ -157,6 +157,31 @@ namespace animate2 {
|
|||
// scale_out.x, scale_out.y);
|
||||
}
|
||||
|
||||
void Animate2::set_form(const std::string& as_form) {
|
||||
dbc::check(forms.contains(as_form),
|
||||
fmt::format("form {} does not exist in animation", as_form));
|
||||
stop();
|
||||
|
||||
const auto& [seq_name, tr_name] = forms.at(as_form);
|
||||
|
||||
dbc::check(sequences.contains(seq_name),
|
||||
fmt::format("sequences do NOT have \"{}\" name", seq_name));
|
||||
|
||||
dbc::check(transforms.contains(tr_name),
|
||||
fmt::format("transforms do NOT have \"{}\" name", tr_name));
|
||||
|
||||
// everything good, do the update
|
||||
form_name = as_form;
|
||||
sequence_name = seq_name;
|
||||
transform_name = tr_name;
|
||||
sequence = sequences.at(seq_name);
|
||||
transform = transforms.at(tr_name);
|
||||
|
||||
$frame_rects = calc_frames();
|
||||
transform.easing_func = ease2::get_easing(transform.easing);
|
||||
transform.motion_func = ease2::get_motion(transform.motion);
|
||||
}
|
||||
|
||||
Animate2 load(const std::string &file, const std::string &anim_name) {
|
||||
using nlohmann::json;
|
||||
std::ifstream infile(file);
|
||||
|
|
@ -165,10 +190,10 @@ namespace animate2 {
|
|||
Animate2 anim;
|
||||
animate2::from_json(data[anim_name], anim);
|
||||
|
||||
// BUG: json doesn't like may "fancy" no-constructor bullshit
|
||||
anim.$frame_rects = anim.calc_frames();
|
||||
anim.transform.easing_func = ease2::get_easing(anim.transform.easing);
|
||||
anim.transform.motion_func = ease2::get_motion(anim.transform.motion);
|
||||
dbc::check(anim.forms.contains("idle"),
|
||||
fmt::format("animation {} must have 'idle' form", anim_name));
|
||||
|
||||
anim.set_form("idle");
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue