|
|
@ -62,8 +62,9 @@ namespace gui { |
|
|
|
END(CLOSE); |
|
|
|
END(CLOSE); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case LOOT_SELECT: |
|
|
|
case LOOT_SELECT: |
|
|
|
commit_move($loot_ui.$gui, $grab_source, data); |
|
|
|
if(commit_move($loot_ui.$gui, $grab_source, data)) { |
|
|
|
state(DNDState::LOOTING); |
|
|
|
state(DNDState::LOOTING); |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case INV_SELECT: |
|
|
|
case INV_SELECT: |
|
|
|
if(commit_drop($loot_ui.$gui, |
|
|
|
if(commit_drop($loot_ui.$gui, |
|
|
@ -92,9 +93,9 @@ namespace gui { |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case INV_SELECT: |
|
|
|
case INV_SELECT: |
|
|
|
// BUG: should I do a bool here and not transition?
|
|
|
|
if(commit_move($status_ui.$gui, $grab_source, data)) { |
|
|
|
commit_move($status_ui.$gui, $grab_source, data); |
|
|
|
state(DNDState::LOOTING); |
|
|
|
state(DNDState::LOOTING); |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
handle_mouse(ev, $status_ui.$gui); |
|
|
|
handle_mouse(ev, $status_ui.$gui); |
|
|
@ -111,8 +112,9 @@ namespace gui { |
|
|
|
END(CLOSE); |
|
|
|
END(CLOSE); |
|
|
|
} break; |
|
|
|
} break; |
|
|
|
case INV_SELECT: |
|
|
|
case INV_SELECT: |
|
|
|
commit_move($status_ui.$gui, $grab_source, data); |
|
|
|
if(commit_move($status_ui.$gui, $grab_source, data)) { |
|
|
|
END(CLOSE); |
|
|
|
END(CLOSE); |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
handle_mouse(ev, $status_ui.$gui); |
|
|
|
handle_mouse(ev, $status_ui.$gui); |
|
|
@ -228,8 +230,8 @@ namespace gui { |
|
|
|
dbc::check(source.has<guecs::GrabSource>(*source_id), |
|
|
|
dbc::check(source.has<guecs::GrabSource>(*source_id), |
|
|
|
"gui does not have a GrabSource at that slot"); |
|
|
|
"gui does not have a GrabSource at that slot"); |
|
|
|
|
|
|
|
|
|
|
|
auto& drop = target.get<guecs::DropTarget>(target_id); |
|
|
|
|
|
|
|
auto& grab = source.get<guecs::GrabSource>(*source_id); |
|
|
|
auto& grab = source.get<guecs::GrabSource>(*source_id); |
|
|
|
|
|
|
|
auto& drop = target.get<guecs::DropTarget>(target_id); |
|
|
|
|
|
|
|
|
|
|
|
if(drop.commit(grab.world_entity)) { |
|
|
|
if(drop.commit(grab.world_entity)) { |
|
|
|
grab.commit(); |
|
|
|
grab.commit(); |
|
|
@ -240,8 +242,9 @@ namespace gui { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void DNDLoot::commit_move(guecs::UI& gui, std::optional<guecs::Entity> source_id, std::any data) { |
|
|
|
bool DNDLoot::commit_move(guecs::UI& gui, std::optional<guecs::Entity> source_id, std::any data) { |
|
|
|
dbc::check(source_id != std::nullopt, "source_id must exist"); |
|
|
|
dbc::check(source_id != std::nullopt, "source_id must exist"); |
|
|
|
|
|
|
|
|
|
|
|
auto& grab = gui.get<guecs::GrabSource>(*source_id); |
|
|
|
auto& grab = gui.get<guecs::GrabSource>(*source_id); |
|
|
|
grab.commit(); |
|
|
|
grab.commit(); |
|
|
|
|
|
|
|
|
|
|
@ -250,13 +253,11 @@ namespace gui { |
|
|
|
|
|
|
|
|
|
|
|
if(drop.commit(grab.world_entity)) { |
|
|
|
if(drop.commit(grab.world_entity)) { |
|
|
|
clear_grab(); |
|
|
|
clear_grab(); |
|
|
|
|
|
|
|
return true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dbc::log("commit drop didn't happen"); |
|
|
|
// swap with the target instead
|
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// BUG: if the drop fails then need to put the grab back?
|
|
|
|
|
|
|
|
// How to confirm the drop will work before doing it?
|
|
|
|
|
|
|
|
// Or, maybe save the commit?
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool DNDLoot::hold_world_item() { |
|
|
|
bool DNDLoot::hold_world_item() { |
|
|
|