diff --git a/resources/w/ui/img/journal/QuestJournal003.png b/resources/w/ui/img/journal/QuestJournal003.png new file mode 100644 index 0000000..35eeefe --- /dev/null +++ b/resources/w/ui/img/journal/QuestJournal003.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30a9aa7c0d35a9e87f8fc859b030be3dcbdb23d379d807ce0bad84749284a430 +size 858275 diff --git a/resources/w/ui/img/journal/quest_objective_blank.png b/resources/w/ui/img/journal/quest_objective_blank.png new file mode 100644 index 0000000..896fe5b --- /dev/null +++ b/resources/w/ui/img/journal/quest_objective_blank.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:775a0465e43598d912ce243299691586a05f121133d10e0604f5e653b6fb0bd2 +size 2673 diff --git a/resources/w/ui/img/journal/quest_objective_completed.png b/resources/w/ui/img/journal/quest_objective_completed.png new file mode 100644 index 0000000..13e8f96 --- /dev/null +++ b/resources/w/ui/img/journal/quest_objective_completed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5bc0e67177b71590f17b9f5c3e7eb767b7189eff12718f015140f1dfc6d55356 +size 2899 diff --git a/resources/w/ui/screen_journal.json b/resources/w/ui/screen_journal.json index 0b0ea0a..755d11b 100644 --- a/resources/w/ui/screen_journal.json +++ b/resources/w/ui/screen_journal.json @@ -4,21 +4,230 @@ "name": "hud_root", "width": "match_parent", "height": "match_parent", - "vertical_align": "center", - "horizontal_align": "center", + "vertical_align": "center", + "horizontal_align": "center", "children": [ + { + "type": "StaticImage", + "name": "background", + "width": 1266, + "height": 585, + "horizontal_gravity": "center", + "vertical_gravity": "center", + "texture": "resources/w/ui/img/journal/QuestJournal003.png" + }, { "type": "Button", - "name": "journalExitButton", - "horizontal_gravity": "center", - "vertical_gravity": "center", - "width": 1125, - "height": 520, + "name": "inventoryExitButton", + "horizontal_gravity": "center", + "vertical_gravity": "center", + "width": 90, + "height": 90, + "x": 580, + "y": 240, "textures": { - "normal": "resources/w/ui/img/QuestJournal001.png", - "hover": "resources/w/ui/img/QuestJournal001.png", - "pressed": "resources/w/ui/img/QuestJournal001.png" + "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", + "vertical_align": "center", + "horizontal_align": "center", + "spacing": 0, + "x": 0, + "y": -195, + "width": 290, + "height": 800, + "children": [ + { + "type": "TextButton", + "name": "item1name", + "x": 0.0, + "y": 0.0, + "width": 270.0, + "height": 60.0, + "text": "Задание 1", + "textPaddingY": -8.0, + "fontSize": 32, + "fontPath": "resources/fonts/DroidSans.ttf", + "centered": false, + "textCentered": false, + "topAligned": false, + "wrap": true, + "color": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "textures": { + "normal": "resources/w/red.png", + "hover": "resources/w/red.png", + "pressed": "resources/w/red.png" + } + }, + { + "type": "TextButton", + "name": "item2name", + "x": 0.0, + "y": 0.0, + "width": 270.0, + "height": 60.0, + "text": "Задание 2", + "textPaddingY": -8.0, + "fontSize": 32, + "fontPath": "resources/fonts/DroidSans.ttf", + "centered": false, + "textCentered": false, + "topAligned": false, + "wrap": true, + "color": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "textures": { + "normal": "resources/w/blue.png", + "hover": "resources/w/blue.png", + "pressed": "resources/w/blue.png" + } + } + ] + }, + { + "type": "TextView", + "name": "quest_title", + "x": 60.0, + "y": 180.0, + "width": 800.0, + "height": 44.0, + "horizontal_gravity": "center", + "vertical_gravity": "top", + "text": "Выбрано задание 1", + "fontSize": 32, + "fontPath": "resources/fonts/DroidSans.ttf", + "centered": false, + "topAligned": false, + "wrap": true, + "color": [ + 1.0, + 1.0, + 0.0, + 1.0 + ] + }, + { + "type": "LinearLayout", + "orientation": "vertical", + "vertical_align": "top", + "horizontal_align": "center", + "spacing": 10, + "x": 305, + "y": 300, + "width": 800, + "height": 300, + "children": [ + { + "type": "LinearLayout", + "orientation": "horizontal", + "spacing": 10, + "x": 0, + "y": 0, + "width": 800, + "height": 40, + "children": [ + { + "type": "StaticImage", + "name": "background", + "width": 40, + "height": 40, + "texture": "resources/w/ui/img/journal/quest_objective_completed.png" + }, + { + "type": "TextView", + "name": "objective1name", + "paddingY": 20, + "width": 740.0, + "height": 60.0, + "text": "Цель 1 Цель 1 Цель 1 Цель 1", + "fontSize": 32, + "fontPath": "resources/fonts/DroidSans.ttf", + "centered": false, + "topAligned": false, + "wrap": true, + "color": [ + 1.0, + 1.0, + 1.0, + 1.0 + ] + } + ] + }, + { + "type": "LinearLayout", + "orientation": "horizontal", + "spacing": 10, + "x": 0, + "y": 0, + "width": 800, + "height": 40, + "children": [ + { + "type": "StaticImage", + "name": "background", + "width": 40, + "height": 40, + "texture": "resources/w/ui/img/journal/quest_objective_blank.png" + }, + { + "type": "TextView", + "name": "objective2name", + "paddingY": 20, + "width": 740.0, + "height": 60.0, + "text": "Цель 2", + "fontSize": 32, + "fontPath": "resources/fonts/DroidSans.ttf", + "centered": false, + "topAligned": false, + "wrap": true, + "color": [ + 1.0, + 1.0, + 1.0, + 1.0 + ] + } + ] + } + ] + }, + { + "type": "TextView", + "name": "quest_description", + "x": 170.0, + "y": 390.0, + "width": 1000.0, + "height": 300.0, + "horizontal_gravity": "center", + "vertical_gravity": "top", + "text": "А все бегут бегут бегут бегут бегут бегут бегут бегут бегут бегут бегут а мы идем.", + "fontSize": 32, + "fontPath": "resources/fonts/DroidSans.ttf", + "centered": false, + "topAligned": false, + "wrap": true, + "color": [ + 1.0, + 1.0, + 0.0, + 1.0 + ] } ] } diff --git a/src/Game.cpp b/src/Game.cpp index 3d0382b..905a063 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -430,6 +430,7 @@ namespace ZL std::cout << "UI loaded successfully" << std::endl; } catch (const std::exception& e) { + std::cerr << "Failed to load UI: " << e.what() << std::endl; } @@ -521,6 +522,7 @@ namespace ZL renderer.RenderUniform1i(textureUniformName, 0); renderer.RenderUniform1f("uAlpha", 1.0); + float width = Environment::projectionWidth; float height = Environment::projectionHeight; diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index 22d2050..aebbb42 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -32,7 +32,6 @@ namespace ZL { void MenuManager::setup(Inventory& inv, const std::string& zipFile) { inventory = &inv; - zipFile_ = zipFile; //hudRoot = loadUiFromFile("resources/config2/hud.json", renderer, zipFile); hudRoot = loadUiFromFile("resources/w/ui/hud_step0.json", renderer, zipFile); @@ -76,71 +75,26 @@ namespace ZL { uiManager.pushMenuFromSavedRoot(newInventoryRoot); uiManager.setButtonCallback("inventoryExitButton", [this](const std::string&) { closeInventory(); - }); + }); + /* + uiManager.pushMenuFromSavedRoot(inventoryRoot); + + uiManager.setTextButtonCallback("close_inventory_button", [this](const std::string&) { + closeInventory(); + }); const auto& items = inventory->getItems(); - const int maxSlots = 7; - - for (int i = 0; i < maxSlots; ++i) { - const std::string btnName = "item" + std::to_string(i + 1) + "Button"; - if (i < static_cast(items.size())) { - uiManager.setNodeVisible(btnName, true); - - auto btn = uiManager.findButton(btnName); - if (btn) { - auto tex = renderer.textureManager.LoadFromPng(items[i].icon, zipFile_, true); - btn->texNormal = btn->texHover = btn->texPressed = tex; - } - - uiManager.setButtonCallback(btnName, [this, i](const std::string&) { - selectInventoryItem(i); - }); - } else { - uiManager.setNodeVisible(btnName, false); + std::string itemText; + if (items.empty()) { + itemText = "Inventory (Empty)"; + } + else { + itemText = "Inventory (" + std::to_string(items.size()) + " items)\n\n"; + for (size_t i = 0; i < items.size(); ++i) { + itemText += std::to_string(i + 1) + ". " + items[i].name + "\n"; } } - - inventorySelectedIndex_ = -1; - if (!items.empty()) { - selectInventoryItem(0); - } - } - - void MenuManager::selectInventoryItem(int index) { - const auto& items = inventory->getItems(); - if (index < 0 || index >= static_cast(items.size())) return; - - // Revert previously selected button to its regular icon - if (inventorySelectedIndex_ >= 0 && inventorySelectedIndex_ < static_cast(items.size())) { - const std::string prevBtnName = "item" + std::to_string(inventorySelectedIndex_ + 1) + "Button"; - auto prevBtn = uiManager.findButton(prevBtnName); - if (prevBtn) { - auto tex = renderer.textureManager.LoadFromPng(items[inventorySelectedIndex_].icon, zipFile_, true); - prevBtn->texNormal = prevBtn->texHover = prevBtn->texPressed = tex; - } - } - - inventorySelectedIndex_ = index; - const auto& item = items[index]; - - // Highlight newly selected button with its selected icon - const std::string btnName = "item" + std::to_string(index + 1) + "Button"; - auto btn = uiManager.findButton(btnName); - if (btn) { - const std::string& selPath = item.selectedIcon.empty() ? item.icon : item.selectedIcon; - auto tex = renderer.textureManager.LoadFromPng(selPath, zipFile_, true); - btn->texNormal = btn->texHover = btn->texPressed = tex; - } - - // Update the large selected picture on the right panel - auto img = uiManager.findStaticImage("selectedItemPic"); - if (img) { - const std::string& path = item.selectedIcon.empty() ? item.icon : item.selectedIcon; - img->texture = renderer.textureManager.LoadFromPng(path, zipFile_, true); - } - - uiManager.setText("selectedText", item.name); - uiManager.setText("selectedDescription", item.description); + uiManager.setText("inventory_items_text", itemText);*/ } void MenuManager::closeInventory() { @@ -225,11 +179,6 @@ namespace ZL { // and hides any hints that have already been completed. // Called after every replaceRoot during step 5. void MenuManager::setupStep5Callbacks() { - if (uiManager.findButton("inventoryButton")) { - uiManager.setButtonCallback("inventoryButton", [this](const std::string&) { - openInventory(); - }); - } if (uiManager.findButton("phoneButton")) { uiManager.setButtonCallback("phoneButton", [this](const std::string&) { openPhoneScreen();