1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

CGArtifact: show yes/no dialog for guarded artifacts. Fix issue 2095

Also fix hover text for CGMine
This commit is contained in:
Arseniy Shestakov
2015-12-24 21:05:02 +03:00
parent 75ca020890
commit 62bab27e7e

View File

@ -629,7 +629,6 @@ std::string CGMine::getObjectName() const
std::string CGMine::getHoverText(PlayerColor player) const std::string CGMine::getHoverText(PlayerColor player) const
{ {
std::string hoverName = getObjectName(); // Sawmill std::string hoverName = getObjectName(); // Sawmill
if (tempOwner != PlayerColor::NEUTRAL) if (tempOwner != PlayerColor::NEUTRAL)
@ -639,11 +638,12 @@ std::string CGMine::getHoverText(PlayerColor player) const
hoverName += "\n(" + VLC->generaltexth->restypes[producedResource] + ")"; hoverName += "\n(" + VLC->generaltexth->restypes[producedResource] + ")";
} }
for (auto & slot : Slots()) // guarded by a few Pikeman if(stacksCount())
{ {
hoverName += "\n"; hoverName += "\n";
hoverName += getRoughAmount(slot.first); hoverName += VLC->generaltexth->allTexts[202]; //Guarded by
hoverName += getCreature(slot.first)->namePl; hoverName += " ";
hoverName += getArmyDescription();
} }
return hoverName; return hoverName;
} }
@ -1164,7 +1164,7 @@ std::string CGArtifact::getObjectName() const
return VLC->arth->artifacts[subID]->Name(); return VLC->arth->artifacts[subID]->Name();
} }
void CGArtifact::onHeroVisit( const CGHeroInstance * h ) const void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
{ {
if(!stacksCount()) if(!stacksCount())
{ {
@ -1175,28 +1175,32 @@ void CGArtifact::onHeroVisit( const CGHeroInstance * h ) const
case Obj::ARTIFACT: case Obj::ARTIFACT:
{ {
iw.soundID = soundBase::treasure; //play sound only for non-scroll arts iw.soundID = soundBase::treasure; //play sound only for non-scroll arts
iw.components.push_back(Component(Component::ARTIFACT,subID,0,0)); iw.components.push_back(Component(Component::ARTIFACT, subID, 0, 0));
if(message.length()) if(message.length())
iw.text << message; iw.text << message;
else else
{ {
if (VLC->arth->artifacts[subID]->EventText().size()) if(VLC->arth->artifacts[subID]->EventText().size())
iw.text << std::pair<ui8, ui32> (MetaString::ART_EVNTS, subID); iw.text << std::pair<ui8, ui32>(MetaString::ART_EVNTS, subID);
else //fix for mod artifacts with no event text else //fix for mod artifacts with no event text
{ {
iw.text.addTxt (MetaString::ADVOB_TXT, 183); //% has found treasure iw.text.addTxt(MetaString::ADVOB_TXT, 183); //% has found treasure
iw.text.addReplacement (h->name); iw.text.addReplacement(h->name);
} }
} }
} }
break; break;
case Obj::SPELL_SCROLL: case Obj::SPELL_SCROLL:
{ {
int spellID = storedArtifact->getGivenSpellID(); int spellID = storedArtifact->getGivenSpellID();
iw.components.push_back (Component(Component::SPELL, spellID,0,0)); iw.components.push_back(Component(Component::SPELL, spellID, 0, 0));
iw.text.addTxt (MetaString::ADVOB_TXT,135); if(message.length())
iw.text.addReplacement(MetaString::SPELL_NAME, spellID); iw.text << message;
else
{
iw.text.addTxt(MetaString::ADVOB_TXT,135);
iw.text.addReplacement(MetaString::SPELL_NAME, spellID);
}
} }
break; break;
} }
@ -1205,16 +1209,38 @@ void CGArtifact::onHeroVisit( const CGHeroInstance * h ) const
} }
else else
{ {
if(message.size()) switch(ID)
{ {
BlockingDialog ynd(true,false); case Obj::ARTIFACT:
ynd.player = h->getOwner(); {
ynd.text << message; BlockingDialog ynd(true,false);
cb->showBlockingDialog(&ynd); ynd.player = h->getOwner();
} if(message.length())
else ynd.text << message;
{ else
blockingDialogAnswered(h, true); {
// TODO: Guard text is more complex in H3, see mantis issue 2325 for details
ynd.text.addTxt(MetaString::GENERAL_TXT, 420);
ynd.text.addReplacement("");
ynd.text.addReplacement(getArmyDescription());
ynd.text.addReplacement(MetaString::GENERAL_TXT, 43); // creatures
}
cb->showBlockingDialog(&ynd);
}
break;
case Obj::SPELL_SCROLL:
{
if(message.length())
{
BlockingDialog ynd(true,false);
ynd.player = h->getOwner();
ynd.text << message;
cb->showBlockingDialog(&ynd);
}
else
blockingDialogAnswered(h, true);
}
break;
} }
} }
} }