#pragma once #include #include "gui/event_router.hpp" #include "gui/guecstra.hpp" #include "events.hpp" #include namespace animator { enum class State { START=__LINE__, ANIMATE=__LINE__, END=__LINE__, }; enum class Event { TICK=__LINE__, PLAY_STOP=__LINE__, RELOAD=__LINE__, }; struct FSM; struct UI { guecs::UI $ui; void button(const std::string& name, std::function cb); void init(const std::string& sprite_name, int width, int height); void render(sf::RenderWindow& window, bool debug=false); bool mouse(float x, float y, guecs::Modifiers mods); std::shared_ptr get_sprite(); }; struct FSM : public DeadSimpleFSM { UI $ui; gui::routing::Router $router; sf::RenderWindow $window; sf::Vector2f $pos{0,0}; sf::Vector2f $scale{0,0}; std::shared_ptr $sprite = nullptr; animate2::Animate2 $anim; std::string $sprite_name=""; std::filesystem::file_time_type $last_mod_time; sf::Clock $timer; 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(); void run_animation(); void tick(); void reload(); void check_update(); }; }