1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

moved to gameconfig

This commit is contained in:
Laserlicht 2024-01-20 17:54:15 +01:00 committed by GitHub
parent d6172a9c4c
commit 883ea23495
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 9 additions and 33 deletions

View File

@ -110,12 +110,6 @@ OptionsTabBase::OptionsTabBase(const JsonPath & configPath)
CSH->setExtraOptionsInfo(info);
});
addCallback("setInviteHero", [&](int index){
ExtraOptionsInfo info = SEL->getStartInfo()->extraOptionsInfo;
info.inviteHero = index;
CSH->setExtraOptionsInfo(info);
});
addCallback("setTurnTimerAccumulate", [&](int index){
TurnTimerInfo info = SEL->getStartInfo()->turnTimerInfo;
info.accumulatingTurnTimer = index;
@ -423,10 +417,4 @@ void OptionsTabBase::recreate()
buttonUnlimitedReplay->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.unlimitedReplay);
buttonUnlimitedReplay->setInputEnabled(SEL->screenType != ESelectionScreen::loadGame);
}
if(auto buttonInviteHero = widget<CToggleButton>("buttonInviteHero"))
{
buttonInviteHero->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.inviteHero);
buttonInviteHero->setInputEnabled(SEL->screenType != ESelectionScreen::loadGame);
}
}

View File

@ -519,7 +519,7 @@ void CTavernWindow::addInvite()
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
if(CSH->client->getStartInfo()->extraOptionsInfo.inviteHero)
if(VLC->settings()->getBoolean(EGameSettings::HEROES_INVITE))
{
const auto & heroesPool = CSH->client->gameState()->heroesPool;
for(auto & elem : heroesPool->unusedHeroesFromPool())

View File

@ -289,7 +289,9 @@
// Chances for a hero with default army to receive corresponding stack out of his predefined starting troops
"startingStackChances": [ 100, 88, 25],
// number of artifacts that can fit in a backpack. -1 is unlimited.
"backpackSize" : -1
"backpackSize" : -1,
// if heroes are invitable in tavern
"invite" : false
},
"towns":

View File

@ -73,13 +73,6 @@
"callback" : "setUnlimitedReplay",
"help" : "vcmi.optionsTab.unlimitedReplay",
"selected" : true
},
{
"name": "buttonInviteHero",
"image": "lobby/checkbox",
"callback" : "setInviteHero",
"help" : "vcmi.optionsTab.inviteHero",
"selected" : true
}
]
},
@ -103,13 +96,6 @@
"alignment": "left",
"color": "yellow",
"text": "vcmi.optionsTab.unlimitedReplay.hover"
},
{
"name": "labelInviteHero",
"font": "small",
"alignment": "left",
"color": "yellow",
"text": "vcmi.optionsTab.inviteHero.hover"
}
]
}

View File

@ -15,8 +15,7 @@ VCMI_LIB_NAMESPACE_BEGIN
bool ExtraOptionsInfo::operator == (const ExtraOptionsInfo & other) const
{
return cheatsAllowed == other.cheatsAllowed &&
unlimitedReplay == other.unlimitedReplay &&
inviteHero == other.inviteHero;
unlimitedReplay == other.unlimitedReplay;
}
VCMI_LIB_NAMESPACE_END

View File

@ -16,7 +16,6 @@ struct DLL_LINKAGE ExtraOptionsInfo
{
bool cheatsAllowed = true;
bool unlimitedReplay = false;
bool inviteHero = false;
bool operator == (const ExtraOptionsInfo & other) const;
@ -25,7 +24,6 @@ struct DLL_LINKAGE ExtraOptionsInfo
{
h & cheatsAllowed;
h & unlimitedReplay;
h & inviteHero;
}
};

View File

@ -74,6 +74,7 @@ void GameSettings::load(const JsonNode & input)
{EGameSettings::HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS, "heroes", "retreatOnWinWithoutTroops" },
{EGameSettings::HEROES_STARTING_STACKS_CHANCES, "heroes", "startingStackChances" },
{EGameSettings::HEROES_BACKPACK_CAP, "heroes", "backpackSize" },
{EGameSettings::HEROES_INVITE, "heroes", "invite" },
{EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA, "mapFormat", "restorationOfErathia" },
{EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" },
{EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH, "mapFormat", "shadowOfDeath" },

View File

@ -38,6 +38,7 @@ enum class EGameSettings
HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS,
HEROES_STARTING_STACKS_CHANCES,
HEROES_BACKPACK_CAP,
HEROES_INVITE,
MARKETS_BLACK_MARKET_RESTOCK_PERIOD,
BANKS_SHOW_GUARDS_COMPOSITION,
MODULE_COMMANDERS,

View File

@ -23,6 +23,7 @@
#include "../../lib/gameState/CGameState.h"
#include "../../lib/gameState/TavernHeroesPool.h"
#include "../../lib/gameState/TavernSlot.h"
#include "../../lib/GameSettings.h"
HeroPoolProcessor::HeroPoolProcessor()
: gameHandler(nullptr)
@ -114,7 +115,7 @@ void HeroPoolProcessor::selectNewHeroForSlot(const PlayerColor & color, TavernHe
CGHeroInstance *newHero = pickHeroFor(needNativeHero, color);
const auto & heroesPool = gameHandler->gameState()->heroesPool;
if(gameHandler->getStartInfo()->extraOptionsInfo.inviteHero && heroesPool->unusedHeroesFromPool().count(nextHero) && heroesPool->isHeroAvailableFor(nextHero, color))
if(VLC->settings()->getBoolean(EGameSettings::HEROES_INVITE) && heroesPool->unusedHeroesFromPool().count(nextHero) && heroesPool->isHeroAvailableFor(nextHero, color))
newHero = heroesPool->unusedHeroesFromPool()[nextHero];
if (newHero)