Taking things from the LootUI to the StatusUI works way better now and there's a DropTarget to match the GrabSource.

This commit is contained in:
Zed A. Shaw 2025-06-08 00:37:30 -04:00
parent 842aac3127
commit 461ad03d27
8 changed files with 93 additions and 70 deletions

View file

@ -43,7 +43,10 @@ namespace gui {
} else {
$gui.set<Textual>(button, {guecs::to_wstring(name)});
$gui.set<Clickable>(button, {
guecs::make_action(*$level.world, Events::GUI::INV_SELECT, {name})
guecs::make_action(*$level.world, Events::GUI::INV_SELECT, {button})
});
$gui.set<DropTarget>(button, {
[&, button]() -> bool { return place_slot(button); }
});
}
}
@ -80,22 +83,20 @@ namespace gui {
init();
}
void StatusUI::select_slot(int slot_id, DinkyECS::Entity entity) {
$selected_slot = slot_id;
void StatusUI::select_slot(DinkyECS::Entity entity) {
$selected_entity = entity;
}
int StatusUI::place_slot(const std::string &name) {
fmt::println("LOOT slot={}, entity={} PLACE into slot={}",
$selected_slot, $selected_entity, name);
bool StatusUI::place_slot(DinkyECS::Entity gui_id) {
if($level.world->has<components::Sprite>($selected_entity)) {
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;
$gui.set_init<guecs::Sprite>(gui_id, {sprite.name});
$slots.insert_or_assign(gui_id, $selected_entity);
return true;
} else {
return false;
}
}
}