Cleaned up and unified the source before the big refactor.
This commit is contained in:
parent
0d6a71b06f
commit
343f3a246f
5 changed files with 11 additions and 29 deletions
|
@ -89,7 +89,7 @@ namespace gui {
|
|||
|
||||
$gui.set_init<guecs::Sprite>(gui_id, {sprite.name});
|
||||
|
||||
$slots.insert_or_assign(gui_id, $selected_entity);
|
||||
contents.insert_or_assign(gui_id, $selected_entity);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -110,28 +110,22 @@ namespace gui {
|
|||
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.");
|
||||
dbc::check($gui.has<guecs::Sprite>(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) {
|
||||
// BET CHAT: I'll have to change this to a full if-else later
|
||||
|
||||
if(!$slots.contains(slot_id)) return std::nullopt;
|
||||
if(!contents.contains(slot_id)) return std::nullopt;
|
||||
|
||||
auto& source = get_grab_source(slot_id);
|
||||
source.grab();
|
||||
return $slots.at(slot_id);
|
||||
return contents.at(slot_id);
|
||||
}
|
||||
|
||||
void StatusUI::commit_grab(DinkyECS::Entity slot_id) {
|
||||
$slots.erase(slot_id);
|
||||
contents.erase(slot_id);
|
||||
$gui.remove<guecs::Sprite>(slot_id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue