1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Added labels that indicate current option values

This commit is contained in:
Ivan Savenko 2023-03-04 13:37:27 +02:00
parent 2f556ccf60
commit b2e5e55c1e
9 changed files with 64 additions and 16 deletions

View File

@ -40,7 +40,7 @@
"vcmi.systemOptions.fullscreenButton.hover" : "Fullscreen",
"vcmi.systemOptions.fullscreenButton.help" : "{Fullscreen}\n\n If selected, VCMI will run in fullscreen mode, otherwise VCMI will run in window",
"vcmi.systemOptions.resolutionButton.hover" : "{Resolution:} %wx%h",
"vcmi.systemOptions.resolutionButton.hover" : "Resolution: %wx%h",
"vcmi.systemOptions.resolutionButton.help" : "{Select Resolution}\n\n Change in-game screen resolution. Game restart required to apply new resolution.",
"vcmi.systemOptions.resolutionMenu.hover" : "Select Resolution",
"vcmi.systemOptions.resolutionMenu.help" : "Change in-game screen resolution.",

View File

@ -34,17 +34,34 @@ AdventureOptionsTab::AdventureOptionsTab()
: InterfaceObjectConfigurable()
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
type |= REDRAW_PARENT;
const JsonNode config(ResourceID("config/widgets/settings/adventureOptionsTab.json"));
addCallback("playerHeroSpeedChanged", [](int value)
addCallback("playerHeroSpeedChanged", [this](int value)
{
auto targetLabel = widget<CLabel>("heroSpeedValueLabel");
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", "heroMoveTime", value);
});
addCallback("enemyHeroSpeedChanged", [](int value)
addCallback("enemyHeroSpeedChanged", [this](int value)
{
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);
});
addCallback("mapScrollSpeedChanged", [](int value)
addCallback("mapScrollSpeedChanged", [this](int value)
{
auto targetLabel = widget<CLabel>("mapScrollingValueLabel");
int valuePercentage = value / 1200; // H3 max value is "1200", displaying it to be 100%
if (targetLabel)
targetLabel->setText(std::to_string(valuePercentage) + "%");
return setIntSetting("adventure", "scrollSpeedPixels", value);
});
addCallback("heroReminderChanged", [](bool value)

View File

@ -22,6 +22,7 @@
BattleOptionsTab::BattleOptionsTab(BattleInterface * owner)
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
type |= REDRAW_PARENT;
const JsonNode config(ResourceID("config/widgets/settings/battleOptionsTab.json"));
addCallback("viewGridChanged", [this, owner](bool value)
@ -139,6 +140,11 @@ void BattleOptionsTab::animationSpeedChangedCallback(int value)
{
Settings speed = settings.write["battle"]["speedFactor"];
speed->Float() = static_cast<float>(value);
auto targetLabel = widget<CLabel>("animationSpeedValueLabel");
int valuePercentage = value * 100 / 3; // H3 max value is "3", displaying it to be 100%
if (targetLabel)
targetLabel->setText(std::to_string(valuePercentage) + "%");
}
void BattleOptionsTab::showQueueChangedCallback(bool value, BattleInterface * parentBattleInterface)

View File

@ -52,6 +52,7 @@ GeneralOptionsTab::GeneralOptionsTab()
onFullscreenChanged(settings.listen["video"]["fullscreen"])
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
type |= REDRAW_PARENT;
const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json"));
addCallback("spellbookAnimationChanged", [](bool value)
@ -62,11 +63,19 @@ GeneralOptionsTab::GeneralOptionsTab()
{
setIntSetting("general", "music", value);
widget<CSlider>("musicSlider")->redraw();
auto targetLabel = widget<CLabel>("musicValueLabel");
if (targetLabel)
targetLabel->setText(std::to_string(value) + "%");
});
addCallback("setVolume", [this](int value)
{
setIntSetting("general", "sound", value);
widget<CSlider>("soundVolumeSlider")->redraw();
auto targetLabel = widget<CLabel>("soundValueLabel");
if (targetLabel)
targetLabel->setText(std::to_string(value) + "%");
});
//settings that do not belong to base game:
addCallback("fullscreenChanged", [this](bool value)

View File

@ -56,7 +56,7 @@ SettingsMainWindow::SettingsMainWindow(BattleInterface * parentBattleUi) : Inter
std::shared_ptr<CButton> restartButton = widget<CButton>("restartButton");
assert(restartButton);
if(CSH->isGuest())
if(CSH->isGuest() || parentBattleUi)
{
loadButton->block(true);
saveButton->block(true);
@ -71,6 +71,7 @@ SettingsMainWindow::SettingsMainWindow(BattleInterface * parentBattleUi) : Inter
parentBattleInterface = parentBattleUi;
tabContentArea = std::make_shared<CTabbedInt>(std::bind(&SettingsMainWindow::createTab, this, _1), Point(0, 0), defaultTabIndex);
tabContentArea->type |= REDRAW_PARENT;
std::shared_ptr<CToggleGroup> mainTabs = widget<CToggleGroup>("settingsTabs");
mainTabs->setSelected(defaultTabIndex);

View File

@ -50,12 +50,11 @@
},
{
"name": "heroSpeedLabel",
"name": "heroSpeedValueLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"text" : "800%",
"position": {"x": 324, "y": 90}
},
@ -111,6 +110,15 @@
"callback": "playerHeroSpeedChanged"
},
{
"name": "enemySpeedValueLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"position": {"x": 324, "y": 150}
},
{
"name": "enemyMovementSpeedPicker",
"type": "toggleGroup",
@ -168,6 +176,14 @@
"callback": "enemyHeroSpeedChanged"
},
{
"name": "mapScrollingValueLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"position": {"x": 324, "y": 210}
},
{
"name": "mapScrollSpeedPicker",
"type": "toggleGroup",

View File

@ -209,6 +209,14 @@
"text": "core.genrltxt.393",
"position": {"x": 150, "y": 362}
},
{
"name": "animationSpeedValueLabel",
"type": "label",
"font": "medium",
"alignment": "center",
"color": "yellow",
"position": {"x": 324, "y": 390}
},
{
"name": "animationSpeedPicker",
"type": "toggleGroup",

View File

@ -134,7 +134,6 @@
"font": "medium",
"alignment": "center",
"color": "yellow",
"text" : "10%",
"position": {"x": 565, "y": 98}
},
@ -162,7 +161,6 @@
"font": "medium",
"alignment": "center",
"color": "yellow",
"text" : "10%",
"position": {"x": 565, "y": 158}
},

View File

@ -7,12 +7,6 @@
"image": "DiBoxBck",
"rect": {"w": 600, "h": 480}
},
// {
// "name": "debugGrid",
// "type": "texture",
// "image": "settingsWindow/debugGrid",
// "rect": {"w": 600, "h": 480}
// },
{
"name": "lineTabs",
"type": "texture",
@ -26,7 +20,6 @@
"rect": { "x" : 370, "y" : 50, "w": 3, "h": 420}
},
{
"name": "settingsTabs",
"type": "toggleGroup",