1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fixed map options to support adventure map rewrite

This commit is contained in:
Ivan Savenko
2023-03-05 20:14:23 +02:00
parent 95440ad540
commit 37b2fb7ff3
2 changed files with 31 additions and 14 deletions

View File

@@ -40,25 +40,42 @@ AdventureOptionsTab::AdventureOptionsTab()
addCallback("playerHeroSpeedChanged", [this](int value) addCallback("playerHeroSpeedChanged", [this](int value)
{ {
auto targetLabel = widget<CLabel>("heroSpeedValueLabel"); auto targetLabel = widget<CLabel>("heroSpeedValueLabel");
int valuePercentage = value / 50; // H3 max value is "50", displaying it to be 100%
if (targetLabel) if (targetLabel)
targetLabel->setText(std::to_string(valuePercentage) + "%"); {
if (value <= 0)
return setIntSetting("adventure", "heroMoveTime", value); {
targetLabel->setText("-");
}
else
{
int valuePercentage = 100 * 100 / value;
targetLabel->setText(std::to_string(valuePercentage) + "%");
}
}
setIntSetting("adventure", "heroMoveTime", value);
}); });
addCallback("enemyHeroSpeedChanged", [this](int value) addCallback("enemyHeroSpeedChanged", [this](int value)
{ {
auto targetLabel = widget<CLabel>("enemySpeedValueLabel"); auto targetLabel = widget<CLabel>("enemySpeedValueLabel");
int valuePercentage = value / 50; // H3 max value is "50", displaying it to be 100%
if (targetLabel)
targetLabel->setText(std::to_string(valuePercentage) + "%");
return setIntSetting("adventure", "enemyMoveTime", value); if (targetLabel)
{
if (value <= 0)
{
targetLabel->setText("-");
}
else
{
int valuePercentage = 100 * 100 / value;
targetLabel->setText(std::to_string(valuePercentage) + "%");
}
}
setIntSetting("adventure", "enemyMoveTime", value);
}); });
addCallback("mapScrollSpeedChanged", [this](int value) addCallback("mapScrollSpeedChanged", [this](int value)
{ {
auto targetLabel = widget<CLabel>("mapScrollingValueLabel"); auto targetLabel = widget<CLabel>("mapScrollingValueLabel");
int valuePercentage = value / 1200; // H3 max value is "1200", displaying it to be 100% int valuePercentage = 100 * value / 1200; // H3 max value is "1200", displaying it to be 100%
if (targetLabel) if (targetLabel)
targetLabel->setText(std::to_string(valuePercentage) + "%"); targetLabel->setText(std::to_string(valuePercentage) + "%");

View File

@@ -192,7 +192,7 @@
"items": "items":
[ [
{ {
"index": 400, "index": 200,
"type": "toggleButton", "type": "toggleButton",
"image": "settingsWindow/button46", "image": "settingsWindow/button46",
"help": "vcmi.adventureOptions.mapScrollSpeed1", "help": "vcmi.adventureOptions.mapScrollSpeed1",
@@ -209,7 +209,7 @@
}, },
{ {
"index": 800, "index": 400,
"type": "toggleButton", "type": "toggleButton",
"image": "settingsWindow/button46", "image": "settingsWindow/button46",
"help": "core.help.357", "help": "core.help.357",
@@ -226,7 +226,7 @@
}, },
{ {
"index": 3, "index": 800,
"type": "toggleButton", "type": "toggleButton",
"image": "settingsWindow/button46", "image": "settingsWindow/button46",
"help": "core.help.358", "help": "core.help.358",
@@ -259,7 +259,7 @@
] ]
}, },
{ {
"index": -1, // TODO "index": 2400, // TODO
"type": "toggleButton", "type": "toggleButton",
"image": "settingsWindow/button46", "image": "settingsWindow/button46",
"help": "vcmi.adventureOptions.mapScrollSpeed5", "help": "vcmi.adventureOptions.mapScrollSpeed5",
@@ -275,7 +275,7 @@
] ]
}, },
{ {
"index": -2, // TODO "index": 4800, // TODO
"type": "toggleButton", "type": "toggleButton",
"image": "settingsWindow/button46", "image": "settingsWindow/button46",
"help": "vcmi.adventureOptions.mapScrollSpeed6", "help": "vcmi.adventureOptions.mapScrollSpeed6",