mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
* custom statusbar in town interface
* added missing file
This commit is contained in:
parent
74cce9b7a0
commit
9ed4f66cb7
@ -91,9 +91,9 @@ void AdventureMapButton<T>::hover (bool on)
|
||||
{
|
||||
Hoverable::hover(on);
|
||||
if (on)
|
||||
LOCPLINT->adventureInt->statusbar.print(name);
|
||||
else if (LOCPLINT->adventureInt->statusbar.current==name)
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
LOCPLINT->statusbar->print(name);
|
||||
else if (LOCPLINT->statusbar->getCurrent()==name)
|
||||
LOCPLINT->statusbar->clear();
|
||||
}
|
||||
template <typename T>
|
||||
void AdventureMapButton<T>::activate()
|
||||
|
@ -459,37 +459,6 @@ void CTownList::draw()
|
||||
else
|
||||
blitAt(arrdo->ourImages[2].bitmap,arrdop.x,arrdop.y);
|
||||
}
|
||||
CStatusBar::CStatusBar(int x, int y)
|
||||
{
|
||||
bg=CGI->bitmaph->loadBitmap("ADROLLVR.bmp");
|
||||
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
||||
pos.x=x;
|
||||
pos.y=y;
|
||||
pos.w=bg->w;
|
||||
pos.h=bg->h;
|
||||
middlex=(bg->w/2)+x;
|
||||
middley=(bg->h/2)+y;
|
||||
}
|
||||
CStatusBar::~CStatusBar()
|
||||
{
|
||||
SDL_FreeSurface(bg);
|
||||
}
|
||||
void CStatusBar::clear()
|
||||
{
|
||||
current="";
|
||||
blitAt(bg,pos.x,pos.y);
|
||||
}
|
||||
void CStatusBar::print(std::string text)
|
||||
{
|
||||
current=text;
|
||||
blitAt(bg,pos.x,pos.y);
|
||||
printAtMiddle(current,middlex,middley,GEOR13,zwykly);
|
||||
}
|
||||
void CStatusBar::show()
|
||||
{
|
||||
blitAt(bg,pos.x,pos.y);
|
||||
printAtMiddle(current,middlex,middley,GEOR13,zwykly);
|
||||
}
|
||||
CMinimap::CMinimap(bool draw)
|
||||
{
|
||||
statusbarTxt = CGI->preth->advWorldMap.first;
|
||||
@ -1360,6 +1329,7 @@ void CAdvMapInt::deactivate()
|
||||
void CAdvMapInt::show()
|
||||
{
|
||||
LOCPLINT->curint = this;
|
||||
LOCPLINT->statusbar = &statusbar;
|
||||
blitAt(bg,0,0);
|
||||
|
||||
kingOverview.show();
|
||||
|
@ -95,20 +95,6 @@ public:
|
||||
void keyPressed (SDL_KeyboardEvent & key);
|
||||
void draw();
|
||||
};
|
||||
class CStatusBar
|
||||
: public CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg; //background
|
||||
int middlex, middley; //middle of statusbar
|
||||
std::string current; //text currently printed
|
||||
|
||||
CStatusBar(int x, int y); //c-tor
|
||||
~CStatusBar(); //d-tor
|
||||
void print(std::string text); //prints text and refreshes statusbar
|
||||
void clear();//clears statusbar and refreshes
|
||||
void show(); //shows statusbar (with current text)
|
||||
};
|
||||
class CMinimap
|
||||
: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
|
||||
{
|
||||
|
@ -65,7 +65,10 @@ void CBuildingRect::hover(bool on)
|
||||
{
|
||||
MotionInterested::deactivate();
|
||||
if(LOCPLINT->castleInt->hBuild == this)
|
||||
{
|
||||
LOCPLINT->castleInt->hBuild = NULL;
|
||||
LOCPLINT->statusbar->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
void CBuildingRect::clickLeft (tribool down)
|
||||
@ -84,7 +87,10 @@ void CBuildingRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
||||
if(CSDL_Ext::SDL_GetPixel(area,sEvent.x-pos.x,sEvent.y-pos.y) == 0) //najechany piksel jest poza polem
|
||||
{
|
||||
if(LOCPLINT->castleInt->hBuild == this)
|
||||
{
|
||||
LOCPLINT->castleInt->hBuild = NULL;
|
||||
LOCPLINT->statusbar->clear();
|
||||
}
|
||||
}
|
||||
else //w polu
|
||||
{
|
||||
@ -93,11 +99,13 @@ void CBuildingRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
||||
if((*LOCPLINT->castleInt->hBuild)<(*this)) //ustawiamy sie, jesli jestesmy na wierzchu
|
||||
{
|
||||
LOCPLINT->castleInt->hBuild = this;
|
||||
LOCPLINT->statusbar->print(str->name);
|
||||
}
|
||||
}
|
||||
else //nie ma budynku, wiec damy nasz
|
||||
{
|
||||
LOCPLINT->castleInt->hBuild = this;
|
||||
LOCPLINT->statusbar->print(str->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,7 +165,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
||||
exit = new AdventureMapButton<CCastleInterface>
|
||||
(CGI->townh->tcommands[8],"",&CCastleInterface::close,744,544,"TSBTNS.DEF",this,false);
|
||||
exit->bitmapOffset = 4;
|
||||
|
||||
statusbar = new CStatusBar(8,555,"TSTATBAR.bmp",732);
|
||||
std::set< std::pair<int,int> > s; //group - id
|
||||
|
||||
for (std::set<int>::const_iterator i=town->builtBuildings.begin();i!=town->builtBuildings.end();i++)
|
||||
@ -254,6 +262,7 @@ void CCastleInterface::showAll(SDL_Surface * to)
|
||||
{
|
||||
if (!to)
|
||||
to=ekran;
|
||||
statusbar->show();
|
||||
blitAt(cityBg,0,0,to);
|
||||
blitAt(townInt,0,374,to);
|
||||
LOCPLINT->adventureInt->resdatabar.draw();
|
||||
@ -376,6 +385,7 @@ void CCastleInterface::activate()
|
||||
{
|
||||
garr->activate();
|
||||
LOCPLINT->curint = this;
|
||||
LOCPLINT->statusbar = statusbar;
|
||||
exit->activate();
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
buildings[i]->activate();
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
SDL_Surface * townInt;
|
||||
SDL_Surface * cityBg;
|
||||
const CGTownInstance * town;
|
||||
CStatusBar * statusbar;
|
||||
|
||||
unsigned char animval, count;
|
||||
|
||||
|
@ -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;
|
||||
}
|
@ -18,6 +18,16 @@ public:
|
||||
virtual void show(SDL_Surface * to = NULL)=0;
|
||||
};
|
||||
|
||||
class IStatusBar
|
||||
{
|
||||
public:
|
||||
virtual ~IStatusBar(){}; //d-tor
|
||||
virtual void print(std::string text)=0; //prints text and refreshes statusbar
|
||||
virtual void clear()=0;//clears statusbar and refreshes
|
||||
virtual void show()=0; //shows statusbar (with current text)
|
||||
virtual std::string getCurrent()=0;
|
||||
};
|
||||
|
||||
class IActivable
|
||||
{
|
||||
public:
|
||||
@ -234,6 +244,7 @@ public:
|
||||
CAdvMapInt * adventureInt;
|
||||
CCastleInterface * castleInt;
|
||||
FPSmanager * mainFPSmng;
|
||||
IStatusBar *statusbar;
|
||||
//TODO: town interace, battle interface, other interfaces
|
||||
|
||||
CCallback * cb;
|
||||
@ -283,4 +294,19 @@ public:
|
||||
SDL_Surface * drawTownInfoWin(const CGTownInstance * curh);
|
||||
|
||||
CPlayerInterface(int Player, int serial);
|
||||
};
|
||||
class CStatusBar
|
||||
: public CIntObject, public IStatusBar
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg; //background
|
||||
int middlex, middley; //middle of statusbar
|
||||
std::string current; //text currently printed
|
||||
|
||||
CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
|
||||
~CStatusBar(); //d-tor
|
||||
void print(std::string text); //prints text and refreshes statusbar
|
||||
void clear();//clears statusbar and refreshes
|
||||
void show(); //shows statusbar (with current text)
|
||||
std::string getCurrent();
|
||||
};
|
41
config/buildings4.txt
Normal file
41
config/buildings4.txt
Normal file
@ -0,0 +1,41 @@
|
||||
1
|
||||
ALL
|
||||
GROUP
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
GROUP
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
GROUP
|
||||
30
|
||||
37
|
||||
GROUP
|
||||
31
|
||||
38
|
||||
GROUP
|
||||
32
|
||||
39
|
||||
GROUP
|
||||
33
|
||||
40
|
||||
GROUP
|
||||
34
|
||||
41
|
||||
GROUP
|
||||
35
|
||||
42
|
||||
GROUP
|
||||
36
|
||||
43
|
||||
GROUP
|
||||
24
|
||||
25
|
||||
GROUP
|
||||
18
|
||||
19
|
||||
EOD
|
@ -54,6 +54,7 @@ void CTownHandler::loadNames()
|
||||
of >> vinya->townID;
|
||||
of >> vinya->ID;
|
||||
of >> vinya->defName;
|
||||
vinya->name = vinya->defName; //TODO - use normal names
|
||||
of >> vinya->pos.x;
|
||||
of >> vinya->pos.y;
|
||||
vinya->pos.z = 0;
|
||||
|
@ -27,7 +27,7 @@ struct Structure
|
||||
{
|
||||
int ID;
|
||||
int3 pos;
|
||||
std::string defName, borderName, areaName;
|
||||
std::string defName, borderName, areaName, name;
|
||||
int townID, group;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user