storyboard::UI now adapts the camera to fit the story beats, but really story should do that.

This commit is contained in:
Zed A. Shaw 2026-02-22 12:14:42 -05:00
parent d56b4bd335
commit 024d0cfae7
9 changed files with 123 additions and 19 deletions

View file

@ -17,6 +17,20 @@ namespace storyboard {
auto config = settings::get("stories");
$story = components::convert<components::Storyboard>(config[story_name]);
$audio = sound::get_sound_pair($story.audio).sound;
config_camera($camera);
}
void UI::config_camera(cinematic::Camera &camera) {
camera.anim.sequences.clear();
camera.anim.forms.clear();
for(auto& [timecode, cell, transform] : $story.beats) {
animate2::Sequence seq{.frames={0}, .durations={60}};
camera.anim.sequences.try_emplace(timecode, seq);
animate2::Form form{timecode, transform};
camera.anim.forms.try_emplace(timecode, form);
}
}
void UI::init() {
@ -66,20 +80,22 @@ namespace storyboard {
}
void UI::track_audio() {
auto& beat = $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(beat[0]);
auto next_beat = parse_time_code(timecode);
if(track_head >= next_beat) {
if($moving) return;
$moving = true; // prevent motion until next tick
// get the original zoom target as from
auto& cell = $ui.cell_for($zoom_target);
$camera.position(cell.mid_x, cell.mid_y);
auto& from_cell = $ui.cell_for($zoom_target);
$camera.position(from_cell.mid_x, from_cell.mid_y);
$zoom_target = cell_name;
$camera.style(timecode);
$zoom_target = beat[1];
$camera.style(beat[2]);
// get the new target from the cell names
zoom($zoom_target);
$camera.play();