mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
vcmi: allow showing more than one components in infobar
Up to 8, AFAIK. So, we can show multi-reward in infobox now. One issue remain - cannot dynamically choose components size based on text size.
This commit is contained in:
@ -881,27 +881,30 @@ void CGResource::onHeroVisit( const CGHeroInstance * h ) const
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(message.length())
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = h->tempOwner;
|
||||
iw.text << message;
|
||||
cb->showInfoDialog(&iw);
|
||||
}
|
||||
collectRes(h->getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
void CGResource::collectRes(const PlayerColor & player) const
|
||||
{
|
||||
cb->giveResource(player, static_cast<Res::ERes>(subID), amount);
|
||||
ShowInInfobox sii;
|
||||
InfoWindow sii;
|
||||
sii.player = player;
|
||||
sii.c = Component(Component::RESOURCE,subID,amount,0);
|
||||
if(!message.empty())
|
||||
{
|
||||
sii.type = EInfoWindowMode::AUTO;
|
||||
sii.text << message;
|
||||
}
|
||||
else
|
||||
{
|
||||
sii.type = EInfoWindowMode::INFO;
|
||||
sii.text.addTxt(MetaString::ADVOB_TXT,113);
|
||||
sii.text.addReplacement(MetaString::RES_NAMES, subID);
|
||||
}
|
||||
sii.components.emplace_back(Component::RESOURCE,subID,amount,0);
|
||||
sii.text.addTxt(MetaString::ADVOB_TXT,113);
|
||||
sii.text.addReplacement(MetaString::RES_NAMES, subID);
|
||||
cb->showCompInfo(&sii);
|
||||
sii.soundID = soundBase::pickup01 + CRandomGenerator::getDefault().nextInt(6);
|
||||
cb->showInfoDialog(&sii);
|
||||
cb->removeObject(this);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user