Just need one function for the 'hold_item' action.
This commit is contained in:
parent
265e53e05a
commit
cd89625c96
2 changed files with 17 additions and 28 deletions
|
@ -153,16 +153,18 @@ namespace gui {
|
||||||
using enum Event;
|
using enum Event;
|
||||||
|
|
||||||
switch(ev) {
|
switch(ev) {
|
||||||
case LOOT_ITEM:
|
case LOOT_ITEM: {
|
||||||
if(hold_world_item()) {
|
auto gui_id = $loot_ui.$gui.entity("item_0");
|
||||||
state(DNDState::ITEM_PICKUP);
|
if(hold_item($loot_ui.$gui, gui_id)) {
|
||||||
}
|
state(DNDState::ITEM_PICKUP);
|
||||||
break;
|
}
|
||||||
case INV_SELECT:
|
} break;
|
||||||
if(hold_inv_item(data)) {
|
case INV_SELECT: {
|
||||||
state(DNDState::INV_PICKUP);
|
auto gui_id = std::any_cast<guecs::Entity>(data);
|
||||||
}
|
if(hold_item($status_ui.$gui, gui_id)) {
|
||||||
break;
|
state(DNDState::INV_PICKUP);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case LOOT_OPEN:
|
case LOOT_OPEN:
|
||||||
open();
|
open();
|
||||||
state(DNDState::LOOTING);
|
state(DNDState::LOOTING);
|
||||||
|
@ -268,27 +270,15 @@ namespace gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DNDLoot::hold_world_item() {
|
bool DNDLoot::hold_item(guecs::UI &gui, guecs::Entity gui_id) {
|
||||||
// NOTE: if > 1 items, go to LOOT_OPEN instead
|
// NOTE: if > 1 items, go to LOOT_OPEN instead
|
||||||
auto gui_id = $loot_ui.$gui.entity("item_0");
|
$grab_source = start_grab(gui, gui_id);
|
||||||
$grab_source = start_grab($loot_ui.$gui, gui_id);
|
|
||||||
|
|
||||||
if($grab_source) {
|
if($grab_source) {
|
||||||
auto& source = $loot_ui.$gui.get<guecs::GrabSource>(*$grab_source);
|
auto& source = gui.get<guecs::GrabSource>(*$grab_source);
|
||||||
$grab_sprite = source.sprite;
|
$grab_sprite = source.sprite;
|
||||||
// call this once to properly position the sprite
|
// call this once to properly position the sprite
|
||||||
handle_mouse(Event::MOUSE_MOVE, $loot_ui.$gui);
|
handle_mouse(Event::MOUSE_MOVE, gui);
|
||||||
}
|
|
||||||
|
|
||||||
return $grab_source != std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DNDLoot::hold_inv_item(std::any& data) {
|
|
||||||
$grab_source = start_grab($status_ui.$gui, data);
|
|
||||||
|
|
||||||
if($grab_source) {
|
|
||||||
auto& source = $status_ui.$gui.get<guecs::GrabSource>(*$grab_source);
|
|
||||||
$grab_sprite = source.sprite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $grab_source != std::nullopt;
|
return $grab_source != std::nullopt;
|
||||||
|
|
|
@ -52,8 +52,7 @@ namespace gui {
|
||||||
bool commit_move(guecs::UI& gui,
|
bool commit_move(guecs::UI& gui,
|
||||||
std::optional<guecs::Entity> source_id, std::any data);
|
std::optional<guecs::Entity> source_id, std::any data);
|
||||||
|
|
||||||
bool hold_world_item();
|
bool hold_item(guecs::UI& gui, guecs::Entity gui_id);
|
||||||
bool hold_inv_item(std::any& data);
|
|
||||||
bool throw_on_floor(guecs::UI& gui, bool from_status);
|
bool throw_on_floor(guecs::UI& gui, bool from_status);
|
||||||
|
|
||||||
void clear_grab();
|
void clear_grab();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue