From 1b1ceac2fe47baf36e60426c184420f973a0e6f8 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Wed, 3 Jun 2026 22:27:18 +0300 Subject: [PATCH] Working on phone --- resources/dialogue/dorm_dialogues.json | 18 ++++ .../dialogue/uni_exterior_dialogues.json | 58 ++++++++++- .../dialogue/uni_interior_dialogues.json | 18 ++++ src/MenuManager.cpp | 96 +++++++++++++++++-- src/MenuManager.h | 11 +++ src/UiManager.cpp | 4 + src/UiManager.h | 1 + 7 files changed, 194 insertions(+), 12 deletions(-) diff --git a/resources/dialogue/dorm_dialogues.json b/resources/dialogue/dorm_dialogues.json index 991c6ab..c0107e3 100644 --- a/resources/dialogue/dorm_dialogues.json +++ b/resources/dialogue/dorm_dialogues.json @@ -318,6 +318,24 @@ "type": "End" } ] + }, + { + "id": "dialog_taxi002", + "start": "line_1", + "nodes": [ + { + "id": "line_1", + "type": "Line", + "speaker": "Бекзат", + "portrait": "resources/dialogue/portrait_hero_neutral.png", + "text": "Я заказал такси до универа, машина уже ждет!", + "next": "end_1" + }, + { + "id": "end_1", + "type": "End" + } + ] }, { "id": "dialog_second_floor001", diff --git a/resources/dialogue/uni_exterior_dialogues.json b/resources/dialogue/uni_exterior_dialogues.json index 4e2404a..9303e57 100644 --- a/resources/dialogue/uni_exterior_dialogues.json +++ b/resources/dialogue/uni_exterior_dialogues.json @@ -27,7 +27,7 @@ "type": "Line", "speaker": "Бекзат", "portrait": "resources/dialogue/portrait_hero_neutral.png", - "text": "Это мусорный контейнер, я не буду в нем копаться!", + "text": "Это куча строительного мусора, я не буду в ней копаться!", "next": "end_1" }, { @@ -69,7 +69,61 @@ "type": "End" } ] - } + }, + { + "id": "dialog_contaier003", + "start": "line_1", + "nodes": [ + { + "id": "line_1", + "type": "Line", + "speaker": "Бекзат", + "portrait": "resources/dialogue/portrait_hero_neutral.png", + "text": "Я уже нашел в этой куче мусора то, что мне нужно.", + "next": "end_1" + }, + { + "id": "end_1", + "type": "End" + } + ] + }, + { + "id": "dialog_taxi001", + "start": "line_1", + "nodes": [ + { + "id": "line_1", + "type": "Line", + "speaker": "Бекзат", + "portrait": "resources/dialogue/portrait_hero_neutral.png", + "text": "Прежде чем выходить за ворота, я должен заказать такси до общаги.", + "next": "end_1" + }, + { + "id": "end_1", + "type": "End" + } + ] + }, + { + "id": "dialog_taxi002", + "start": "line_1", + "nodes": [ + { + "id": "line_1", + "type": "Line", + "speaker": "Бекзат", + "portrait": "resources/dialogue/portrait_hero_neutral.png", + "text": "Я заказал такси до общаги, машина уже ждет!", + "next": "end_1" + }, + { + "id": "end_1", + "type": "End" + } + ] + }, ], "cutscenes": [ { diff --git a/resources/dialogue/uni_interior_dialogues.json b/resources/dialogue/uni_interior_dialogues.json index fb1c337..fb5e372 100644 --- a/resources/dialogue/uni_interior_dialogues.json +++ b/resources/dialogue/uni_interior_dialogues.json @@ -1083,6 +1083,24 @@ "type": "End" } ] + }, + { + "id": "dialog_taxi003", + "start": "line_1", + "nodes": [ + { + "id": "line_1", + "type": "Line", + "speaker": "Бекзат", + "portrait": "resources/dialogue/portrait_hero_neutral.png", + "text": "Чтобы заказать такси, я сначала должен выйти на улицу.", + "next": "end_1" + }, + { + "id": "end_1", + "type": "End" + } + ] } ], "cutscenes": [ diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index c9753f2..08a13a2 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -89,9 +89,11 @@ namespace ZL { hudUniExtDarkRoot = loadUiFromFile("resources/w/ui/hud_uni_ext_dark.json", renderer, zipFile); - //phoneChatListRoot = loadUiFromFile("resources/w/ui/screen_phone_bank.json", renderer, zipFile); - //phoneChatListRoot = loadUiFromFile("resources/w/ui/screen_phone_map_dorm.json", renderer, zipFile); - //phoneChatListRoot = loadUiFromFile("resources/w/ui/screen_phone_video.json", renderer, zipFile); + phoneMainRoot = loadUiFromFile("resources/w/ui/screen_phone.json", renderer, zipFile); + phoneBankRoot = loadUiFromFile("resources/w/ui/screen_phone_bank.json", renderer, zipFile); + phoneVideoRoot = loadUiFromFile("resources/w/ui/screen_phone_video.json", renderer, zipFile); + phoneMapDormRoot = loadUiFromFile("resources/w/ui/screen_phone_map_dorm.json", renderer, zipFile); + phoneMapUniRoot = loadUiFromFile("resources/w/ui/screen_phone_map_uni.json", renderer, zipFile); phoneChatListRoot = loadUiFromFile("resources/w/ui/screen_phone_chat_list.json", renderer, zipFile); phoneChat1Root = loadUiFromFile("resources/w/ui/screen_phone_chat1.json", renderer, zipFile); phoneChat2Root = loadUiFromFile("resources/w/ui/screen_phone_chat2.json", renderer, zipFile); @@ -269,10 +271,30 @@ namespace ZL { state = GameState::PhoneScreen; tutorialPhoneScreenOpened = true; uiManager.setNodeVisible("hint6a", false); + uiManager.pushMenuFromSavedRoot(phoneMainRoot); + + uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) { + closePhoneEntirely(); + }); + uiManager.setButtonCallback("phoneMessenger", [this](const std::string&) { + openPhoneMessenger(); + }); + uiManager.setButtonCallback("phoneBank", [this](const std::string&) { + openPhoneBank(); + }); + uiManager.setButtonCallback("phoneVideo", [this](const std::string&) { + openPhoneVideo(); + }); + uiManager.setButtonCallback("phoneTaxi", [this](const std::string&) { + openPhoneTaxi(); + }); + } + + void MenuManager::openPhoneMessenger() { uiManager.pushMenuFromSavedRoot(phoneChatListRoot); uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) { - closePhoneScreen(); + closePhoneEntirely(); }); uiManager.setButtonCallback("phoneMain", [this](const std::string&) {}); uiManager.setTextButtonCallback("chat1button", [this](const std::string&) { @@ -286,6 +308,58 @@ namespace ZL { }); } + void MenuManager::openPhoneBank() { + uiManager.pushMenuFromSavedRoot(phoneBankRoot); + + uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) { + closePhoneEntirely(); + }); + uiManager.setButtonCallback("buttonBack", [this](const std::string&) { + uiManager.popMenu(); + }); + } + + void MenuManager::openPhoneVideo() { + uiManager.pushMenuFromSavedRoot(phoneVideoRoot); + + uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) { + closePhoneEntirely(); + }); + uiManager.setButtonCallback("buttonBack", [this](const std::string&) { + uiManager.popMenu(); + }); + uiManager.setButtonCallback("videoSkip", [this](const std::string&) { + // TODO: trigger time-skip game feature + closePhoneEntirely(); + }); + } + + void MenuManager::openPhoneTaxi() { + if (currentLocationName_ == "uni_interior") { + closePhoneEntirely(); + if (startDialogueFunc) startDialogueFunc("dialog_taxi003"); + } else if (currentLocationName_ == "uni_exterior") { + openPhoneMapScreen(phoneMapUniRoot); + } else { + openPhoneMapScreen(phoneMapDormRoot); + } + } + + void MenuManager::openPhoneMapScreen(std::shared_ptr mapRoot) { + uiManager.pushMenuFromSavedRoot(mapRoot); + + uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) { + closePhoneEntirely(); + }); + uiManager.setButtonCallback("buttonBack", [this](const std::string&) { + uiManager.popMenu(); + }); + uiManager.setButtonCallback("mapGo", [this](const std::string&) { + closePhoneEntirely(); + if (startDialogueFunc) startDialogueFunc("dialog_taxi002"); + }); + } + void MenuManager::openPhoneChatFromList(std::shared_ptr chatRoot, const std::string& dialogueId) { phoneChatVisibleBubbles_.clear(); uiManager.pushMenuFromSavedRoot(chatRoot); @@ -314,17 +388,19 @@ namespace ZL { uiManager.popMenu(); } - void MenuManager::closePhoneScreenFromChat() { + void MenuManager::closePhoneEntirely() { state = GameState::Gameplay; phoneChatVisibleBubbles_.clear(); - uiManager.popMenu(); - uiManager.popMenu(); + const int depth = uiManager.menuStackSize(); + for (int i = 0; i < depth; ++i) uiManager.popMenu(); + } + + void MenuManager::closePhoneScreenFromChat() { + closePhoneEntirely(); } void MenuManager::closePhoneScreen() { - state = GameState::Gameplay; - phoneChatVisibleBubbles_.clear(); - uiManager.popMenu(); + closePhoneEntirely(); } // Registers phoneButton / journalButton callbacks on the current HUD root diff --git a/src/MenuManager.h b/src/MenuManager.h index 10441d8..50c9cc4 100644 --- a/src/MenuManager.h +++ b/src/MenuManager.h @@ -55,6 +55,7 @@ namespace ZL { void closePhoneScreen(); void revealPhoneChatBubble(const std::string& slotName); bool isPhoneScreenOpen() const { return state == GameState::PhoneScreen; } + void closePhoneEntirely(); std::function startDialogueFunc; std::function startDarklandsTransitionFunc; @@ -82,6 +83,11 @@ namespace ZL { void refreshItemPickupHud(); void setupStep5Callbacks(); void setupGameplayHudCallbacks(); + void openPhoneMessenger(); + void openPhoneBank(); + void openPhoneVideo(); + void openPhoneTaxi(); + void openPhoneMapScreen(std::shared_ptr mapRoot); void resetPhoneChatNodes(); void recomputePhoneChatPositions(); void openPhoneChatFromList(std::shared_ptr chatRoot, const std::string& dialogueId); @@ -120,6 +126,11 @@ namespace ZL { std::shared_ptr hudUniIntStep13Root; std::shared_ptr hudUniIntDarkFullRoot; std::shared_ptr hudUniExtDarkRoot; + std::shared_ptr phoneMainRoot; + std::shared_ptr phoneBankRoot; + std::shared_ptr phoneVideoRoot; + std::shared_ptr phoneMapDormRoot; + std::shared_ptr phoneMapUniRoot; std::shared_ptr phoneChatListRoot; std::shared_ptr phoneChat1Root; std::shared_ptr phoneChat2Root; diff --git a/src/UiManager.cpp b/src/UiManager.cpp index 30e4ffa..111c69b 100644 --- a/src/UiManager.cpp +++ b/src/UiManager.cpp @@ -1321,6 +1321,10 @@ namespace ZL { menuStack.clear(); } + int UiManager::menuStackSize() const { + return static_cast(menuStack.size()); + } + void UiManager::draw(Renderer& renderer) { renderer.PushProjectionMatrix(Environment::projectionWidth, Environment::projectionHeight, -1, 1); renderer.PushMatrix(); diff --git a/src/UiManager.h b/src/UiManager.h index 039eb39..29385c9 100644 --- a/src/UiManager.h +++ b/src/UiManager.h @@ -407,6 +407,7 @@ namespace ZL { bool pushMenuFromSavedRoot(std::shared_ptr newRoot); bool popMenu(); void clearMenuStack(); + int menuStackSize() const; void update(float deltaMs); void startAnimation(const std::string& animName);