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

Show non-learnable spells from rewardable object as greyed-out

This commit is contained in:
Ivan Savenko 2024-07-27 18:09:12 +00:00
parent f9348fc84a
commit 74fea5109b
2 changed files with 8 additions and 2 deletions

View File

@ -290,7 +290,10 @@ std::string CComponent::getSubtitle() const
return CGI->artifacts()->getById(data.subType.as<ArtifactID>())->getNameTranslated();
case ComponentType::SPELL_SCROLL:
case ComponentType::SPELL:
return CGI->spells()->getById(data.subType.as<SpellID>())->getNameTranslated();
if (data.value < 0)
return "{#A9A9A9|" + CGI->spells()->getById(data.subType.as<SpellID>())->getNameTranslated() + "}";
else
return CGI->spells()->getById(data.subType.as<SpellID>())->getNameTranslated();
case ComponentType::NONE:
case ComponentType::MORALE:
case ComponentType::LUCK:

View File

@ -115,7 +115,10 @@ void Rewardable::Reward::loadComponents(std::vector<Component> & comps, const CG
comps.emplace_back(ComponentType::ARTIFACT, entry);
for(const auto & entry : spells)
comps.emplace_back(ComponentType::SPELL, entry);
{
bool learnable = !h || h->canLearnSpell(entry.toEntity(VLC), true);
comps.emplace_back(ComponentType::SPELL, entry, learnable ? 0 : -1);
}
for(const auto & entry : creatures)
comps.emplace_back(ComponentType::CREATURE, entry.type->getId(), entry.count);