More of the drag/drop is handled by the GrabSource/DropTarget components.

This commit is contained in:
Zed A. Shaw 2025-06-09 23:59:44 -04:00
parent 7a551cf83a
commit 570b70ab0c
7 changed files with 36 additions and 81 deletions

View file

@ -134,22 +134,17 @@ namespace gui {
break;
case LOOT_SELECT: {
$grab_source = std::any_cast<DinkyECS::Entity>(data);
if(auto world_entity = $loot_ui.begin_grab(*$grab_source)) {
$status_ui.begin_drop(*world_entity);
} else {
// BUG: need a cancel operation here
$grab_source = std::nullopt;
state(State::LOOTING);
}
auto& source = $loot_ui.get_grab_source(*$grab_source);
source.grab();
} break;
case INV_SELECT: {
auto gui_id = std::any_cast<DinkyECS::Entity>(data);
if($grab_source) {
auto& drop = $status_ui.get_drop_target(gui_id);
auto& grab = $loot_ui.get_grab_source(*$grab_source);
if(drop.commit()) {
if(drop.commit(grab.world_entity)) {
$loot_ui.commit_grab(*$grab_source);
$grab_source = std::nullopt;
}
@ -195,8 +190,9 @@ namespace gui {
if($grab_source) {
auto& drop = $loot_ui.get_drop_target(gui_id);
auto& grab = $status_ui.get_grab_source(*$grab_source);
if(drop.commit()) {
if(drop.commit(grab.world_entity)) {
$status_ui.commit_grab(*$grab_source);
$grab_source = std::nullopt;
}
@ -206,14 +202,8 @@ namespace gui {
} break;
case INV_SELECT: {
$grab_source = std::any_cast<DinkyECS::Entity>(data);
if(auto world_entity = $status_ui.begin_grab(*$grab_source)) {
$loot_ui.begin_drop(*world_entity);
} else {
// BUG: need a cancel operation here
$grab_source = std::nullopt;
state(State::LOOTING);
}
auto& source = $status_ui.get_grab_source(*$grab_source);
source.grab();
} break;
case MOUSE_CLICK:
mouse_action(false);