From 088f9e022e8760d9efeddc57d5c6c0e3bfb8be38 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 22 Feb 2026 23:02:02 -0500 Subject: [PATCH] Refactor the story->camera converter to be a part of the camera. --- camera.cpp | 13 +++++++++++++ camera.hpp | 5 +++++ storyboard/ui.cpp | 15 +-------------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/camera.cpp b/camera.cpp index 4f18106..a0a75e7 100644 --- a/camera.cpp +++ b/camera.cpp @@ -115,4 +115,17 @@ namespace cinematic { void Camera::play() { anim.play(); } + + void Camera::from_story(components::Storyboard& story) { + anim.sequences.clear(); + anim.forms.clear(); + + for(auto& [timecode, cell, transform] : story.beats) { + animate2::Sequence seq{.frames={0}, .durations={60}}; + anim.sequences.try_emplace(timecode, seq); + + animate2::Form form{timecode, transform}; + anim.forms.try_emplace(timecode, form); + } + } } diff --git a/camera.hpp b/camera.hpp index f63fce3..3303bfa 100644 --- a/camera.hpp +++ b/camera.hpp @@ -3,6 +3,10 @@ #include "constants.hpp" #include +namespace components { + struct Storyboard; +} + namespace cinematic { struct Camera { animate2::Animate2 anim; @@ -26,6 +30,7 @@ namespace cinematic { void style(const std::string &name); void reset(sf::RenderTexture& target); void update_camera_bounds(sf::Vector2f size); + void from_story(components::Storyboard& story); }; void init(); diff --git a/storyboard/ui.cpp b/storyboard/ui.cpp index a69080c..68ab1aa 100644 --- a/storyboard/ui.cpp +++ b/storyboard/ui.cpp @@ -17,20 +17,7 @@ namespace storyboard { auto config = settings::get("stories"); $story = components::convert(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); - } + $camera.from_story($story); } void UI::init() {