Mostly refactored out the common things for drag/drop so now just to refine how it's used and bring back moving the sprite around.

This commit is contained in:
Zed A. Shaw 2025-06-10 00:52:38 -04:00
parent 570b70ab0c
commit be7b86a913
6 changed files with 17 additions and 13 deletions

View file

@ -46,7 +46,7 @@ namespace gui {
update();
}
void LootUI::commit_grab(DinkyECS::Entity slot_id) {
void LootUI::remove_slot(DinkyECS::Entity slot_id) {
contents.erase(slot_id);
update();
}
@ -67,7 +67,8 @@ namespace gui {
"item in inventory UI doesn't exist in world. New level?");
auto& sprite = $level.world->get<components::Sprite>(item);
$gui.set_init<guecs::Sprite>(id, {sprite.name});
$gui.set<guecs::GrabSource>(id, {item});
$gui.set<guecs::GrabSource>(id, {
item, [&, id]() { return remove_slot(id); }});
} else {
$gui.set<guecs::DropTarget>(id, {
[&, id](DinkyECS::Entity world_entity) -> bool { return place_slot(id, world_entity); }