Working on UI journal
This commit is contained in:
1 parent
90c57932ec
commit
9adcde5c05
6 files changed
+246
-77
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
+16
-67
@@ -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<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);
|
||||
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<int>(items.size())) return;
|
||||
|
||||
// Revert previously selected button to its regular icon
|
||||
if (inventorySelectedIndex_ >= 0 && inventorySelectedIndex_ < static_cast<int>(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();
|
||||
|
||||
Reference in new issue
Block a user