Animator tool can now play, stop, loop, and toggle an animation.

This commit is contained in:
Zed A. Shaw 2026-02-02 00:02:10 -05:00
parent 7d79e75651
commit df730047ac
3 changed files with 200 additions and 142 deletions

50
tools/animator.hpp Normal file
View file

@ -0,0 +1,50 @@
#pragma once
#include <guecs/ui.hpp>
#include "gui/event_router.hpp"
#include "gui/guecstra.hpp"
#include "events.hpp"
namespace animator {
enum class State {
START=__LINE__,
ANIMATE=__LINE__,
END=__LINE__,
};
enum class Event {
TICK=__LINE__,
PLAY=__LINE__,
STOP=__LINE__,
LOOP=__LINE__,
TOGGLE=__LINE__,
};
struct FSM;
struct UI {
guecs::UI $ui;
void button(const std::string& name, std::function<void(guecs::Modifiers mods)> cb);
void init(const std::string& sprite_name, FSM& fsm);
void render(sf::RenderWindow& window);
bool mouse(float x, float y, guecs::Modifiers mods);
std::shared_ptr<sf::Sprite> get_sprite();
};
struct FSM : public DeadSimpleFSM<State, Event> {
UI $ui;
gui::routing::Router $router;
sf::RenderWindow $window{sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Animation Crafting Tool"};
void init(const std::string &sprite_name);
void event(Event ev, std::any data={});
void START(Event ev);
void ANIMATE(Event ev);
void END(Event ev);
void handle_keyboard_mouse();
void render();
bool active();
};
}