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

Hover text for heroes.

This commit is contained in:
Michał W. Urbańczyk 2008-08-02 10:25:58 +00:00
parent 1f4b4364df
commit dc82232e70
4 changed files with 12 additions and 11 deletions

View File

@ -634,6 +634,11 @@ std::vector<int> CTownScript::yourObjects() //returns IDs of objects which are h
void CHeroScript::newObject(int objid)
{
cb->setBlockVis(objid,true);
MetaString ms;
ms << std::pair<ui8,ui32>(1,15);
ms.replacements.push_back(cb->getHero(objid)->name);
ms.replacements.push_back(cb->getHero(objid)->type->heroClass->name);
cb->setHoverName(objid,&ms);
}
void CHeroScript::onHeroVisit(int objid, int heroID)
@ -661,15 +666,6 @@ std::vector<int> CHeroScript::yourObjects() //returns IDs of objects which are h
ret.push_back(34); //hero
return ret;
}
//std::string CHeroScript::hoverText(int objid)
//{
// //CGHeroInstance* h = static_cast<CGHeroInstance*>(os);
// //std::string ret = VLC->generaltexth->allTexts[15];
// //boost::algorithm::replace_first(ret,"%s",h->name);
// //boost::algorithm::replace_first(ret,"%s",h->type->heroClass->name);
// //return ret;
// return "";
//}
void CMonsterS::newObject(int objid)
{
//os->blockVisit = true;

View File

@ -568,7 +568,7 @@ SComponent::SComponent(const Component &c)
switch(c.id)
{
case resource:
if(c.when==1)
if(c.when == -1)
subtitle += CGI->generaltexth->allTexts[3].substr(2,CGI->generaltexth->allTexts[3].length()-2);
break;
}

View File

@ -81,6 +81,10 @@ std::string toString(MetaString &ms)
}
}
}
for(int i=0;i<ms.replacements.size();i++)
{
ret.replace(ret.find("%s"),2,ms.replacements[i]);
}
return ret;
}

View File

@ -145,10 +145,11 @@ struct MetaString : public CPack<MetaString> //2001 helper for object scrips
std::vector<std::string> strings;
std::vector<std::pair<ui8,ui32> > texts; //pairs<text handler type, text number>; types: 1 - generaltexthandler->all; 2 - objh->xtrainfo; 3 - objh->names; 4 - objh->restypes; 5 - arth->artifacts[id].name; 6 - generaltexth->arraytxt; 7 - creh->creatures[os->subID].namePl; 8 - objh->creGens; 9 - objh->mines[ID].first; 10 - objh->mines[ID].second; 11 - objh->advobtxt
std::vector<si32> message;
std::vector<std::string> replacements;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & strings & texts & message;
h & strings & texts & message & replacements;
}
MetaString& operator<<(const std::pair<ui8,ui32> &txt)