diff --git a/GameObjectManager.cpp b/GameObjectManager.cpp index c417308..0532fd1 100644 --- a/GameObjectManager.cpp +++ b/GameObjectManager.cpp @@ -281,6 +281,14 @@ void GameObjectManager::handleEvent(const SDL_Event& event) { isDialogActive = false; } } + if (isBatteryDialogActive) { + BatteryDialogIndex++; + if (BatteryDialogIndex < batteryDialogTextures.size()) { + batteryDialogTexturePtr = std::make_shared(CreateTextureDataFromBmp24(batteryDialogTextures[BatteryDialogIndex])); + } else { + isBatteryDialogActive = false; + } + } } else if (event.type == SDL_MOUSEBUTTONDOWN) { const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true); @@ -322,12 +330,13 @@ void GameObjectManager::handleEvent(const SDL_Event& event) { if (InventoryItem* item = GetItemSelected(true)){ std::cout << item->name << std::endl; if (item->name == "carToy") { - std::cout << item->name << std::endl; + // Проверить, наведена ли мышь на лампу const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true); std::cout << highlightedObjects.size() << std::endl; for (auto* ao : highlightedObjects) { if (ao && ao->name == "lampe") { + isBatteryDialogActive = true; // Create a new lamp object with updated texture ActiveObject updatedLamp = *ao; // Change from dark to lit texture diff --git a/GameObjectManager.h b/GameObjectManager.h index 4352176..98cb22e 100644 --- a/GameObjectManager.h +++ b/GameObjectManager.h @@ -96,6 +96,13 @@ public: std::shared_ptr dialogTexturePtr; // Активная текстура диалога bool isDialogActive = false; // Флаг активности диалога + std::vector batteryDialogTextures = { // Список диалогов + "./battery_dialog.bmp", + }; + int BatteryDialogIndex = 0; // Текущий индекс диалога + std::shared_ptr batteryDialogTexturePtr; // Активная текстура диалога + bool isBatteryDialogActive = false; // Флаг активности диалога + private: //int animationCounter = 0; int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши diff --git a/RenderSystem.cpp b/RenderSystem.cpp index 68e0207..5a55ed4 100644 --- a/RenderSystem.cpp +++ b/RenderSystem.cpp @@ -221,6 +221,16 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) { renderer.DrawVertexRenderStruct(gameObjects.inventoryIconMeshMutable); // Используем 2D меш инвентаря renderer.PopMatrix(); } + if (gameObjects.isBatteryDialogActive && gameObjects.batteryDialogTexturePtr) { + renderer.PushMatrix(); + float xPos = Environment::width / 2.0f - 250; // Центрируем + float yPos = Environment::height / 2.0f - 125; // Центрируем + renderer.TranslateMatrix(Vector3f{xPos, yPos, 0.0f}); + renderer.ScaleMatrix(Vector3f{10.5f, 10.5f, 1.0f}); // Увеличиваем размер + glBindTexture(GL_TEXTURE_2D, gameObjects.batteryDialogTexturePtr->getTexID()); + renderer.DrawVertexRenderStruct(gameObjects.inventoryIconMeshMutable); // Используем 2D меш инвентаря + renderer.PopMatrix(); + } //for (const auto* ao : gameObjects.aoMgr.findByHighlighted(true)) { for (auto& ao : gameObjects.rooms[gameObjects.current_room_index].findByHighlighted(true)) { diff --git a/battery_dialog.bmp b/battery_dialog.bmp new file mode 100644 index 0000000..25c8f9c Binary files /dev/null and b/battery_dialog.bmp differ diff --git a/start_dialog.bmp b/start_dialog.bmp index cef6253..30e9e68 100644 Binary files a/start_dialog.bmp and b/start_dialog.bmp differ