Mostly worked out how to do looting but now need how to take out of inventory and put into loot.
This commit is contained in:
parent
c509162be1
commit
94385b195d
7 changed files with 139 additions and 54 deletions
|
@ -48,13 +48,19 @@ namespace gui {
|
|||
}
|
||||
|
||||
std::optional<DinkyECS::Entity> LootUI::select_slot(int slot_id) {
|
||||
if(size_t(slot_id) < contents.size()) {
|
||||
if(slot_id >= 0 && size_t(slot_id) < contents.size()) {
|
||||
return contents.at(slot_id);
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<sf::Sprite> LootUI::grab_sprite(int slot_id) {
|
||||
auto id = $gui.entity("item_", slot_id);
|
||||
auto& sprite = $gui.get<guecs::Sprite>(id);
|
||||
return sprite.sprite;
|
||||
}
|
||||
|
||||
void LootUI::remove_slot(int slot_id) {
|
||||
dbc::check(size_t(slot_id) < contents.size(),
|
||||
fmt::format("invalid slot id {} give, contents.size={}",
|
||||
|
@ -70,12 +76,8 @@ namespace gui {
|
|||
for(size_t i = 0; i < INV_SLOTS; i++) {
|
||||
auto id = $gui.entity("item_", int(i));
|
||||
|
||||
fmt::println("checking for sprite at {}", id);
|
||||
if($gui.has<guecs::Sprite>(id)) {
|
||||
fmt::println("REMOVING SPRITE {}", id);
|
||||
$gui.remove<guecs::Sprite>(id);
|
||||
} else {
|
||||
fmt::println("nothing at {}", id);
|
||||
}
|
||||
|
||||
if(i < contents.size()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue