From dc82232e70b6a360974ec926469389ed9c06bf86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 2 Aug 2008 10:25:58 +0000 Subject: [PATCH] Hover text for heroes. --- CLua.cpp | 14 +++++--------- CPlayerInterface.cpp | 2 +- client/Client.cpp | 4 ++++ lib/NetPacks.h | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CLua.cpp b/CLua.cpp index 85a006661..36937fd1e 100644 --- a/CLua.cpp +++ b/CLua.cpp @@ -634,6 +634,11 @@ std::vector CTownScript::yourObjects() //returns IDs of objects which are h void CHeroScript::newObject(int objid) { cb->setBlockVis(objid,true); + MetaString ms; + ms << std::pair(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 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(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; diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index b5bf15f42..7d9503dd2 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -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; } diff --git a/client/Client.cpp b/client/Client.cpp index d68db84ec..23d60ad6c 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -81,6 +81,10 @@ std::string toString(MetaString &ms) } } } + for(int i=0;i //2001 helper for object scrips std::vector strings; std::vector > texts; //pairs; 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 message; + std::vector replacements; template void serialize(Handler &h, const int version) { - h & strings & texts & message; + h & strings & texts & message & replacements; } MetaString& operator<<(const std::pair &txt)