From e6bfe85e2ed9bbb8be045e58aaa5eddcff0e0825 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Wed, 3 Jun 2026 22:53:47 +0300 Subject: [PATCH] Working on phone and bank account --- resources/dialogue/dorm_dialogues.json | 18 ++++++++++ .../dialogue/uni_exterior_dialogues.json | 18 ++++++++++ resources/w/ui/screen_phone_chat_list.json | 18 ++++++++++ src/Location.cpp | 1 - src/MenuManager.cpp | 35 +++++++++++++++++++ src/MenuManager.h | 9 +++++ 6 files changed, 98 insertions(+), 1 deletion(-) diff --git a/resources/dialogue/dorm_dialogues.json b/resources/dialogue/dorm_dialogues.json index c0107e3..0be1cfa 100644 --- a/resources/dialogue/dorm_dialogues.json +++ b/resources/dialogue/dorm_dialogues.json @@ -336,6 +336,24 @@ "type": "End" } ] + }, + { + "id": "dialog_taxi004", + "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 9303e57..70bfbb0 100644 --- a/resources/dialogue/uni_exterior_dialogues.json +++ b/resources/dialogue/uni_exterior_dialogues.json @@ -124,6 +124,24 @@ } ] }, + { + "id": "dialog_taxi004", + "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/w/ui/screen_phone_chat_list.json b/resources/w/ui/screen_phone_chat_list.json index 4109a1b..efea8af 100644 --- a/resources/w/ui/screen_phone_chat_list.json +++ b/resources/w/ui/screen_phone_chat_list.json @@ -79,6 +79,15 @@ "pressed": "resources/w/ui/img/phone/ChatListItem001.png" } }, + { + "type": "StaticImage", + "name": "chat1Unread", + "x" : 408, + "y" : 24, + "width": 28.7, + "height": 28.7, + "texture": "resources/w/ui/img/phone/ChatListUnread1.png" + }, { "type": "TextView", "name": "chat1msg", @@ -134,6 +143,15 @@ "pressed": "resources/w/ui/img/phone/ChatListItem002.png" } }, + { + "type": "StaticImage", + "name": "chat2Unread", + "x" : 408, + "y" : 24, + "width": 28.7, + "height": 28.7, + "texture": "resources/w/ui/img/phone/ChatListUnread1.png" + }, { "type": "TextView", "name": "chat2msg", diff --git a/src/Location.cpp b/src/Location.cpp index aed6e5f..2072a8f 100644 --- a/src/Location.cpp +++ b/src/Location.cpp @@ -14,7 +14,6 @@ #include "external/nlohmann/json.hpp" #include - namespace ZL { extern const char* CONST_ZIP_FILE; diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index 08a13a2..b57f423 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -53,6 +53,19 @@ namespace ZL { return max(1, lines); } + static std::string formatMoney(int amount) { + bool negative = amount < 0; + std::string digits = std::to_string(negative ? -amount : amount); + std::string result; + const int len = static_cast(digits.size()); + for (int i = 0; i < len; ++i) { + if (i > 0 && (len - i) % 3 == 0) result += ' '; + result += digits[i]; + } + if (negative) result = "-" + result; + return result + " сом"; + } + static std::array questStatusColor(Quest::QuestStatus status) { switch (status) { case Quest::QuestStatus::Completed: return { 0.25f, 0.95f, 0.35f, 1.0f }; @@ -292,24 +305,44 @@ namespace ZL { void MenuManager::openPhoneMessenger() { uiManager.pushMenuFromSavedRoot(phoneChatListRoot); + refreshChatUnreadIndicators(); uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) { closePhoneEntirely(); }); uiManager.setButtonCallback("phoneMain", [this](const std::string&) {}); uiManager.setTextButtonCallback("chat1button", [this](const std::string&) { + chatUnread_[0] = false; openPhoneChatFromList(phoneChat1Root, "dialog_chat_aiperi001"); }); uiManager.setTextButtonCallback("chat2button", [this](const std::string&) { + chatUnread_[1] = false; openPhoneChatFromList(phoneChat2Root, "dialog_chat_parents001"); }); uiManager.setTextButtonCallback("chat3button", [this](const std::string&) { + chatUnread_[2] = false; openPhoneChatFromList(phoneChat3Root, "dialog_chat_news001"); }); } + void MenuManager::refreshChatUnreadIndicators() { + uiManager.setNodeVisible("chat1Unread", chatUnread_[0]); + uiManager.setNodeVisible("chat2Unread", chatUnread_[1]); + uiManager.setNodeVisible("chat3Unread", chatUnread_[2]); + } + + void MenuManager::setChatUnread(int chatIndex, bool unread) { + if (chatIndex < 0 || chatIndex > 2) return; + chatUnread_[chatIndex] = unread; + } + + void MenuManager::spendMoney(int amount) { + money_ -= amount; + } + void MenuManager::openPhoneBank() { uiManager.pushMenuFromSavedRoot(phoneBankRoot); + uiManager.setText("balanceText", formatMoney(money_)); uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) { closePhoneEntirely(); @@ -355,6 +388,7 @@ namespace ZL { uiManager.popMenu(); }); uiManager.setButtonCallback("mapGo", [this](const std::string&) { + money_ -= 500; closePhoneEntirely(); if (startDialogueFunc) startDialogueFunc("dialog_taxi002"); }); @@ -386,6 +420,7 @@ namespace ZL { void MenuManager::returnToPhoneChatList() { phoneChatVisibleBubbles_.clear(); uiManager.popMenu(); + refreshChatUnreadIndicators(); } void MenuManager::closePhoneEntirely() { diff --git a/src/MenuManager.h b/src/MenuManager.h index 50c9cc4..e1348c3 100644 --- a/src/MenuManager.h +++ b/src/MenuManager.h @@ -57,6 +57,11 @@ namespace ZL { bool isPhoneScreenOpen() const { return state == GameState::PhoneScreen; } void closePhoneEntirely(); + void setChatUnread(int chatIndex, bool unread); + + void spendMoney(int amount); + int getMoney() const { return money_; } + std::function startDialogueFunc; std::function startDarklandsTransitionFunc; @@ -88,6 +93,7 @@ namespace ZL { void openPhoneVideo(); void openPhoneTaxi(); void openPhoneMapScreen(std::shared_ptr mapRoot); + void refreshChatUnreadIndicators(); void resetPhoneChatNodes(); void recomputePhoneChatPositions(); void openPhoneChatFromList(std::shared_ptr chatRoot, const std::string& dialogueId); @@ -154,6 +160,9 @@ namespace ZL { // Dialogues that have been started at least once; re-opening a chat won't restart them std::unordered_set startedDialogues_; + bool chatUnread_[3] = { true, true, true }; + int money_ = 5500; + // Phone chat state struct PhoneChatBubbleInfo { std::string nodeName;