Working on journal portrait mode

This commit is contained in:
Vladislav Khorev 2026-06-27 11:50:09 +03:00
parent b41e312511
commit 1b172460e0
7 changed files with 617 additions and 17 deletions

BIN
resources/w/ui/img/journal/PortraitQuestJournalBkg001.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,293 @@
{
"root": {
"type": "FrameLayout",
"name": "hud_root",
"width": "match_parent",
"height": "match_parent",
"vertical_align": "top",
"horizontal_align": "center",
"children": [
{
"type": "StaticImage",
"name": "background",
"width": 640,
"height": 1200,
"y": 68,
"horizontal_gravity": "center",
"vertical_gravity": "top",
"texture": "resources/w/ui/img/journal/PortraitQuestJournalBkg001.png"
},
{
"type": "Button",
"name": "journalExitButton",
"horizontal_gravity": "center",
"vertical_gravity": "top",
"width": 120,
"height": 120,
"x": 267,
"y": 60,
"textures": {
"normal": "resources/w/ui/img/Close001_State=Default.png",
"hover": "resources/w/ui/img/Close001_State=Selected.png",
"pressed": "resources/w/ui/img/Close001_State=Tap.png"
}
},
{
"type": "LinearLayout",
"orientation": "vertical",
"horizontal_gravity": "center",
"vertical_gravity": "top",
"spacing": 0,
"x": 0,
"y": 170,
"width": 640,
"height": 1080,
"children": [
{
"type": "TextButton",
"name": "item1name",
"x": 0.0,
"y": 0.0,
"width": 640,
"height": 0,
"text": "Главное Задание 1",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkg001.png",
"hover": "resources/w/ui/img/journal/ButtonBkg001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkg001.png"
}
},
{
"type": "TextButton",
"name": "item2name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 0.0,
"text": "Задание 2",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
},
{
"type": "TextButton",
"name": "item3name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 213.0,
"text": "Задание 3",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.02,
0.875,
0.447,
0.6
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
},
{
"type": "TextButton",
"name": "item4name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 0.0,
"text": "",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
},
{
"type": "TextButton",
"name": "item5name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 0.0,
"text": "",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
},
{
"type": "TextButton",
"name": "item6name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 0.0,
"text": "",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
},
{
"type": "TextButton",
"name": "item7name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 0.0,
"text": "",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
},
{
"type": "TextButton",
"name": "item8name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 0.0,
"text": "",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
},
{
"type": "TextButton",
"name": "item9name",
"x": 0.0,
"y": 0.0,
"width": 640.0,
"height": 0.0,
"text": "",
"textPaddingY": 8.0,
"textPaddingX": 32.0,
"fontSize": 48,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": true,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
1.0
],
"textures": {
"normal": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"hover": "resources/w/ui/img/journal/ButtonBkgTransparent001.png",
"pressed": "resources/w/ui/img/journal/ButtonBkgTransparent001.png"
}
}
]
}
]
}
}

View File

@ -0,0 +1,201 @@
{
"root": {
"type": "FrameLayout",
"name": "hud_root",
"width": "match_parent",
"height": "match_parent",
"vertical_align": "top",
"horizontal_align": "center",
"children": [
{
"type": "StaticImage",
"name": "background",
"width": 640,
"height": 1200,
"y": 68,
"horizontal_gravity": "center",
"vertical_gravity": "top",
"texture": "resources/w/ui/img/journal/PortraitQuestJournalItemBkg001.png"
},
{
"type": "Button",
"name": "journalItemExitButton",
"horizontal_gravity": "center",
"vertical_gravity": "top",
"width": 120,
"height": 120,
"x": 267,
"y": 60,
"textures": {
"normal": "resources/w/ui/img/Close001_State=Default.png",
"hover": "resources/w/ui/img/Close001_State=Selected.png",
"pressed": "resources/w/ui/img/Close001_State=Tap.png"
}
},
{
"type": "TextView",
"name": "quest_title",
"x": 30.0,
"y": 230.0,
"width": 640.0,
"height": 44.0,
"horizontal_gravity": "center",
"vertical_gravity": "top",
"text": "Главное Задание 1",
"fontSize": 56,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": false,
"wrap": true,
"color": [
0.992,
0.78,
0.0,
1.0
]
},
{
"type": "LinearLayout",
"orientation": "horizontal",
"spacing": 10,
"horizontal_gravity": "center",
"vertical_gravity": "top",
"x": 36,
"y": 370,
"width": 640,
"height": 80,
"children": [
{
"type": "StaticImage",
"name": "objective1checkbox",
"width": 60,
"height": 60,
"texture": "resources/w/ui/img/journal/quest_objective_completed.png"
},
{
"type": "TextView",
"name": "objective1name",
"paddingY": 20,
"width": 740.0,
"height": 80.0,
"textPaddingY": 20.0,
"text": "Цель 1 Цель 1 Цель 1 Цель 1",
"fontSize": 32,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": false,
"wrap": true,
"color": [
0.02,
0.875,
0.447,
0.6
]
}
]
},
{
"type": "LinearLayout",
"orientation": "horizontal",
"spacing": 10,
"horizontal_gravity": "center",
"vertical_gravity": "top",
"x": 36,
"y": 450,
"width": 640,
"height": 80,
"children": [
{
"type": "StaticImage",
"name": "objective2checkbox",
"width": 60,
"height": 60,
"texture": "resources/w/ui/img/journal/quest_objective_blank.png"
},
{
"type": "TextView",
"name": "objective2name",
"paddingY": 20,
"width": 740.0,
"height": 80.0,
"text": "Цель 2",
"textPaddingY": 20.0,
"fontSize": 32,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": false,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
0.9
]
}
]
},
{
"type": "LinearLayout",
"orientation": "horizontal",
"spacing": 10,
"horizontal_gravity": "center",
"vertical_gravity": "top",
"x": 36,
"y": 530,
"width": 640,
"height": 80,
"children": [
{
"type": "StaticImage",
"name": "objective3checkbox",
"width": 60,
"height": 60,
"texture": "resources/w/ui/img/journal/quest_objective_blank.png"
},
{
"type": "TextView",
"name": "objective3name",
"paddingY": 20,
"width": 740.0,
"height": 80.0,
"text": "Цель 3",
"textPaddingY": 20.0,
"fontSize": 32,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": false,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
0.9
]
}
]
},
{
"type": "TextView",
"name": "quest_description",
"x": 4.0,
"y": 480.0,
"width": 580.0,
"height": 400.0,
"horizontal_gravity": "center",
"vertical_gravity": "top",
"text": "А все бегут бегут бегут бегут бегут бегут бегут бегут бегут бегут бегут а мы идем.",
"fontSize": 32,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": false,
"topAligned": false,
"wrap": true,
"color": [
0.996,
0.977,
0.761,
0.75
]
}
]
}
}

View File

@ -49,7 +49,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 90,
"height": 0,
"text": "Главное Задание 1",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -76,7 +76,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "Задание 2",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -103,7 +103,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "Задание 3",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -130,7 +130,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -157,7 +157,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -184,7 +184,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -211,7 +211,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -238,7 +238,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "",
"textPaddingY": 4.0,
"textPaddingX": 16.0,
@ -265,7 +265,7 @@
"x": 0.0,
"y": 0.0,
"width": 270.0,
"height": 60.0,
"height": 0.0,
"text": "",
"textPaddingY": 4.0,
"textPaddingX": 16.0,

View File

@ -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_;

View File

@ -138,6 +138,9 @@ namespace ZL {
void rebuildChatBubblesFromHistory(int chatIndex, bool isPortrait);
void showModalMenuScreen();
void openPortraitQuestJournalItem(int index);
void closePortraitJournalItem();
void showAboutScreen();
void showSettingsScreen();
void showLoadGameScreen();
@ -168,6 +171,7 @@ namespace ZL {
int inventorySelectedIndex_ = -1;
int selectedQuestIndex = -1;
int journalMenuStackDepth_ = 0;
std::vector<std::string> visibleQuestIds;
std::shared_ptr<UiNode> hudRoot;
@ -232,6 +236,8 @@ namespace ZL {
std::shared_ptr<UiNode> newInventoryRoot;
std::shared_ptr<UiNode> questJournalRoot;
std::shared_ptr<UiNode> portraitQuestJournalListRoot;
std::shared_ptr<UiNode> portraitQuestJournalItemRoot;
std::shared_ptr<Texture> texObjectiveCompleted_;
std::shared_ptr<Texture> texObjectiveBlank_;