Make the AIM_CLICK handler in FSM properly deal with an item already there while looting or not. Closes #56.
This commit is contained in:
parent
87e69bebde
commit
584c4e9f67
6 changed files with 41 additions and 25 deletions
|
@ -107,7 +107,8 @@ namespace gui {
|
|||
|
||||
switch(ev) {
|
||||
case AIM_CLICK: {
|
||||
bool worked = throw_on_floor();
|
||||
// take from inventory, drop on floor
|
||||
bool worked = throw_on_floor($status_ui.$gui, true);
|
||||
dbc::check(worked, "Need to fix this, should be able to abort.");
|
||||
END(CLOSE);
|
||||
} break;
|
||||
|
@ -137,12 +138,12 @@ namespace gui {
|
|||
END(CLOSE);
|
||||
}
|
||||
break;
|
||||
case AIM_CLICK:
|
||||
// BUG: because I put things into fake loot containers it's actually
|
||||
// hard to put things back. It's probably a System::remove from the
|
||||
// loot container combined with a System::drop_item
|
||||
dbc::log("Put it back?");
|
||||
break;
|
||||
case AIM_CLICK: {
|
||||
// THIS IS PUT IT BACK ON THE FLOOR
|
||||
bool worked = throw_on_floor($loot_ui.$gui, false);
|
||||
dbc::check(worked, "Failed to drop it back on the floor.");
|
||||
END(CLOSE);
|
||||
} break;
|
||||
default:
|
||||
handle_mouse(ev, $loot_ui.$gui);
|
||||
}
|
||||
|
@ -174,7 +175,7 @@ namespace gui {
|
|||
case TICK: // ignored
|
||||
break;
|
||||
default:
|
||||
dbc::sentinel(fmt::format("invalid event: {}", int(ev)));
|
||||
dbc::log(fmt::format("invalid event: {}", int(ev)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,15 +297,22 @@ namespace gui {
|
|||
* Dropping on the ground is only possible from the
|
||||
* status_ui for now.
|
||||
*/
|
||||
bool DNDLoot::throw_on_floor() {
|
||||
bool DNDLoot::throw_on_floor(guecs::UI& gui, bool from_status) {
|
||||
dbc::check($grab_source != std::nullopt, "attempt to commit_drop but no grab_source set");
|
||||
dbc::check($status_ui.$gui.has<guecs::GrabSource>(*$grab_source),
|
||||
dbc::check(gui.has<guecs::GrabSource>(*$grab_source),
|
||||
"StatusUI doesn't actually have that GrabSource in the gui.");
|
||||
|
||||
auto& grab = $status_ui.$gui.get<guecs::GrabSource>(*$grab_source);
|
||||
auto& grab = gui.get<guecs::GrabSource>(*$grab_source);
|
||||
grab.commit();
|
||||
|
||||
bool result = $status_ui.drop_item(grab.world_entity);
|
||||
bool result = false;
|
||||
|
||||
if(from_status) {
|
||||
result = $status_ui.drop_item(grab.world_entity);
|
||||
} else {
|
||||
result = $loot_ui.drop_item(grab.world_entity);
|
||||
}
|
||||
|
||||
clear_grab();
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue