Even better API, but still not the best organization. This will let me implement both sides, then I can pull it out and try to generalize it into a few guecs components.

This commit is contained in:
Zed A. Shaw 2025-06-08 23:55:59 -04:00
parent 3e0adf0c22
commit 4b0d76bbcc
7 changed files with 63 additions and 22 deletions

View file

@ -46,15 +46,17 @@ namespace gui {
update();
}
std::optional<DinkyECS::Entity> LootUI::start_grab(DinkyECS::Entity slot_id) {
std::optional<DinkyECS::Entity> LootUI::begin_grab(DinkyECS::Entity slot_id) {
if(contents.contains(slot_id)) {
auto& source = get_grab_source(slot_id);
source.grab();
return contents.at(slot_id);
} else {
return std::nullopt;
}
}
void LootUI::commit_drop(DinkyECS::Entity slot_id) {
void LootUI::commit_grab(DinkyECS::Entity slot_id) {
contents.erase(slot_id);
update();
}
@ -103,4 +105,8 @@ namespace gui {
bool LootUI::mouse(float x, float y, bool hover) {
return $gui.mouse(x, y, hover);
}
guecs::DropTarget& LootUI::get_drop_target(DinkyECS::Entity gui_id) {
return $gui.get<guecs::DropTarget>(gui_id);
}
}