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