getting selected inventory items
This commit is contained in:
parent
37f0a6aa08
commit
4ff416757f
@ -150,6 +150,10 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
|
||||
switch_room(1);
|
||||
}
|
||||
else if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (InventoryItem* item = GetItemSelected(true)) {
|
||||
|
||||
}
|
||||
else {
|
||||
const auto highlightedObjects = aoMgr.findByHighlighted(true);
|
||||
|
||||
for (auto* ao : highlightedObjects) {
|
||||
@ -162,6 +166,7 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
|
||||
|
||||
aoMgr.removeByName(ao->name);
|
||||
}
|
||||
}
|
||||
// bx.Interpolate(animationCounter);
|
||||
// animationCounter += 2;
|
||||
}
|
||||
@ -255,6 +260,7 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
|
||||
UnselectAllItems();
|
||||
if (InventoryItem* item = GetItemByHotkey(hot_key)) {
|
||||
item->isSelected = true;
|
||||
std:: cout << item->name << std::endl;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -45,6 +45,16 @@ namespace ZL
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InventoryItem* GetItemSelected(bool selected)
|
||||
{
|
||||
for (auto& [_, item] : gInventoryMap) {
|
||||
if (item.isSelected == selected) {
|
||||
return &item;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PrintInventory()
|
||||
{
|
||||
std::cout << "Inventory contents:\n";
|
||||
|
||||
@ -36,4 +36,5 @@ namespace ZL
|
||||
// Add these new functions
|
||||
void UnselectAllItems();
|
||||
InventoryItem* GetItemByHotkey(int hotkey);
|
||||
InventoryItem* GetItemSelected(bool isSelected);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user