Some clean up
This commit is contained in:
parent
6149182f02
commit
fb7b42ddf9
46
resources/config2/hud.json
Normal file
46
resources/config2/hud.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,42 +5,6 @@
|
|||||||
"width": "match_parent",
|
"width": "match_parent",
|
||||||
"height": "match_parent",
|
"height": "match_parent",
|
||||||
"children": [
|
"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",
|
"type": "FrameLayout",
|
||||||
"name": "inventory_items_panel",
|
"name": "inventory_items_panel",
|
||||||
@ -58,22 +22,22 @@
|
|||||||
"height": 420.0,
|
"height": 420.0,
|
||||||
"texture": "resources/w/red.png"
|
"texture": "resources/w/red.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextView",
|
"type": "TextView",
|
||||||
"name": "inventory_title_text",
|
"name": "inventory_title_text",
|
||||||
"x": 20.0,
|
"x": 20.0,
|
||||||
"y": 18.0,
|
"y": 18.0,
|
||||||
"width": 230.0,
|
"width": 230.0,
|
||||||
"height": 34.0,
|
"height": 34.0,
|
||||||
"text": "Inventory",
|
"text": "Inventory",
|
||||||
"fontSize": 24,
|
"fontSize": 24,
|
||||||
"fontPath": "resources/fonts/DroidSans.ttf",
|
"fontPath": "resources/fonts/DroidSans.ttf",
|
||||||
"centered": false,
|
"centered": false,
|
||||||
"topAligned": true,
|
"topAligned": true,
|
||||||
"paddingX": 0.0,
|
"paddingX": 0.0,
|
||||||
"paddingY": 0.0,
|
"paddingY": 0.0,
|
||||||
"color": [1.0, 1.0, 1.0, 1.0]
|
"color": [1.0, 1.0, 1.0, 1.0]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextView",
|
"type": "TextView",
|
||||||
"name": "inventory_items_text",
|
"name": "inventory_items_text",
|
||||||
@ -94,21 +58,21 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "close_inventory_button",
|
"name": "close_inventory_button",
|
||||||
"x": 266.0,
|
"x": 266.0,
|
||||||
"y": 16.0,
|
"y": 16.0,
|
||||||
"width": 40.0,
|
"width": 40.0,
|
||||||
"height": 40.0,
|
"height": 40.0,
|
||||||
"text": "X",
|
"text": "X",
|
||||||
"fontSize": 20,
|
"fontSize": 20,
|
||||||
"fontPath": "resources/fonts/DroidSans.ttf",
|
"fontPath": "resources/fonts/DroidSans.ttf",
|
||||||
"textCentered": true,
|
"textCentered": true,
|
||||||
"color": [1.0, 1.0, 1.0, 1.0],
|
"color": [1.0, 1.0, 1.0, 1.0],
|
||||||
"textures": {
|
"textures": {
|
||||||
"normal": "resources/w/blue.png",
|
"normal": "resources/w/blue.png",
|
||||||
"hover": "resources/w/blue.png",
|
"hover": "resources/w/blue.png",
|
||||||
"pressed": "resources/w/blue.png"
|
"pressed": "resources/w/blue.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
BIN
resources/w/jam/female_packed0_diffuse.png
(Stored with Git LFS)
BIN
resources/w/jam/female_packed0_diffuse.png
(Stored with Git LFS)
Binary file not shown.
BIN
resources/w/jam/female_packed1_diffuse.png
(Stored with Git LFS)
BIN
resources/w/jam/female_packed1_diffuse.png
(Stored with Git LFS)
Binary file not shown.
BIN
resources/w/jam/female_packed2_diffuse.png
(Stored with Git LFS)
BIN
resources/w/jam/female_packed2_diffuse.png
(Stored with Git LFS)
Binary file not shown.
BIN
resources/w/jam/female_packed3_diffuse.png
(Stored with Git LFS)
BIN
resources/w/jam/female_packed3_diffuse.png
(Stored with Git LFS)
Binary file not shown.
BIN
resources/w/jam/woman_idle001.anim
(Stored with Git LFS)
BIN
resources/w/jam/woman_idle001.anim
(Stored with Git LFS)
Binary file not shown.
BIN
resources/w/jam/woman_idle002.anim
(Stored with Git LFS)
BIN
resources/w/jam/woman_idle002.anim
(Stored with Git LFS)
Binary file not shown.
BIN
resources/w/jam/woman_walk001.anim
(Stored with Git LFS)
BIN
resources/w/jam/woman_walk001.anim
(Stored with Git LFS)
Binary file not shown.
BIN
resources/w/jam/woman_walk002.anim
(Stored with Git LFS)
BIN
resources/w/jam/woman_walk002.anim
(Stored with Git LFS)
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
@ -33,8 +33,9 @@ namespace ZL {
|
|||||||
void MenuManager::setup(Inventory& inv, const std::string& zipFile) {
|
void MenuManager::setup(Inventory& inv, const std::string& zipFile) {
|
||||||
inventory = &inv;
|
inventory = &inv;
|
||||||
|
|
||||||
ingameRoot = loadUiFromFile("resources/config2/ui_inventory.json", renderer, zipFile);
|
hudRoot = loadUiFromFile("resources/config2/hud.json", renderer, zipFile);
|
||||||
questJournalRoot = loadUiFromFile("resources/config2/ui_quest_journal.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);
|
questJournal.loadFromFile("resources/quests/quests.json", zipFile);
|
||||||
|
|
||||||
@ -43,37 +44,10 @@ namespace ZL {
|
|||||||
|
|
||||||
void MenuManager::enterGameplay() {
|
void MenuManager::enterGameplay() {
|
||||||
state = GameState::Gameplay;
|
state = GameState::Gameplay;
|
||||||
uiManager.replaceRoot(ingameRoot);
|
uiManager.replaceRoot(hudRoot);
|
||||||
|
|
||||||
uiManager.setNodeVisible("inventory_items_panel", false);
|
|
||||||
uiManager.setNodeVisible("close_inventory_button", false);
|
|
||||||
inventoryOpen = false;
|
|
||||||
|
|
||||||
uiManager.setTextButtonCallback("inventory_button", [this](const std::string&) {
|
uiManager.setTextButtonCallback("inventory_button", [this](const std::string&) {
|
||||||
std::cout << "[UI] Inventory button clicked" << std::endl;
|
openInventory();
|
||||||
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;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
uiManager.setTextButtonCallback("quest_journal_button", [this](const std::string&) {
|
uiManager.setTextButtonCallback("quest_journal_button", [this](const std::string&) {
|
||||||
@ -81,13 +55,34 @@ namespace ZL {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuManager::openQuestJournal() {
|
void MenuManager::openInventory() {
|
||||||
if (inventoryOpen) {
|
state = GameState::Inventory;
|
||||||
uiManager.setNodeVisible("inventory_items_panel", false);
|
uiManager.pushMenuFromSavedRoot(inventoryRoot);
|
||||||
uiManager.setNodeVisible("close_inventory_button", false);
|
|
||||||
inventoryOpen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
state = GameState::QuestJournal;
|
||||||
uiManager.pushMenuFromSavedRoot(questJournalRoot);
|
uiManager.pushMenuFromSavedRoot(questJournalRoot);
|
||||||
|
|
||||||
@ -117,10 +112,13 @@ namespace ZL {
|
|||||||
|
|
||||||
void MenuManager::toggleQuestJournal() {
|
void MenuManager::toggleQuestJournal() {
|
||||||
std::cout << "[quest] toggleQuestJournal: " << (isQuestJournalOpen() ? "closing" : "opening") << std::endl;
|
std::cout << "[quest] toggleQuestJournal: " << (isQuestJournalOpen() ? "closing" : "opening") << std::endl;
|
||||||
if (isQuestJournalOpen()) {
|
if (state == GameState::QuestJournal) {
|
||||||
closeQuestJournal();
|
closeQuestJournal();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (state == GameState::Inventory) {
|
||||||
|
closeInventory();
|
||||||
|
}
|
||||||
openQuestJournal();
|
openQuestJournal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ namespace ZL {
|
|||||||
|
|
||||||
enum class GameState {
|
enum class GameState {
|
||||||
Gameplay,
|
Gameplay,
|
||||||
|
Inventory,
|
||||||
QuestJournal
|
QuestJournal
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -26,9 +27,15 @@ namespace ZL {
|
|||||||
MenuManager(Renderer& iRenderer);
|
MenuManager(Renderer& iRenderer);
|
||||||
|
|
||||||
void setup(Inventory& inv, const std::string& zipFile);
|
void setup(Inventory& inv, const std::string& zipFile);
|
||||||
|
|
||||||
|
void openInventory();
|
||||||
|
void closeInventory();
|
||||||
|
|
||||||
void openQuestJournal();
|
void openQuestJournal();
|
||||||
void closeQuestJournal();
|
void closeQuestJournal();
|
||||||
void toggleQuestJournal();
|
void toggleQuestJournal();
|
||||||
|
|
||||||
|
bool isInventoryOpen() const { return state == GameState::Inventory; }
|
||||||
bool isQuestJournalOpen() const { return state == GameState::QuestJournal; }
|
bool isQuestJournalOpen() const { return state == GameState::QuestJournal; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -42,10 +49,10 @@ namespace ZL {
|
|||||||
GameState state = GameState::Gameplay;
|
GameState state = GameState::Gameplay;
|
||||||
Inventory* inventory = nullptr;
|
Inventory* inventory = nullptr;
|
||||||
|
|
||||||
std::shared_ptr<UiNode> ingameRoot;
|
std::shared_ptr<UiNode> hudRoot;
|
||||||
|
std::shared_ptr<UiNode> inventoryRoot;
|
||||||
std::shared_ptr<UiNode> questJournalRoot;
|
std::shared_ptr<UiNode> questJournalRoot;
|
||||||
|
|
||||||
bool inventoryOpen = false;
|
|
||||||
int selectedQuestIndex = -1;
|
int selectedQuestIndex = -1;
|
||||||
std::vector<std::string> visibleQuestIds;
|
std::vector<std::string> visibleQuestIds;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user