Working on UI journal
This commit is contained in:
parent
90c57932ec
commit
9adcde5c05
BIN
resources/w/ui/img/journal/QuestJournal003.png
(Stored with Git LFS)
Normal file
BIN
resources/w/ui/img/journal/QuestJournal003.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/w/ui/img/journal/quest_objective_blank.png
(Stored with Git LFS)
Normal file
BIN
resources/w/ui/img/journal/quest_objective_blank.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/w/ui/img/journal/quest_objective_completed.png
(Stored with Git LFS)
Normal file
BIN
resources/w/ui/img/journal/quest_objective_completed.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -8,17 +8,226 @@
|
|||||||
"horizontal_align": "center",
|
"horizontal_align": "center",
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"type": "Button",
|
"type": "StaticImage",
|
||||||
"name": "journalExitButton",
|
"name": "background",
|
||||||
|
"width": 1266,
|
||||||
|
"height": 585,
|
||||||
"horizontal_gravity": "center",
|
"horizontal_gravity": "center",
|
||||||
"vertical_gravity": "center",
|
"vertical_gravity": "center",
|
||||||
"width": 1125,
|
"texture": "resources/w/ui/img/journal/QuestJournal003.png"
|
||||||
"height": 520,
|
},
|
||||||
|
{
|
||||||
|
"type": "Button",
|
||||||
|
"name": "inventoryExitButton",
|
||||||
|
"horizontal_gravity": "center",
|
||||||
|
"vertical_gravity": "center",
|
||||||
|
"width": 90,
|
||||||
|
"height": 90,
|
||||||
|
"x": 580,
|
||||||
|
"y": 240,
|
||||||
"textures": {
|
"textures": {
|
||||||
"normal": "resources/w/ui/img/QuestJournal001.png",
|
"normal": "resources/w/ui/img/Close001_State=Default.png",
|
||||||
"hover": "resources/w/ui/img/QuestJournal001.png",
|
"hover": "resources/w/ui/img/Close001_State=Selected.png",
|
||||||
"pressed": "resources/w/ui/img/QuestJournal001.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
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -430,6 +430,7 @@ namespace ZL
|
|||||||
std::cout << "UI loaded successfully" << std::endl;
|
std::cout << "UI loaded successfully" << std::endl;
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
|
|
||||||
std::cerr << "Failed to load UI: " << e.what() << std::endl;
|
std::cerr << "Failed to load UI: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,6 +522,7 @@ namespace ZL
|
|||||||
renderer.RenderUniform1i(textureUniformName, 0);
|
renderer.RenderUniform1i(textureUniformName, 0);
|
||||||
renderer.RenderUniform1f("uAlpha", 1.0);
|
renderer.RenderUniform1f("uAlpha", 1.0);
|
||||||
|
|
||||||
|
|
||||||
float width = Environment::projectionWidth;
|
float width = Environment::projectionWidth;
|
||||||
float height = Environment::projectionHeight;
|
float height = Environment::projectionHeight;
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,6 @@ namespace ZL {
|
|||||||
|
|
||||||
void MenuManager::setup(Inventory& inv, const std::string& zipFile) {
|
void MenuManager::setup(Inventory& inv, const std::string& zipFile) {
|
||||||
inventory = &inv;
|
inventory = &inv;
|
||||||
zipFile_ = zipFile;
|
|
||||||
|
|
||||||
//hudRoot = loadUiFromFile("resources/config2/hud.json", renderer, zipFile);
|
//hudRoot = loadUiFromFile("resources/config2/hud.json", renderer, zipFile);
|
||||||
hudRoot = loadUiFromFile("resources/w/ui/hud_step0.json", renderer, zipFile);
|
hudRoot = loadUiFromFile("resources/w/ui/hud_step0.json", renderer, zipFile);
|
||||||
@ -77,70 +76,25 @@ namespace ZL {
|
|||||||
uiManager.setButtonCallback("inventoryExitButton", [this](const std::string&) {
|
uiManager.setButtonCallback("inventoryExitButton", [this](const std::string&) {
|
||||||
closeInventory();
|
closeInventory();
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
|
uiManager.pushMenuFromSavedRoot(inventoryRoot);
|
||||||
|
|
||||||
const auto& items = inventory->getItems();
|
uiManager.setTextButtonCallback("close_inventory_button", [this](const std::string&) {
|
||||||
const int maxSlots = 7;
|
closeInventory();
|
||||||
|
|
||||||
for (int i = 0; i < maxSlots; ++i) {
|
|
||||||
const std::string btnName = "item" + std::to_string(i + 1) + "Button";
|
|
||||||
if (i < static_cast<int>(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inventorySelectedIndex_ = -1;
|
|
||||||
if (!items.empty()) {
|
|
||||||
selectInventoryItem(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuManager::selectInventoryItem(int index) {
|
|
||||||
const auto& items = inventory->getItems();
|
const auto& items = inventory->getItems();
|
||||||
if (index < 0 || index >= static_cast<int>(items.size())) return;
|
std::string itemText;
|
||||||
|
if (items.empty()) {
|
||||||
// Revert previously selected button to its regular icon
|
itemText = "Inventory (Empty)";
|
||||||
if (inventorySelectedIndex_ >= 0 && inventorySelectedIndex_ < static_cast<int>(items.size())) {
|
}
|
||||||
const std::string prevBtnName = "item" + std::to_string(inventorySelectedIndex_ + 1) + "Button";
|
else {
|
||||||
auto prevBtn = uiManager.findButton(prevBtnName);
|
itemText = "Inventory (" + std::to_string(items.size()) + " items)\n\n";
|
||||||
if (prevBtn) {
|
for (size_t i = 0; i < items.size(); ++i) {
|
||||||
auto tex = renderer.textureManager.LoadFromPng(items[inventorySelectedIndex_].icon, zipFile_, true);
|
itemText += std::to_string(i + 1) + ". " + items[i].name + "\n";
|
||||||
prevBtn->texNormal = prevBtn->texHover = prevBtn->texPressed = tex;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uiManager.setText("inventory_items_text", itemText);*/
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuManager::closeInventory() {
|
void MenuManager::closeInventory() {
|
||||||
@ -225,11 +179,6 @@ namespace ZL {
|
|||||||
// and hides any hints that have already been completed.
|
// and hides any hints that have already been completed.
|
||||||
// Called after every replaceRoot during step 5.
|
// Called after every replaceRoot during step 5.
|
||||||
void MenuManager::setupStep5Callbacks() {
|
void MenuManager::setupStep5Callbacks() {
|
||||||
if (uiManager.findButton("inventoryButton")) {
|
|
||||||
uiManager.setButtonCallback("inventoryButton", [this](const std::string&) {
|
|
||||||
openInventory();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (uiManager.findButton("phoneButton")) {
|
if (uiManager.findButton("phoneButton")) {
|
||||||
uiManager.setButtonCallback("phoneButton", [this](const std::string&) {
|
uiManager.setButtonCallback("phoneButton", [this](const std::string&) {
|
||||||
openPhoneScreen();
|
openPhoneScreen();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user