There's a UISystem now for to compliment the entities and components in GUECS. I now use that to do the drag/drop transfers instead of raw code right in the FSM.
parent
e01e697535
commit
4a48910273
@ -0,0 +1,25 @@ |
|||||||
|
#include "gui/uisystems.hpp" |
||||||
|
#include "gui/guecstra.hpp" |
||||||
|
|
||||||
|
namespace UISystem { |
||||||
|
std::optional<guecs::Entity> loot_grab(guecs::UI& gui, guecs::Entity gui_id) { |
||||||
|
if(auto source = gui.get_if<guecs::GrabSource>(gui_id)) { |
||||||
|
source->grab(); |
||||||
|
return gui_id; |
||||||
|
} else { |
||||||
|
return std::nullopt; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool loot_drop(guecs::UI& source, guecs::UI& target, guecs::Entity source_id, guecs::Entity target_id) { |
||||||
|
auto& drop = target.get<guecs::DropTarget>(target_id); |
||||||
|
auto& grab = source.get<guecs::GrabSource>(source_id); |
||||||
|
|
||||||
|
if(drop.commit(grab.world_entity)) { |
||||||
|
grab.commit(); |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
#pragma once |
||||||
|
#include <guecs/ui.hpp> |
||||||
|
#include <optional> |
||||||
|
|
||||||
|
namespace UISystem { |
||||||
|
std::optional<guecs::Entity> loot_grab(guecs::UI& gui, guecs::Entity gui_id); |
||||||
|
|
||||||
|
|
||||||
|
bool loot_drop(guecs::UI& source, guecs::UI& target, guecs::Entity grab_source, guecs::Entity target_id); |
||||||
|
} |
Loading…
Reference in new issue