From 87459d41bbccf7c10a905881ea3c93da9ef8fbc1 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Tue, 17 Jun 2025 12:46:17 -0400 Subject: [PATCH] Add the buttons I'll need for the next round of development. --- gui/loot_ui.cpp | 19 +++++++++++++------ gui/loot_ui.hpp | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gui/loot_ui.cpp b/gui/loot_ui.cpp index 2a2b19f..f95dbbe 100644 --- a/gui/loot_ui.cpp +++ b/gui/loot_ui.cpp @@ -16,21 +16,28 @@ namespace gui { "[item_4 | item_5 |item_6 | item_7 ]" "[item_8 | item_9 |item_10| item_11]" "[item_12| item_13|item_14|item_15 ]" - "[_ | %(100,50)close| _]" + "[ =take_all | =close| =destroy]" ); } + void LootUI::make_button(const std::string &name, const std::wstring& label, Events::GUI event) { + + auto button = $gui.entity(name); + $gui.set(button, {}); + $gui.set(button, {label}); + $gui.set(button, + guecs::make_action($level, event)); + } + void LootUI::init() { using guecs::THEME; auto bg_color = THEME.DARK_LIGHT; bg_color.a = 140; $gui.set($gui.MAIN, {$gui.$parser, bg_color}); - auto close = $gui.entity("close"); - $gui.set(close, {}); - $gui.set(close, {L"CLOSE"}); - $gui.set(close, - guecs::make_action($level, Events::GUI::LOOT_CLOSE)); + make_button("close", L"CLOSE", Events::GUI::LOOT_CLOSE); + make_button("take_all", L"TAKE ALL", Events::GUI::LOOT_CLOSE); + make_button("destroy", L"DESTROY", Events::GUI::LOOT_CLOSE); for(int i = 0; i < INV_SLOTS; i++) { auto id = $gui.entity("item_", i); diff --git a/gui/loot_ui.hpp b/gui/loot_ui.hpp index 2dc857d..8762bbb 100644 --- a/gui/loot_ui.hpp +++ b/gui/loot_ui.hpp @@ -20,6 +20,7 @@ namespace gui { void render(sf::RenderWindow& window); void update_level(GameLevel &level); bool mouse(float x, float y, bool hover); + void make_button(const std::string &name, const std::wstring& label, Events::GUI event); void remove_slot(DinkyECS::Entity slot_id); bool place_slot(DinkyECS::Entity gui_id, DinkyECS::Entity world_entity);