Can now round-trip a torch from loot to inventory and back.

This commit is contained in:
Zed A. Shaw 2025-06-09 14:02:26 -04:00
parent 4b0d76bbcc
commit 2a6b892e7f
5 changed files with 80 additions and 22 deletions

View file

@ -154,7 +154,6 @@ namespace gui {
}
$window.setMouseCursorVisible(true);
dbc::log("INV_SELECT back to looting");
state(State::LOOTING);
}
} break;
@ -184,10 +183,6 @@ namespace gui {
}
void FSM::INV_GRAB(Event ev, std::any data) {
dbc::log("INV_SELECT NOT IMPlEMENTED");
state(State::LOOTING);
return;
using enum Event;
(void)data;
@ -197,21 +192,48 @@ namespace gui {
state(State::IDLE);
break;
case LOOT_SELECT: {
state(State::IDLE);
auto gui_id = std::any_cast<DinkyECS::Entity>(data);
if($grab_source) {
if($loot_ui.commit_drop(gui_id)) {
$status_ui.commit_grab(*$grab_source);
$grab_source = std::nullopt;
}
//$window.setMouseCursorVisible(true);
state(State::LOOTING);
}
} break;
case INV_SELECT: {
state(State::IDLE);
$grab_source = std::any_cast<DinkyECS::Entity>(data);
if(auto world_entity = $status_ui.begin_grab(*$grab_source)) {
//$window.setMouseCursorVisible(false);
$loot_ui.begin_drop(*world_entity);
} else {
// BUG: need a cancel operation here
//$window.setMouseCursorVisible(true);
$grab_source = std::nullopt;
}
} break;
case MOUSE_CLICK:
mouse_action(false);
break;
case MOUSE_MOVE: {
if($grab_source) {
auto& source = $status_ui.get_grab_source(*$grab_source);
source.move($router.position);
}
mouse_action(true);
} break;
case MOUSE_DRAG_START: {
mouse_action(false);
} break;
case MOUSE_DRAG: {
if($grab_source) {
auto& source = $status_ui.get_grab_source(*$grab_source);
source.move($router.position);
}
mouse_action(true);
} break;
case MOUSE_DROP:
@ -235,9 +257,8 @@ namespace gui {
state(State::LOOT_GRAB);
break;
case INV_SELECT:
dbc::log("INV_SELECT disabled in FSM::LOOTING");
state(State::IDLE);
// INV_GRAB(ev, data);
state(State::INV_GRAB);
INV_GRAB(ev, data);
break;
case MOUSE_DRAG_START:
case MOUSE_CLICK:
@ -313,8 +334,7 @@ namespace gui {
state(State::LOOTING);
} break;
case INV_SELECT:
dbc::log("INV_SELECT disabled in IDLE");
// state(State::INV_GRAB);
state(State::INV_GRAB);
break;
case MOUSE_CLICK:
mouse_action(false);