1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Buildings in town (tylko zamek, trzeba inaczej sortować, jeden budynek źle trafiony)

This commit is contained in:
Michał W. Urbańczyk
2008-01-15 21:38:01 +00:00
parent bce31ba91b
commit 4b772315bb
7 changed files with 132 additions and 7 deletions

View File

@@ -34,6 +34,16 @@ std::string getBgName(int type) //TODO - co z tym zrobi
throw new std::exception("std::string getBgName(int type): invalid type");
}
}
class SORTHELP
{
public:
bool operator ()
(const boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*> *a ,
const boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*> *b)
{
return (a->get<0>())<(b->get<0>());
}
} srthlp ;
CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
{
@@ -47,6 +57,28 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
CSDL_Ext::blueToPlayersAdv(townInt,LOCPLINT->playerID);
exit = new AdventureMapButton<CCastleInterface>(CGI->townh->tcommands[8],"",&CCastleInterface::close,744,544,"TSBTNS.DEF",this,Activate);
exit->bitmapOffset = 4;
for (std::set<int>::const_iterator i=town->builtBuildings.begin();i!=town->builtBuildings.end();i++)
{
if(CGI->townh->structures.find(town->subID) != CGI->townh->structures.end())
{
if(CGI->townh->structures[town->subID].find(*i)!=CGI->townh->structures[town->subID].end())
{
CDefHandler *b = CGI->spriteh->giveDef(CGI->townh->structures[town->subID][*i]->defName);
boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*> *t
= new boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*>
(*i,b,CGI->townh->structures[town->subID][*i],NULL,NULL);
//TODO: obw�dki i pola
buildings.push_back(t);
}
else continue;
}
else
break;
}
std::sort(buildings.begin(),buildings.end(),srthlp);
if(Activate)
{
activate();
@@ -62,6 +94,20 @@ CCastleInterface::~CCastleInterface()
delete fort;
delete bigTownPic;
delete flag;
for(int i=0;i<buildings.size();i++)
{
if (buildings[i]->get<1>())
delete (buildings[i]->get<1>());
//if (buildings[i]->get<2>())
// delete (buildings[i]->get<2>());
if (buildings[i]->get<3>())
SDL_FreeSurface(buildings[i]->get<3>());
if (buildings[i]->get<4>())
SDL_FreeSurface(buildings[i]->get<4>());
delete buildings[i];
}
}
void CCastleInterface::close()
{
@@ -145,6 +191,12 @@ void CCastleInterface::show()
itoa(i->second.second,temp,10);
CSDL_Ext::printTo(temp,305+(62*(i->first))+57,387+61,GEOR13,zwykly);
}
//blit buildings
for(int i=0;i<buildings.size();i++)
{
blitAt(buildings[i]->get<1>()->ourImages[0].bitmap,buildings[i]->get<2>()->x,buildings[i]->get<2>()->y);
}
}
void CCastleInterface::activate()