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

@ -83,10 +83,6 @@ namespace gui {
init();
}
void StatusUI::start_drop(DinkyECS::Entity entity) {
$selected_entity = entity;
}
bool StatusUI::place_slot(DinkyECS::Entity gui_id) {
if($level.world->has<components::Sprite>($selected_entity)) {
auto& sprite = $level.world->get<components::Sprite>($selected_entity);
@ -103,4 +99,33 @@ namespace gui {
guecs::DropTarget& StatusUI::get_drop_target(DinkyECS::Entity gui_id) {
return $gui.get<guecs::DropTarget>(gui_id);
}
void StatusUI::begin_drop(DinkyECS::Entity entity) {
$selected_entity = entity;
}
bool StatusUI::commit_drop(DinkyECS::Entity gui_id) {
auto& drop = get_drop_target(gui_id);
return drop.commit();
}
bool StatusUI::has_grab_source(DinkyECS::Entity gui_id) {
return $gui.has<guecs::Sprite>(gui_id);
}
guecs::GrabSource& StatusUI::get_grab_source(DinkyECS::Entity gui_id) {
dbc::check(has_grab_source(gui_id), "invalid GrabSource requested, entity isn't in the GUI.");
return static_cast<guecs::GrabSource&>($gui.get<guecs::Sprite>(gui_id));
}
std::optional<DinkyECS::Entity> StatusUI::begin_grab(DinkyECS::Entity slot_id) {
(void)slot_id;
return std::nullopt;
}
void StatusUI::commit_grab(DinkyECS::Entity slot_id) {
(void)slot_id;
}
}