RitualUI is now ritual::UI and uses a FSM to coordinate its activities.
This commit is contained in:
parent
d1bd6b7c45
commit
8a1f42c0f1
6 changed files with 141 additions and 231 deletions
|
@ -5,40 +5,48 @@
|
|||
#include "textures.hpp"
|
||||
#include "guecs.hpp"
|
||||
#include "rituals.hpp"
|
||||
#include "fsm.hpp"
|
||||
|
||||
namespace gui {
|
||||
enum class RitualUIState {
|
||||
OPEN=0,
|
||||
CLOSED=1,
|
||||
OPENING=2,
|
||||
CLOSING=3
|
||||
};
|
||||
|
||||
class RitualUI {
|
||||
public:
|
||||
sf::IntRect $ritual_closed_rect{{0,0},{380,720}};
|
||||
sf::IntRect $ritual_open_rect{{380 * 2,0},{380,720}};
|
||||
ritual::Engine $engine;
|
||||
ritual::CraftingState $craft_state;
|
||||
RitualUIState $ritual_state = RitualUIState::CLOSED;
|
||||
textures::SpriteTexture $ritual_ui;
|
||||
components::Animation $ritual_anim;
|
||||
guecs::UI $gui;
|
||||
GameLevel $level;
|
||||
std::unordered_map<DinkyECS::Entity, DinkyECS::Entity> $selected;
|
||||
namespace ritual {
|
||||
enum class State {
|
||||
START=0,
|
||||
OPENED=1,
|
||||
CLOSED=2,
|
||||
OPENING=3,
|
||||
CLOSING=4
|
||||
};
|
||||
|
||||
RitualUI(GameLevel level);
|
||||
bool mouse(float x, float y, bool hover);
|
||||
void toggle();
|
||||
bool is_open();
|
||||
void init();
|
||||
void render(sf::RenderWindow &window);
|
||||
void update();
|
||||
|
||||
void attempt_combine();
|
||||
void update_items();
|
||||
void combine_clicked(DinkyECS::Entity ent);
|
||||
void inv_slot_clicked(DinkyECS::Entity ent, DinkyECS::Entity item_id);
|
||||
void reset_inv_positions();
|
||||
};
|
||||
enum class Event {
|
||||
STARTED=0,
|
||||
TOGGLE=1,
|
||||
TICK=2
|
||||
};
|
||||
|
||||
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}};
|
||||
components::Animation $ritual_anim;
|
||||
guecs::UI $gui;
|
||||
GameLevel $level;
|
||||
textures::SpriteTexture $ritual_ui;
|
||||
|
||||
UI(GameLevel level);
|
||||
|
||||
void event(Event ev);
|
||||
void START(Event);
|
||||
void OPENED(Event);
|
||||
void CLOSED(Event);
|
||||
void OPENING(Event);
|
||||
void CLOSING(Event);
|
||||
|
||||
bool mouse(float x, float y, bool hover);
|
||||
void render(sf::RenderWindow &window);
|
||||
bool is_open();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue