You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
821 B
32 lines
821 B
#include "gui/uisystems.hpp"
|
|
#include "gui/guecstra.hpp"
|
|
|
|
namespace UISystem {
|
|
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;
|
|
} else {
|
|
return std::nullopt;
|
|
}
|
|
}
|
|
|
|
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);
|
|
|
|
if(drop.commit(grab.world_entity)) {
|
|
grab.commit();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|