diff --git a/gui/fsm.cpp b/gui/fsm.cpp index e67dde8..3f020f6 100644 --- a/gui/fsm.cpp +++ b/gui/fsm.cpp @@ -136,11 +136,9 @@ namespace gui { $grab_source = std::any_cast(data); if(auto world_entity = $loot_ui.begin_grab(*$grab_source)) { - $window.setMouseCursorVisible(false); $status_ui.begin_drop(*world_entity); } else { // BUG: need a cancel operation here - $window.setMouseCursorVisible(true); $grab_source = std::nullopt; state(State::LOOTING); } @@ -154,7 +152,6 @@ namespace gui { $grab_source = std::nullopt; } - $window.setMouseCursorVisible(true); state(State::LOOTING); } } break; @@ -200,7 +197,6 @@ namespace gui { $grab_source = std::nullopt; } - //$window.setMouseCursorVisible(true); state(State::LOOTING); } } break; @@ -208,11 +204,9 @@ namespace gui { $grab_source = std::any_cast(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; state(State::LOOTING); } diff --git a/gui/loot_ui.cpp b/gui/loot_ui.cpp index e11271a..f9c49f2 100644 --- a/gui/loot_ui.cpp +++ b/gui/loot_ui.cpp @@ -97,12 +97,8 @@ namespace gui { } } - bool LootUI::has_grab_source(DinkyECS::Entity gui_id) { - return $gui.has(gui_id); - } - guecs::GrabSource& LootUI::get_grab_source(DinkyECS::Entity gui_id) { - dbc::check(has_grab_source(gui_id), "invalid GrabSource requested, entity isn't in the GUI."); + dbc::check($gui.has(gui_id), "invalid GrabSource requested, entity isn't in the GUI."); return static_cast($gui.get(gui_id)); } diff --git a/gui/loot_ui.hpp b/gui/loot_ui.hpp index 97d0d0a..3a22f5a 100644 --- a/gui/loot_ui.hpp +++ b/gui/loot_ui.hpp @@ -16,7 +16,6 @@ namespace gui { DinkyECS::Entity $selected_entity; LootUI(GameLevel level); - void init(); void update(); void render(sf::RenderWindow& window); @@ -24,7 +23,6 @@ namespace gui { bool mouse(float x, float y, bool hover); guecs::GrabSource& get_grab_source(DinkyECS::Entity entity); - bool has_grab_source(DinkyECS::Entity gui_id); std::optional begin_grab(DinkyECS::Entity slot); void commit_grab(DinkyECS::Entity slot_id); diff --git a/gui/status_ui.cpp b/gui/status_ui.cpp index fd2d1bb..c528e3d 100644 --- a/gui/status_ui.cpp +++ b/gui/status_ui.cpp @@ -89,7 +89,7 @@ namespace gui { $gui.set_init(gui_id, {sprite.name}); - $slots.insert_or_assign(gui_id, $selected_entity); + contents.insert_or_assign(gui_id, $selected_entity); return true; } else { return false; @@ -110,28 +110,22 @@ namespace gui { return drop.commit(); } - bool StatusUI::has_grab_source(DinkyECS::Entity gui_id) { - return $gui.has(gui_id); - } - guecs::GrabSource& StatusUI::get_grab_source(DinkyECS::Entity gui_id) { - dbc::check(has_grab_source(gui_id), "invalid GrabSource requested, entity isn't in the GUI."); + dbc::check($gui.has(gui_id), "invalid GrabSource requested, entity isn't in the GUI."); return static_cast($gui.get(gui_id)); } std::optional StatusUI::begin_grab(DinkyECS::Entity slot_id) { - // BET CHAT: I'll have to change this to a full if-else later - - if(!$slots.contains(slot_id)) return std::nullopt; + if(!contents.contains(slot_id)) return std::nullopt; auto& source = get_grab_source(slot_id); source.grab(); - return $slots.at(slot_id); + return contents.at(slot_id); } void StatusUI::commit_grab(DinkyECS::Entity slot_id) { - $slots.erase(slot_id); + contents.erase(slot_id); $gui.remove(slot_id); } } diff --git a/gui/status_ui.hpp b/gui/status_ui.hpp index 93ef6ed..1b77959 100644 --- a/gui/status_ui.hpp +++ b/gui/status_ui.hpp @@ -11,22 +11,21 @@ namespace gui { class StatusUI { public: guecs::UI $gui; - std::unordered_map $slots; GameLevel $level; - ritual::UI $ritual_ui; + std::unordered_map contents; DinkyECS::Entity $selected_entity; + ritual::UI $ritual_ui; StatusUI(GameLevel level); void select_ritual(); void update_level(GameLevel &level); - bool mouse(float x, float y, bool hover); void init(); void render(sf::RenderWindow &window); void update(); - bool place_slot(DinkyECS::Entity gui_id); + bool mouse(float x, float y, bool hover); + guecs::GrabSource& get_grab_source(DinkyECS::Entity entity); - bool has_grab_source(DinkyECS::Entity gui_id); std::optional begin_grab(DinkyECS::Entity slot); void commit_grab(DinkyECS::Entity slot_id); @@ -34,5 +33,6 @@ namespace gui { guecs::DropTarget& get_drop_target(DinkyECS::Entity gui_id); void begin_drop(DinkyECS::Entity world_entity); bool commit_drop(DinkyECS::Entity gui_id); + bool place_slot(DinkyECS::Entity gui_id); }; }