mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
A patch from Gernsworth that fixes #166. CGStatusBar is extended to support alignment, old CStatusBar class is removed.
This commit is contained in:
@ -109,7 +109,7 @@ public:
|
|||||||
SDL_Surface * bg;
|
SDL_Surface * bg;
|
||||||
std::vector<CDefHandler *> gems;
|
std::vector<CDefHandler *> gems;
|
||||||
CMinimap minimap;
|
CMinimap minimap;
|
||||||
CStatusBar statusbar;
|
CGStatusBar statusbar;
|
||||||
|
|
||||||
CAdventureMapButton kingOverview,//- kingdom overview
|
CAdventureMapButton kingOverview,//- kingdom overview
|
||||||
underground,//- underground switch
|
underground,//- underground switch
|
||||||
|
@ -54,7 +54,6 @@ class CInGameConsole;
|
|||||||
class CGarrisonInt;
|
class CGarrisonInt;
|
||||||
class CInGameConsole;
|
class CInGameConsole;
|
||||||
union SDL_Event;
|
union SDL_Event;
|
||||||
class IStatusBar;
|
|
||||||
class CInfoWindow;
|
class CInfoWindow;
|
||||||
class IShowActivatable;
|
class IShowActivatable;
|
||||||
class ClickableL;
|
class ClickableL;
|
||||||
|
@ -158,31 +158,31 @@ CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPl
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusBar = new CStatusBar(7 + pos.x, 569 + pos.y, "Spelroll.bmp");
|
statusBar = new CGStatusBar(7 + pos.x, 569 + pos.y, "Spelroll.bmp");
|
||||||
SDL_Rect temp_rect = genRect(45, 35, 479 + pos.x, 405 + pos.y);
|
SDL_Rect temp_rect = genRect(45, 35, 479 + pos.x, 405 + pos.y);
|
||||||
exitBtn = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fexitb, this), CGI->generaltexth->zelp[460].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[460].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
exitBtn = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fexitb, this), CGI->generaltexth->zelp[460].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[460].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(45, 35, 221 + pos.x, 405 + pos.y);
|
temp_rect = genRect(45, 35, 221 + pos.x, 405 + pos.y);
|
||||||
battleSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fbattleSpellsb, this), CGI->generaltexth->zelp[453].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[453].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
battleSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fbattleSpellsb, this), CGI->generaltexth->zelp[453].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[453].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(45, 35, 355 + pos.x, 405 + pos.y);
|
temp_rect = genRect(45, 35, 355 + pos.x, 405 + pos.y);
|
||||||
adventureSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fadvSpellsb, this), CGI->generaltexth->zelp[452].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[452].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
adventureSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fadvSpellsb, this), CGI->generaltexth->zelp[452].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[452].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(45, 35, 418 + pos.x, 405 + pos.y);
|
temp_rect = genRect(45, 35, 418 + pos.x, 405 + pos.y);
|
||||||
manaPoints = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fmanaPtsb, this), CGI->generaltexth->zelp[459].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[459].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
manaPoints = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fmanaPtsb, this), CGI->generaltexth->zelp[459].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[459].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
|
|
||||||
temp_rect = genRect(36, 56, 549 + pos.x, 94 + pos.y);
|
temp_rect = genRect(36, 56, 549 + pos.x, 94 + pos.y);
|
||||||
selectSpellsA = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 0), CGI->generaltexth->zelp[454].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[454].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
selectSpellsA = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 0), CGI->generaltexth->zelp[454].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[454].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(36, 56, 549 + pos.x, 151 + pos.y);
|
temp_rect = genRect(36, 56, 549 + pos.x, 151 + pos.y);
|
||||||
selectSpellsE = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 3), CGI->generaltexth->zelp[457].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[457].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
selectSpellsE = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 3), CGI->generaltexth->zelp[457].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[457].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(36, 56, 549 + pos.x, 210 + pos.y);
|
temp_rect = genRect(36, 56, 549 + pos.x, 210 + pos.y);
|
||||||
selectSpellsF = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 1), CGI->generaltexth->zelp[455].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[455].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
selectSpellsF = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 1), CGI->generaltexth->zelp[455].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[455].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(36, 56, 549 + pos.x, 270 + pos.y);
|
temp_rect = genRect(36, 56, 549 + pos.x, 270 + pos.y);
|
||||||
selectSpellsW = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 2), CGI->generaltexth->zelp[456].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[456].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
selectSpellsW = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 2), CGI->generaltexth->zelp[456].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[456].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(36, 56, 549 + pos.x, 330 + pos.y);
|
temp_rect = genRect(36, 56, 549 + pos.x, 330 + pos.y);
|
||||||
selectSpellsAll = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 4), CGI->generaltexth->zelp[458].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[458].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
selectSpellsAll = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 4), CGI->generaltexth->zelp[458].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[458].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
|
|
||||||
temp_rect = genRect(leftCorner->h, leftCorner->w, 97 + pos.x, 77 + pos.y);
|
temp_rect = genRect(leftCorner->h, leftCorner->w, 97 + pos.x, 77 + pos.y);
|
||||||
lCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fLcornerb, this), CGI->generaltexth->zelp[450].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[450].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
lCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fLcornerb, this), CGI->generaltexth->zelp[450].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[450].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
temp_rect = genRect(rightCorner->h, rightCorner->w, 487 + pos.x, 72 + pos.y);
|
temp_rect = genRect(rightCorner->h, rightCorner->w, 487 + pos.x, 72 + pos.y);
|
||||||
rCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fRcornerb, this), CGI->generaltexth->zelp[451].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[451].first)), boost::bind(&CStatusBar::clear, statusBar), myInt);
|
rCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fRcornerb, this), CGI->generaltexth->zelp[451].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[451].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
|
||||||
|
|
||||||
//areas for spells
|
//areas for spells
|
||||||
int xpos = 117 + pos.x, ypos = 90 + pos.y;
|
int xpos = 117 + pos.x, ypos = 90 + pos.y;
|
||||||
|
@ -17,7 +17,7 @@ struct SDL_Surface;
|
|||||||
class CDefHandler;
|
class CDefHandler;
|
||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
class CStatusBar;
|
class CGStatusBar;
|
||||||
class CPlayerInterface;
|
class CPlayerInterface;
|
||||||
|
|
||||||
/// Spellbook button is used by the spell window class
|
/// Spellbook button is used by the spell window class
|
||||||
@ -71,7 +71,7 @@ private:
|
|||||||
SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
|
SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
|
||||||
SpellbookInteractiveArea * lCorner, * rCorner;
|
SpellbookInteractiveArea * lCorner, * rCorner;
|
||||||
SpellArea * spellAreas[12];
|
SpellArea * spellAreas[12];
|
||||||
CStatusBar * statusBar;
|
CGStatusBar * statusBar;
|
||||||
|
|
||||||
Uint8 sitesPerTabAdv[5];
|
Uint8 sitesPerTabAdv[5];
|
||||||
Uint8 sitesPerTabBattle[5];
|
Uint8 sitesPerTabBattle[5];
|
||||||
|
@ -3939,7 +3939,12 @@ void CInGameConsole::startEnteringText()
|
|||||||
enteredText = "_";
|
enteredText = "_";
|
||||||
if(GH.topInt() == adventureInt)
|
if(GH.topInt() == adventureInt)
|
||||||
{
|
{
|
||||||
|
GH.statusbar->alignment = TOPLEFT;
|
||||||
|
GH.statusbar->calcOffset();
|
||||||
GH.statusbar->print(enteredText);
|
GH.statusbar->print(enteredText);
|
||||||
|
|
||||||
|
//Prevent changes to the text from mouse interaction with the adventure map
|
||||||
|
GH.statusbar->lock(true);
|
||||||
}
|
}
|
||||||
else if(LOCPLINT->battleInt)
|
else if(LOCPLINT->battleInt)
|
||||||
{
|
{
|
||||||
@ -3960,7 +3965,10 @@ void CInGameConsole::endEnteringText(bool printEnteredText)
|
|||||||
enteredText = "";
|
enteredText = "";
|
||||||
if(GH.topInt() == adventureInt)
|
if(GH.topInt() == adventureInt)
|
||||||
{
|
{
|
||||||
GH.statusbar->clear();
|
GH.statusbar->alignment = CENTER;
|
||||||
|
GH.statusbar->calcOffset();
|
||||||
|
GH.statusbar->lock(false);
|
||||||
|
GH.statusbar->clear();
|
||||||
}
|
}
|
||||||
else if(LOCPLINT->battleInt)
|
else if(LOCPLINT->battleInt)
|
||||||
{
|
{
|
||||||
@ -3972,7 +3980,10 @@ void CInGameConsole::refreshEnteredText()
|
|||||||
{
|
{
|
||||||
if(GH.topInt() == adventureInt)
|
if(GH.topInt() == adventureInt)
|
||||||
{
|
{
|
||||||
|
GH.statusbar->lock(false);
|
||||||
|
GH.statusbar->clear();
|
||||||
GH.statusbar->print(enteredText);
|
GH.statusbar->print(enteredText);
|
||||||
|
GH.statusbar->lock(true);
|
||||||
}
|
}
|
||||||
else if(LOCPLINT->battleInt)
|
else if(LOCPLINT->battleInt)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "Geometries.h"
|
#include "Geometries.h"
|
||||||
|
|
||||||
class CFramerateManager;
|
class CFramerateManager;
|
||||||
class IStatusBar;
|
class CGStatusBar;
|
||||||
class CIntObject;
|
class CIntObject;
|
||||||
class IUpdateable;
|
class IUpdateable;
|
||||||
class IShowActivatable;
|
class IShowActivatable;
|
||||||
@ -43,7 +43,7 @@ class CGuiHandler
|
|||||||
public:
|
public:
|
||||||
CFramerateManager * mainFPSmng; //to keep const framerate
|
CFramerateManager * mainFPSmng; //to keep const framerate
|
||||||
std::list<IShowActivatable *> listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on)
|
std::list<IShowActivatable *> listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on)
|
||||||
IStatusBar * statusbar;
|
CGStatusBar * statusbar;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::list<CIntObject*> CIntObjectList;
|
typedef std::list<CIntObject*> CIntObjectList;
|
||||||
|
@ -59,16 +59,6 @@ public:
|
|||||||
virtual ~IShowActivatable(){}; //d-tor
|
virtual ~IShowActivatable(){}; //d-tor
|
||||||
};
|
};
|
||||||
|
|
||||||
// Status bar interface
|
|
||||||
class IStatusBar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IStatusBar(){}; //d-tor
|
|
||||||
virtual void print(const std::string & text)=0; //prints text and refreshes statusbar
|
|
||||||
virtual void clear()=0;//clears statusbar and refreshes
|
|
||||||
virtual std::string getCurrent()=0; //returns currently displayed text
|
|
||||||
};
|
|
||||||
|
|
||||||
//typedef ui16 ActivityFlag;
|
//typedef ui16 ActivityFlag;
|
||||||
|
|
||||||
// Base UI element
|
// Base UI element
|
||||||
|
@ -1099,63 +1099,6 @@ CSimpleWindow::~CSimpleWindow()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusBar::CStatusBar(int x, int y, std::string name, int maxw)
|
|
||||||
{
|
|
||||||
bg=BitmapHandler::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)+pos.x;
|
|
||||||
middley=(bg->h/2)+pos.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
CStatusBar::~CStatusBar()
|
|
||||||
{
|
|
||||||
SDL_FreeSurface(bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStatusBar::clear()
|
|
||||||
{
|
|
||||||
if(LOCPLINT->cingconsole->enteredText == "") //for appropriate support for in-game console
|
|
||||||
{
|
|
||||||
current="";
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStatusBar::print(const std::string & text)
|
|
||||||
{
|
|
||||||
if(LOCPLINT->cingconsole->enteredText == "" || text == LOCPLINT->cingconsole->enteredText) //for appropriate support for in-game console
|
|
||||||
{
|
|
||||||
current=text;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStatusBar::showAll(SDL_Surface * to)
|
|
||||||
{
|
|
||||||
show(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStatusBar::show(SDL_Surface * to)
|
|
||||||
{
|
|
||||||
SDL_Rect srcRect = genRect(pos.h,pos.w,0,0);
|
|
||||||
SDL_Rect dstRect = genRect(pos.h,pos.w,pos.x,pos.y);
|
|
||||||
CSDL_Ext::blitSurface(bg,&srcRect,to,&dstRect);
|
|
||||||
|
|
||||||
graphics->fonts[FONT_SMALL]->renderTextCenter(to, current, Colors::WHITE, Point(middlex, middley));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CStatusBar::getCurrent()
|
|
||||||
{
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHoverableArea::hover (bool on)
|
void CHoverableArea::hover (bool on)
|
||||||
{
|
{
|
||||||
if (on)
|
if (on)
|
||||||
@ -1215,7 +1158,8 @@ void CLabel::showAll(SDL_Surface * to)
|
|||||||
if(!toPrint.length())
|
if(!toPrint.length())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blitLine(to, pos.topLeft()/2 + pos.bottomRight()/2, toPrint);
|
//blitLine(to, pos.topLeft()/2 + pos.bottomRight()/2, toPrint);
|
||||||
|
blitLine(to, pos.topLeft() + textOffset, toPrint);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1439,14 +1383,18 @@ void CTextBox::sliderMoved(int to)
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Point CGStatusBar::edgeOffset = Point(5, 1);
|
||||||
|
|
||||||
void CGStatusBar::print(const std::string & Text)
|
void CGStatusBar::print(const std::string & Text)
|
||||||
{
|
{
|
||||||
setTxt(Text);
|
if(!textLock)
|
||||||
|
setTxt(Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGStatusBar::clear()
|
void CGStatusBar::clear()
|
||||||
{
|
{
|
||||||
setTxt("");
|
if(!textLock)
|
||||||
|
setTxt("");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CGStatusBar::getCurrent()
|
std::string CGStatusBar::getCurrent()
|
||||||
@ -1468,6 +1416,7 @@ CGStatusBar::CGStatusBar(CPicture *BG, EFonts Font /*= FONT_SMALL*/, EAlignment
|
|||||||
addChild(bg);
|
addChild(bg);
|
||||||
pos = bg->pos;
|
pos = bg->pos;
|
||||||
calcOffset();
|
calcOffset();
|
||||||
|
textLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGStatusBar::CGStatusBar(int x, int y, std::string name/*="ADROLLVR.bmp"*/, int maxw/*=-1*/)
|
CGStatusBar::CGStatusBar(int x, int y, std::string name/*="ADROLLVR.bmp"*/, int maxw/*=-1*/)
|
||||||
@ -1477,12 +1426,13 @@ CGStatusBar::CGStatusBar(int x, int y, std::string name/*="ADROLLVR.bmp"*/, int
|
|||||||
init();
|
init();
|
||||||
bg = new CPicture(name);
|
bg = new CPicture(name);
|
||||||
pos = bg->pos;
|
pos = bg->pos;
|
||||||
if(maxw < pos.w)
|
if((unsigned int)maxw < pos.w)
|
||||||
{
|
{
|
||||||
vstd::amin(pos.w, maxw);
|
vstd::amin(pos.w, maxw);
|
||||||
bg->srcRect = new Rect(0, 0, maxw, pos.h);
|
bg->srcRect = new Rect(0, 0, maxw, pos.h);
|
||||||
}
|
}
|
||||||
calcOffset();
|
calcOffset();
|
||||||
|
textLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGStatusBar::~CGStatusBar()
|
CGStatusBar::~CGStatusBar()
|
||||||
@ -1492,7 +1442,7 @@ CGStatusBar::~CGStatusBar()
|
|||||||
|
|
||||||
void CGStatusBar::show(SDL_Surface * to)
|
void CGStatusBar::show(SDL_Surface * to)
|
||||||
{
|
{
|
||||||
|
showAll(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGStatusBar::init()
|
void CGStatusBar::init()
|
||||||
@ -1505,15 +1455,23 @@ void CGStatusBar::calcOffset()
|
|||||||
{
|
{
|
||||||
switch(alignment)
|
switch(alignment)
|
||||||
{
|
{
|
||||||
|
case TOPLEFT:
|
||||||
|
textOffset = Point(edgeOffset.x, edgeOffset.y);
|
||||||
|
break;
|
||||||
case CENTER:
|
case CENTER:
|
||||||
textOffset = Point(pos.w/2, pos.h/2);
|
textOffset = Point(pos.w/2, pos.h/2);
|
||||||
break;
|
break;
|
||||||
case BOTTOMRIGHT:
|
case BOTTOMRIGHT:
|
||||||
textOffset = Point(pos.w, pos.h);
|
textOffset = Point(pos.w - edgeOffset.x, pos.h - edgeOffset.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGStatusBar::lock(bool shouldLock)
|
||||||
|
{
|
||||||
|
textLock = shouldLock;
|
||||||
|
}
|
||||||
|
|
||||||
CTextInput::CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB):
|
CTextInput::CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB):
|
||||||
CLabel(Pos.x, Pos.y, font, CENTER),
|
CLabel(Pos.x, Pos.y, font, CENTER),
|
||||||
cb(CB)
|
cb(CB)
|
||||||
|
@ -312,23 +312,6 @@ public:
|
|||||||
size_t getPos();
|
size_t getPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Status bar which is shown at the bottom of the in-game screens
|
|
||||||
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(const std::string & text); //prints text and refreshes statusbar
|
|
||||||
void clear();//clears statusbar and refreshes
|
|
||||||
void showAll(SDL_Surface * to); //shows statusbar (with current text)
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
std::string getCurrent(); //getter for current
|
|
||||||
};
|
|
||||||
|
|
||||||
class CTextContainer : public virtual CIntObject
|
class CTextContainer : public virtual CIntObject
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -409,11 +392,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Status bar which is shown at the bottom of the in-game screens
|
/// Status bar which is shown at the bottom of the in-game screens
|
||||||
class CGStatusBar : public CLabel, public IStatusBar
|
class CGStatusBar : public CLabel
|
||||||
{
|
{
|
||||||
|
bool textLock; //Used for blocking changes to the text
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
IStatusBar *oldStatusBar;
|
CGStatusBar *oldStatusBar;
|
||||||
|
|
||||||
//statusbar interface overloads
|
//statusbar interface overloads
|
||||||
void print(const std::string & Text); //prints text and refreshes statusbar
|
void print(const std::string & Text); //prints text and refreshes statusbar
|
||||||
@ -427,6 +411,10 @@ public:
|
|||||||
|
|
||||||
~CGStatusBar();
|
~CGStatusBar();
|
||||||
void calcOffset();
|
void calcOffset();
|
||||||
|
|
||||||
|
void lock(bool shouldLock); //If true, current text cannot be changed until lock(false) is called
|
||||||
|
|
||||||
|
const static Point edgeOffset; //Amount to move text from side when alignment is left or right
|
||||||
};
|
};
|
||||||
|
|
||||||
/// UIElement which can get input focus
|
/// UIElement which can get input focus
|
||||||
|
Reference in New Issue
Block a user