mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
code review
This commit is contained in:
parent
b82a51d184
commit
0a4b5dbe10
@ -409,12 +409,12 @@ void OptionsTabBase::recreate()
|
|||||||
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->setInputEnabled(SEL->screenType != ESelectionScreen::loadGame);
|
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->setInputEnabled(SEL->screenType != ESelectionScreen::loadGame);
|
buttonUnlimitedReplay->block(SEL->screenType == ESelectionScreen::loadGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -519,8 +519,9 @@ void CTavernWindow::addInvite()
|
|||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
if(VLC->settings()->getBoolean(EGameSettings::HEROES_INVITE))
|
if(!VLC->settings()->getBoolean(EGameSettings::HEROES_TAVERN_INVITE))
|
||||||
{
|
return;
|
||||||
|
|
||||||
const auto & heroesPool = CSH->client->gameState()->heroesPool;
|
const auto & heroesPool = CSH->client->gameState()->heroesPool;
|
||||||
for(auto & elem : heroesPool->unusedHeroesFromPool())
|
for(auto & elem : heroesPool->unusedHeroesFromPool())
|
||||||
{
|
{
|
||||||
@ -539,7 +540,6 @@ void CTavernWindow::addInvite()
|
|||||||
inviteHeroImageArea = std::make_shared<LRClickableArea>(Rect(245, 428, 48, 32), [&](){ GH.windows().createAndPushWindow<HeroSelector>(inviteableHeroes, [&](CGHeroInstance* h){ heroToInvite = h; addInvite(); }); }, [&](){ GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(heroToInvite)); });
|
inviteHeroImageArea = std::make_shared<LRClickableArea>(Rect(245, 428, 48, 32), [&](){ GH.windows().createAndPushWindow<HeroSelector>(inviteableHeroes, [&](CGHeroInstance* h){ heroToInvite = h; addInvite(); }); }, [&](){ GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(heroToInvite)); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CTavernWindow::recruitb()
|
void CTavernWindow::recruitb()
|
||||||
{
|
{
|
||||||
|
@ -291,7 +291,7 @@
|
|||||||
// number of artifacts that can fit in a backpack. -1 is unlimited.
|
// number of artifacts that can fit in a backpack. -1 is unlimited.
|
||||||
"backpackSize" : -1,
|
"backpackSize" : -1,
|
||||||
// if heroes are invitable in tavern
|
// if heroes are invitable in tavern
|
||||||
"invite" : false
|
"tavernInvite" : false
|
||||||
},
|
},
|
||||||
|
|
||||||
"towns":
|
"towns":
|
||||||
|
@ -74,7 +74,7 @@ void GameSettings::load(const JsonNode & input)
|
|||||||
{EGameSettings::HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS, "heroes", "retreatOnWinWithoutTroops" },
|
{EGameSettings::HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS, "heroes", "retreatOnWinWithoutTroops" },
|
||||||
{EGameSettings::HEROES_STARTING_STACKS_CHANCES, "heroes", "startingStackChances" },
|
{EGameSettings::HEROES_STARTING_STACKS_CHANCES, "heroes", "startingStackChances" },
|
||||||
{EGameSettings::HEROES_BACKPACK_CAP, "heroes", "backpackSize" },
|
{EGameSettings::HEROES_BACKPACK_CAP, "heroes", "backpackSize" },
|
||||||
{EGameSettings::HEROES_INVITE, "heroes", "invite" },
|
{EGameSettings::HEROES_TAVERN_INVITE, "heroes", "tavernInvite" },
|
||||||
{EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA, "mapFormat", "restorationOfErathia" },
|
{EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA, "mapFormat", "restorationOfErathia" },
|
||||||
{EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" },
|
{EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" },
|
||||||
{EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH, "mapFormat", "shadowOfDeath" },
|
{EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH, "mapFormat", "shadowOfDeath" },
|
||||||
|
@ -38,7 +38,7 @@ enum class EGameSettings
|
|||||||
HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS,
|
HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS,
|
||||||
HEROES_STARTING_STACKS_CHANCES,
|
HEROES_STARTING_STACKS_CHANCES,
|
||||||
HEROES_BACKPACK_CAP,
|
HEROES_BACKPACK_CAP,
|
||||||
HEROES_INVITE,
|
HEROES_TAVERN_INVITE,
|
||||||
MARKETS_BLACK_MARKET_RESTOCK_PERIOD,
|
MARKETS_BLACK_MARKET_RESTOCK_PERIOD,
|
||||||
BANKS_SHOW_GUARDS_COMPOSITION,
|
BANKS_SHOW_GUARDS_COMPOSITION,
|
||||||
MODULE_COMMANDERS,
|
MODULE_COMMANDERS,
|
||||||
|
@ -112,11 +112,7 @@ void HeroPoolProcessor::selectNewHeroForSlot(const PlayerColor & color, TavernHe
|
|||||||
sah.slotID = slot;
|
sah.slotID = slot;
|
||||||
sah.replenishPoints = true;
|
sah.replenishPoints = true;
|
||||||
|
|
||||||
CGHeroInstance *newHero = pickHeroFor(needNativeHero, color);
|
CGHeroInstance *newHero = (nextHero == HeroTypeID::NONE) ? pickHeroFor(needNativeHero, color) : gameHandler->gameState()->heroesPool->unusedHeroesFromPool()[nextHero];
|
||||||
|
|
||||||
const auto & heroesPool = gameHandler->gameState()->heroesPool;
|
|
||||||
if(VLC->settings()->getBoolean(EGameSettings::HEROES_INVITE) && heroesPool->unusedHeroesFromPool().count(nextHero) && heroesPool->isHeroAvailableFor(nextHero, color))
|
|
||||||
newHero = heroesPool->unusedHeroesFromPool()[nextHero];
|
|
||||||
|
|
||||||
if (newHero)
|
if (newHero)
|
||||||
{
|
{
|
||||||
@ -155,6 +151,7 @@ bool HeroPoolProcessor::hireHero(const ObjectInstanceID & objectID, const HeroTy
|
|||||||
const PlayerState * playerState = gameHandler->getPlayerState(player);
|
const PlayerState * playerState = gameHandler->getPlayerState(player);
|
||||||
const CGObjectInstance * mapObject = gameHandler->getObj(objectID);
|
const CGObjectInstance * mapObject = gameHandler->getObj(objectID);
|
||||||
const CGTownInstance * town = gameHandler->getTown(objectID);
|
const CGTownInstance * town = gameHandler->getTown(objectID);
|
||||||
|
const auto & heroesPool = gameHandler->gameState()->heroesPool;
|
||||||
|
|
||||||
if (!mapObject && gameHandler->complain("Invalid map object!"))
|
if (!mapObject && gameHandler->complain("Invalid map object!"))
|
||||||
return false;
|
return false;
|
||||||
@ -171,6 +168,10 @@ bool HeroPoolProcessor::hireHero(const ObjectInstanceID & objectID, const HeroTy
|
|||||||
if (gameHandler->getHeroCount(player, true) >= VLC->settings()->getInteger(EGameSettings::HEROES_PER_PLAYER_TOTAL_CAP) && gameHandler->complain("Cannot hire hero, too many heroes garrizoned and wandering already!"))
|
if (gameHandler->getHeroCount(player, true) >= VLC->settings()->getInteger(EGameSettings::HEROES_PER_PLAYER_TOTAL_CAP) && gameHandler->complain("Cannot hire hero, too many heroes garrizoned and wandering already!"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if(VLC->settings()->getBoolean(EGameSettings::HEROES_TAVERN_INVITE) && nextHero != HeroTypeID::NONE)
|
||||||
|
if(!heroesPool->unusedHeroesFromPool().count(nextHero) && !heroesPool->isHeroAvailableFor(nextHero, player) && gameHandler->complain("Cannot set next hero!"))
|
||||||
|
return false;
|
||||||
|
|
||||||
if(town) //tavern in town
|
if(town) //tavern in town
|
||||||
{
|
{
|
||||||
if(gameHandler->getPlayerRelations(mapObject->tempOwner, player) == PlayerRelations::ENEMIES && gameHandler->complain("Can't buy hero in enemy town!"))
|
if(gameHandler->getPlayerRelations(mapObject->tempOwner, player) == PlayerRelations::ENEMIES && gameHandler->complain("Can't buy hero in enemy town!"))
|
||||||
@ -197,7 +198,7 @@ bool HeroPoolProcessor::hireHero(const ObjectInstanceID & objectID, const HeroTy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto recruitableHeroes = gameHandler->gameState()->heroesPool->getHeroesFor(player);
|
auto recruitableHeroes = heroesPool->getHeroesFor(player);
|
||||||
|
|
||||||
const CGHeroInstance * recruitedHero = nullptr;
|
const CGHeroInstance * recruitedHero = nullptr;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user