select inventory 1-9

This commit is contained in:
maka70vv 2025-03-02 18:19:25 +06:00
parent aa84fa0823
commit 103c43eba1

View File

@ -259,14 +259,22 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
case SDLK_1:
case SDLK_2:
{
int hot_key = (event.key.keysym.sym == SDLK_1) ? 1 : 2;
case SDLK_3:
case SDLK_4:
case SDLK_5:
case SDLK_6:
case SDLK_7:
case SDLK_8:
case SDLK_9:
{
UnselectAllItems();
if (InventoryItem* item = GetItemByHotkey(hot_key)) {
if (InventoryItem* item = GetItemByHotkey(event.key.keysym.sym - SDLK_1 + 1)) {
item->isSelected = true;
std:: cout << item->name << std::endl;
}
}
break;
// ...handle other keys...
}