Refactor the story->camera converter to be a part of the camera.
This commit is contained in:
parent
024d0cfae7
commit
088f9e022e
3 changed files with 19 additions and 14 deletions
13
camera.cpp
13
camera.cpp
|
|
@ -115,4 +115,17 @@ namespace cinematic {
|
||||||
void Camera::play() {
|
void Camera::play() {
|
||||||
anim.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include <SFML/Graphics/RenderTexture.hpp>
|
#include <SFML/Graphics/RenderTexture.hpp>
|
||||||
|
|
||||||
|
namespace components {
|
||||||
|
struct Storyboard;
|
||||||
|
}
|
||||||
|
|
||||||
namespace cinematic {
|
namespace cinematic {
|
||||||
struct Camera {
|
struct Camera {
|
||||||
animate2::Animate2 anim;
|
animate2::Animate2 anim;
|
||||||
|
|
@ -26,6 +30,7 @@ namespace cinematic {
|
||||||
void style(const std::string &name);
|
void style(const std::string &name);
|
||||||
void reset(sf::RenderTexture& target);
|
void reset(sf::RenderTexture& target);
|
||||||
void update_camera_bounds(sf::Vector2f size);
|
void update_camera_bounds(sf::Vector2f size);
|
||||||
|
void from_story(components::Storyboard& story);
|
||||||
};
|
};
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
|
||||||
|
|
@ -17,20 +17,7 @@ namespace storyboard {
|
||||||
auto config = settings::get("stories");
|
auto config = settings::get("stories");
|
||||||
$story = components::convert<components::Storyboard>(config[story_name]);
|
$story = components::convert<components::Storyboard>(config[story_name]);
|
||||||
$audio = sound::get_sound_pair($story.audio).sound;
|
$audio = sound::get_sound_pair($story.audio).sound;
|
||||||
config_camera($camera);
|
$camera.from_story($story);
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
void UI::init() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue