Some clean up
This commit is contained in:
1 parent
6149182f02
commit
fb7b42ddf9
20 files changed
+81
-984069
No files matched your search
@@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
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
+26
-28
@@ -33,7 +33,8 @@ namespace ZL {
|
||||
void MenuManager::setup(Inventory& inv, const std::string& zipFile) {
|
||||
inventory = &inv;
|
||||
|
||||
ingameRoot = loadUiFromFile("resources/config2/ui_inventory.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,17 +44,24 @@ 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;
|
||||
openInventory();
|
||||
});
|
||||
|
||||
uiManager.setTextButtonCallback("quest_journal_button", [this](const std::string&) {
|
||||
openQuestJournal();
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -67,27 +75,14 @@ namespace ZL {
|
||||
}
|
||||
}
|
||||
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;
|
||||
});
|
||||
|
||||
uiManager.setTextButtonCallback("quest_journal_button", [this](const std::string&) {
|
||||
openQuestJournal();
|
||||
});
|
||||
void MenuManager::closeInventory() {
|
||||
state = GameState::Gameplay;
|
||||
uiManager.popMenu();
|
||||
}
|
||||
|
||||
void MenuManager::openQuestJournal() {
|
||||
if (inventoryOpen) {
|
||||
uiManager.setNodeVisible("inventory_items_panel", false);
|
||||
uiManager.setNodeVisible("close_inventory_button", false);
|
||||
inventoryOpen = false;
|
||||
}
|
||||
|
||||
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
@@ -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;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user