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

vcmi: allow showing simple rewardables in infobox

This commit is contained in:
Konstantin 2023-03-06 14:31:06 +03:00
parent 4617ce10e5
commit c759400767
3 changed files with 10 additions and 2 deletions

View File

@ -231,6 +231,8 @@ void CRandomRewardObjectInfo::configureObject(CRewardableObject * object, CRando
object->canRefuse = parameters["canRefuse"].Bool();
object->showInInfobox = parameters["showInInfobox"].Bool();
auto visitMode = parameters["visitMode"].String();
for(int i = 0; i < Rewardable::VisitModeString.size(); ++i)
{

View File

@ -134,13 +134,15 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
{
auto vi = info[index];
logGlobal->debug("Granting reward %d. Message says: %s", index, vi.message.toString());
// show message only if it is not empty
if (!vi.message.toString().empty())
if (showInInfobox || !vi.message.toString().empty()) // show message only if it is not empty or in infobox
{
InfoWindow iw;
iw.player = h->tempOwner;
iw.text = vi.message;
vi.reward.loadComponents(iw.components, h);
iw.type = EInfoWindowMode::AUTO;
if(showInInfobox)
iw.type = EInfoWindowMode::INFO;
cb->showInfoDialog(&iw);
}
// grant reward afterwards. Note that it may remove object

View File

@ -306,6 +306,9 @@ protected:
/// if true - player can refuse visiting an object (e.g. Tomb)
bool canRefuse;
/// if true - object info will shown in infobox (like resource pickup)
bool showInInfobox;
/// return true if this object was "cleared" before and no longer has rewards applicable to selected hero
/// unlike wasVisited, this method uses information not available to player owner, for example, if object was cleared by another player before
bool wasVisitedBefore(const CGHeroInstance * contextHero) const;
@ -345,6 +348,7 @@ public:
h & static_cast<CArmedInstance&>(*this);
h & info;
h & canRefuse;
h & showInInfobox;
h & resetParameters;
h & onSelect;
h & visitMode;