Working on phone and bank account

This commit is contained in:
Vladislav Khorev 2026-06-03 22:53:47 +03:00
parent 1b1ceac2fe
commit e6bfe85e2e
6 changed files with 98 additions and 1 deletions

View File

@ -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",

View File

@ -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": [
{

View File

@ -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",

View File

@ -14,7 +14,6 @@
#include "external/nlohmann/json.hpp"
#include <SDL.h>
namespace ZL
{
extern const char* CONST_ZIP_FILE;

View File

@ -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<int>(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<float, 4> 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() {

View File

@ -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<void(const std::string&)> startDialogueFunc;
std::function<void()> startDarklandsTransitionFunc;
@ -88,6 +93,7 @@ namespace ZL {
void openPhoneVideo();
void openPhoneTaxi();
void openPhoneMapScreen(std::shared_ptr<UiNode> mapRoot);
void refreshChatUnreadIndicators();
void resetPhoneChatNodes();
void recomputePhoneChatPositions();
void openPhoneChatFromList(std::shared_ptr<UiNode> 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<std::string> startedDialogues_;
bool chatUnread_[3] = { true, true, true };
int money_ = 5500;
// Phone chat state
struct PhoneChatBubbleInfo {
std::string nodeName;