Combat UI can now send events to the GUIwhen they click on buttons, and I've got a crappy wood texture for the buttons to test that.

This commit is contained in:
Zed A. Shaw 2025-02-18 14:24:57 -05:00
parent 722d55d948
commit 69a810b5a1
7 changed files with 38 additions and 20 deletions

View file

@ -1,6 +1,7 @@
#include "combat_ui.hpp"
#include "constants.hpp"
#include "color.hpp"
#include "events.hpp"
namespace gui {
using namespace guecs;
@ -11,7 +12,7 @@ namespace gui {
$gui.position(RAY_VIEW_X, RAY_VIEW_HEIGHT, RAY_VIEW_WIDTH, SCREEN_HEIGHT - RAY_VIEW_HEIGHT);
$gui.layout(
"[*%(100,150)button_attack1 | *%(100,150)button_attack2 | *%(100,150)button_attack3 | *%(100,150)button_heal]"
"[ >.%(100,50)label_hp | *%.(190,50)bar_hp | _ ]");
"[ >.%(100,50)label_hp | *%.(198,50)bar_hp | _ ]");
}
void CombatUI::render(TexturePack& textures) {
@ -22,8 +23,9 @@ namespace gui {
auto button = $gui.entity(name);
world.set<lel::Cell>(button, cell);
world.set<Sprite>(button, {"trash_button"});
world.set<Clickable>(button, {100});
world.set<Textual>(button, {"Button"});
world.set<Clickable>(button,
guecs::make_action(*$level.world, Events::GUI::ATTACK));
world.set<Textual>(button, {"Attack"});
} else if(name.starts_with("bar_")) {
$meter = $gui.entity(name);
world.set<lel::Cell>($meter, cell);