mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Animated buildings in the castle.
This commit is contained in:
@@ -98,6 +98,7 @@ public:
|
|||||||
|
|
||||||
CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
||||||
{
|
{
|
||||||
|
count=0;
|
||||||
town = Town;
|
town = Town;
|
||||||
townInt = CGI->bitmaph->loadBitmap("TOWNSCRN.bmp");
|
townInt = CGI->bitmaph->loadBitmap("TOWNSCRN.bmp");
|
||||||
cityBg = CGI->bitmaph->loadBitmap(getBgName(town->subID));
|
cityBg = CGI->bitmaph->loadBitmap(getBgName(town->subID));
|
||||||
@@ -134,9 +135,16 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
|||||||
|
|
||||||
if(Activate)
|
if(Activate)
|
||||||
{
|
{
|
||||||
|
LOCPLINT->objsToBlit.push_back(this);
|
||||||
activate();
|
activate();
|
||||||
show();
|
showAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//blit buildings on bg
|
||||||
|
//for(int i=0;i<buildings.size();i++)
|
||||||
|
//{
|
||||||
|
// blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,cityBg);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
CCastleInterface::~CCastleInterface()
|
CCastleInterface::~CCastleInterface()
|
||||||
{
|
{
|
||||||
@@ -156,15 +164,18 @@ CCastleInterface::~CCastleInterface()
|
|||||||
}
|
}
|
||||||
void CCastleInterface::close()
|
void CCastleInterface::close()
|
||||||
{
|
{
|
||||||
|
LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
|
||||||
deactivate();
|
deactivate();
|
||||||
LOCPLINT->castleInt = NULL;
|
LOCPLINT->castleInt = NULL;
|
||||||
LOCPLINT->adventureInt->show();
|
LOCPLINT->adventureInt->show();
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
void CCastleInterface::show()
|
void CCastleInterface::showAll(SDL_Surface * to)
|
||||||
{
|
{
|
||||||
blitAt(cityBg,0,0);
|
if (!to)
|
||||||
blitAt(townInt,0,374);
|
to=ekran;
|
||||||
|
blitAt(cityBg,0,0,to);
|
||||||
|
blitAt(townInt,0,374,to);
|
||||||
LOCPLINT->adventureInt->resdatabar.draw();
|
LOCPLINT->adventureInt->resdatabar.draw();
|
||||||
|
|
||||||
int pom;
|
int pom;
|
||||||
@@ -177,7 +188,7 @@ void CCastleInterface::show()
|
|||||||
else if(town->builtBuildings.find(7)!=town->builtBuildings.end())
|
else if(town->builtBuildings.find(7)!=town->builtBuildings.end())
|
||||||
pom = 0;
|
pom = 0;
|
||||||
else pom = 3;
|
else pom = 3;
|
||||||
blitAt(fort->ourImages[pom].bitmap,122,413);
|
blitAt(fort->ourImages[pom].bitmap,122,413,to);
|
||||||
|
|
||||||
//draw ((village/town/city) hall)/capitol icon
|
//draw ((village/town/city) hall)/capitol icon
|
||||||
if(town->builtBuildings.find(13)!=town->builtBuildings.end())
|
if(town->builtBuildings.find(13)!=town->builtBuildings.end())
|
||||||
@@ -187,7 +198,7 @@ void CCastleInterface::show()
|
|||||||
else if(town->builtBuildings.find(11)!=town->builtBuildings.end())
|
else if(town->builtBuildings.find(11)!=town->builtBuildings.end())
|
||||||
pom = 1;
|
pom = 1;
|
||||||
else pom = 0;
|
else pom = 0;
|
||||||
blitAt(hall->ourImages[pom].bitmap,80,413);
|
blitAt(hall->ourImages[pom].bitmap,80,413,to);
|
||||||
|
|
||||||
//draw creatures icons and their growths
|
//draw creatures icons and their growths
|
||||||
for(int i=0;i<CREATURES_PER_TOWN;i++)
|
for(int i=0;i<CREATURES_PER_TOWN;i++)
|
||||||
@@ -206,18 +217,18 @@ void CCastleInterface::show()
|
|||||||
int pomx, pomy;
|
int pomx, pomy;
|
||||||
pomx = 22 + (55*((i>3)?(i-4):i));
|
pomx = 22 + (55*((i>3)?(i-4):i));
|
||||||
pomy = (i>3)?(507):(459);
|
pomy = (i>3)?(507):(459);
|
||||||
blitAt(CGI->creh->smallImgs[cid],pomx,pomy);
|
blitAt(CGI->creh->smallImgs[cid],pomx,pomy,to);
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << '+' << town->creatureIncome[i];
|
oss << '+' << town->creatureIncome[i];
|
||||||
CSDL_Ext::printAtMiddle(oss.str(),pomx+16,pomy+37,GEOR13,zwykly);
|
CSDL_Ext::printAtMiddle(oss.str(),pomx+16,pomy+37,GEOR13,zwykly,to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//print name and income
|
//print name and income
|
||||||
CSDL_Ext::printAt(town->name,85,389,GEOR13,zwykly);
|
CSDL_Ext::printAt(town->name,85,389,GEOR13,zwykly,to);
|
||||||
char temp[10];
|
char temp[10];
|
||||||
itoa(town->income,temp,10);
|
itoa(town->income,temp,10);
|
||||||
CSDL_Ext::printAtMiddle(temp,195,442,GEOR13,zwykly);
|
CSDL_Ext::printAtMiddle(temp,195,442,GEOR13,zwykly,to);
|
||||||
|
|
||||||
//blit town icon
|
//blit town icon
|
||||||
pom = town->subID*2;
|
pom = town->subID*2;
|
||||||
@@ -225,10 +236,10 @@ void CCastleInterface::show()
|
|||||||
pom += F_NUMBER*2;
|
pom += F_NUMBER*2;
|
||||||
if(town->builded >= MAX_BUILDING_PER_TURN)
|
if(town->builded >= MAX_BUILDING_PER_TURN)
|
||||||
pom++;
|
pom++;
|
||||||
blitAt(bigTownPic->ourImages[pom].bitmap,15,387);
|
blitAt(bigTownPic->ourImages[pom].bitmap,15,387,to);
|
||||||
|
|
||||||
//flag
|
//flag
|
||||||
blitAt(flag->ourImages[town->getOwner()].bitmap,241,387);
|
blitAt(flag->ourImages[town->getOwner()].bitmap,241,387,to);
|
||||||
//print garrison
|
//print garrison
|
||||||
for(
|
for(
|
||||||
std::map<int,std::pair<CCreature*,int> >::const_iterator i=town->garrison.slots.begin();
|
std::map<int,std::pair<CCreature*,int> >::const_iterator i=town->garrison.slots.begin();
|
||||||
@@ -236,16 +247,41 @@ void CCastleInterface::show()
|
|||||||
i++
|
i++
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
blitAt(CGI->creh->bigImgs[i->second.first->idNumber],305+(62*(i->first)),387);
|
blitAt(CGI->creh->bigImgs[i->second.first->idNumber],305+(62*(i->first)),387,to);
|
||||||
itoa(i->second.second,temp,10);
|
itoa(i->second.second,temp,10);
|
||||||
CSDL_Ext::printTo(temp,305+(62*(i->first))+57,387+61,GEOR13,zwykly);
|
CSDL_Ext::printTo(temp,305+(62*(i->first))+57,387+61,GEOR13,zwykly,to);
|
||||||
}
|
}
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
void CCastleInterface::show(SDL_Surface * to)
|
||||||
|
{
|
||||||
|
if (!to)
|
||||||
|
to=ekran;
|
||||||
|
count++;
|
||||||
|
if(count==5)
|
||||||
|
{
|
||||||
|
count=0;
|
||||||
|
animval++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//blit buildings
|
//blit buildings
|
||||||
for(int i=0;i<buildings.size();i++)
|
for(int i=0;i<buildings.size();i++)
|
||||||
{
|
{
|
||||||
blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y);
|
if((animval)%(buildings[i]->def->ourImages.size()))
|
||||||
|
{
|
||||||
|
blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||||
|
blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||||
}
|
}
|
||||||
|
//for(int i=0;i<buildings.size();i++)
|
||||||
|
//{
|
||||||
|
// if((animval)%(buildings[i]->def->ourImages.size())==0)
|
||||||
|
// blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||||
|
// else continue;
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
void CCastleInterface::activate()
|
void CCastleInterface::activate()
|
||||||
|
@@ -24,13 +24,15 @@ public:
|
|||||||
void clickRight (tribool down);
|
void clickRight (tribool down);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCastleInterface
|
class CCastleInterface : public IShowable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SDL_Surface * townInt;
|
SDL_Surface * townInt;
|
||||||
SDL_Surface * cityBg;
|
SDL_Surface * cityBg;
|
||||||
const CGTownInstance * town;
|
const CGTownInstance * town;
|
||||||
|
|
||||||
|
unsigned char animval, count;
|
||||||
|
|
||||||
CDefHandler *hall,*fort,
|
CDefHandler *hall,*fort,
|
||||||
*bigTownPic, *flag;
|
*bigTownPic, *flag;
|
||||||
|
|
||||||
@@ -40,7 +42,8 @@ public:
|
|||||||
|
|
||||||
CCastleInterface(const CGTownInstance * Town, bool Activate=true);
|
CCastleInterface(const CGTownInstance * Town, bool Activate=true);
|
||||||
~CCastleInterface();
|
~CCastleInterface();
|
||||||
void show();
|
void show(SDL_Surface * to=NULL);
|
||||||
|
void showAll(SDL_Surface * to=NULL);
|
||||||
void close();
|
void close();
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
|
Reference in New Issue
Block a user