Working on journal portrait mode
This commit is contained in:
1 parent
b41e312511
commit
1b172460e0
7 files changed
+617
-17
No files matched your search
+102
-8
@@ -115,8 +115,6 @@ namespace ZL {
|
||||
hudStep5aRoot = loadUiFromFile("resources/w/ui/hud_step5a.json", renderer, zipFile);
|
||||
hudStep5bRoot = loadUiFromFile("resources/w/ui/hud_step5b.json", renderer, zipFile);
|
||||
hudStep5abRoot = loadUiFromFile("resources/w/ui/hud_step5ab.json", renderer, zipFile);
|
||||
//hudStep5abRoot = loadUiFromFile("resources/w/ui/portrait_hud_uni_int_full.json", renderer, zipFile);
|
||||
//hudStep5abRoot = loadUiFromFile("resources/w/ui/portrait_hud_uni_int_dark_full.json", renderer, zipFile);
|
||||
hudUniExtRoot = loadUiFromFile("resources/w/ui/hud_uni_ext.json", renderer, zipFile);
|
||||
hudUniIntStep10Root = loadUiFromFile("resources/w/ui/hud_uni_int_step10.json", renderer, zipFile);
|
||||
hudUniIntStep11Root = loadUiFromFile("resources/w/ui/hud_uni_int_step11.json", renderer, zipFile);
|
||||
@@ -160,8 +158,10 @@ namespace ZL {
|
||||
verticalPhoneChat3Root = loadUiFromFile("resources/w/ui/portrait_screen_phone_chat3.json", renderer, zipFile);
|
||||
|
||||
modalMenuRoot = loadUiFromFile("resources/w/ui/screen_modal_menu.json", renderer, zipFile);
|
||||
newInventoryRoot = loadUiFromFile("resources/w/ui/screen_inventory.json", renderer, zipFile);
|
||||
questJournalRoot = loadUiFromFile("resources/w/ui/screen_journal.json", renderer, zipFile);
|
||||
newInventoryRoot = loadUiFromFile("resources/w/ui/screen_inventory.json", renderer, zipFile);
|
||||
questJournalRoot = loadUiFromFile("resources/w/ui/screen_journal.json", renderer, zipFile);
|
||||
portraitQuestJournalListRoot = loadUiFromFile("resources/w/ui/portrait_screen_journal.json", renderer, zipFile);
|
||||
portraitQuestJournalItemRoot = loadUiFromFile("resources/w/ui/portrait_screen_journal_item.json", renderer, zipFile);
|
||||
mainMenuRoot = loadUiFromFile("resources/w/ui/screen_main_menu.json", renderer, zipFile);
|
||||
aboutScreenRoot = loadUiFromFile("resources/w/ui/screen_about.json", renderer, zipFile);
|
||||
settingsScreenRoot = loadUiFromFile("resources/w/ui/screen_settings.json", renderer, zipFile);
|
||||
@@ -535,10 +535,13 @@ namespace ZL {
|
||||
void MenuManager::openQuestJournal() {
|
||||
uiState_ = GameUiState::QuestJournal;
|
||||
gameState_.tutorialJournalScreenOpened = true;
|
||||
journalMenuStackDepth_ = 1;
|
||||
|
||||
uiManager.setNodeVisible("hint6b", false);
|
||||
uiManager.setNodeVisible("hint6barrow", false);
|
||||
uiManager.pushMenuFromSavedRoot(questJournalRoot);
|
||||
|
||||
const bool portrait = isPortraitMode();
|
||||
uiManager.pushMenuFromSavedRoot(portrait ? portraitQuestJournalListRoot : questJournalRoot);
|
||||
|
||||
uiManager.setButtonCallback("journalExitButton", [this](const std::string&) {
|
||||
closeQuestJournal();
|
||||
@@ -556,7 +559,7 @@ namespace ZL {
|
||||
}
|
||||
|
||||
refreshQuestJournalUi();
|
||||
if (!visibleQuestIds.empty()) {
|
||||
if (!portrait && !visibleQuestIds.empty()) {
|
||||
selectQuestByIndex(0);
|
||||
}
|
||||
}
|
||||
@@ -565,7 +568,8 @@ namespace ZL {
|
||||
uiState_ = GameUiState::Gameplay;
|
||||
selectedQuestIndex = -1;
|
||||
visibleQuestIds.clear();
|
||||
uiManager.popMenu();
|
||||
for (int i = 0; i < journalMenuStackDepth_; ++i) uiManager.popMenu();
|
||||
journalMenuStackDepth_ = 0;
|
||||
uiManager.updateAllLayouts();
|
||||
}
|
||||
|
||||
@@ -1210,7 +1214,11 @@ namespace ZL {
|
||||
if (node && tb && tb->textRenderer) {
|
||||
const float availW = node->width - 2.0f * tb->textPaddingX;
|
||||
const int numLines = countWrappedLines(quest->definition.title, *tb->textRenderer, availW);
|
||||
node->height = numLines * 30.0f + 30.0f;
|
||||
if (isPortraitMode()) {
|
||||
node->height = numLines * 48.0f + 48.0f;
|
||||
} else {
|
||||
node->height = numLines * 30.0f + 30.0f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uiManager.setTextButtonText(kItemNames[i], "");
|
||||
@@ -1229,6 +1237,11 @@ namespace ZL {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPortraitMode() && journalMenuStackDepth_ == 1) {
|
||||
openPortraitQuestJournalItem(index);
|
||||
return;
|
||||
}
|
||||
|
||||
selectedQuestIndex = index;
|
||||
Quest::QuestState* quest = gameState_.questJournal.findQuest(visibleQuestIds[index]);
|
||||
if (!quest) {
|
||||
@@ -1277,6 +1290,63 @@ namespace ZL {
|
||||
refreshQuestJournalUi();
|
||||
}
|
||||
|
||||
void MenuManager::openPortraitQuestJournalItem(int index) {
|
||||
selectedQuestIndex = index;
|
||||
journalMenuStackDepth_ = 2;
|
||||
uiManager.pushMenuFromSavedRoot(portraitQuestJournalItemRoot);
|
||||
|
||||
uiManager.setButtonCallback("journalItemExitButton", [this](const std::string&) {
|
||||
closePortraitJournalItem();
|
||||
});
|
||||
|
||||
Quest::QuestState* quest = gameState_.questJournal.findQuest(visibleQuestIds[index]);
|
||||
if (!quest) return;
|
||||
const auto& def = quest->definition;
|
||||
|
||||
uiManager.setText("quest_title", def.title);
|
||||
|
||||
static const char* kCheckboxes[3] = { "objective1checkbox", "objective2checkbox", "objective3checkbox" };
|
||||
static const char* kObjNames[3] = { "objective1name", "objective2name", "objective3name" };
|
||||
|
||||
std::vector<const Quest::QuestObjective*> visibleObjs;
|
||||
for (const auto& obj : def.objectives)
|
||||
if (obj.visible) visibleObjs.push_back(&obj);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (i < static_cast<int>(visibleObjs.size())) {
|
||||
const auto& obj = *visibleObjs[i];
|
||||
const bool isActive = (&obj - def.objectives.data() == quest->activeObjectiveIndex);
|
||||
auto img = uiManager.findStaticImage(kCheckboxes[i]);
|
||||
if (img) img->texture = obj.completed ? texObjectiveCompleted_ : texObjectiveBlank_;
|
||||
std::array<float, 4> color;
|
||||
if (obj.completed) {
|
||||
color = { 0.02f, 0.875f, 0.447f, 0.6f };
|
||||
} else if (isActive) {
|
||||
color = { 0.996f, 0.977f, 0.761f, 1.0f };
|
||||
} else {
|
||||
color = { 0.996f, 0.977f, 0.761f, 0.9f };
|
||||
}
|
||||
uiManager.setText(kObjNames[i], obj.text);
|
||||
uiManager.setTextColor(kObjNames[i], color);
|
||||
uiManager.setNodeVisible(kCheckboxes[i], true);
|
||||
uiManager.setNodeVisible(kObjNames[i], true);
|
||||
} else {
|
||||
uiManager.setNodeVisible(kCheckboxes[i], false);
|
||||
uiManager.setNodeVisible(kObjNames[i], false);
|
||||
}
|
||||
}
|
||||
|
||||
uiManager.setText("quest_description", def.description);
|
||||
uiManager.updateAllLayouts();
|
||||
}
|
||||
|
||||
void MenuManager::closePortraitJournalItem() {
|
||||
journalMenuStackDepth_ = 1;
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
refreshQuestJournalUi();
|
||||
}
|
||||
|
||||
void MenuManager::resetPhoneChatNodes() {
|
||||
static const char* kChatNodes[] = {
|
||||
"message01in", "message02out", "message03in", "message04out",
|
||||
@@ -1700,6 +1770,30 @@ namespace ZL {
|
||||
}
|
||||
|
||||
void MenuManager::onOrientationChanged() {
|
||||
if (uiState_ == GameUiState::QuestJournal) {
|
||||
const int savedQuestIndex = selectedQuestIndex;
|
||||
const bool wasOnItemDetail = (journalMenuStackDepth_ == 2);
|
||||
|
||||
for (int i = 0; i < journalMenuStackDepth_; ++i) uiManager.popMenu();
|
||||
journalMenuStackDepth_ = 0;
|
||||
uiState_ = GameUiState::Gameplay;
|
||||
selectedQuestIndex = -1;
|
||||
visibleQuestIds.clear();
|
||||
|
||||
openQuestJournal();
|
||||
|
||||
if (isPortraitMode() && wasOnItemDetail &&
|
||||
savedQuestIndex >= 0 && savedQuestIndex < static_cast<int>(visibleQuestIds.size())) {
|
||||
selectQuestByIndex(savedQuestIndex);
|
||||
} else if (!isPortraitMode() && savedQuestIndex > 0 &&
|
||||
savedQuestIndex < static_cast<int>(visibleQuestIds.size())) {
|
||||
selectQuestByIndex(savedQuestIndex);
|
||||
}
|
||||
|
||||
uiManager.updateAllLayouts();
|
||||
return;
|
||||
}
|
||||
|
||||
if (uiState_ != GameUiState::PhoneScreen) return;
|
||||
|
||||
const PhoneSubScreen savedSubScreen = currentPhoneSubScreen_;
|
||||
|
||||
Reference in new issue
Block a user