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"
|
|
|
|
|
2024-08-28 23:07:00 +02:00
|
|
|
#include "../../eventsSDL/InputHandler.h"
|
2023-08-23 14:07:50 +02:00
|
|
|
#include "../../../lib/filesystem/ResourcePath.h"
|
2023-02-12 20:25:59 +02:00
|
|
|
#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
|
|
|
{
|
2024-08-09 17:30:04 +02:00
|
|
|
OBJECT_CONSTRUCTION;
|
2023-07-03 18:24:12 +02:00
|
|
|
setRedrawParent(true);
|
2023-03-04 13:37:27 +02:00
|
|
|
|
2024-08-28 23:07:00 +02:00
|
|
|
addConditional("touchscreen", GH.input().getCurrentInputMode() == InputMode::TOUCH);
|
|
|
|
addConditional("keyboardMouse", GH.input().getCurrentInputMode() == InputMode::KEYBOARD_AND_MOUSE);
|
|
|
|
addConditional("controller", GH.input().getCurrentInputMode() == InputMode::CONTROLLER);
|
2023-07-16 11:00:40 +02:00
|
|
|
#ifdef VCMI_MOBILE
|
|
|
|
addConditional("mobile", true);
|
|
|
|
addConditional("desktop", false);
|
|
|
|
#else
|
|
|
|
addConditional("mobile", false);
|
|
|
|
addConditional("desktop", true);
|
|
|
|
#endif
|
|
|
|
|
2023-09-01 23:26:14 +02:00
|
|
|
const JsonNode config(JsonPath::builtin("config/widgets/settings/adventureOptionsTab.json"));
|
2023-03-04 13:37:27 +02:00
|
|
|
addCallback("playerHeroSpeedChanged", [this](int value)
|
2023-02-18 18:49:43 +02:00
|
|
|
{
|
2023-03-04 13:37:27 +02:00
|
|
|
auto targetLabel = widget<CLabel>("heroSpeedValueLabel");
|
|
|
|
if (targetLabel)
|
2023-03-05 20:14:23 +02:00
|
|
|
{
|
|
|
|
if (value <= 0)
|
|
|
|
{
|
|
|
|
targetLabel->setText("-");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int valuePercentage = 100 * 100 / value;
|
|
|
|
targetLabel->setText(std::to_string(valuePercentage) + "%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setIntSetting("adventure", "heroMoveTime", value);
|
2023-02-18 18:49:43 +02:00
|
|
|
});
|
2023-03-04 13:37:27 +02:00
|
|
|
addCallback("enemyHeroSpeedChanged", [this](int value)
|
2023-02-18 18:49:43 +02:00
|
|
|
{
|
2023-03-04 13:37:27 +02:00
|
|
|
auto targetLabel = widget<CLabel>("enemySpeedValueLabel");
|
|
|
|
|
2023-03-05 20:14:23 +02:00
|
|
|
if (targetLabel)
|
|
|
|
{
|
|
|
|
if (value <= 0)
|
|
|
|
{
|
|
|
|
targetLabel->setText("-");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int valuePercentage = 100 * 100 / value;
|
|
|
|
targetLabel->setText(std::to_string(valuePercentage) + "%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setIntSetting("adventure", "enemyMoveTime", value);
|
2023-02-18 18:49:43 +02:00
|
|
|
});
|
2023-03-04 13:37:27 +02:00
|
|
|
addCallback("mapScrollSpeedChanged", [this](int value)
|
2023-02-18 18:49:43 +02:00
|
|
|
{
|
2023-03-04 13:37:27 +02:00
|
|
|
auto targetLabel = widget<CLabel>("mapScrollingValueLabel");
|
2023-03-05 20:14:23 +02:00
|
|
|
int valuePercentage = 100 * value / 1200; // H3 max value is "1200", displaying it to be 100%
|
2023-03-04 13:37:27 +02:00
|
|
|
if (targetLabel)
|
|
|
|
targetLabel->setText(std::to_string(valuePercentage) + "%");
|
|
|
|
|
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-03-07 02:29:04 +02:00
|
|
|
addCallback("infoBarPickChanged", [](bool value)
|
|
|
|
{
|
|
|
|
return setBoolSetting("gameTweaks", "infoBarPick", value);
|
|
|
|
});
|
2023-06-01 17:48:31 +02:00
|
|
|
addCallback("borderScrollChanged", [](bool value)
|
|
|
|
{
|
|
|
|
return setBoolSetting("adventure", "borderScroll", value);
|
|
|
|
});
|
2023-07-16 14:52:43 +02:00
|
|
|
addCallback("infoBarCreatureManagementChanged", [](bool value)
|
2023-07-15 23:14:59 +02:00
|
|
|
{
|
2023-07-16 14:52:43 +02:00
|
|
|
return setBoolSetting("gameTweaks", "infoBarCreatureManagement", value);
|
2023-07-15 23:14:59 +02:00
|
|
|
});
|
2023-07-16 11:00:40 +02:00
|
|
|
addCallback("leftButtonDragChanged", [](bool value)
|
|
|
|
{
|
|
|
|
return setBoolSetting("adventure", "leftButtonDrag", value);
|
|
|
|
});
|
2024-08-28 22:36:41 +02:00
|
|
|
addCallback("rightButtonDragChanged", [](bool value)
|
|
|
|
{
|
|
|
|
return setBoolSetting("adventure", "rightButtonDrag", value);
|
|
|
|
});
|
2023-12-10 14:38:58 +02:00
|
|
|
addCallback("smoothDraggingChanged", [](bool value)
|
|
|
|
{
|
|
|
|
return setBoolSetting("adventure", "smoothDragging", value);
|
|
|
|
});
|
2023-12-24 18:18:48 +02:00
|
|
|
addCallback("skipAdventureMapAnimationsChanged", [](bool value)
|
|
|
|
{
|
|
|
|
return setBoolSetting("gameTweaks", "skipAdventureMapAnimations", value);
|
|
|
|
});
|
2024-01-18 01:47:18 +02:00
|
|
|
addCallback("hideBackgroundChanged", [](bool value)
|
|
|
|
{
|
|
|
|
return setBoolSetting("adventure", "hideBackground", value);
|
|
|
|
});
|
2023-02-12 20:25:59 +02:00
|
|
|
build(config);
|
|
|
|
|
|
|
|
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
|
2023-03-02 19:24:32 +02:00
|
|
|
playerHeroSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["heroMoveTime"].Float()));
|
2023-02-12 20:25:59 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleGroup> enemyHeroSpeedToggle = widget<CToggleGroup>("enemyMovementSpeedPicker");
|
2023-03-02 19:24:32 +02:00
|
|
|
enemyHeroSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["enemyMoveTime"].Float()));
|
2023-02-12 20:25:59 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleGroup> mapScrollSpeedToggle = widget<CToggleGroup>("mapScrollSpeedPicker");
|
2023-03-02 19:24:32 +02:00
|
|
|
mapScrollSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["scrollSpeedPixels"].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-03-05 23:53:06 +02:00
|
|
|
|
2023-03-07 02:29:04 +02:00
|
|
|
std::shared_ptr<CToggleButton> infoBarPickCheckbox = widget<CToggleButton>("infoBarPickCheckbox");
|
|
|
|
infoBarPickCheckbox->setSelected(settings["gameTweaks"]["infoBarPick"].Bool());
|
2023-06-01 17:48:31 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleButton> borderScrollCheckbox = widget<CToggleButton>("borderScrollCheckbox");
|
|
|
|
borderScrollCheckbox->setSelected(settings["adventure"]["borderScroll"].Bool());
|
2023-07-15 23:14:59 +02:00
|
|
|
|
2023-07-16 14:52:43 +02:00
|
|
|
std::shared_ptr<CToggleButton> infoBarCreatureManagementCheckbox = widget<CToggleButton>("infoBarCreatureManagementCheckbox");
|
|
|
|
infoBarCreatureManagementCheckbox->setSelected(settings["gameTweaks"]["infoBarCreatureManagement"].Bool());
|
2023-07-18 15:05:09 +02:00
|
|
|
|
2023-07-16 11:00:40 +02:00
|
|
|
std::shared_ptr<CToggleButton> leftButtonDragCheckbox = widget<CToggleButton>("leftButtonDragCheckbox");
|
|
|
|
if (leftButtonDragCheckbox)
|
|
|
|
leftButtonDragCheckbox->setSelected(settings["adventure"]["leftButtonDrag"].Bool());
|
2023-12-10 14:38:58 +02:00
|
|
|
|
2024-08-28 22:36:41 +02:00
|
|
|
std::shared_ptr<CToggleButton> rightButtonDragCheckbox = widget<CToggleButton>("rightButtonDragCheckbox");
|
|
|
|
if (rightButtonDragCheckbox)
|
|
|
|
rightButtonDragCheckbox->setSelected(settings["adventure"]["rightButtonDrag"].Bool());
|
|
|
|
|
2023-12-10 14:38:58 +02:00
|
|
|
std::shared_ptr<CToggleButton> smoothDraggingCheckbox = widget<CToggleButton>("smoothDraggingCheckbox");
|
|
|
|
if (smoothDraggingCheckbox)
|
|
|
|
smoothDraggingCheckbox->setSelected(settings["adventure"]["smoothDragging"].Bool());
|
2023-12-24 18:18:48 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleButton> skipAdventureMapAnimationsCheckbox = widget<CToggleButton>("skipAdventureMapAnimationsCheckbox");
|
|
|
|
skipAdventureMapAnimationsCheckbox->setSelected(settings["gameTweaks"]["skipAdventureMapAnimations"].Bool());
|
2024-01-18 01:47:18 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CToggleButton> hideBackgroundCheckbox = widget<CToggleButton>("hideBackgroundCheckbox");
|
|
|
|
hideBackgroundCheckbox->setSelected(settings["adventure"]["hideBackground"].Bool());
|
2023-02-19 00:36:40 +02:00
|
|
|
}
|