Fixing dialogues and cutscenes, minor bug fixing

This commit is contained in:
Vladislav Khorev committed 2026-06-13 15:07:09 +03:00
1 parent 2b32fce5e0
commit fff5a9d4aa
18 files changed
+4010 -2208

No files matched your search

+39 -4
View File
@@ -53,6 +53,22 @@ namespace ZL {
return max(1, lines);
}
static std::string trimChatPreview(const std::string& msg, int maxChars = 22) {
int charCount = 0;
int bytePos = 0;
const int len = static_cast<int>(msg.size());
while (bytePos < len && charCount < maxChars) {
const unsigned char c = static_cast<unsigned char>(msg[bytePos]);
if (c < 0x80) bytePos += 1;
else if (c < 0xE0) bytePos += 2;
else if (c < 0xF0) bytePos += 3;
else bytePos += 4;
++charCount;
}
if (bytePos >= len) return msg;
return msg.substr(0, bytePos) + "...";
}
static std::string formatMoney(int amount) {
bool negative = amount < 0;
std::string digits = std::to_string(negative ? -amount : amount);
@@ -459,14 +475,23 @@ namespace ZL {
}
void MenuManager::refreshChatUnreadIndicators() {
uiManager.setNodeVisible("chat1Unread", chatUnread_[0]);
uiManager.setNodeVisible("chat2Unread", chatUnread_[1]);
uiManager.setNodeVisible("chat3Unread", chatUnread_[2]);
static const char* kUnreadNodes[3] = { "chat1Unread", "chat2Unread", "chat3Unread" };
static const char* kMsgNodes[3] = { "chat1msg", "chat2msg", "chat3msg" };
for (int i = 0; i < 3; ++i) {
uiManager.setNodeVisible(kUnreadNodes[i], chatUnread_[i]);
if (!chatPreviewMsg_[i].empty())
uiManager.setText(kMsgNodes[i], chatPreviewMsg_[i]);
}
}
void MenuManager::setChatUnread(int chatIndex, bool unread) {
void MenuManager::setChatUnread(int chatIndex, bool unread, const std::string& previewMsg) {
if (chatIndex < 0 || chatIndex > 2) return;
chatUnread_[chatIndex] = unread;
if (!previewMsg.empty()) {
chatPreviewMsg_[chatIndex] = trimChatPreview(previewMsg);
} else if (!unread && !chatHistory_[chatIndex].empty()) {
chatPreviewMsg_[chatIndex] = trimChatPreview(chatHistory_[chatIndex].back().text);
}
}
void MenuManager::spendMoney(int amount) {
@@ -575,6 +600,11 @@ namespace ZL {
}
void MenuManager::returnToPhoneChatList() {
if (activeChatIndex_ >= 0 && activeChatIndex_ <= 2
&& !chatHistory_[activeChatIndex_].empty()) {
chatPreviewMsg_[activeChatIndex_] =
trimChatPreview(chatHistory_[activeChatIndex_].back().text);
}
activeChatIndex_ = -1;
phoneChatVisibleBubbles_.clear();
uiManager.popMenu();
@@ -592,6 +622,11 @@ namespace ZL {
void MenuManager::closePhoneEntirely() {
if (activeChatIndex_ >= 0 && activeChatIndex_ <= 2
&& !chatHistory_[activeChatIndex_].empty()) {
chatPreviewMsg_[activeChatIndex_] =
trimChatPreview(chatHistory_[activeChatIndex_].back().text);
}
activeChatIndex_ = -1;
state = GameState::Gameplay;
phoneChatVisibleBubbles_.clear();