Working on phone and bank account
This commit is contained in:
parent
1b1ceac2fe
commit
e6bfe85e2e
@ -336,6 +336,24 @@
|
|||||||
"type": "End"
|
"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",
|
"id": "dialog_second_floor001",
|
||||||
|
|||||||
@ -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": [
|
"cutscenes": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -79,6 +79,15 @@
|
|||||||
"pressed": "resources/w/ui/img/phone/ChatListItem001.png"
|
"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",
|
"type": "TextView",
|
||||||
"name": "chat1msg",
|
"name": "chat1msg",
|
||||||
@ -134,6 +143,15 @@
|
|||||||
"pressed": "resources/w/ui/img/phone/ChatListItem002.png"
|
"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",
|
"type": "TextView",
|
||||||
"name": "chat2msg",
|
"name": "chat2msg",
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
#include "external/nlohmann/json.hpp"
|
#include "external/nlohmann/json.hpp"
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ZL
|
namespace ZL
|
||||||
{
|
{
|
||||||
extern const char* CONST_ZIP_FILE;
|
extern const char* CONST_ZIP_FILE;
|
||||||
|
|||||||
@ -53,6 +53,19 @@ namespace ZL {
|
|||||||
return max(1, lines);
|
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) {
|
static std::array<float, 4> questStatusColor(Quest::QuestStatus status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case Quest::QuestStatus::Completed: return { 0.25f, 0.95f, 0.35f, 1.0f };
|
case Quest::QuestStatus::Completed: return { 0.25f, 0.95f, 0.35f, 1.0f };
|
||||||
@ -292,24 +305,44 @@ namespace ZL {
|
|||||||
|
|
||||||
void MenuManager::openPhoneMessenger() {
|
void MenuManager::openPhoneMessenger() {
|
||||||
uiManager.pushMenuFromSavedRoot(phoneChatListRoot);
|
uiManager.pushMenuFromSavedRoot(phoneChatListRoot);
|
||||||
|
refreshChatUnreadIndicators();
|
||||||
|
|
||||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||||
closePhoneEntirely();
|
closePhoneEntirely();
|
||||||
});
|
});
|
||||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||||
uiManager.setTextButtonCallback("chat1button", [this](const std::string&) {
|
uiManager.setTextButtonCallback("chat1button", [this](const std::string&) {
|
||||||
|
chatUnread_[0] = false;
|
||||||
openPhoneChatFromList(phoneChat1Root, "dialog_chat_aiperi001");
|
openPhoneChatFromList(phoneChat1Root, "dialog_chat_aiperi001");
|
||||||
});
|
});
|
||||||
uiManager.setTextButtonCallback("chat2button", [this](const std::string&) {
|
uiManager.setTextButtonCallback("chat2button", [this](const std::string&) {
|
||||||
|
chatUnread_[1] = false;
|
||||||
openPhoneChatFromList(phoneChat2Root, "dialog_chat_parents001");
|
openPhoneChatFromList(phoneChat2Root, "dialog_chat_parents001");
|
||||||
});
|
});
|
||||||
uiManager.setTextButtonCallback("chat3button", [this](const std::string&) {
|
uiManager.setTextButtonCallback("chat3button", [this](const std::string&) {
|
||||||
|
chatUnread_[2] = false;
|
||||||
openPhoneChatFromList(phoneChat3Root, "dialog_chat_news001");
|
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() {
|
void MenuManager::openPhoneBank() {
|
||||||
uiManager.pushMenuFromSavedRoot(phoneBankRoot);
|
uiManager.pushMenuFromSavedRoot(phoneBankRoot);
|
||||||
|
uiManager.setText("balanceText", formatMoney(money_));
|
||||||
|
|
||||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||||
closePhoneEntirely();
|
closePhoneEntirely();
|
||||||
@ -355,6 +388,7 @@ namespace ZL {
|
|||||||
uiManager.popMenu();
|
uiManager.popMenu();
|
||||||
});
|
});
|
||||||
uiManager.setButtonCallback("mapGo", [this](const std::string&) {
|
uiManager.setButtonCallback("mapGo", [this](const std::string&) {
|
||||||
|
money_ -= 500;
|
||||||
closePhoneEntirely();
|
closePhoneEntirely();
|
||||||
if (startDialogueFunc) startDialogueFunc("dialog_taxi002");
|
if (startDialogueFunc) startDialogueFunc("dialog_taxi002");
|
||||||
});
|
});
|
||||||
@ -386,6 +420,7 @@ namespace ZL {
|
|||||||
void MenuManager::returnToPhoneChatList() {
|
void MenuManager::returnToPhoneChatList() {
|
||||||
phoneChatVisibleBubbles_.clear();
|
phoneChatVisibleBubbles_.clear();
|
||||||
uiManager.popMenu();
|
uiManager.popMenu();
|
||||||
|
refreshChatUnreadIndicators();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuManager::closePhoneEntirely() {
|
void MenuManager::closePhoneEntirely() {
|
||||||
|
|||||||
@ -57,6 +57,11 @@ namespace ZL {
|
|||||||
bool isPhoneScreenOpen() const { return state == GameState::PhoneScreen; }
|
bool isPhoneScreenOpen() const { return state == GameState::PhoneScreen; }
|
||||||
void closePhoneEntirely();
|
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(const std::string&)> startDialogueFunc;
|
||||||
std::function<void()> startDarklandsTransitionFunc;
|
std::function<void()> startDarklandsTransitionFunc;
|
||||||
|
|
||||||
@ -88,6 +93,7 @@ namespace ZL {
|
|||||||
void openPhoneVideo();
|
void openPhoneVideo();
|
||||||
void openPhoneTaxi();
|
void openPhoneTaxi();
|
||||||
void openPhoneMapScreen(std::shared_ptr<UiNode> mapRoot);
|
void openPhoneMapScreen(std::shared_ptr<UiNode> mapRoot);
|
||||||
|
void refreshChatUnreadIndicators();
|
||||||
void resetPhoneChatNodes();
|
void resetPhoneChatNodes();
|
||||||
void recomputePhoneChatPositions();
|
void recomputePhoneChatPositions();
|
||||||
void openPhoneChatFromList(std::shared_ptr<UiNode> chatRoot, const std::string& dialogueId);
|
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
|
// Dialogues that have been started at least once; re-opening a chat won't restart them
|
||||||
std::unordered_set<std::string> startedDialogues_;
|
std::unordered_set<std::string> startedDialogues_;
|
||||||
|
|
||||||
|
bool chatUnread_[3] = { true, true, true };
|
||||||
|
int money_ = 5500;
|
||||||
|
|
||||||
// Phone chat state
|
// Phone chat state
|
||||||
struct PhoneChatBubbleInfo {
|
struct PhoneChatBubbleInfo {
|
||||||
std::string nodeName;
|
std::string nodeName;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user