Now floor drops always work by having a drop against a wall just drop at your feet. Closes #77.

This commit is contained in:
Zed A. Shaw 2025-08-02 23:26:42 -04:00
parent 1788b8fb28
commit 694ee210d6
8 changed files with 30 additions and 38 deletions

View file

@ -111,8 +111,8 @@ namespace gui {
switch(ev) {
case AIM_CLICK: {
// take from inventory, drop on floor
bool worked = throw_on_floor($status_ui.$gui, true);
if(worked) END(CLOSE);
throw_on_floor($status_ui.$gui, true);
END(CLOSE);
} break;
case INV_SELECT: {
auto drop_id = std::any_cast<guecs::Entity>(data);
@ -137,8 +137,8 @@ namespace gui {
break;
case AIM_CLICK: {
// THIS IS PUT IT BACK ON THE FLOOR
bool worked = throw_on_floor($loot_ui.$gui, false);
if(worked) END(CLOSE);
throw_on_floor($loot_ui.$gui, false);
END(CLOSE);
} break;
default:
handle_mouse(ev, $loot_ui.$gui);
@ -282,27 +282,21 @@ namespace gui {
* Dropping on the ground is only possible from the
* status_ui for now.
*/
bool DNDLoot::throw_on_floor(guecs::UI& gui, bool from_status) {
void 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(gui.has<guecs::GrabSource>(*$grab_source),
"StatusUI doesn't actually have that GrabSource in the gui.");
auto& grab = gui.get<guecs::GrabSource>(*$grab_source);
bool result = false;
if(from_status) {
result = $status_ui.drop_item(grab.world_entity);
$status_ui.drop_item(grab.world_entity);
} else {
result = $loot_ui.drop_item(grab.world_entity);
$loot_ui.drop_item(grab.world_entity);
}
if(result) {
grab.commit();
clear_grab();
}
return result;
grab.commit();
clear_grab();
}
/*

View file

@ -53,7 +53,7 @@ namespace gui {
std::optional<guecs::Entity> source_id, guecs::Entity drop_id);
bool hold_item(guecs::UI& gui, guecs::Entity gui_id);
bool throw_on_floor(guecs::UI& gui, bool from_status);
void throw_on_floor(guecs::UI& gui, bool from_status);
void clear_grab();

View file

@ -127,10 +127,9 @@ namespace gui {
update();
}
bool LootUI::drop_item(DinkyECS::Entity item_id) {
bool dropped = System::drop_item($level, item_id);
if(dropped) update();
return dropped;
void LootUI::drop_item(DinkyECS::Entity item_id) {
System::drop_item($level, item_id);
update();
}
bool LootUI::mouse(float x, float y, bool hover) {

View file

@ -32,7 +32,7 @@ namespace gui {
void remove_slot(guecs::Entity slot_id);
bool place_slot(guecs::Entity gui_id, DinkyECS::Entity world_entity);
void add_loose_item(DinkyECS::Entity entity);
bool drop_item(DinkyECS::Entity item_id);
void drop_item(DinkyECS::Entity item_id);
bool occupied(guecs::Entity gui_id);
void swap(guecs::Entity gui_a, guecs::Entity gui_b);
};

View file

@ -114,10 +114,9 @@ namespace gui {
}
}
bool StatusUI::drop_item(DinkyECS::Entity item_id) {
bool dropped = System::drop_item($level, item_id);
if(dropped) update();
return dropped;
void StatusUI::drop_item(DinkyECS::Entity item_id) {
System::drop_item($level, item_id);
update();
}
// NOTE: do I need this or how does it relate to drop_item?

View file

@ -29,7 +29,7 @@ namespace gui {
void remove_slot(guecs::Entity slot_id);
bool place_slot(guecs::Entity gui_id, DinkyECS::Entity world_entity);
bool drop_item(DinkyECS::Entity item_id);
void drop_item(DinkyECS::Entity item_id);
void swap(guecs::Entity gui_a, guecs::Entity gui_b);
bool occupied(guecs::Entity slot);