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
|
|
|
|
*
|
|
|
|
*/
|
2023-02-12 20:25:59 +02:00
|
|
|
#include "StdInc.h"
|
2023-02-12 18:49:41 +02:00
|
|
|
|
|
|
|
#include "AdventureOptionsTab.h"
|
|
|
|
|
2023-02-12 20:25:59 +02:00
|
|
|
#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()
|
2023-02-12 20:25:59 +02:00
|
|
|
: InterfaceObjectConfigurable()
|
2023-02-12 18:49:41 +02:00
|
|
|
{
|
2023-02-12 20:25:59 +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)
|
|
|
|
{
|
2023-02-19 00:36:40 +02:00
|
|
|
return setIntSetting("adventure", "heroMoveTime", value);
|
2023-02-18 18:49:43 +02:00
|
|
|
});
|
|
|
|
addCallback("enemyHeroSpeedChanged", [](int value)
|
|
|
|
{
|
2023-02-19 00:36:40 +02:00
|
|
|
return setIntSetting("adventure", "enemyMoveTime", value);
|
2023-02-18 18:49:43 +02:00
|
|
|
});
|
|
|
|
addCallback("mapScrollSpeedChanged", [](int value)
|
|
|
|
{
|
2023-02-19 00:36:40 +02:00
|
|
|
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);
|
|
|
|
});
|
2023-02-14 00:53:28 +02:00
|
|
|
//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);
|
|
|
|
});
|
2023-02-12 20:25:59 +02:00
|
|
|
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()));
|
2023-02-12 20:25:59 +02:00
|
|
|
|
|
|
|
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()));
|
2023-02-12 20:25:59 +02:00
|
|
|
|
|
|
|
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()));
|
2023-02-12 20:25:59 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-02-12 20:25:59 +02:00
|
|
|
std::shared_ptr<CToggleButton> quickCombatCheckbox = widget<CToggleButton>("quickCombatCheckbox");
|
2023-02-18 18:49:43 +02:00
|
|
|
quickCombatCheckbox->setSelected(settings["adventure"]["quickCombat"].Bool());
|
2023-02-14 00:53:28 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleButton> numericQuantitiesCheckbox = widget<CToggleButton>("numericQuantitiesCheckbox");
|
2023-02-18 18:49:43 +02:00
|
|
|
numericQuantitiesCheckbox->setSelected(settings["gameTweaks"]["numericCreaturesQuantities"].Bool());
|
2023-02-14 00:53:28 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleButton> forceMovementInfoCheckbox = widget<CToggleButton>("forceMovementInfoCheckbox");
|
2023-02-18 18:49:43 +02:00
|
|
|
forceMovementInfoCheckbox->setSelected(settings["gameTweaks"]["forceMovementInfo"].Bool());
|
2023-02-14 21:30:06 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleButton> showGridCheckbox = widget<CToggleButton>("showGridCheckbox");
|
2023-02-18 18:49:43 +02:00
|
|
|
showGridCheckbox->setSelected(settings["gameTweaks"]["showGrid"].Bool());
|
2023-02-19 00:36:40 +02:00
|
|
|
}
|