diff --git a/GameObjectManager.cpp b/GameObjectManager.cpp index b6d8120..1887ea1 100644 --- a/GameObjectManager.cpp +++ b/GameObjectManager.cpp @@ -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; diff --git a/Inventory.cpp b/Inventory.cpp index 292cfb0..4bb7a39 100644 --- a/Inventory.cpp +++ b/Inventory.cpp @@ -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"; diff --git a/Inventory.h b/Inventory.h index 655bcc7..ad5daf3 100644 --- a/Inventory.h +++ b/Inventory.h @@ -36,4 +36,5 @@ namespace ZL // Add these new functions void UnselectAllItems(); InventoryItem* GetItemByHotkey(int hotkey); + InventoryItem* GetItemSelected(bool isSelected); }