Fixing UI bugs, some clean up

This commit is contained in:
Vladislav Khorev 2026-07-20 18:09:16 +03:00
parent 1d8e103690
commit 1c20333f30
18 changed files with 37 additions and 26 deletions

Binary file not shown.

View File

@ -188,7 +188,7 @@
"vertical_gravity": "top", "vertical_gravity": "top",
"width": 274, "width": 274,
"height": 274, "height": 274,
"x": -200, "x": 200,
"y": 650, "y": 650,
"textures": { "textures": {
"normal": "resources/w/ui/img/inv/ItemBook002.png", "normal": "resources/w/ui/img/inv/ItemBook002.png",

View File

@ -92,7 +92,7 @@
"vertical_align": "bottom", "vertical_align": "bottom",
"name": "objective1nameLayout", "name": "objective1nameLayout",
"paddingY": 0, "paddingY": 0,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"x": 56, "x": 56,
"y": 370, "y": 370,
@ -103,7 +103,7 @@
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"paddingY": -20, "paddingY": -20,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"text": "Цель 1 Цель 1 Цель 1 Цель 1", "text": "Цель 1 Цель 1 Цель 1 Цель 1",
"fontSize": 32, "fontSize": 32,
@ -139,7 +139,7 @@
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"vertical_align": "bottom", "vertical_align": "bottom",
"width": 540.0, "width": 510.0,
"height": 80.0, "height": 80.0,
"x": 56, "x": 56,
"y": 450, "y": 450,
@ -150,7 +150,7 @@
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"paddingY": 0, "paddingY": 0,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"text": "Цель 2", "text": "Цель 2",
"fontSize": 32, "fontSize": 32,
@ -187,7 +187,7 @@
"vertical_align": "bottom", "vertical_align": "bottom",
"name": "objective3nameLayout", "name": "objective3nameLayout",
"paddingY": 0, "paddingY": 0,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"x": 56, "x": 56,
"y": 530, "y": 530,
@ -197,7 +197,7 @@
"name": "objective3name", "name": "objective3name",
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"text": "Цель 3", "text": "Цель 3",
"fontSize": 32, "fontSize": 32,
@ -218,7 +218,7 @@
"type": "TextView", "type": "TextView",
"name": "quest_description", "name": "quest_description",
"x": 4.0, "x": 4.0,
"y": 480.0, "y": 510.0,
"width": 580.0, "width": 580.0,
"height": 400.0, "height": 400.0,
"horizontal_gravity": "center", "horizontal_gravity": "center",

View File

@ -125,7 +125,7 @@
"y": 10, "y": 10,
"width": 160, "width": 160,
"height": 36, "height": 36,
"text": "v. 1.0.2", "text": "v. 1.0.3",
"fontSize": 24, "fontSize": 24,
"textCentered": false, "textCentered": false,
"topAligned": true, "topAligned": true,

View File

@ -116,7 +116,7 @@
"y": 10, "y": 10,
"width": 160, "width": 160,
"height": 36, "height": 36,
"text": "v. 1.0.2", "text": "v. 1.0.3",
"fontSize": 24, "fontSize": 24,
"textCentered": false, "textCentered": false,
"topAligned": true, "topAligned": true,

Binary file not shown.

View File

@ -188,7 +188,7 @@
"vertical_gravity": "top", "vertical_gravity": "top",
"width": 274, "width": 274,
"height": 274, "height": 274,
"x": -200, "x": 200,
"y": 650, "y": 650,
"textures": { "textures": {
"normal": "resources/w/ui/img/inv/ItemBook002.png", "normal": "resources/w/ui/img/inv/ItemBook002.png",

View File

@ -92,7 +92,7 @@
"vertical_align": "bottom", "vertical_align": "bottom",
"name": "objective1nameLayout", "name": "objective1nameLayout",
"paddingY": 0, "paddingY": 0,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"x": 56, "x": 56,
"y": 370, "y": 370,
@ -103,7 +103,7 @@
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"paddingY": -20, "paddingY": -20,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"text": "", "text": "",
"fontSize": 32, "fontSize": 32,
@ -139,7 +139,7 @@
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"vertical_align": "bottom", "vertical_align": "bottom",
"width": 540.0, "width": 510.0,
"height": 80.0, "height": 80.0,
"x": 56, "x": 56,
"y": 450, "y": 450,
@ -150,7 +150,7 @@
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"paddingY": 0, "paddingY": 0,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"text": "", "text": "",
"fontSize": 32, "fontSize": 32,
@ -187,7 +187,7 @@
"vertical_align": "bottom", "vertical_align": "bottom",
"name": "objective3nameLayout", "name": "objective3nameLayout",
"paddingY": 0, "paddingY": 0,
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"x": 56, "x": 56,
"y": 530, "y": 530,
@ -197,7 +197,7 @@
"name": "objective3name", "name": "objective3name",
"horizontal_gravity": "center", "horizontal_gravity": "center",
"vertical_gravity": "top", "vertical_gravity": "top",
"width": 540.0, "width": 510.0,
"height": 60.0, "height": 60.0,
"text": "", "text": "",
"fontSize": 32, "fontSize": 32,
@ -218,7 +218,7 @@
"type": "TextView", "type": "TextView",
"name": "quest_description", "name": "quest_description",
"x": 4.0, "x": 4.0,
"y": 480.0, "y": 510.0,
"width": 580.0, "width": 580.0,
"height": 400.0, "height": 400.0,
"horizontal_gravity": "center", "horizontal_gravity": "center",

View File

@ -125,7 +125,7 @@
"y": 10, "y": 10,
"width": 160, "width": 160,
"height": 36, "height": 36,
"text": "v. 1.0.2", "text": "v. 1.0.3",
"fontSize": 24, "fontSize": 24,
"textCentered": false, "textCentered": false,
"topAligned": true, "topAligned": true,

View File

@ -125,7 +125,7 @@
"y": 10, "y": 10,
"width": 160, "width": 160,
"height": 36, "height": 36,
"text": "v. 1.0.2", "text": "v. 1.0.3",
"fontSize": 24, "fontSize": 24,
"textCentered": false, "textCentered": false,
"topAligned": true, "topAligned": true,

View File

@ -903,9 +903,14 @@ namespace FRG {
uiManager.setButtonCallback("inventoryMain", [this](const std::string&) {}); uiManager.setButtonCallback("inventoryMain", [this](const std::string&) {});
const auto& items = inventory->getItems(); const auto& items = inventory->getItems();
/*logger() << "Item count: " << items.size() << std::endl;
for (int x = 0; x < items.size(); x++)
{
std::cout << "item " << x << ": " << items[x].id << std::endl;
}*/
const int maxSlots = 9; const int maxSlots = 9;
for (int i = 0; i < maxSlots; ++i) { for (int i = 0; i < maxSlots; ++i) {
const std::string btnName = "item" + std::to_string(i + 1) + "Button"; std::string btnName = "item" + std::to_string(i + 1) + "Button";
if (i < static_cast<int>(items.size())) { if (i < static_cast<int>(items.size())) {
uiManager.setNodeVisible(btnName, true); uiManager.setNodeVisible(btnName, true);
auto btn = uiManager.findButton(btnName); auto btn = uiManager.findButton(btnName);
@ -913,8 +918,12 @@ namespace FRG {
auto tex = renderer.textureManager.LoadFromPng(items[i].icon, CONST_ZIP_FILE, true); auto tex = renderer.textureManager.LoadFromPng(items[i].icon, CONST_ZIP_FILE, true);
btn->texNormal = btn->texHover = btn->texPressed = tex; btn->texNormal = btn->texHover = btn->texPressed = tex;
} }
//logger() << "Set button ballback to button: " << btnName << std::endl;
uiManager.setButtonCallback(btnName, [this, i](const std::string&) { uiManager.setButtonCallback(btnName, [this, i](const std::string&) {
//logger() << "Callback called for button number " << i << std::endl;
selectInventoryItem(i); selectInventoryItem(i);
//logger() << "Callback called for button number " << i << " END" << std::endl;
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg"); audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
}); });
} else { } else {

View File

@ -1253,7 +1253,7 @@ namespace FRG {
bool UiManager::setButtonCallback(const std::string& name, std::function<void(const std::string&)> cb) { bool UiManager::setButtonCallback(const std::string& name, std::function<void(const std::string&)> cb) {
auto b = findButton(name); auto b = findButton(name);
if (!b) { if (!b) {
std::cerr << "UiManager: setButtonCallback failed, button not found: " << name << std::endl; logger() << "UiManager: setButtonCallback failed, button not found: " << name << std::endl;
return false; return false;
} }
b->onClick = std::move(cb); b->onClick = std::move(cb);
@ -1850,11 +1850,13 @@ namespace FRG {
for (auto it = allInteractives.rbegin(); it != allInteractives.rend(); ++it) { for (auto it = allInteractives.rbegin(); it != allInteractives.rend(); ++it) {
if (std::holds_alternative<std::shared_ptr<UiButton>>(*it)) { if (std::holds_alternative<std::shared_ptr<UiButton>>(*it)) {
auto& b = std::get<std::shared_ptr<UiButton>>(*it); auto& b = std::get<std::shared_ptr<UiButton>>(*it);
//logger() << "onTouchDown found the button: " << b->name << std::endl;
if (b->state != ButtonState::Disabled && if (b->state != ButtonState::Disabled &&
b->getClickZoneRect().containsConsideringBorder((float)x, (float)y, b->border)) { b->getClickZoneRect().containsConsideringBorder((float)x, (float)y, b->border)) {
b->state = ButtonState::Pressed; b->state = ButtonState::Pressed;
pressedButtons[fingerId] = b; pressedButtons[fingerId] = b;
if (b->onPress) b->onPress(b->name); if (b->onPress) b->onPress(b->name);
//logger() << "onTouchDown pressed the button: " << b->name << std::endl;
break; break;
} }
} else { } else {