diff --git a/GameObjectManager.cpp b/GameObjectManager.cpp index 9a13acc..83f9ccf 100644 --- a/GameObjectManager.cpp +++ b/GameObjectManager.cpp @@ -305,6 +305,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); @@ -346,12 +354,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..f88b869 100644 --- a/GameObjectManager.h +++ b/GameObjectManager.h @@ -88,7 +88,7 @@ public: ZL::VertexRenderStruct monsterScreenMeshMutable; std::vector dialogTextures = { // Список диалогов - "./start_dialog.bmp", + "./photo.bmp", "./next_dialog.bmp", "./final_dialog.bmp", }; @@ -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..59690c1 100644 --- a/RenderSystem.cpp +++ b/RenderSystem.cpp @@ -222,6 +222,19 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) { 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)) { std::cout << ao->name << std::endl; 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/photo.bmp b/photo.bmp new file mode 100644 index 0000000..30e9e68 Binary files /dev/null and b/photo.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