1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/client/windows/settings/AdventureOptionsTab.cpp

97 lines
3.6 KiB
C++
Raw Normal View History

2023-02-12 18:49:41 +02:00
/*
* AdventureOptionsTab.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
2023-02-12 18:49:41 +02:00
#include "AdventureOptionsTab.h"
#include "../../../lib/filesystem/ResourceID.h"
#include "../../gui/CGuiHandler.h"
#include "../../widgets/Buttons.h"
#include "../../widgets/TextControls.h"
#include "../../widgets/Images.h"
#include "CConfigHandler.h"
static void setBoolSetting(std::string group, std::string field, bool value)
{
Settings fullscreen = settings.write[group][field];
fullscreen->Bool() = value;
}
static void setIntSetting(std::string group, std::string field, int value)
{
Settings entry = settings.write[group][field];
entry->Float() = value;
}
2023-02-12 18:49:41 +02:00
AdventureOptionsTab::AdventureOptionsTab()
: InterfaceObjectConfigurable()
2023-02-12 18:49:41 +02:00
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/adventureOptionsTab.json"));
2023-02-18 18:49:43 +02:00
addCallback("playerHeroSpeedChanged", [](int value)
{
return setIntSetting("adventure", "heroMoveTime", value);
2023-02-18 18:49:43 +02:00
});
addCallback("enemyHeroSpeedChanged", [](int value)
{
return setIntSetting("adventure", "enemyMoveTime", value);
2023-02-18 18:49:43 +02:00
});
addCallback("mapScrollSpeedChanged", [](int value)
{
return setIntSetting("adventure", "scrollSpeedPixels", value);
2023-02-18 18:49:43 +02:00
});
addCallback("heroReminderChanged", [](bool value)
{
return setBoolSetting("adventure", "heroReminder", value);
});
addCallback("quickCombatChanged", [](bool value)
{
return setBoolSetting("adventure", "quickCombat", value);
});
//settings that do not belong to base game:
2023-02-18 18:49:43 +02:00
addCallback("numericQuantitiesChanged", [](bool value)
{
return setBoolSetting("gameTweaks", "numericCreaturesQuantities", value);
});
addCallback("forceMovementInfoChanged", [](bool value)
{
return setBoolSetting("gameTweaks", "forceMovementInfo", value);
});
addCallback("showGridChanged", [](bool value)
{
return setBoolSetting("gameTweaks", "showGrid", value);
});
build(config);
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
2023-02-18 18:49:43 +02:00
playerHeroSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["heroSpeed"].Float()));
std::shared_ptr<CToggleGroup> enemyHeroSpeedToggle = widget<CToggleGroup>("enemyMovementSpeedPicker");
2023-02-18 18:49:43 +02:00
enemyHeroSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["enemySpeed"].Float()));
std::shared_ptr<CToggleGroup> mapScrollSpeedToggle = widget<CToggleGroup>("mapScrollSpeedPicker");
2023-02-18 18:49:43 +02:00
mapScrollSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["scrollSpeed"].Float()));
std::shared_ptr<CToggleButton> heroReminderCheckbox = widget<CToggleButton>("heroReminderCheckbox");
2023-02-18 18:49:43 +02:00
heroReminderCheckbox->setSelected(settings["adventure"]["heroReminder"].Bool());
2023-02-12 18:49:41 +02:00
std::shared_ptr<CToggleButton> quickCombatCheckbox = widget<CToggleButton>("quickCombatCheckbox");
2023-02-18 18:49:43 +02:00
quickCombatCheckbox->setSelected(settings["adventure"]["quickCombat"].Bool());
std::shared_ptr<CToggleButton> numericQuantitiesCheckbox = widget<CToggleButton>("numericQuantitiesCheckbox");
2023-02-18 18:49:43 +02:00
numericQuantitiesCheckbox->setSelected(settings["gameTweaks"]["numericCreaturesQuantities"].Bool());
std::shared_ptr<CToggleButton> forceMovementInfoCheckbox = widget<CToggleButton>("forceMovementInfoCheckbox");
2023-02-18 18:49:43 +02:00
forceMovementInfoCheckbox->setSelected(settings["gameTweaks"]["forceMovementInfo"].Bool());
std::shared_ptr<CToggleButton> showGridCheckbox = widget<CToggleButton>("showGridCheckbox");
2023-02-18 18:49:43 +02:00
showGridCheckbox->setSelected(settings["gameTweaks"]["showGrid"].Bool());
}