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.
This commit is contained in:
parent
e01e697535
commit
4a48910273
11 changed files with 62 additions and 60 deletions
25
gui/uisystems.cpp
Normal file
25
gui/uisystems.cpp
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue