The ritual UI is now a lot better using a FSM to control everything. Probably one more session to work out the remaining functionality.

This commit is contained in:
Zed A. Shaw 2025-05-01 14:40:24 -04:00
parent 8a1f42c0f1
commit 6269d10807
7 changed files with 184 additions and 25 deletions

View file

@ -8,24 +8,30 @@
#include "fsm.hpp"
namespace gui {
namespace ritual {
enum class State {
START=0,
OPENED=1,
CLOSED=2,
OPENING=3,
CLOSING=4
CLOSING=4,
CRAFTING=5
};
enum class Event {
STARTED=0,
TOGGLE=1,
TICK=2
TICK=2,
SELECT=3,
COMBINE=4
};
class UI : public DeadSimpleFSM<State, Event>{
struct SelectedItem {
DinkyECS::Entity slot_id;
DinkyECS::Entity item_id;
};
class UI : public DeadSimpleFSM<State, Event> {
public:
sf::IntRect $ritual_closed_rect{{0,0},{380,720}};
sf::IntRect $ritual_open_rect{{380 * 2,0},{380,720}};
@ -33,12 +39,16 @@ namespace gui {
guecs::UI $gui;
GameLevel $level;
textures::SpriteTexture $ritual_ui;
::ritual::Blanket& $blanket;
::ritual::Engine $ritual_engine;
::ritual::CraftingState $craft_state;
UI(GameLevel level);
void event(Event ev);
void event(Event ev, std::any data={});
void START(Event);
void OPENED(Event);
void OPENED(Event, std::any data={});
void CRAFTING(Event, std::any data={});
void CLOSED(Event);
void OPENING(Event);
void CLOSING(Event);
@ -46,7 +56,13 @@ namespace gui {
bool mouse(float x, float y, bool hover);
void render(sf::RenderWindow &window);
bool is_open();
void load_blanket();
void clear_blanket();
void select_item(SelectedItem pair);
void show_craft_result();
void clear_craft_result();
void show_craft_failure();
void run_crafting_engine();
};
}
}