From 0fefc83c36e1b33828cc58a3dc6c3a839c876719 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 22 Feb 2026 23:40:00 -0500 Subject: [PATCH] stories.json now encodes the duration for a transform so that the time code of the event isn't also controlling the time that the transform runs. --- assets/stories.json | 25 ++++++++++++------------- camera.cpp | 5 +++-- components.hpp | 2 +- storyboard/ui.cpp | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/assets/stories.json b/assets/stories.json index 4ceea23..1961517 100644 --- a/assets/stories.json +++ b/assets/stories.json @@ -9,19 +9,18 @@ "[g|h|i]" ], "beats": [ - ["00:00", "a","pan"], - ["00:01", "a","shake"], - ["00:02", "a","pause"], - ["00:03", "g","pan"], - ["00:04", "h","pan"], - ["00:05", "h","bounce"], - ["00:06", "c1","pan"], - ["00:07", "c2","pan"], - ["00:08", "d","bounce"], - ["00:09", "e","shake"], - ["00:10", "i","pan"], - ["00:11", "i","shake"], - ["00:12", "i","bounce"] + ["00:00", "a","pan", "60"], + ["00:01", "a","shake", "30"], + ["00:5", "g","pan", "60"], + ["00:6", "h","pan", "60"], + ["00:7", "h","bounce", "60"], + ["00:8", "c1","pan", "60"], + ["00:9", "c2","pan", "60"], + ["00:10", "d","bounce", "60"], + ["00:11", "e","shake", "60"], + ["00:12", "i","pan", "60"], + ["00:13", "i","shake", "60"], + ["00:14", "i","bounce", "60"] ] } } diff --git a/camera.cpp b/camera.cpp index a0a75e7..cc1e5c1 100644 --- a/camera.cpp +++ b/camera.cpp @@ -4,6 +4,7 @@ #include "config.hpp" #include #include +#include namespace cinematic { using animate2::Animate2, std::string, std::min, std::clamp; @@ -120,8 +121,8 @@ namespace cinematic { anim.sequences.clear(); anim.forms.clear(); - for(auto& [timecode, cell, transform] : story.beats) { - animate2::Sequence seq{.frames={0}, .durations={60}}; + for(auto& [timecode, cell, transform, duration] : story.beats) { + animate2::Sequence seq{.frames={0}, .durations={std::stoi(duration)}}; anim.sequences.try_emplace(timecode, seq); animate2::Form form{timecode, transform}; diff --git a/components.hpp b/components.hpp index 9f33b95..17d5285 100644 --- a/components.hpp +++ b/components.hpp @@ -107,7 +107,7 @@ namespace components { std::string image; std::string audio; std::vector layout; - std::vector> beats; + std::vector> beats; }; struct Combat { diff --git a/storyboard/ui.cpp b/storyboard/ui.cpp index 68ab1aa..a98a637 100644 --- a/storyboard/ui.cpp +++ b/storyboard/ui.cpp @@ -67,7 +67,7 @@ namespace storyboard { } void UI::track_audio() { - auto& [timecode, cell_name, form] = $story.beats[cur_beat % $story.beats.size()]; + auto& [timecode, cell_name, form, _] = $story.beats[cur_beat % $story.beats.size()]; auto track_head = $audio->getPlayingOffset(); auto next_beat = parse_time_code(timecode);