Quick start to making it possible to use healing items, or any item really. Going with a style that it has to be on your toolbar to use it, and the toolbelt looks in your inventory to see ifyou have healing items.

This commit is contained in:
Zed A. Shaw 2025-08-06 13:16:22 -04:00
parent b9656013b0
commit 0d889cd0ff
4 changed files with 22 additions and 3 deletions

View file

@ -3,6 +3,7 @@
#include "rituals.hpp"
#include <fmt/xchar.h>
#include "gui/guecstra.hpp"
#include "inventory.hpp"
namespace gui {
using namespace guecs;
@ -13,7 +14,7 @@ namespace gui {
$gui.position(COMBAT_UI_X, COMBAT_UI_Y, COMBAT_UI_WIDTH, COMBAT_UI_HEIGHT);
$gui.layout(
"[button_0 | button_1 | button_2 | button_3"
"|button_4 | button_5 | button_6 | hp_gauge ]"
"|button_4 | button_5 | button_6 | healing_button | hp_gauge ]"
);
}
@ -63,6 +64,19 @@ namespace gui {
}
}
auto healing_button = $gui.entity("healing_button");
auto& inventory = $level.world->get<inventory::Model>($level.player);
if(inventory.has("pocket_l")) {
auto healing_item = inventory.get("pocket_l");
$gui.set<Icon>(healing_button, {"healing_potion_small"});
$gui.set<Clickable>(healing_button,
guecs::make_action($level, Events::GUI::USE_ITEM, {healing_item}));
} else {
$gui.remove<Icon>(healing_button);
$gui.remove<Clickable>(healing_button);
}
auto hp_gauge = $gui.entity("hp_gauge");
$gui.set<Sprite>(hp_gauge, {"stone_doll_cursed"});
$gui.set<Clickable>(hp_gauge,