mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
improve extraoptions
This commit is contained in:
parent
58d1c93c1b
commit
941c1576c5
@ -230,6 +230,16 @@ void CLobbyScreen::toggleChat()
|
|||||||
|
|
||||||
void CLobbyScreen::updateAfterStateChange()
|
void CLobbyScreen::updateAfterStateChange()
|
||||||
{
|
{
|
||||||
|
if(CSH->isHost() && screenType == ESelectionScreen::newGame)
|
||||||
|
{
|
||||||
|
bool isMultiplayer = CSH->loadMode == ELoadMode::MULTI;
|
||||||
|
ExtraOptionsInfo info = SEL->getStartInfo()->extraOptionsInfo;
|
||||||
|
info.cheatsAllowed = isMultiplayer ? persistentStorage["startExtraOptions"]["multiPlayer"]["cheatsAllowed"].Bool() : !persistentStorage["startExtraOptions"]["singlePlayer"]["cheatsNotAllowed"].Bool();
|
||||||
|
info.unlimitedReplay = persistentStorage["startExtraOptions"][isMultiplayer ? "multiPlayer" : "singlePlayer"]["unlimitedReplay"].Bool();
|
||||||
|
if(info.cheatsAllowed != CSH->si->extraOptionsInfo.cheatsAllowed || info.unlimitedReplay != CSH->si->extraOptionsInfo.unlimitedReplay)
|
||||||
|
CSH->setExtraOptionsInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
if(CSH->mi)
|
if(CSH->mi)
|
||||||
{
|
{
|
||||||
if (tabOpt)
|
if (tabOpt)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "../../lib/Languages.h"
|
#include "../../lib/Languages.h"
|
||||||
#include "../../lib/MetaString.h"
|
#include "../../lib/MetaString.h"
|
||||||
#include "../../lib/CGeneralTextHandler.h"
|
#include "../../lib/CGeneralTextHandler.h"
|
||||||
|
#include "../../lib/CConfigHandler.h"
|
||||||
|
|
||||||
static std::string timeToString(int time)
|
static std::string timeToString(int time)
|
||||||
{
|
{
|
||||||
@ -100,12 +101,18 @@ OptionsTabBase::OptionsTabBase(const JsonPath & configPath)
|
|||||||
});
|
});
|
||||||
|
|
||||||
addCallback("setCheatAllowed", [&](int index){
|
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;
|
ExtraOptionsInfo info = SEL->getStartInfo()->extraOptionsInfo;
|
||||||
info.cheatsAllowed = index;
|
info.cheatsAllowed = index;
|
||||||
CSH->setExtraOptionsInfo(info);
|
CSH->setExtraOptionsInfo(info);
|
||||||
});
|
});
|
||||||
|
|
||||||
addCallback("setUnlimitedReplay", [&](int index){
|
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;
|
ExtraOptionsInfo info = SEL->getStartInfo()->extraOptionsInfo;
|
||||||
info.unlimitedReplay = index;
|
info.unlimitedReplay = index;
|
||||||
CSH->setExtraOptionsInfo(info);
|
CSH->setExtraOptionsInfo(info);
|
||||||
@ -410,13 +417,11 @@ void OptionsTabBase::recreate(bool campaign)
|
|||||||
if(auto buttonCheatAllowed = widget<CToggleButton>("buttonCheatAllowed"))
|
if(auto buttonCheatAllowed = widget<CToggleButton>("buttonCheatAllowed"))
|
||||||
{
|
{
|
||||||
buttonCheatAllowed->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.cheatsAllowed);
|
buttonCheatAllowed->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.cheatsAllowed);
|
||||||
buttonCheatAllowed->block(SEL->screenType == ESelectionScreen::loadGame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(auto buttonUnlimitedReplay = widget<CToggleButton>("buttonUnlimitedReplay"))
|
if(auto buttonUnlimitedReplay = widget<CToggleButton>("buttonUnlimitedReplay"))
|
||||||
{
|
{
|
||||||
buttonUnlimitedReplay->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.unlimitedReplay);
|
buttonUnlimitedReplay->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.unlimitedReplay);
|
||||||
buttonUnlimitedReplay->block(SEL->screenType == ESelectionScreen::loadGame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(auto textureCampaignOverdraw = widget<CFilledTexture>("textureCampaignOverdraw"))
|
if(auto textureCampaignOverdraw = widget<CFilledTexture>("textureCampaignOverdraw"))
|
||||||
|
@ -296,6 +296,7 @@ void CGameState::updateOnLoad(StartInfo * si)
|
|||||||
scenarioOps->playerInfos = si->playerInfos;
|
scenarioOps->playerInfos = si->playerInfos;
|
||||||
for(auto & i : si->playerInfos)
|
for(auto & i : si->playerInfos)
|
||||||
gs->players[i.first].human = i.second.isControlledByHuman();
|
gs->players[i.first].human = i.second.isControlledByHuman();
|
||||||
|
scenarioOps->extraOptionsInfo = si->extraOptionsInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRandomMap, Load::ProgressAccumulator & progressTracking)
|
void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRandomMap, Load::ProgressAccumulator & progressTracking)
|
||||||
|
Loading…
Reference in New Issue
Block a user