|
|
|
@ -27,6 +27,7 @@ namespace gui { |
|
|
|
|
$loot_ui($level), |
|
|
|
|
$font{FONT_FILE_NAME} |
|
|
|
|
{ |
|
|
|
|
$window.setPosition({0,0}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FSM::event(Event ev) { |
|
|
|
@ -132,31 +133,42 @@ namespace gui { |
|
|
|
|
state(State::IDLE); |
|
|
|
|
break; |
|
|
|
|
case LOOT_SELECT: { |
|
|
|
|
int slot_id = std::any_cast<int>(data); |
|
|
|
|
$grab_source = std::any_cast<DinkyECS::Entity>(data); |
|
|
|
|
|
|
|
|
|
if(auto world_entity = $loot_ui.select_slot(slot_id)) { |
|
|
|
|
$grab_source = $loot_ui.$gui.entity("item_", slot_id); |
|
|
|
|
if(auto world_entity = $loot_ui.select_slot(*$grab_source)) { |
|
|
|
|
auto& source = $loot_ui.get_grabber(*$grab_source); |
|
|
|
|
|
|
|
|
|
source.grab($window); |
|
|
|
|
source.move($router.position); |
|
|
|
|
|
|
|
|
|
$status_ui.select_slot(slot_id, *world_entity); |
|
|
|
|
$status_ui.select_slot(*world_entity); |
|
|
|
|
} else { |
|
|
|
|
// BUG: need a cancel operation here
|
|
|
|
|
$window.setMouseCursorVisible(true); |
|
|
|
|
$grab_source = std::nullopt; |
|
|
|
|
} |
|
|
|
|
} break; |
|
|
|
|
case INV_SELECT: { |
|
|
|
|
std::string slot_name = std::any_cast<std::string>(data); |
|
|
|
|
int slot_id = $status_ui.place_slot(slot_name); |
|
|
|
|
dbc::check(slot_id != -1, "status_ui is trying to place -1 slot_id"); |
|
|
|
|
if(slot_id != -1) { |
|
|
|
|
$loot_ui.remove_slot(slot_id); |
|
|
|
|
auto gui_id = std::any_cast<DinkyECS::Entity>(data); |
|
|
|
|
dbc::log(fmt::format("INV_SELECT $grab_source null? {} gui_id {}", |
|
|
|
|
$grab_source == std::nullopt, gui_id)); |
|
|
|
|
|
|
|
|
|
if($grab_source) { |
|
|
|
|
auto& drop = $status_ui.$gui.get<guecs::DropTarget>(gui_id); |
|
|
|
|
|
|
|
|
|
if(drop.action()) { |
|
|
|
|
$loot_ui.remove_slot(*$grab_source); |
|
|
|
|
$grab_source = std::nullopt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$window.setMouseCursorVisible(true); |
|
|
|
|
dbc::log("INV_SELECT back to looting"); |
|
|
|
|
state(State::LOOTING); |
|
|
|
|
} |
|
|
|
|
} break; |
|
|
|
|
case MOUSE_CLICK: |
|
|
|
|
mouse_action(false); |
|
|
|
|
break; |
|
|
|
|
case MOUSE_DRAG: |
|
|
|
|
case MOUSE_MOVE: { |
|
|
|
|
if($grab_source) { |
|
|
|
|
auto& source = $loot_ui.get_grabber(*$grab_source); |
|
|
|
@ -164,16 +176,9 @@ namespace gui { |
|
|
|
|
} |
|
|
|
|
mouse_action(true); |
|
|
|
|
} break; |
|
|
|
|
case MOUSE_DRAG_START: { |
|
|
|
|
mouse_action(false); |
|
|
|
|
} break; |
|
|
|
|
case MOUSE_DRAG: { |
|
|
|
|
if($grab_source) { |
|
|
|
|
auto& source = $loot_ui.get_grabber(*$grab_source); |
|
|
|
|
source.move($router.position); |
|
|
|
|
} |
|
|
|
|
mouse_action(true); |
|
|
|
|
} break; |
|
|
|
|
case MOUSE_DRAG_START: |
|
|
|
|
dbc::check(false, "DRAG START IN LOOT GRAB"); |
|
|
|
|
break; |
|
|
|
|
case MOUSE_DROP: |
|
|
|
|
mouse_action(false); |
|
|
|
|
break; |
|
|
|
@ -186,6 +191,10 @@ 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; |
|
|
|
|
|
|
|
|
@ -297,9 +306,12 @@ namespace gui { |
|
|
|
|
auto& data = items["TORCH_BAD"]; |
|
|
|
|
|
|
|
|
|
for(int i = 0; $loot_ui.contents.size() < 10; i++) { |
|
|
|
|
auto gui_id = $loot_ui.$gui.entity("item_", i); |
|
|
|
|
if(!$loot_ui.contents.contains(gui_id)) { |
|
|
|
|
auto torch = $level.world->entity(); |
|
|
|
|
components::configure_entity(*$level.world, torch, data["components"]); |
|
|
|
|
$loot_ui.contents.push_back(torch); |
|
|
|
|
$loot_ui.contents.try_emplace(gui_id, torch); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$loot_ui.update(); |
|
|
|
|