mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +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);
|
Hoverable::hover(on);
|
||||||
if (on)
|
if (on)
|
||||||
LOCPLINT->adventureInt->statusbar.print(name);
|
LOCPLINT->statusbar->print(name);
|
||||||
else if (LOCPLINT->adventureInt->statusbar.current==name)
|
else if (LOCPLINT->statusbar->getCurrent()==name)
|
||||||
LOCPLINT->adventureInt->statusbar.clear();
|
LOCPLINT->statusbar->clear();
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AdventureMapButton<T>::activate()
|
void AdventureMapButton<T>::activate()
|
||||||
|
@ -459,37 +459,6 @@ void CTownList::draw()
|
|||||||
else
|
else
|
||||||
blitAt(arrdo->ourImages[2].bitmap,arrdop.x,arrdop.y);
|
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)
|
CMinimap::CMinimap(bool draw)
|
||||||
{
|
{
|
||||||
statusbarTxt = CGI->preth->advWorldMap.first;
|
statusbarTxt = CGI->preth->advWorldMap.first;
|
||||||
@ -1360,6 +1329,7 @@ void CAdvMapInt::deactivate()
|
|||||||
void CAdvMapInt::show()
|
void CAdvMapInt::show()
|
||||||
{
|
{
|
||||||
LOCPLINT->curint = this;
|
LOCPLINT->curint = this;
|
||||||
|
LOCPLINT->statusbar = &statusbar;
|
||||||
blitAt(bg,0,0);
|
blitAt(bg,0,0);
|
||||||
|
|
||||||
kingOverview.show();
|
kingOverview.show();
|
||||||
|
@ -95,20 +95,6 @@ public:
|
|||||||
void keyPressed (SDL_KeyboardEvent & key);
|
void keyPressed (SDL_KeyboardEvent & key);
|
||||||
void draw();
|
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
|
class CMinimap
|
||||||
: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
|
: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,10 @@ void CBuildingRect::hover(bool on)
|
|||||||
{
|
{
|
||||||
MotionInterested::deactivate();
|
MotionInterested::deactivate();
|
||||||
if(LOCPLINT->castleInt->hBuild == this)
|
if(LOCPLINT->castleInt->hBuild == this)
|
||||||
|
{
|
||||||
LOCPLINT->castleInt->hBuild = NULL;
|
LOCPLINT->castleInt->hBuild = NULL;
|
||||||
|
LOCPLINT->statusbar->clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CBuildingRect::clickLeft (tribool down)
|
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(CSDL_Ext::SDL_GetPixel(area,sEvent.x-pos.x,sEvent.y-pos.y) == 0) //najechany piksel jest poza polem
|
||||||
{
|
{
|
||||||
if(LOCPLINT->castleInt->hBuild == this)
|
if(LOCPLINT->castleInt->hBuild == this)
|
||||||
|
{
|
||||||
LOCPLINT->castleInt->hBuild = NULL;
|
LOCPLINT->castleInt->hBuild = NULL;
|
||||||
|
LOCPLINT->statusbar->clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else //w polu
|
else //w polu
|
||||||
{
|
{
|
||||||
@ -93,11 +99,13 @@ void CBuildingRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
|||||||
if((*LOCPLINT->castleInt->hBuild)<(*this)) //ustawiamy sie, jesli jestesmy na wierzchu
|
if((*LOCPLINT->castleInt->hBuild)<(*this)) //ustawiamy sie, jesli jestesmy na wierzchu
|
||||||
{
|
{
|
||||||
LOCPLINT->castleInt->hBuild = this;
|
LOCPLINT->castleInt->hBuild = this;
|
||||||
|
LOCPLINT->statusbar->print(str->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //nie ma budynku, wiec damy nasz
|
else //nie ma budynku, wiec damy nasz
|
||||||
{
|
{
|
||||||
LOCPLINT->castleInt->hBuild = this;
|
LOCPLINT->castleInt->hBuild = this;
|
||||||
|
LOCPLINT->statusbar->print(str->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +165,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
|||||||
exit = new AdventureMapButton<CCastleInterface>
|
exit = new AdventureMapButton<CCastleInterface>
|
||||||
(CGI->townh->tcommands[8],"",&CCastleInterface::close,744,544,"TSBTNS.DEF",this,false);
|
(CGI->townh->tcommands[8],"",&CCastleInterface::close,744,544,"TSBTNS.DEF",this,false);
|
||||||
exit->bitmapOffset = 4;
|
exit->bitmapOffset = 4;
|
||||||
|
statusbar = new CStatusBar(8,555,"TSTATBAR.bmp",732);
|
||||||
std::set< std::pair<int,int> > s; //group - id
|
std::set< std::pair<int,int> > s; //group - id
|
||||||
|
|
||||||
for (std::set<int>::const_iterator i=town->builtBuildings.begin();i!=town->builtBuildings.end();i++)
|
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)
|
if (!to)
|
||||||
to=ekran;
|
to=ekran;
|
||||||
|
statusbar->show();
|
||||||
blitAt(cityBg,0,0,to);
|
blitAt(cityBg,0,0,to);
|
||||||
blitAt(townInt,0,374,to);
|
blitAt(townInt,0,374,to);
|
||||||
LOCPLINT->adventureInt->resdatabar.draw();
|
LOCPLINT->adventureInt->resdatabar.draw();
|
||||||
@ -376,6 +385,7 @@ void CCastleInterface::activate()
|
|||||||
{
|
{
|
||||||
garr->activate();
|
garr->activate();
|
||||||
LOCPLINT->curint = this;
|
LOCPLINT->curint = this;
|
||||||
|
LOCPLINT->statusbar = statusbar;
|
||||||
exit->activate();
|
exit->activate();
|
||||||
for(int i=0;i<buildings.size();i++)
|
for(int i=0;i<buildings.size();i++)
|
||||||
buildings[i]->activate();
|
buildings[i]->activate();
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
SDL_Surface * townInt;
|
SDL_Surface * townInt;
|
||||||
SDL_Surface * cityBg;
|
SDL_Surface * cityBg;
|
||||||
const CGTownInstance * town;
|
const CGTownInstance * town;
|
||||||
|
CStatusBar * statusbar;
|
||||||
|
|
||||||
unsigned char animval, count;
|
unsigned char animval, count;
|
||||||
|
|
||||||
|
@ -1836,4 +1836,45 @@ void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
|
|||||||
this->objsToBlit.push_back(adventureInt->heroWindow);
|
this->objsToBlit.push_back(adventureInt->heroWindow);
|
||||||
adventureInt->hide();
|
adventureInt->hide();
|
||||||
adventureInt->heroWindow->activate();
|
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;
|
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
|
class IActivable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -234,6 +244,7 @@ public:
|
|||||||
CAdvMapInt * adventureInt;
|
CAdvMapInt * adventureInt;
|
||||||
CCastleInterface * castleInt;
|
CCastleInterface * castleInt;
|
||||||
FPSmanager * mainFPSmng;
|
FPSmanager * mainFPSmng;
|
||||||
|
IStatusBar *statusbar;
|
||||||
//TODO: town interace, battle interface, other interfaces
|
//TODO: town interace, battle interface, other interfaces
|
||||||
|
|
||||||
CCallback * cb;
|
CCallback * cb;
|
||||||
@ -283,4 +294,19 @@ public:
|
|||||||
SDL_Surface * drawTownInfoWin(const CGTownInstance * curh);
|
SDL_Surface * drawTownInfoWin(const CGTownInstance * curh);
|
||||||
|
|
||||||
CPlayerInterface(int Player, int serial);
|
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->townID;
|
||||||
of >> vinya->ID;
|
of >> vinya->ID;
|
||||||
of >> vinya->defName;
|
of >> vinya->defName;
|
||||||
|
vinya->name = vinya->defName; //TODO - use normal names
|
||||||
of >> vinya->pos.x;
|
of >> vinya->pos.x;
|
||||||
of >> vinya->pos.y;
|
of >> vinya->pos.y;
|
||||||
vinya->pos.z = 0;
|
vinya->pos.z = 0;
|
||||||
|
@ -27,7 +27,7 @@ struct Structure
|
|||||||
{
|
{
|
||||||
int ID;
|
int ID;
|
||||||
int3 pos;
|
int3 pos;
|
||||||
std::string defName, borderName, areaName;
|
std::string defName, borderName, areaName, name;
|
||||||
int townID, group;
|
int townID, group;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user