Working on phone messages
This commit is contained in:
1 parent
cdab525858
commit
9425f9b19a
20 files changed
+591
-28
No files matched your search
+59
-6
@@ -83,6 +83,7 @@ namespace ZL {
|
||||
hudStep5abRoot = loadUiFromFile("resources/w/ui/hud_step5ab.json", renderer, zipFile);
|
||||
//phoneScreenRoot = loadUiFromFile("resources/w/ui/screen_phone_chat_list.json", renderer, zipFile);
|
||||
phoneScreenRoot = loadUiFromFile("resources/w/ui/screen_phone_chat2.json", renderer, zipFile);
|
||||
//phoneScreenRoot = loadUiFromFile("resources/w/ui/screen_phone_chat1.json", renderer, zipFile);
|
||||
newInventoryRoot = loadUiFromFile("resources/w/ui/screen_inventory.json", renderer, zipFile);
|
||||
questJournalRoot = loadUiFromFile("resources/w/ui/screen_journal.json", renderer, zipFile);
|
||||
|
||||
@@ -202,17 +203,19 @@ namespace ZL {
|
||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||
closePhoneScreen();
|
||||
});
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {
|
||||
//Keep the callback
|
||||
});
|
||||
uiManager.setTextButtonCallback("chat1button", [this](const std::string&) {
|
||||
std::cout << "Hello test " << std::endl;
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||
|
||||
});
|
||||
// Reset chat state and start the dialogue
|
||||
phoneChatVisibleBubbles_.clear();
|
||||
resetPhoneChatNodes();
|
||||
if (startDialogueFunc) {
|
||||
startDialogueFunc("dialog_chat_aiperi001");
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager::closePhoneScreen() {
|
||||
state = GameState::Gameplay;
|
||||
phoneChatVisibleBubbles_.clear();
|
||||
uiManager.popMenu();
|
||||
}
|
||||
|
||||
@@ -412,4 +415,54 @@ namespace ZL {
|
||||
refreshQuestJournalUi();
|
||||
}
|
||||
|
||||
void MenuManager::resetPhoneChatNodes() {
|
||||
static const char* kChatNodes[] = {
|
||||
"message01in", "message02out", "message03in", "message04out",
|
||||
"message05in", "message06in", "message07in", "message08out",
|
||||
"message09in", "message10in", "message11in", nullptr
|
||||
};
|
||||
for (int i = 0; kChatNodes[i]; ++i) {
|
||||
uiManager.setNodeVisible(kChatNodes[i], false);
|
||||
auto n = uiManager.findNode(kChatNodes[i]);
|
||||
if (n) { n->scaleX = 1.0f; n->scaleY = 1.0f; }
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager::recomputePhoneChatPositions() {
|
||||
float totalHeight = 0.0f;
|
||||
for (size_t i = 0; i < phoneChatVisibleBubbles_.size(); ++i) {
|
||||
totalHeight += phoneChatVisibleBubbles_[i].height;
|
||||
if (i > 0) totalHeight += CHAT_SPACING;
|
||||
}
|
||||
|
||||
const float available = CHAT_TOP_Y - CHAT_BOTTOM_Y;
|
||||
const float topY = (totalHeight <= available)
|
||||
? CHAT_TOP_Y
|
||||
: CHAT_BOTTOM_Y + totalHeight;
|
||||
|
||||
float cursor = topY;
|
||||
for (auto& bubble : phoneChatVisibleBubbles_) {
|
||||
auto node = uiManager.findNode(bubble.nodeName);
|
||||
if (!node) continue;
|
||||
node->localY = cursor - bubble.height;
|
||||
cursor -= bubble.height + CHAT_SPACING;
|
||||
}
|
||||
uiManager.updateAllLayouts();
|
||||
}
|
||||
|
||||
void MenuManager::revealPhoneChatBubble(const std::string& slotName) {
|
||||
if (state != GameState::PhoneScreen) return;
|
||||
auto node = uiManager.findNode(slotName);
|
||||
if (!node) return;
|
||||
|
||||
// Zero scale before making visible to avoid a one-frame flash at full size
|
||||
node->scaleX = 0.0f;
|
||||
node->scaleY = 0.0f;
|
||||
|
||||
phoneChatVisibleBubbles_.push_back({slotName, node->height});
|
||||
uiManager.setNodeVisible(slotName, true);
|
||||
recomputePhoneChatPositions();
|
||||
uiManager.startPopIn(slotName, 300.0f);
|
||||
}
|
||||
|
||||
} // namespace ZL
|
||||
Reference in new issue
Block a user