1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

improve extraoptions

This commit is contained in:
Laserlicht
2024-05-14 00:33:30 +02:00
committed by GitHub
parent 58d1c93c1b
commit 941c1576c5
3 changed files with 18 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#include "../../lib/Languages.h"
#include "../../lib/MetaString.h"
#include "../../lib/CGeneralTextHandler.h"
#include "../../lib/CConfigHandler.h"
static std::string timeToString(int time)
{
@ -100,12 +101,18 @@ OptionsTabBase::OptionsTabBase(const JsonPath & configPath)
});
addCallback("setCheatAllowed", [&](int index){
bool isMultiplayer = CSH->loadMode == ELoadMode::MULTI;
Settings entry = persistentStorage.write["startExtraOptions"][isMultiplayer ? "multiPlayer" : "singlePlayer"][isMultiplayer ? "cheatsAllowed" : "cheatsNotAllowed"];
entry->Bool() = isMultiplayer ? index : !index;
ExtraOptionsInfo info = SEL->getStartInfo()->extraOptionsInfo;
info.cheatsAllowed = index;
CSH->setExtraOptionsInfo(info);
});
addCallback("setUnlimitedReplay", [&](int index){
bool isMultiplayer = CSH->loadMode == ELoadMode::MULTI;
Settings entry = persistentStorage.write["startExtraOptions"][isMultiplayer ? "multiPlayer" : "singlePlayer"]["unlimitedReplay"];
entry->Bool() = index;
ExtraOptionsInfo info = SEL->getStartInfo()->extraOptionsInfo;
info.unlimitedReplay = index;
CSH->setExtraOptionsInfo(info);
@ -410,13 +417,11 @@ void OptionsTabBase::recreate(bool campaign)
if(auto buttonCheatAllowed = widget<CToggleButton>("buttonCheatAllowed"))
{
buttonCheatAllowed->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.cheatsAllowed);
buttonCheatAllowed->block(SEL->screenType == ESelectionScreen::loadGame);
}
if(auto buttonUnlimitedReplay = widget<CToggleButton>("buttonUnlimitedReplay"))
{
buttonUnlimitedReplay->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.unlimitedReplay);
buttonUnlimitedReplay->block(SEL->screenType == ESelectionScreen::loadGame);
}
if(auto textureCampaignOverdraw = widget<CFilledTexture>("textureCampaignOverdraw"))