Basic loot UI mostly working. Each time you open there's a torch and you can place it visually on any slot on your character.
This commit is contained in:
parent
4b34de2109
commit
5c47a0151c
13 changed files with 123 additions and 46 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <guecs/ui.hpp>
|
||||
#include "rand.hpp"
|
||||
#include <fmt/xchar.h>
|
||||
#include "gui/guecstra.hpp"
|
||||
|
||||
namespace gui {
|
||||
using namespace guecs;
|
||||
|
@ -19,13 +20,6 @@ namespace gui {
|
|||
"[hand_r|_|_ |hand_l]"
|
||||
"[ring_r|_|_ |ring_l]"
|
||||
"[pocket_r|armor_leg|pocket_l]");
|
||||
|
||||
size_t inv_id = 0;
|
||||
for(auto [name, entity] : $gui.$name_ents) {
|
||||
if(name.starts_with("inv_")) {
|
||||
$slots[name] = inv_id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StatusUI::init() {
|
||||
|
@ -49,7 +43,7 @@ namespace gui {
|
|||
} else {
|
||||
$gui.set<Textual>(button, {guecs::to_wstring(name)});
|
||||
$gui.set<Clickable>(button, {
|
||||
[this](auto ent, auto data){ select_slot(ent, data); }
|
||||
guecs::make_action(*$level.world, Events::GUI::LOOT_PLACE, {name})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -71,13 +65,6 @@ namespace gui {
|
|||
$ritual_ui.event(ritual::Event::TOGGLE);
|
||||
}
|
||||
|
||||
void StatusUI::select_slot(DinkyECS::Entity ent, any slot_name) {
|
||||
(void)ent;
|
||||
(void)slot_name;
|
||||
dbc::log("REWRITE!");
|
||||
}
|
||||
|
||||
/* WARNING: This is really not the greatest way to do this. */
|
||||
void StatusUI::update() {
|
||||
dbc::log("REWRITE ME!");
|
||||
}
|
||||
|
@ -92,4 +79,22 @@ namespace gui {
|
|||
$level = level;
|
||||
init();
|
||||
}
|
||||
|
||||
void StatusUI::select_slot(int slot_id, DinkyECS::Entity entity) {
|
||||
$selected_slot = slot_id;
|
||||
$selected_entity = entity;
|
||||
}
|
||||
|
||||
int StatusUI::place_slot(const std::string &name) {
|
||||
fmt::println("LOOT slot={}, entity={} PLACE into slot={}",
|
||||
$selected_slot, $selected_entity, name);
|
||||
|
||||
auto& sprite = $level.world->get<components::Sprite>($selected_entity);
|
||||
auto gui_id = $gui.entity(name);
|
||||
$gui.set_init<guecs::Sprite>(gui_id, {sprite.name});
|
||||
|
||||
$slots.insert_or_assign(name, $selected_entity);
|
||||
|
||||
return $selected_slot;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue