Have a simple thing that moves every 3 seconds of a song/audio playing to a new panel.
This commit is contained in:
parent
de7f9f3445
commit
b5280b4a4d
3 changed files with 35 additions and 1 deletions
|
|
@ -1,14 +1,17 @@
|
||||||
#include "storyboard/ui.hpp"
|
#include "storyboard/ui.hpp"
|
||||||
#include "components.hpp"
|
#include "components.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
#include "sound.hpp"
|
||||||
|
|
||||||
namespace storyboard {
|
namespace storyboard {
|
||||||
UI::UI() :
|
UI::UI() :
|
||||||
$view_texture({SCREEN_WIDTH, SCREEN_HEIGHT}),
|
$view_texture({SCREEN_WIDTH, SCREEN_HEIGHT}),
|
||||||
$view_sprite($view_texture.getTexture())
|
$view_sprite($view_texture.getTexture()),
|
||||||
|
$audio(sound::get_sound_pair("ambient_1").sound)
|
||||||
{
|
{
|
||||||
$view_sprite.setPosition({0, 0});
|
$view_sprite.setPosition({0, 0});
|
||||||
$camera.style("pan");
|
$camera.style("pan");
|
||||||
|
sound::play("ambient_1", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::init() {
|
void UI::init() {
|
||||||
|
|
@ -23,9 +26,14 @@ namespace storyboard {
|
||||||
"[a|b|c]"
|
"[a|b|c]"
|
||||||
"[*%(200,100)d|_|f]"
|
"[*%(200,100)d|_|f]"
|
||||||
"[g|h|i]");
|
"[g|h|i]");
|
||||||
|
|
||||||
|
for(auto& [key, value] : $ui.$parser.cells) {
|
||||||
|
$cell_names.push_back(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::render(sf::RenderWindow &window) {
|
void UI::render(sf::RenderWindow &window) {
|
||||||
|
track_audio();
|
||||||
$view_texture.clear();
|
$view_texture.clear();
|
||||||
|
|
||||||
$camera.render($view_texture);
|
$camera.render($view_texture);
|
||||||
|
|
@ -36,6 +44,26 @@ namespace storyboard {
|
||||||
window.draw($view_sprite);
|
window.draw($view_sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UI::track_audio() {
|
||||||
|
int track_head = int($audio->getPlayingOffset().asSeconds());
|
||||||
|
|
||||||
|
if(track_head % 3 == 0) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
// get the new target from the cell names
|
||||||
|
$zoom_target = $cell_names.at(track_head % $cell_names.size());
|
||||||
|
zoom($zoom_target);
|
||||||
|
$camera.play();
|
||||||
|
} else {
|
||||||
|
$moving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool UI::mouse(float x, float y, guecs::Modifiers mods) {
|
bool UI::mouse(float x, float y, guecs::Modifiers mods) {
|
||||||
auto& cell = $ui.cell_for($zoom_target);
|
auto& cell = $ui.cell_for($zoom_target);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include <guecs/ui.hpp>
|
#include <guecs/ui.hpp>
|
||||||
#include "camera.hpp"
|
#include "camera.hpp"
|
||||||
|
#include <SFML/Audio/Sound.hpp>
|
||||||
|
|
||||||
namespace storyboard {
|
namespace storyboard {
|
||||||
|
|
||||||
|
|
@ -10,7 +11,10 @@ namespace storyboard {
|
||||||
sf::RenderTexture $view_texture;
|
sf::RenderTexture $view_texture;
|
||||||
sf::Sprite $view_sprite;
|
sf::Sprite $view_sprite;
|
||||||
cinematic::Camera $camera;
|
cinematic::Camera $camera;
|
||||||
|
std::shared_ptr<sf::Sound> $audio;
|
||||||
std::string $zoom_target = "a";
|
std::string $zoom_target = "a";
|
||||||
|
int $moving = false;
|
||||||
|
std::vector<std::string> $cell_names;
|
||||||
|
|
||||||
UI();
|
UI();
|
||||||
|
|
||||||
|
|
@ -19,6 +23,7 @@ namespace storyboard {
|
||||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||||
void zoom(const std::string &cell_name);
|
void zoom(const std::string &cell_name);
|
||||||
void reset();
|
void reset();
|
||||||
|
void track_audio();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ int main(int, char*[]) {
|
||||||
guecs::init(&backend);
|
guecs::init(&backend);
|
||||||
animation::init();
|
animation::init();
|
||||||
cinematic::init();
|
cinematic::init();
|
||||||
|
sound::init();
|
||||||
|
|
||||||
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Storyboard Editor");
|
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Storyboard Editor");
|
||||||
window.setVerticalSyncEnabled(VSYNC);
|
window.setVerticalSyncEnabled(VSYNC);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue