mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* Witch HutL After the first visit to the hut, right-click/hover on that hut mention the skill available.
* refactorings
This commit is contained in:
parent
6a3bfbee46
commit
fd66234a39
@ -497,7 +497,8 @@ void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
std::vector<std::string> temp = LOCPLINT->cb->getObjDescriptions(pom);
|
||||
if (temp.size())
|
||||
{
|
||||
LOCPLINT->adventureInt->statusbar.print((*((temp.end())-1)));
|
||||
boost::replace_all(temp.back(),"\n"," ");
|
||||
LOCPLINT->adventureInt->statusbar.print(temp.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -852,7 +852,11 @@ void CGameState::applyNL(IPack * pack)
|
||||
case 1001://set object property
|
||||
{
|
||||
SetObjectProperty *p = static_cast<SetObjectProperty*>(pack);
|
||||
setObjProperty(p);
|
||||
CGObjectInstance *obj = map->objects[p->id];
|
||||
if(!obj)
|
||||
tlog1 << "Wrong object ID - property cannot be set!\n";
|
||||
else
|
||||
obj->setProperty(p->what,p->val);
|
||||
break;
|
||||
}
|
||||
case 1002:
|
||||
@ -1789,33 +1793,6 @@ void CGameState::loadTownDInfos()
|
||||
}
|
||||
}
|
||||
|
||||
void CGameState::setObjProperty( SetObjectProperty * p )
|
||||
{
|
||||
CGObjectInstance *obj = map->objects[p->id];
|
||||
|
||||
switch(p->what)
|
||||
{
|
||||
case 1:
|
||||
obj->tempOwner = p->val;
|
||||
break;
|
||||
case 2:
|
||||
obj->blockVisit = p->val;
|
||||
break;
|
||||
case 3:
|
||||
static_cast<CArmedInstance*>(obj)->army.slots[0].second = p->val;
|
||||
break;
|
||||
case 4:
|
||||
static_cast<CGVisitableOPH*>(obj)->visitors.insert(p->val);
|
||||
break;
|
||||
case 5:
|
||||
static_cast<CGVisitableOPW*>(obj)->visited = p->val;
|
||||
break;
|
||||
case 6:
|
||||
obj->ID = p->val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CGameState::getNeighbours(int3 tile, std::vector<int3> &vec, bool onLand)
|
||||
{
|
||||
vec.clear();
|
||||
|
@ -228,7 +228,6 @@ private:
|
||||
void loadTownDInfos();
|
||||
void applyNL(IPack * pack);
|
||||
|
||||
void setObjProperty( SetObjectProperty * p );
|
||||
void apply(IPack * pack);
|
||||
void randomizeObject(CGObjectInstance *cur);
|
||||
std::pair<int,int> pickObject(CGObjectInstance *obj);
|
||||
|
@ -45,6 +45,9 @@ IObjectInterface::IObjectInterface()
|
||||
void IObjectInterface::initObj()
|
||||
{}
|
||||
|
||||
void IObjectInterface::setProperty( ui8 what, ui32 val )
|
||||
{}
|
||||
|
||||
void CObjectHandler::loadObjects()
|
||||
{
|
||||
tlog5 << "\t\tReading cregens \n";
|
||||
@ -181,6 +184,26 @@ void CGObjectInstance::initObj()
|
||||
{
|
||||
}
|
||||
|
||||
void CGObjectInstance::setProperty( ui8 what, ui32 val )
|
||||
{
|
||||
switch(what)
|
||||
{
|
||||
case 1:
|
||||
tempOwner = val;
|
||||
break;
|
||||
case 2:
|
||||
blockVisit = val;
|
||||
break;
|
||||
case 6:
|
||||
ID = val;
|
||||
break;
|
||||
}
|
||||
setPropertyDer(what, val);
|
||||
}
|
||||
|
||||
void CGObjectInstance::setPropertyDer( ui8 what, ui32 val )
|
||||
{}
|
||||
|
||||
int lowestSpeed(const CGHeroInstance * chi)
|
||||
{
|
||||
if(!chi->army.slots.size())
|
||||
@ -700,6 +723,11 @@ const HeroBonus * CGHeroInstance::getBonus( int from, int id ) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CGHeroInstance::setPropertyDer( ui8 what, ui32 val )
|
||||
{
|
||||
if(what == 3)
|
||||
army.slots[0].second = val;
|
||||
}
|
||||
int CGTownInstance::getSightDistance() const //returns sight distance
|
||||
{
|
||||
return 10;
|
||||
@ -1084,6 +1112,12 @@ void CGVisitableOPH::arenaSelected( int heroID, int primSkill ) const
|
||||
cb->changePrimSkill(heroID,primSkill,2);
|
||||
}
|
||||
|
||||
void CGVisitableOPH::setPropertyDer( ui8 what, ui32 val )
|
||||
{
|
||||
if(what == 4)
|
||||
visitors.insert(val);
|
||||
}
|
||||
|
||||
bool CArmedInstance::needsLastStack() const
|
||||
{
|
||||
return false;
|
||||
@ -1342,6 +1376,12 @@ void CGVisitableOPW::onHeroVisit( const CGHeroInstance * h ) const
|
||||
}
|
||||
}
|
||||
|
||||
void CGVisitableOPW::setPropertyDer( ui8 what, ui32 val )
|
||||
{
|
||||
if(what == 5)
|
||||
visited = val;
|
||||
}
|
||||
|
||||
void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
int destinationid=-1;
|
||||
@ -1566,6 +1606,8 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = h->getOwner();
|
||||
if(!vstd::contains(playersVisited,h->tempOwner))
|
||||
cb->setObjProperty(id,10,h->tempOwner);
|
||||
|
||||
if(h->getSecSkillLevel(ability)) //you alredy know this skill
|
||||
{
|
||||
@ -1588,6 +1630,25 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
|
||||
cb->showInfoDialog(&iw);
|
||||
}
|
||||
|
||||
const std::string & CGWitchHut::getHoverText() const
|
||||
{
|
||||
hoverName = VLC->generaltexth->names[ID];
|
||||
if(vstd::contains(playersVisited,cb->getCurrentPlayer())) //TODO: use local player, not current
|
||||
{
|
||||
hoverName += "\n" + VLC->generaltexth->allTexts[356]; // + (learn %s)
|
||||
boost::algorithm::replace_first(hoverName,"%s",VLC->generaltexth->skillName[ability]);
|
||||
if(cb->getSelectedHero(cb->getCurrentPlayer())->getSecSkillLevel(ability)) //hero knows that ability
|
||||
hoverName += "\n\n" + VLC->generaltexth->allTexts[357]; // (Already learned)
|
||||
}
|
||||
return hoverName;
|
||||
}
|
||||
|
||||
void CGWitchHut::setPropertyDer( ui8 what, ui32 val )
|
||||
{
|
||||
if(what == 10)
|
||||
playersVisited.insert(val);
|
||||
}
|
||||
|
||||
void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
|
||||
|
@ -88,7 +88,8 @@ public:
|
||||
virtual void onHeroVisit(const CGHeroInstance * h) const;
|
||||
virtual void onHeroLeave(const CGHeroInstance * h) const;
|
||||
virtual void newTurn() const;
|
||||
virtual void initObj();
|
||||
virtual void initObj(); //synchr
|
||||
virtual void setProperty(ui8 what, ui32 val);//synchr
|
||||
};
|
||||
|
||||
class DLL_EXPORT CGObjectInstance : protected IObjectInterface
|
||||
@ -120,6 +121,8 @@ public:
|
||||
virtual const std::string & getHoverText() const;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void initObj();
|
||||
void setProperty(ui8 what, ui32 val);//synchr
|
||||
virtual void setPropertyDer(ui8 what, ui32 val);//synchr
|
||||
|
||||
friend class CGameHandler;
|
||||
|
||||
@ -239,6 +242,8 @@ public:
|
||||
virtual ~CGHeroInstance();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void setPropertyDer(ui8 what, ui32 val);//synchr
|
||||
void initObj();
|
||||
void onHeroVisit(const CGHeroInstance * h) const;
|
||||
};
|
||||
@ -321,6 +326,7 @@ public:
|
||||
si8 ttype; //tree type - used only by trees of knowledge: 0 - give level for free; 1 - take 2000 gold; 2 - take 10 gems
|
||||
const std::string & getHoverText() const;
|
||||
|
||||
void setPropertyDer(ui8 what, ui32 val);//synchr
|
||||
void onHeroVisit(const CGHeroInstance * h) const;
|
||||
void onNAHeroVisit(int heroID, bool alreadyVisited) const;
|
||||
void initObj();
|
||||
@ -422,9 +428,11 @@ class DLL_EXPORT CGWitchHut : public CGObjectInstance
|
||||
{
|
||||
public:
|
||||
std::vector<si32> allowedAbilities;
|
||||
|
||||
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;
|
||||
void onHeroVisit(const CGHeroInstance * h) const;
|
||||
void initObj();
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -580,6 +588,7 @@ class DLL_EXPORT CGVisitableOPW : public CGObjectInstance //objects visitable OP
|
||||
public:
|
||||
ui8 visited; //true if object has been visited this week
|
||||
|
||||
void setPropertyDer(ui8 what, ui32 val);//synchr
|
||||
void onHeroVisit(const CGHeroInstance * h) const;
|
||||
void newTurn() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user