Initially implemented 'ritual blanket' UI for the crafting of rituals in combat.

This commit is contained in:
Zed A. Shaw 2025-03-19 22:10:17 -04:00
parent 263b7741f6
commit 65c9e4b0c6
5 changed files with 56 additions and 30 deletions

View file

@ -12,31 +12,40 @@ namespace gui {
{
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
$gui.layout(
"[ ritual_ui ]"
"[inv_slot1 | inv_slot2 | inv_slot3]"
"[inv_slot4 | inv_slot5 | inv_slot6]"
"[*%(100,300)circle_area]"
"[_]"
"[_]");
"[inv_slot5 | inv_slot6 | inv_slot7| inv_slot8]"
"[inv_slot9 | inv_slot10 | inv_slot11| inv_slot12]"
"[inv_slot13 | inv_slot14 | inv_slot15| inv_slot16]"
"[inv_slot17 | inv_slot18 | inv_slot19| inv_slot20]"
"[inv_slot21 | inv_slot22 | inv_slot23| inv_slot24]"
"[*%(100,500)circle_area]"
"[_]"
"[_]"
"[_]"
"[_]"
"[ ritual_ui ]");
}
void RitualUI::init() {
$gui.world().set_the<Background>({$gui.$parser});
// $gui.world().set_the<Background>({$gui.$parser});
for(auto& [name, cell] : $gui.cells()) {
if(name == "circle_area") {
dbc::log("circle area not setup...");
} else {
auto button = $gui.entity(name);
$gui.set<Rectangle>(button, {});
$gui.set<Textual>(button, {""});
$gui.set<ActionData>(button, {make_any<string>(name)});
auto button = $gui.entity(name);
if(name == "ritual_ui") {
$gui.set<Clickable>(button, {
[this](auto, auto){ select_ritual(); }
});
}
if(name == "circle_area") {
// $gui.set<Rectangle>(button, {});
$gui.set<Clickable>(button, {
[this](auto, auto){ dbc::log("circle clicked"); }
});
} else if(name.starts_with("inv_slot")) {
// $gui.set<Rectangle>(button, {});
$gui.set<Clickable>(button, {
[this, name](auto, auto){ dbc::log(fmt::format("inv_slot {}", name)); }
});
} else if(name == "ritual_ui") {
$gui.set<Clickable>(button, {
[this](auto, auto){ toggle(); }
});
}
}
@ -55,7 +64,15 @@ namespace gui {
$gui.init();
}
void RitualUI::select_ritual() {
bool RitualUI::is_open() {
return $ritual_state != RitualUIState::CLOSED;
}
bool RitualUI::mouse(float x, float y) {
return $gui.mouse(x, y);
}
void RitualUI::toggle() {
using enum RitualUIState;
switch($ritual_state) {
@ -117,5 +134,6 @@ namespace gui {
$ritual_ui.sprite->setScale(scale);
window.draw(*$ritual_ui.sprite);
if($ritual_state == OPEN) $gui.render(window);
}
}