From 8a1f42c0f198556b3a618bf6111de8e52e4ae134 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 1 May 2025 00:24:11 -0400 Subject: [PATCH] RitualUI is now ritual::UI and uses a FSM to coordinate its activities. --- guecs.cpp | 8 ++ guecs.hpp | 2 + ritual_ui.cpp | 270 +++++++++++++++----------------------------------- ritual_ui.hpp | 76 +++++++------- status_ui.cpp | 4 +- status_ui.hpp | 2 +- 6 files changed, 136 insertions(+), 226 deletions(-) diff --git a/guecs.cpp b/guecs.cpp index dc7dabf..47b8af8 100644 --- a/guecs.cpp +++ b/guecs.cpp @@ -125,6 +125,14 @@ namespace guecs { $parser.position(x, y, width, height); } + sf::Vector2f UI::get_position() { + return {float($parser.grid_x), float($parser.grid_y)}; + } + + sf::Vector2f UI::get_size() { + return {float($parser.grid_w), float($parser.grid_h)}; + } + void UI::layout(std::string grid) { $grid = grid; bool good = $parser.parse($grid); diff --git a/guecs.hpp b/guecs.hpp index f686bc7..679f127 100644 --- a/guecs.hpp +++ b/guecs.hpp @@ -136,6 +136,8 @@ namespace guecs { UI(); void position(int x, int y, int width, int height); + sf::Vector2f get_position(); + sf::Vector2f get_size(); void layout(std::string grid); DinkyECS::Entity init_entity(std::string name); DinkyECS::Entity entity(std::string name); diff --git a/ritual_ui.cpp b/ritual_ui.cpp index 7279a9b..1df238a 100644 --- a/ritual_ui.cpp +++ b/ritual_ui.cpp @@ -7,217 +7,109 @@ #include "sound.hpp" namespace gui { - using namespace guecs; - using std::any, std::any_cast, std::string, std::make_any; - - RitualUI::RitualUI(GameLevel level) : - $level(level) - { - $gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT); - $gui.layout( - "[_]" - "[inv_slot0 | inv_slot1 | inv_slot2| inv_slot3]" - "[inv_slot4 | inv_slot5 | inv_slot6| inv_slot7]" - "[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]" - "[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]" - "[reset |*%(200,400)result_text|_]" - "[*%(100,200)result_image|_ |_]" - "[_|_|_]" - "[combine|_|_]" - "[_|craft0|craft1|craft2|craft3|_]" - "[_|craft4|craft5|craft6|craft7|_]" - "[ ritual_ui ]"); - } - - void RitualUI::init() { - update_items(); - - auto combine = $gui.entity("combine"); - $gui.set(combine, {0.4f}); - $gui.set(combine, {"the_ritual_circle"}); - $gui.set(combine, { - [&](auto ent, auto){ combine_clicked(ent); } - }); - - auto result_image = $gui.entity("result_image"); - $gui.set(result_image, {"severed_finger-128"}); - $gui.set(result_image, {10, {60, 60, 60, 30}}); - - auto result_text = $gui.entity("result_text"); - $gui.set(result_text, {15, {60, 60, 60, 30}}); - $gui.set(result_text, { - L"Celiac migas\nunicorn hexagon.\nBrooklyn williamsburg\ntruffaut pickled\nchillwave raclette\nchurch-key sus.", 16, ColorValue::LIGHT_LIGHT, 10}); - - auto reset = $gui.entity("reset"); - $gui.set(reset, {5, {60, 60, 60, 30}}); - $gui.set