Some clean up

This commit is contained in:
Vladislav Khorev committed 2026-05-02 20:40:29 +03:00
1 parent 6149182f02
commit fb7b42ddf9
20 files changed
+122 -984110

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
{
"root": {
"type": "FrameLayout",
"name": "hud_root",
"width": "match_parent",
"height": "match_parent",
"children": [
{
"type": "TextButton",
"name": "inventory_button",
"x": 50.0,
"y": 50.0,
"width": 150.0,
"height": 60.0,
"text": "Inventory",
"fontSize": 24,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": 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": "quest_journal_button",
"x": 220.0,
"y": 50.0,
"width": 170.0,
"height": 60.0,
"text": "Quests",
"fontSize": 24,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": 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"
}
}
]
}
}
+31 -67
View File
@@ -5,42 +5,6 @@
"width": "match_parent",
"height": "match_parent",
"children": [
{
"type": "TextButton",
"name": "inventory_button",
"x": 50.0,
"y": 50.0,
"width": 150.0,
"height": 60.0,
"text": "Inventory",
"fontSize": 24,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": 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": "quest_journal_button",
"x": 220.0,
"y": 50.0,
"width": 170.0,
"height": 60.0,
"text": "Quests",
"fontSize": 24,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": 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": "FrameLayout",
"name": "inventory_items_panel",
@@ -58,22 +22,22 @@
"height": 420.0,
"texture": "resources/w/red.png"
},
{
"type": "TextView",
"name": "inventory_title_text",
"x": 20.0,
"y": 18.0,
"width": 230.0,
"height": 34.0,
"text": "Inventory",
"fontSize": 24,
"fontPath": "resources/fonts/DroidSans.ttf",
"centered": false,
"topAligned": true,
"paddingX": 0.0,
"paddingY": 0.0,
"color": [1.0, 1.0, 1.0, 1.0]
},
{
"type": "TextView",
"name": "inventory_title_text",
"x": 20.0,
"y": 18.0,
"width": 230.0,
"height": 34.0,
"text": "Inventory",
"fontSize": 24,
"fontPath": "resources/fonts/DroidSans.ttf",
"centered": false,
"topAligned": true,
"paddingX": 0.0,
"paddingY": 0.0,
"color": [1.0, 1.0, 1.0, 1.0]
},
{
"type": "TextView",
"name": "inventory_items_text",
@@ -94,21 +58,21 @@
},
{
"type": "TextButton",
"name": "close_inventory_button",
"x": 266.0,
"y": 16.0,
"width": 40.0,
"height": 40.0,
"text": "X",
"fontSize": 20,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": 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"
}
"name": "close_inventory_button",
"x": 266.0,
"y": 16.0,
"width": 40.0,
"height": 40.0,
"text": "X",
"fontSize": 20,
"fontPath": "resources/fonts/DroidSans.ttf",
"textCentered": 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"
}
}
]
}
File diff suppressed because it is too large. Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+36 -38
View File
@@ -33,8 +33,9 @@ namespace ZL {
void MenuManager::setup(Inventory& inv, const std::string& zipFile) {
inventory = &inv;
ingameRoot = loadUiFromFile("resources/config2/ui_inventory.json", renderer, zipFile);
questJournalRoot = loadUiFromFile("resources/config2/ui_quest_journal.json", renderer, zipFile);
hudRoot = loadUiFromFile("resources/config2/hud.json", renderer, zipFile);
inventoryRoot = loadUiFromFile("resources/config2/ui_inventory.json", renderer, zipFile);
questJournalRoot = loadUiFromFile("resources/config2/ui_quest_journal.json", renderer, zipFile);
questJournal.loadFromFile("resources/quests/quests.json", zipFile);
@@ -43,37 +44,10 @@ namespace ZL {
void MenuManager::enterGameplay() {
state = GameState::Gameplay;
uiManager.replaceRoot(ingameRoot);
uiManager.setNodeVisible("inventory_items_panel", false);
uiManager.setNodeVisible("close_inventory_button", false);
inventoryOpen = false;
uiManager.replaceRoot(hudRoot);
uiManager.setTextButtonCallback("inventory_button", [this](const std::string&) {
std::cout << "[UI] Inventory button clicked" << std::endl;
uiManager.setNodeVisible("inventory_items_panel", true);
uiManager.setNodeVisible("close_inventory_button", true);
inventoryOpen = true;
const auto& items = inventory->getItems();
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";
}
}
uiManager.setText("inventory_items_text", itemText);
});
uiManager.setTextButtonCallback("close_inventory_button", [this](const std::string&) {
std::cout << "[UI] Close button clicked" << std::endl;
uiManager.setNodeVisible("inventory_items_panel", false);
uiManager.setNodeVisible("close_inventory_button", false);
inventoryOpen = false;
openInventory();
});
uiManager.setTextButtonCallback("quest_journal_button", [this](const std::string&) {
@@ -81,13 +55,34 @@ namespace ZL {
});
}
void MenuManager::openQuestJournal() {
if (inventoryOpen) {
uiManager.setNodeVisible("inventory_items_panel", false);
uiManager.setNodeVisible("close_inventory_button", false);
inventoryOpen = false;
}
void MenuManager::openInventory() {
state = GameState::Inventory;
uiManager.pushMenuFromSavedRoot(inventoryRoot);
uiManager.setTextButtonCallback("close_inventory_button", [this](const std::string&) {
closeInventory();
});
const auto& items = inventory->getItems();
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";
}
}
uiManager.setText("inventory_items_text", itemText);
}
void MenuManager::closeInventory() {
state = GameState::Gameplay;
uiManager.popMenu();
}
void MenuManager::openQuestJournal() {
state = GameState::QuestJournal;
uiManager.pushMenuFromSavedRoot(questJournalRoot);
@@ -117,10 +112,13 @@ namespace ZL {
void MenuManager::toggleQuestJournal() {
std::cout << "[quest] toggleQuestJournal: " << (isQuestJournalOpen() ? "closing" : "opening") << std::endl;
if (isQuestJournalOpen()) {
if (state == GameState::QuestJournal) {
closeQuestJournal();
}
else {
if (state == GameState::Inventory) {
closeInventory();
}
openQuestJournal();
}
}
+9 -2
View File
@@ -15,6 +15,7 @@ namespace ZL {
enum class GameState {
Gameplay,
Inventory,
QuestJournal
};
@@ -26,9 +27,15 @@ namespace ZL {
MenuManager(Renderer& iRenderer);
void setup(Inventory& inv, const std::string& zipFile);
void openInventory();
void closeInventory();
void openQuestJournal();
void closeQuestJournal();
void toggleQuestJournal();
bool isInventoryOpen() const { return state == GameState::Inventory; }
bool isQuestJournalOpen() const { return state == GameState::QuestJournal; }
protected:
@@ -42,10 +49,10 @@ namespace ZL {
GameState state = GameState::Gameplay;
Inventory* inventory = nullptr;
std::shared_ptr<UiNode> ingameRoot;
std::shared_ptr<UiNode> hudRoot;
std::shared_ptr<UiNode> inventoryRoot;
std::shared_ptr<UiNode> questJournalRoot;
bool inventoryOpen = false;
int selectedQuestIndex = -1;
std::vector<std::string> visibleQuestIds;
};