Clean up more of the FSM so that it's almost nothing.Now I'll try to make a stand-alone 'dnd' state machine to handle drag and drop functionality.
This commit is contained in:
parent
06a843f169
commit
1ab708c4eb
3 changed files with 43 additions and 50 deletions
|
@ -2,7 +2,9 @@
|
|||
#include "gui/guecstra.hpp"
|
||||
|
||||
namespace UISystem {
|
||||
std::optional<guecs::Entity> loot_grab(guecs::UI& gui, guecs::Entity gui_id) {
|
||||
std::optional<guecs::Entity> loot_grab(guecs::UI& gui, std::any data) {
|
||||
auto gui_id = std::any_cast<guecs::Entity>(data);
|
||||
|
||||
if(auto source = gui.get_if<guecs::GrabSource>(gui_id)) {
|
||||
source->grab();
|
||||
return gui_id;
|
||||
|
@ -11,9 +13,14 @@ namespace UISystem {
|
|||
}
|
||||
}
|
||||
|
||||
bool loot_drop(guecs::UI& source, guecs::UI& target, guecs::Entity source_id, guecs::Entity target_id) {
|
||||
bool loot_drop(guecs::UI& source, guecs::UI& target,
|
||||
std::optional<guecs::Entity> source_id, std::any data)
|
||||
{
|
||||
if(!source_id) return false;
|
||||
auto target_id = std::any_cast<guecs::Entity>(data);
|
||||
|
||||
auto& drop = target.get<guecs::DropTarget>(target_id);
|
||||
auto& grab = source.get<guecs::GrabSource>(source_id);
|
||||
auto& grab = source.get<guecs::GrabSource>(*source_id);
|
||||
|
||||
if(drop.commit(grab.world_entity)) {
|
||||
grab.commit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue