mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Improved tooltips.
This commit is contained in:
@@ -48,6 +48,17 @@ void IObjectInterface::initObj()
|
|||||||
void IObjectInterface::setProperty( ui8 what, ui32 val )
|
void IObjectInterface::setProperty( ui8 what, ui32 val )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void CPlayersVisited::setPropertyDer( ui8 what, ui32 val )
|
||||||
|
{
|
||||||
|
if(what == 10)
|
||||||
|
players.insert(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPlayersVisited::hasVisited( ui8 player ) const
|
||||||
|
{
|
||||||
|
return vstd::contains(players,player);
|
||||||
|
}
|
||||||
|
|
||||||
void CObjectHandler::loadObjects()
|
void CObjectHandler::loadObjects()
|
||||||
{
|
{
|
||||||
tlog5 << "\t\tReading cregens \n";
|
tlog5 << "\t\tReading cregens \n";
|
||||||
@@ -1641,7 +1652,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
{
|
{
|
||||||
InfoWindow iw;
|
InfoWindow iw;
|
||||||
iw.player = h->getOwner();
|
iw.player = h->getOwner();
|
||||||
if(!vstd::contains(playersVisited,h->tempOwner))
|
if(!hasVisited(h->tempOwner))
|
||||||
cb->setObjProperty(id,10,h->tempOwner);
|
cb->setObjProperty(id,10,h->tempOwner);
|
||||||
|
|
||||||
if(h->getSecSkillLevel(ability)) //you alredy know this skill
|
if(h->getSecSkillLevel(ability)) //you alredy know this skill
|
||||||
@@ -1668,7 +1679,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
const std::string & CGWitchHut::getHoverText() const
|
const std::string & CGWitchHut::getHoverText() const
|
||||||
{
|
{
|
||||||
hoverName = VLC->generaltexth->names[ID];
|
hoverName = VLC->generaltexth->names[ID];
|
||||||
if(vstd::contains(playersVisited,cb->getCurrentPlayer())) //TODO: use local player, not current
|
if(hasVisited(cb->getCurrentPlayer())) //TODO: use local player, not current
|
||||||
{
|
{
|
||||||
hoverName += "\n" + VLC->generaltexth->allTexts[356]; // + (learn %s)
|
hoverName += "\n" + VLC->generaltexth->allTexts[356]; // + (learn %s)
|
||||||
boost::algorithm::replace_first(hoverName,"%s",VLC->generaltexth->skillName[ability]);
|
boost::algorithm::replace_first(hoverName,"%s",VLC->generaltexth->skillName[ability]);
|
||||||
@@ -1678,11 +1689,6 @@ const std::string & CGWitchHut::getHoverText() const
|
|||||||
return hoverName;
|
return hoverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGWitchHut::setPropertyDer( ui8 what, ui32 val )
|
|
||||||
{
|
|
||||||
if(what == 10)
|
|
||||||
playersVisited.insert(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
||||||
{
|
{
|
||||||
@@ -1917,6 +1923,9 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!hasVisited(h->tempOwner))
|
||||||
|
cb->setObjProperty(id,10,h->tempOwner);
|
||||||
|
|
||||||
InfoWindow iw;
|
InfoWindow iw;
|
||||||
iw.player = h->getOwner();
|
iw.player = h->getOwner();
|
||||||
iw.text.addTxt(MetaString::ADVOB_TXT,127 + ID - 88);
|
iw.text.addTxt(MetaString::ADVOB_TXT,127 + ID - 88);
|
||||||
@@ -1976,5 +1985,14 @@ void CGShrine::initObj()
|
|||||||
|
|
||||||
const std::string & CGShrine::getHoverText() const
|
const std::string & CGShrine::getHoverText() const
|
||||||
{
|
{
|
||||||
|
hoverName = VLC->generaltexth->names[ID];
|
||||||
|
if(hasVisited(cb->getCurrentPlayer())) //TODO: use local player, not current
|
||||||
|
{
|
||||||
|
hoverName += "\n" + VLC->generaltexth->allTexts[355]; // + (learn %s)
|
||||||
|
boost::algorithm::replace_first(hoverName,"%s",VLC->spellh->spells[spell].name);
|
||||||
|
const CGHeroInstance *h = cb->getSelectedHero(cb->getCurrentPlayer());
|
||||||
|
if(h && vstd::contains(h->spells,spell)) //hero knows that ability
|
||||||
|
hoverName += "\n\n" + VLC->generaltexth->allTexts[354]; // (Already learned)
|
||||||
|
}
|
||||||
return hoverName;
|
return hoverName;
|
||||||
}
|
}
|
@@ -136,6 +136,20 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DLL_EXPORT CPlayersVisited: public CGObjectInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::set<ui8> players;
|
||||||
|
|
||||||
|
bool hasVisited(ui8 player) const;
|
||||||
|
void setPropertyDer(ui8 what, ui32 val);//synchr
|
||||||
|
|
||||||
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
|
{
|
||||||
|
h & players;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class DLL_EXPORT CArmedInstance: public CGObjectInstance
|
class DLL_EXPORT CArmedInstance: public CGObjectInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -432,20 +446,18 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_EXPORT CGWitchHut : public CGObjectInstance
|
class DLL_EXPORT CGWitchHut : public CPlayersVisited
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<si32> allowedAbilities;
|
std::vector<si32> allowedAbilities;
|
||||||
ui32 ability;
|
ui32 ability;
|
||||||
std::set<ui8> playersVisited; //players who know what skill is given here (used for hover texts)
|
|
||||||
|
|
||||||
void setPropertyDer(ui8 what, ui32 val);//synchr
|
|
||||||
const std::string & getHoverText() const;
|
const std::string & getHoverText() const;
|
||||||
void onHeroVisit(const CGHeroInstance * h) const;
|
void onHeroVisit(const CGHeroInstance * h) const;
|
||||||
void initObj();
|
void initObj();
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & static_cast<CGObjectInstance&>(*this);
|
h & static_cast<CGObjectInstance&>(*this) & static_cast<CPlayersVisited&>(*this);;
|
||||||
h & allowedAbilities & ability;
|
h & allowedAbilities & ability;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -532,7 +544,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_EXPORT CGShrine : public CGObjectInstance
|
class DLL_EXPORT CGShrine : public CPlayersVisited
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ui8 spell; //number of spell or 255 if random
|
ui8 spell; //number of spell or 255 if random
|
||||||
@@ -542,7 +554,7 @@ public:
|
|||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & static_cast<CGObjectInstance&>(*this);
|
h & static_cast<CGObjectInstance&>(*this) & static_cast<CPlayersVisited&>(*this);;
|
||||||
h & spell;
|
h & spell;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -104,5 +104,6 @@ bool IGameCallback::isAllowed( int type, int id )
|
|||||||
return gs->map->allowedSpell[id];
|
return gs->map->allowedSpell[id];
|
||||||
default:
|
default:
|
||||||
tlog1 << "Wrong call to IGameCallback::isAllowed!\n";
|
tlog1 << "Wrong call to IGameCallback::isAllowed!\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user