diff --git a/GameObjectManager.cpp b/GameObjectManager.cpp index d7ffb6b..c417308 100644 --- a/GameObjectManager.cpp +++ b/GameObjectManager.cpp @@ -30,6 +30,11 @@ void GameObjectManager::initialize() { initializeLoadingScreen(); + if (!dialogTextures.empty()) { // Проверяем, есть ли диалоги + dialogTexturePtr = std::make_shared(CreateTextureDataFromBmp24(dialogTextures[dialogIndex])); + isDialogActive = true; + } + std::function loadingFunction1 = [this]() { @@ -268,7 +273,14 @@ void GameObjectManager::switch_room(int index){ void GameObjectManager::handleEvent(const SDL_Event& event) { // debug room switching if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) { - + if (isDialogActive) { + dialogIndex++; + if (dialogIndex < dialogTextures.size()) { + dialogTexturePtr = std::make_shared(CreateTextureDataFromBmp24(dialogTextures[dialogIndex])); + } else { + isDialogActive = false; + } + } } else if (event.type == SDL_MOUSEBUTTONDOWN) { const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true); diff --git a/GameObjectManager.h b/GameObjectManager.h index 0b433f1..de743f7 100644 --- a/GameObjectManager.h +++ b/GameObjectManager.h @@ -71,10 +71,6 @@ public: //ActiveObjectManager aoMgr; int objects_in_inventory; - std::shared_ptr dialog; - bool isDialogActive = true; - - std::shared_ptr loadingScreenTexturePtr; ZL::VertexDataStruct loadingScreenMesh; @@ -91,6 +87,14 @@ public: ZL::VertexDataStruct monsterScreenMesh; ZL::VertexRenderStruct monsterScreenMeshMutable; + std::vector dialogTextures = { // Список диалогов + "./start_dialog.bmp", + "./next_dialog.bmp", + }; + int dialogIndex = 0; // Текущий индекс диалога + std::shared_ptr dialogTexturePtr; // Активная текстура диалога + bool isDialogActive = false; // Флаг активности диалога + private: //int animationCounter = 0; int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши diff --git a/RenderSystem.cpp b/RenderSystem.cpp index 549f59f..8945af8 100644 --- a/RenderSystem.cpp +++ b/RenderSystem.cpp @@ -210,6 +210,18 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) { renderer.PushMatrix(); renderer.LoadIdentity(); + // Отрисовка диалогового окна, если оно активно + if (gameObjects.isDialogActive && gameObjects.dialogTexturePtr) { + 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{1.5f, 1.5f, 1.0f}); // Увеличиваем размер + glBindTexture(GL_TEXTURE_2D, gameObjects.dialogTexturePtr->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; @@ -401,8 +413,4 @@ void RenderSystem::drawObjects(GameObjectManager& gameObjects){ } } -void RenderSystem::drawDialog(GameObjectManager& gameObjects){ - -} - } // namespace ZL diff --git a/next_dialog.bmp b/next_dialog.bmp new file mode 100644 index 0000000..d669462 Binary files /dev/null and b/next_dialog.bmp differ