mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Hover text for heroes.
This commit is contained in:
14
CLua.cpp
14
CLua.cpp
@ -634,6 +634,11 @@ std::vector<int> CTownScript::yourObjects() //returns IDs of objects which are h
|
|||||||
void CHeroScript::newObject(int objid)
|
void CHeroScript::newObject(int objid)
|
||||||
{
|
{
|
||||||
cb->setBlockVis(objid,true);
|
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)
|
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
|
ret.push_back(34); //hero
|
||||||
return ret;
|
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)
|
void CMonsterS::newObject(int objid)
|
||||||
{
|
{
|
||||||
//os->blockVisit = true;
|
//os->blockVisit = true;
|
||||||
|
@ -568,7 +568,7 @@ SComponent::SComponent(const Component &c)
|
|||||||
switch(c.id)
|
switch(c.id)
|
||||||
{
|
{
|
||||||
case resource:
|
case resource:
|
||||||
if(c.when==1)
|
if(c.when == -1)
|
||||||
subtitle += CGI->generaltexth->allTexts[3].substr(2,CGI->generaltexth->allTexts[3].length()-2);
|
subtitle += CGI->generaltexth->allTexts[3].substr(2,CGI->generaltexth->allTexts[3].length()-2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,10 +145,11 @@ struct MetaString : public CPack<MetaString> //2001 helper for object scrips
|
|||||||
std::vector<std::string> strings;
|
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<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<si32> message;
|
||||||
|
std::vector<std::string> replacements;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
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)
|
MetaString& operator<<(const std::pair<ui8,ui32> &txt)
|
||||||
|
Reference in New Issue
Block a user