From 14619558fa2d61db886f9b5eca561ec84205f161 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 28 Apr 2025 13:21:10 -0400 Subject: [PATCH] Better UI for the ritual crafting that almost works, but need to get the selected items to move down. Might need some state machine love soon. --- Makefile | 2 +- assets/rituals.json | 2 +- guecs.cpp | 4 ++ guecs.hpp | 1 + ritual_ui.cpp | 90 +++++++++++++++++++++++++++------------------ ritual_ui.hpp | 5 ++- rituals.cpp | 21 ++++++++++- rituals.hpp | 13 ++++--- tests/rituals.cpp | 9 ++++- 9 files changed, 99 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index 9e0fc75..3c7cc0c 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ tracy_build: meson compile -j 10 -C builddir test: build - ./builddir/runtests + ./builddir/runtests "[rituals-belt]" run: build test ifeq '$(OS)' 'Windows_NT' diff --git a/assets/rituals.json b/assets/rituals.json index 91758e3..fcfe060 100644 --- a/assets/rituals.json +++ b/assets/rituals.json @@ -197,6 +197,6 @@ } }, "starting_junk": [ - "mushroom", "rusty_nails" + "dirty_kerchief", "pocket_watch", "chess_pawn", "mushroom", "severed_finger", "rusty_nails" ] } diff --git a/guecs.cpp b/guecs.cpp index 7fd30fb..3c52abf 100644 --- a/guecs.cpp +++ b/guecs.cpp @@ -151,6 +151,10 @@ namespace guecs { return $name_ents.at(name); } + DinkyECS::Entity UI::entity(std::string name, int id) { + return entity(fmt::format("{}{}", name, id)); + } + void UI::init() { if($world.has_the()) { auto& bg = $world.get_the(); diff --git a/guecs.hpp b/guecs.hpp index 68e3581..68158ee 100644 --- a/guecs.hpp +++ b/guecs.hpp @@ -139,6 +139,7 @@ namespace guecs { void layout(std::string grid); DinkyECS::Entity init_entity(std::string name); DinkyECS::Entity entity(std::string name); + DinkyECS::Entity entity(std::string name, int id); inline lel::CellMap& cells() { return $parser.cells; diff --git a/ritual_ui.cpp b/ritual_ui.cpp index 2f2b7b9..6949099 100644 --- a/ritual_ui.cpp +++ b/ritual_ui.cpp @@ -20,23 +20,39 @@ namespace gui { "[inv_slot4 | inv_slot5 | inv_slot6| inv_slot7]" "[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]" "[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]" - "[*%(100,600)circle_area]" - "[_]" - "[_]" - "[_]" - "[_]" - "[_]" + "[reset |*%(200,400)result_text|_]" + "[*%(100,200)result_image|_ |_]" + "[_|_|_]" + "[combine|_|_]" + "[_|craft1|craft2|craft3|craft4|_]" + "[_|craft5|craft6|craft7|craft8|_]" "[ ritual_ui ]"); } void RitualUI::init() { update_items(); - auto circle = $gui.entity("circle_area"); - $gui.set(circle, {0.4f}); - $gui.set(circle, {"the_ritual_circle"}); - $gui.set(circle, { - [&](auto ent, auto){ ritual_circle_clicked(ent); } + 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, {}); + $gui.set