1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Clang-tidy related fixed

This commit is contained in:
Dydzio
2023-02-18 17:49:43 +01:00
parent 7e409df3cb
commit 7137329e80
4 changed files with 127 additions and 47 deletions

View File

@@ -35,38 +35,62 @@ AdventureOptionsTab::AdventureOptionsTab()
{ {
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/adventureOptionsTab.json")); const JsonNode config(ResourceID("config/widgets/settings/adventureOptionsTab.json"));
addCallback("playerHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "heroSpeed", _1)); addCallback("playerHeroSpeedChanged", [](int value)
addCallback("enemyHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "enemySpeed", _1)); {
addCallback("mapScrollSpeedChanged", std::bind(&setIntSetting, "adventure", "scrollSpeed", _1)); return setIntSetting("adventure", "heroSpeed", value);
addCallback("heroReminderChanged", std::bind(&setBoolSetting, "adventure", "heroReminder", _1)); });
addCallback("quickCombatChanged", std::bind(&setBoolSetting, "adventure", "quickCombat", _1)); addCallback("enemyHeroSpeedChanged", [](int value)
{
return setIntSetting("adventure", "enemySpeed", value);
});
addCallback("mapScrollSpeedChanged", [](int value)
{
return setIntSetting("adventure", "scrollSpeed", value);
});
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: //settings that do not belong to base game:
addCallback("numericQuantitiesChanged", std::bind(&setBoolSetting, "gameTweaks", "numericCreaturesQuantities", _1)); addCallback("numericQuantitiesChanged", [](bool value)
addCallback("forceMovementInfoChanged", std::bind(&setBoolSetting, "gameTweaks", "forceMovementInfo", _1)); {
addCallback("showGridChanged", std::bind(&setBoolSetting, "gameTweaks", "showGrid", _1)); 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); build(config);
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker"); std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
playerHeroSpeedToggle->setSelected((int)settings["adventure"]["heroSpeed"].Float()); playerHeroSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["heroSpeed"].Float()));
std::shared_ptr<CToggleGroup> enemyHeroSpeedToggle = widget<CToggleGroup>("enemyMovementSpeedPicker"); std::shared_ptr<CToggleGroup> enemyHeroSpeedToggle = widget<CToggleGroup>("enemyMovementSpeedPicker");
enemyHeroSpeedToggle->setSelected((int)settings["adventure"]["enemySpeed"].Float()); enemyHeroSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["enemySpeed"].Float()));
std::shared_ptr<CToggleGroup> mapScrollSpeedToggle = widget<CToggleGroup>("mapScrollSpeedPicker"); std::shared_ptr<CToggleGroup> mapScrollSpeedToggle = widget<CToggleGroup>("mapScrollSpeedPicker");
mapScrollSpeedToggle->setSelected((int)settings["adventure"]["scrollSpeed"].Float()); mapScrollSpeedToggle->setSelected(static_cast<int>(settings["adventure"]["scrollSpeed"].Float()));
std::shared_ptr<CToggleButton> heroReminderCheckbox = widget<CToggleButton>("heroReminderCheckbox"); std::shared_ptr<CToggleButton> heroReminderCheckbox = widget<CToggleButton>("heroReminderCheckbox");
heroReminderCheckbox->setSelected((bool)settings["adventure"]["heroReminder"].Bool()); heroReminderCheckbox->setSelected(settings["adventure"]["heroReminder"].Bool());
std::shared_ptr<CToggleButton> quickCombatCheckbox = widget<CToggleButton>("quickCombatCheckbox"); std::shared_ptr<CToggleButton> quickCombatCheckbox = widget<CToggleButton>("quickCombatCheckbox");
quickCombatCheckbox->setSelected((bool)settings["adventure"]["quickCombat"].Bool()); quickCombatCheckbox->setSelected(settings["adventure"]["quickCombat"].Bool());
std::shared_ptr<CToggleButton> numericQuantitiesCheckbox = widget<CToggleButton>("numericQuantitiesCheckbox"); std::shared_ptr<CToggleButton> numericQuantitiesCheckbox = widget<CToggleButton>("numericQuantitiesCheckbox");
numericQuantitiesCheckbox->setSelected((bool)settings["gameTweaks"]["numericCreaturesQuantities"].Bool()); numericQuantitiesCheckbox->setSelected(settings["gameTweaks"]["numericCreaturesQuantities"].Bool());
std::shared_ptr<CToggleButton> forceMovementInfoCheckbox = widget<CToggleButton>("forceMovementInfoCheckbox"); std::shared_ptr<CToggleButton> forceMovementInfoCheckbox = widget<CToggleButton>("forceMovementInfoCheckbox");
forceMovementInfoCheckbox->setSelected((bool)settings["gameTweaks"]["forceMovementInfo"].Bool()); forceMovementInfoCheckbox->setSelected(settings["gameTweaks"]["forceMovementInfo"].Bool());
std::shared_ptr<CToggleButton> showGridCheckbox = widget<CToggleButton>("showGridCheckbox"); std::shared_ptr<CToggleButton> showGridCheckbox = widget<CToggleButton>("showGridCheckbox");
showGridCheckbox->setSelected((bool)settings["gameTweaks"]["showGrid"].Bool()); showGridCheckbox->setSelected(settings["gameTweaks"]["showGrid"].Bool());
} }

View File

@@ -25,13 +25,34 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner):
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/battleOptionsTab.json")); const JsonNode config(ResourceID("config/widgets/settings/battleOptionsTab.json"));
addCallback("viewGridChanged", std::bind(&BattleOptionsTab::viewGridChangedCallback, this, _1, owner)); addCallback("viewGridChanged", [this, owner](bool value)
addCallback("movementShadowChanged", std::bind(&BattleOptionsTab::movementShadowChangedCallback, this, _1, owner)); {
addCallback("mouseShadowChanged", std::bind(&BattleOptionsTab::mouseShadowChangedCallback, this, _1)); viewGridChangedCallback(value, owner);
addCallback("animationSpeedChanged", std::bind(&BattleOptionsTab::animationSpeedChangedCallback, this, _1)); });
addCallback("showQueueChanged", std::bind(&BattleOptionsTab::showQueueChangedCallback, this, _1, owner)); addCallback("movementShadowChanged", [this, owner](bool value)
addCallback("queueSizeChanged", std::bind(&BattleOptionsTab::queueSizeChangedCallback, this, _1)); {
addCallback("skipBattleIntroMusicChanged", std::bind(&BattleOptionsTab::skipBattleIntroMusicChangedCallback, this, _1)); movementShadowChangedCallback(value, owner);
});
addCallback("mouseShadowChanged", [this](bool value)
{
mouseShadowChangedCallback(value);
});
addCallback("animationSpeedChanged", [this](int value)
{
animationSpeedChangedCallback(value);
});
addCallback("showQueueChanged", [this, owner](bool value)
{
showQueueChangedCallback(value, owner);
});
addCallback("queueSizeChanged", [this](int value)
{
queueSizeChangedCallback(value);
});
addCallback("skipBattleIntroMusicChanged", [this](bool value)
{
skipBattleIntroMusicChangedCallback(value);
});
build(config); build(config);
std::shared_ptr<CToggleGroup> animationSpeedToggle = widget<CToggleGroup>("animationSpeedPicker"); std::shared_ptr<CToggleGroup> animationSpeedToggle = widget<CToggleGroup>("animationSpeedPicker");
@@ -41,19 +62,19 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner):
queueSizeToggle->setSelected(getQueueSizeId()); queueSizeToggle->setSelected(getQueueSizeId());
std::shared_ptr<CToggleButton> viewGridCheckbox = widget<CToggleButton>("viewGridCheckbox"); std::shared_ptr<CToggleButton> viewGridCheckbox = widget<CToggleButton>("viewGridCheckbox");
viewGridCheckbox->setSelected((bool)settings["battle"]["cellBorders"].Bool()); viewGridCheckbox->setSelected(settings["battle"]["cellBorders"].Bool());
std::shared_ptr<CToggleButton> movementShadowCheckbox = widget<CToggleButton>("movementShadowCheckbox"); std::shared_ptr<CToggleButton> movementShadowCheckbox = widget<CToggleButton>("movementShadowCheckbox");
movementShadowCheckbox->setSelected((bool)settings["battle"]["stackRange"].Bool()); movementShadowCheckbox->setSelected(settings["battle"]["stackRange"].Bool());
std::shared_ptr<CToggleButton> mouseShadowCheckbox = widget<CToggleButton>("mouseShadowCheckbox"); std::shared_ptr<CToggleButton> mouseShadowCheckbox = widget<CToggleButton>("mouseShadowCheckbox");
mouseShadowCheckbox->setSelected((bool)settings["battle"]["mouseShadow"].Bool()); mouseShadowCheckbox->setSelected(settings["battle"]["mouseShadow"].Bool());
std::shared_ptr<CToggleButton> showQueueCheckbox = widget<CToggleButton>("showQueueCheckbox"); std::shared_ptr<CToggleButton> showQueueCheckbox = widget<CToggleButton>("showQueueCheckbox");
showQueueCheckbox->setSelected((bool)settings["battle"]["showQueue"].Bool()); showQueueCheckbox->setSelected(settings["battle"]["showQueue"].Bool());
std::shared_ptr<CToggleButton> skipBattleIntroMusicCheckbox = widget<CToggleButton>("skipBattleIntroMusicCheckbox"); std::shared_ptr<CToggleButton> skipBattleIntroMusicCheckbox = widget<CToggleButton>("skipBattleIntroMusicCheckbox");
skipBattleIntroMusicCheckbox->setSelected((bool)settings["gameTweaks"]["skipBattleIntroMusic"].Bool()); skipBattleIntroMusicCheckbox->setSelected(settings["gameTweaks"]["skipBattleIntroMusic"].Bool());
} }
int BattleOptionsTab::getAnimSpeed() const int BattleOptionsTab::getAnimSpeed() const
@@ -117,7 +138,7 @@ void BattleOptionsTab::mouseShadowChangedCallback(bool value)
void BattleOptionsTab::animationSpeedChangedCallback(int value) void BattleOptionsTab::animationSpeedChangedCallback(int value)
{ {
Settings speed = settings.write["battle"]["speedFactor"]; Settings speed = settings.write["battle"]["speedFactor"];
speed->Float() = float(value); speed->Float() = static_cast<float>(value);
} }
void BattleOptionsTab::showQueueChangedCallback(bool value, BattleInterface * parentBattleInterface) void BattleOptionsTab::showQueueChangedCallback(bool value, BattleInterface * parentBattleInterface)

View File

@@ -49,16 +49,42 @@ GeneralOptionsTab::GeneralOptionsTab()
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json")); const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json"));
addCallback("spellbookAnimationChanged", std::bind(&setBoolSetting, "video", "spellbookAnimation", _1)); addCallback("spellbookAnimationChanged", [](bool value)
addCallback("setMusic", [this](int value) { setIntSetting("general", "music", value); widget<CSlider>("musicSlider")->redraw(); }); {
addCallback("setVolume", [this](int value) { setIntSetting("general", "sound", value); widget<CSlider>("soundVolumeSlider")->redraw(); }); return setBoolSetting("video", "spellbookAnimation", value);
});
addCallback("setMusic", [this](int value)
{
setIntSetting("general", "music", value);
widget<CSlider>("musicSlider")->redraw();
});
addCallback("setVolume", [this](int value)
{
setIntSetting("general", "sound", value);
widget<CSlider>("soundVolumeSlider")->redraw();
});
//settings that do not belong to base game: //settings that do not belong to base game:
addCallback("fullscreenChanged", std::bind(&GeneralOptionsTab::setFullscreenMode, this, _1)); addCallback("fullscreenChanged", [this](bool value)
addCallback("setGameResolution", std::bind(&GeneralOptionsTab::selectGameResolution, this)); {
addCallback("framerateChanged", std::bind(&setBoolSetting, "general", "showfps", _1)); setFullscreenMode(value);
});
addCallback("setGameResolution", [this](int dummyValue)
{
selectGameResolution();
});
addCallback("framerateChanged", [](bool value)
{
setBoolSetting("general", "showfps", value);
});
//moved from "other" tab that is disabled for now to avoid excessible tabs with barely any content //moved from "other" tab that is disabled for now to avoid excessible tabs with barely any content
addCallback("availableCreaturesAsDwellingLabelChanged", std::bind(&setBoolSetting, "gameTweaks", "availableCreaturesAsDwellingLabel", _1)); addCallback("availableCreaturesAsDwellingLabelChanged", [](bool value)
addCallback("compactTownCreatureInfoChanged", std::bind(&setBoolSetting, "gameTweaks", "compactTownCreatureInfo", _1)); {
setBoolSetting("gameTweaks", "availableCreaturesAsDwellingLabel", value);
});
addCallback("compactTownCreatureInfoChanged", [](bool value)
{
return setBoolSetting("gameTweaks", "compactTownCreatureInfo", value);
});
build(config); build(config);
std::shared_ptr<CLabel> resolutionLabel = widget<CLabel>("resolutionLabel"); std::shared_ptr<CLabel> resolutionLabel = widget<CLabel>("resolutionLabel");
@@ -67,17 +93,17 @@ GeneralOptionsTab::GeneralOptionsTab()
std::shared_ptr<CToggleButton> spellbookAnimationCheckbox = widget<CToggleButton>("spellbookAnimationCheckbox"); std::shared_ptr<CToggleButton> spellbookAnimationCheckbox = widget<CToggleButton>("spellbookAnimationCheckbox");
spellbookAnimationCheckbox->setSelected((bool)settings["video"]["spellbookAnimation"].Bool()); spellbookAnimationCheckbox->setSelected(settings["video"]["spellbookAnimation"].Bool());
std::shared_ptr<CToggleButton> fullscreenCheckbox = widget<CToggleButton>("fullscreenCheckbox"); std::shared_ptr<CToggleButton> fullscreenCheckbox = widget<CToggleButton>("fullscreenCheckbox");
fullscreenCheckbox->setSelected((bool)settings["video"]["fullscreen"].Bool()); fullscreenCheckbox->setSelected(settings["video"]["fullscreen"].Bool());
onFullscreenChanged([&](const JsonNode &newState) //used when pressing F4 etc. to change fullscreen checkbox state onFullscreenChanged([&](const JsonNode &newState) //used when pressing F4 etc. to change fullscreen checkbox state
{ {
widget<CToggleButton>("fullscreenCheckbox")->setSelected(newState.Bool()); widget<CToggleButton>("fullscreenCheckbox")->setSelected(newState.Bool());
}); });
std::shared_ptr<CToggleButton> framerateCheckbox = widget<CToggleButton>("framerateCheckbox"); std::shared_ptr<CToggleButton> framerateCheckbox = widget<CToggleButton>("framerateCheckbox");
framerateCheckbox->setSelected((bool)settings["general"]["showfps"].Bool()); framerateCheckbox->setSelected(settings["general"]["showfps"].Bool());
std::shared_ptr<CSlider> musicSlider = widget<CSlider>("musicSlider"); std::shared_ptr<CSlider> musicSlider = widget<CSlider>("musicSlider");
musicSlider->moveTo(CCS->musich->getVolume()); musicSlider->moveTo(CCS->musich->getVolume());
@@ -86,10 +112,10 @@ GeneralOptionsTab::GeneralOptionsTab()
volumeSlider->moveTo(CCS->soundh->getVolume()); volumeSlider->moveTo(CCS->soundh->getVolume());
std::shared_ptr<CToggleButton> availableCreaturesAsDwellingLabelCheckbox = widget<CToggleButton>("availableCreaturesAsDwellingLabelCheckbox"); std::shared_ptr<CToggleButton> availableCreaturesAsDwellingLabelCheckbox = widget<CToggleButton>("availableCreaturesAsDwellingLabelCheckbox");
availableCreaturesAsDwellingLabelCheckbox->setSelected((bool)settings["gameTweaks"]["availableCreaturesAsDwellingLabel"].Bool()); availableCreaturesAsDwellingLabelCheckbox->setSelected(settings["gameTweaks"]["availableCreaturesAsDwellingLabel"].Bool());
std::shared_ptr<CToggleButton> compactTownCreatureInfo = widget<CToggleButton>("compactTownCreatureInfoCheckbox"); std::shared_ptr<CToggleButton> compactTownCreatureInfo = widget<CToggleButton>("compactTownCreatureInfoCheckbox");
compactTownCreatureInfo->setSelected((bool)settings["gameTweaks"]["compactTownCreatureInfo"].Bool()); compactTownCreatureInfo->setSelected(settings["gameTweaks"]["compactTownCreatureInfo"].Bool());
} }
@@ -127,7 +153,10 @@ void GeneralOptionsTab::selectGameResolution()
GH.pushIntT<CObjectListWindow>(items, nullptr, GH.pushIntT<CObjectListWindow>(items, nullptr,
CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.hover"), CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.hover"),
CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.help"), CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.help"),
std::bind(&GeneralOptionsTab::setGameResolution, this, _1), [this](int index)
{
setGameResolution(index);
},
currentResolutionIndex); currentResolutionIndex);
} }

View File

@@ -27,15 +27,21 @@ OtherOptionsWindow::OtherOptionsWindow() : InterfaceObjectConfigurable()
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settings/otherOptionsTab.json")); const JsonNode config(ResourceID("config/widgets/settings/otherOptionsTab.json"));
addCallback("availableCreaturesAsDwellingLabelChanged", std::bind(&setBoolSetting, "gameTweaks", "availableCreaturesAsDwellingLabel", _1)); addCallback("availableCreaturesAsDwellingLabelChanged", [](bool value)
addCallback("compactTownCreatureInfoChanged", std::bind(&setBoolSetting, "gameTweaks", "compactTownCreatureInfo", _1)); {
return setBoolSetting("gameTweaks", "availableCreaturesAsDwellingLabel", value);
});
addCallback("compactTownCreatureInfoChanged", [](bool value)
{
return setBoolSetting("gameTweaks", "compactTownCreatureInfo", value);
});
build(config); build(config);
std::shared_ptr<CToggleButton> availableCreaturesAsDwellingLabelCheckbox = widget<CToggleButton>("availableCreaturesAsDwellingLabelCheckbox"); std::shared_ptr<CToggleButton> availableCreaturesAsDwellingLabelCheckbox = widget<CToggleButton>("availableCreaturesAsDwellingLabelCheckbox");
availableCreaturesAsDwellingLabelCheckbox->setSelected((bool)settings["gameTweaks"]["availableCreaturesAsDwellingLabel"].Bool()); availableCreaturesAsDwellingLabelCheckbox->setSelected(settings["gameTweaks"]["availableCreaturesAsDwellingLabel"].Bool());
std::shared_ptr<CToggleButton> compactTownCreatureInfo = widget<CToggleButton>("compactTownCreatureInfoCheckbox"); std::shared_ptr<CToggleButton> compactTownCreatureInfo = widget<CToggleButton>("compactTownCreatureInfoCheckbox");
compactTownCreatureInfo->setSelected((bool)settings["gameTweaks"]["compactTownCreatureInfo"].Bool()); compactTownCreatureInfo->setSelected(settings["gameTweaks"]["compactTownCreatureInfo"].Bool());
} }