1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

* custom statusbar in town interface

* added missing file
This commit is contained in:
Michał W. Urbańczyk
2008-01-27 20:37:10 +00:00
parent 74cce9b7a0
commit 9ed4f66cb7
10 changed files with 126 additions and 50 deletions

View File

@ -1836,4 +1836,45 @@ void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
this->objsToBlit.push_back(adventureInt->heroWindow);
adventureInt->hide();
adventureInt->heroWindow->activate();
}
CStatusBar::CStatusBar(int x, int y, std::string name, int maxw)
{
bg=CGI->bitmaph->loadBitmap(name);
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
pos.x=x;
pos.y=y;
if(maxw >= 0)
pos.w = std::min(bg->w,maxw);
else
pos.w=bg->w;
pos.h=bg->h;
middlex=(pos.w/2)+x;
middley=(bg->h/2)+y;
}
CStatusBar::~CStatusBar()
{
SDL_FreeSurface(bg);
}
void CStatusBar::clear()
{
current="";
SDL_Rect pom = genRect(pos.h,pos.w,pos.x,pos.y);
SDL_BlitSurface(bg,&genRect(pos.h,pos.w,0,0),ekran,&pom);
}
void CStatusBar::print(std::string text)
{
current=text;
SDL_Rect pom = genRect(pos.h,pos.w,pos.x,pos.y);
SDL_BlitSurface(bg,&genRect(pos.h,pos.w,0,0),ekran,&pom);
printAtMiddle(current,middlex,middley,GEOR13,zwykly);
}
void CStatusBar::show()
{
SDL_Rect pom = genRect(pos.h,pos.w,pos.x,pos.y);
SDL_BlitSurface(bg,&genRect(pos.h,pos.w,0,0),ekran,&pom);
printAtMiddle(current,middlex,middley,GEOR13,zwykly);
}
std::string CStatusBar::getCurrent()
{
return current;
}