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:
parent
570b70ab0c
commit
be7b86a913
6 changed files with 17 additions and 13 deletions
|
@ -89,7 +89,8 @@ namespace gui {
|
|||
if($level.world->has<components::Sprite>(world_entity)) {
|
||||
auto& sprite = $level.world->get<components::Sprite>(world_entity);
|
||||
$gui.set_init<guecs::Sprite>(gui_id, {sprite.name});
|
||||
$gui.set<guecs::GrabSource>(gui_id, {world_entity});
|
||||
$gui.set<guecs::GrabSource>(gui_id, {world_entity,
|
||||
[&, gui_id]() { return remove_slot(gui_id); }});
|
||||
contents.insert_or_assign(gui_id, world_entity);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -107,9 +108,11 @@ namespace gui {
|
|||
return $gui.get<guecs::GrabSource>(gui_id);
|
||||
}
|
||||
|
||||
void StatusUI::commit_grab(DinkyECS::Entity slot_id) {
|
||||
contents.erase(slot_id);
|
||||
$gui.remove<guecs::GrabSource>(slot_id);
|
||||
$gui.remove<guecs::Sprite>(slot_id);
|
||||
void StatusUI::remove_slot(DinkyECS::Entity slot_id) {
|
||||
if(contents.contains(slot_id)) {
|
||||
contents.erase(slot_id);
|
||||
$gui.remove<guecs::GrabSource>(slot_id);
|
||||
$gui.remove<guecs::Sprite>(slot_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue