This commit is contained in:
parent
7f1c8e2012
commit
3b2b2c2001
14 changed files with 287 additions and 272 deletions
|
@ -1,6 +1,6 @@
|
|||
/*=========================================================================
|
||||
|
||||
gui.cpp
|
||||
gbutton.cpp
|
||||
|
||||
Author: PKG
|
||||
Created:
|
||||
|
@ -45,10 +45,6 @@
|
|||
Vars
|
||||
---- */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
@ -57,18 +53,15 @@
|
|||
---------------------------------------------------------------------- */
|
||||
void CGUIGroupFrame::setFlags(GUI_FLAGS _flags)
|
||||
{
|
||||
// int childFlags;
|
||||
|
||||
// childFlags=_flags&(-1^FLAG_SELECTED); // Don't propogate the SELECTED flag
|
||||
|
||||
CGUIObject *pGUI;
|
||||
|
||||
CGUIObject::setFlags(_flags);
|
||||
if(getChild())getChild()->setFlags(_flags);
|
||||
// if(getNext())getNext()->setFlags(_flags);
|
||||
|
||||
// if(_flags&FLAG_SELECTED)
|
||||
// {
|
||||
// selectFrame();
|
||||
// }
|
||||
pGUI=getChild();
|
||||
while(pGUI)
|
||||
{
|
||||
pGUI->setFlags(_flags);
|
||||
pGUI=pGUI->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,62 +73,16 @@ void CGUIGroupFrame::setFlags(GUI_FLAGS _flags)
|
|||
---------------------------------------------------------------------- */
|
||||
void CGUIGroupFrame::clearFlags(GUI_FLAGS _flags)
|
||||
{
|
||||
// int childFlags;
|
||||
|
||||
// childFlags=_flags&(-1^FLAG_SELECTED); // Don't propogate the SELECTED flag
|
||||
|
||||
CGUIObject *pGUI;
|
||||
|
||||
CGUIObject::clearFlags(_flags);
|
||||
if(getChild())getChild()->clearFlags(_flags);
|
||||
// if(getNext())getNext()->clearFlags(_flags);
|
||||
|
||||
// if(_flags&FLAG_SELECTED)
|
||||
// {
|
||||
// unselectFrame();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
/*
|
||||
void CGUIGroupFrame::selectFrame()
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
|
||||
pGUI=getChild();
|
||||
if(pGUI)
|
||||
while(pGUI)
|
||||
{
|
||||
pGUI->select();
|
||||
pGUI->clearFlags(_flags);
|
||||
pGUI=pGUI->getNext();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
/*
|
||||
void CGUIGroupFrame::unselectFrame()
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
|
||||
pGUI=getChild();
|
||||
if(pGUI)
|
||||
{
|
||||
pGUI->unselect();
|
||||
pGUI=pGUI->getNext();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -194,7 +141,6 @@ void CGUIControlFrame::setFlags(GUI_FLAGS _flags)
|
|||
CGUIObject::setFlags(_flags);
|
||||
childFlags=(GUI_FLAGS)(_flags&(-1^FLAG_SELECTED)); // Don't propogate the SELECTED flag
|
||||
if(getChild())getChild()->setFlags(childFlags);
|
||||
// if(getNext())getNext()->setFlags(_flags);
|
||||
|
||||
if(_flags&FLAG_SELECTED)
|
||||
{
|
||||
|
@ -216,7 +162,6 @@ void CGUIControlFrame::clearFlags(GUI_FLAGS _flags)
|
|||
CGUIObject::clearFlags(_flags);
|
||||
childFlags=(GUI_FLAGS)(_flags&(-1^FLAG_SELECTED)); // Don't propogate the SELECTED flag
|
||||
if(getChild())getChild()->clearFlags(childFlags);
|
||||
// if(getNext())getNext()->clearFlags(_flags);
|
||||
|
||||
if(_flags&FLAG_SELECTED)
|
||||
{
|
||||
|
|
|
@ -43,9 +43,6 @@ public:
|
|||
|
||||
protected:
|
||||
GUI_FLAGS getInitialFlags() {return FLAG_DRAWBORDER;}
|
||||
|
||||
// void selectFrame();
|
||||
// void unselectFrame();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*=========================================================================
|
||||
|
||||
gui.cpp
|
||||
greadout.cpp
|
||||
|
||||
Author: PKG
|
||||
Created:
|
||||
|
@ -27,7 +27,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
|
@ -56,16 +55,12 @@
|
|||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUITextReadout::init(GUIId _id)
|
||||
void CGUITextReadout::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIObject::init(_id);
|
||||
CGUIObjectWithFont::init(_parent,_id);
|
||||
m_target=0;
|
||||
m_data=0;
|
||||
m_textId=TranslationDatabase::NO_STRING;
|
||||
m_fontBank=new ("TextBox-Font") FontBank();
|
||||
m_fontBank->initialise(&standardFont);
|
||||
m_fontBank->setJustification(FontBank::JUST_CENTRE);
|
||||
m_fontBank->setOt(CGUIObject::DEFAULT_OT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +104,7 @@ void CGUITextReadout::render()
|
|||
{
|
||||
getFontBank()->print((getW()-(BORDERWIDTH*2))/2,m_textY,m_textId);
|
||||
}
|
||||
CGUIObject::render();
|
||||
CGUIObjectWithFont::render();
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,7 +116,7 @@ void CGUITextReadout::render()
|
|||
---------------------------------------------------------------------- */
|
||||
void CGUITextReadout::think(int _frames)
|
||||
{
|
||||
CGUIObject::think(_frames);
|
||||
CGUIObjectWithFont::think(_frames);
|
||||
if(*m_target!=m_lastValue)
|
||||
{
|
||||
recalc();
|
||||
|
@ -137,7 +132,7 @@ void CGUITextReadout::think(int _frames)
|
|||
---------------------------------------------------------------------- */
|
||||
void CGUITextReadout::recalc()
|
||||
{
|
||||
CGUIObject::recalc();
|
||||
CGUIObjectWithFont::recalc();
|
||||
|
||||
if(m_data)
|
||||
{
|
||||
|
@ -150,7 +145,6 @@ void CGUITextReadout::recalc()
|
|||
m_textId=4;
|
||||
|
||||
fb=getFontBank();
|
||||
fb->setPrintArea(getX()+BORDERWIDTH,getY()+BORDERHEIGHT,getW()-(BORDERWIDTH*2),getH()-(BORDERHEIGHT*2));
|
||||
|
||||
m_textId=STR__DUMMY;
|
||||
data=m_data;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
class CGUITextReadout : public CGUIObject
|
||||
class CGUITextReadout : public CGUIObjectWithFont
|
||||
{
|
||||
public:
|
||||
typedef struct
|
||||
|
@ -44,26 +44,23 @@ public:
|
|||
} TextReadoutData;
|
||||
|
||||
|
||||
virtual void init(GUIId _id);
|
||||
virtual void init(CGUIObject *_parent,GUIId _id);
|
||||
|
||||
virtual void setReadoutTarget(int *_target);
|
||||
virtual void setReadoutData(TextReadoutData *_data);
|
||||
|
||||
|
||||
virtual void render();
|
||||
virtual void think(int _frames);
|
||||
|
||||
|
||||
protected:
|
||||
void recalc();
|
||||
class FontBank *getFontBank() {return m_fontBank;}
|
||||
|
||||
|
||||
private:
|
||||
int *m_target;
|
||||
TextReadoutData *m_data;
|
||||
int m_lastValue;
|
||||
class FontBank *m_fontBank;
|
||||
unsigned int m_textId;
|
||||
int m_textY;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*=========================================================================
|
||||
|
||||
gui.cpp
|
||||
gtextbox.cpp
|
||||
|
||||
Author: PKG
|
||||
Created:
|
||||
|
@ -62,28 +62,10 @@
|
|||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUITextBox::init(GUIId _id)
|
||||
void CGUITextBox::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIObject::init(_id);
|
||||
CGUIObjectWithFont::init(_parent,_id);
|
||||
m_textId=TranslationDatabase::NO_STRING;
|
||||
m_fontBank=new ("TextBox-Font") FontBank();
|
||||
m_fontBank->initialise(&standardFont);
|
||||
m_fontBank->setJustification(FontBank::JUST_CENTRE);
|
||||
m_fontBank->setOt(CGUIObject::DEFAULT_OT);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUITextBox::shutdown()
|
||||
{
|
||||
CGUIObject::shutdown();
|
||||
m_fontBank->dump();
|
||||
m_fontBank=NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +98,7 @@ void CGUITextBox::render()
|
|||
{
|
||||
getFontBank()->print((getW()-(BORDERWIDTH*2))/2,m_textY,m_textId);
|
||||
}
|
||||
CGUIObject::render();
|
||||
CGUIObjectWithFont::render();
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,9 +113,8 @@ void CGUITextBox::recalc()
|
|||
FontBank *fb;
|
||||
char *string;
|
||||
|
||||
CGUIObject::recalc();
|
||||
CGUIObjectWithFont::recalc();
|
||||
fb=getFontBank();
|
||||
fb->setPrintArea(getX()+BORDERWIDTH,getY()+BORDERHEIGHT,getW()-(BORDERWIDTH*2),getH()-(BORDERHEIGHT*2));
|
||||
string=(char*)TranslationDatabase::getString(m_textId);
|
||||
|
||||
#ifdef __VERSION_DEBUG__
|
||||
|
|
|
@ -34,11 +34,10 @@
|
|||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
class CGUITextBox : public CGUIObject
|
||||
class CGUITextBox : public CGUIObjectWithFont
|
||||
{
|
||||
public:
|
||||
virtual void init(GUIId _id);
|
||||
virtual void shutdown();
|
||||
virtual void init(CGUIObject *_parent,GUIId _id);
|
||||
|
||||
virtual void setText(unsigned int _textId);
|
||||
|
||||
|
@ -47,11 +46,9 @@ public:
|
|||
|
||||
protected:
|
||||
void recalc();
|
||||
class FontBank *getFontBank() {return m_fontBank;}
|
||||
|
||||
|
||||
private:
|
||||
class FontBank *m_fontBank;
|
||||
unsigned int m_textId;
|
||||
int m_textY;
|
||||
|
||||
|
|
|
@ -53,17 +53,13 @@
|
|||
Vars
|
||||
---- */
|
||||
|
||||
CGUIObject *CGUIObject::s_llBase=NULL;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIObject::init(GUIId _id)
|
||||
void CGUIObject::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
ASSERT(this!=m_this);
|
||||
|
||||
|
@ -71,25 +67,36 @@ void CGUIObject::init(GUIId _id)
|
|||
m_x=m_y=m_w=m_h=0;
|
||||
m_flags=getInitialFlags();
|
||||
m_this=this;
|
||||
m_parent=_parent;
|
||||
m_child=NULL;
|
||||
m_next=NULL;
|
||||
|
||||
// Add to the end of the linked list of GUI objects..
|
||||
// Also check for duplicate IDs
|
||||
if(s_llBase)
|
||||
// Link in with the parent
|
||||
if(m_parent)
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
pGUI=s_llBase;
|
||||
while(pGUI->m_llNext)
|
||||
if(m_parent->m_child)
|
||||
{
|
||||
ASSERT(pGUI->m_id==_id);
|
||||
pGUI=pGUI->m_llNext;
|
||||
CGUIObject *pGUI;
|
||||
pGUI=m_parent->m_child;
|
||||
while(pGUI->m_next)
|
||||
{
|
||||
pGUI=pGUI->m_next;
|
||||
}
|
||||
pGUI->m_next=this;
|
||||
}
|
||||
pGUI->m_llNext=this;
|
||||
else
|
||||
{
|
||||
m_parent->m_child=this;
|
||||
}
|
||||
setOt(m_parent->getOt()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_llBase=this;
|
||||
// PKG - Need to add some code to check that only one bastard ( that is, parentless :) object
|
||||
// is ever in existance.
|
||||
GUI_DBGMSG("INFO: GUI object without parent created!");
|
||||
setOt(INITIAL_OT);
|
||||
}
|
||||
m_llNext=0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,20 +108,14 @@ void CGUIObject::init(GUIId _id)
|
|||
---------------------------------------------------------------------- */
|
||||
void CGUIObject::shutdown()
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
|
||||
ASSERT(this==m_this);
|
||||
|
||||
m_this=0;
|
||||
if(m_child)m_child->shutdown(); m_child=NULL;
|
||||
if(m_next)m_next->shutdown(); m_next=NULL;
|
||||
m_parent=NULL;
|
||||
|
||||
// Remove from linked list of GUI objects..
|
||||
pGUI=s_llBase;
|
||||
while(pGUI->m_llNext!=this);
|
||||
{
|
||||
ASSERT(pGUI); // Huh? Couldn't find this item in the list!?!?!
|
||||
pGUI=pGUI->m_llNext;
|
||||
}
|
||||
pGUI->m_llNext=this->m_llNext;
|
||||
// Is this actually safe? Not really.. (PKG)
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -123,41 +124,61 @@ void CGUIObject::shutdown()
|
|||
Purpose: NB: The chain of render functions needs to be reversed so
|
||||
that the draworder is correct! Look at any subclasses
|
||||
render() function to see what I mean by this.. (PKG)
|
||||
um.. or does it?
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
#ifdef __USER_paul__
|
||||
int forceBorderDraw=true;
|
||||
#endif
|
||||
void CGUIObject::render()
|
||||
{
|
||||
ASSERT(this==m_this);
|
||||
|
||||
if(m_child)m_child->render();
|
||||
if(m_next)m_next->render();
|
||||
|
||||
if(isHidden())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __USER_paul__
|
||||
if(getFlags(FLAG_DRAWBORDER)||forceBorderDraw)
|
||||
#else
|
||||
if(getFlags(FLAG_DRAWBORDER))
|
||||
#endif
|
||||
{
|
||||
POLY_G4 *g4;
|
||||
int x,y,w,h;
|
||||
int r,g,b;
|
||||
int x,y,w,h;
|
||||
int r,g,b;
|
||||
int ot;
|
||||
|
||||
x=getX();
|
||||
y=getY();
|
||||
x=getX()+getParentX();
|
||||
y=getY()+getParentY();
|
||||
w=getW();
|
||||
h=getH();
|
||||
r=g=b=240;
|
||||
if(isSelected())
|
||||
{
|
||||
r=g=b=225;
|
||||
}
|
||||
else
|
||||
{
|
||||
r=g=b=150;
|
||||
}
|
||||
ot=getOt();
|
||||
|
||||
// Border
|
||||
DrawLine(x ,y ,x+w,y ,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x ,y ,x ,y+h,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x+w,y ,x+w,y+h,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x ,y+h,x+w,y+h,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x ,y ,x+w,y ,r,g,b,ot);
|
||||
DrawLine(x ,y ,x ,y+h,r,g,b,ot);
|
||||
DrawLine(x+w,y ,x+w,y+h,r,g,b,ot);
|
||||
DrawLine(x ,y+h,x+w,y+h,r,g,b,ot);
|
||||
|
||||
x+=3;y+=2;w-=6;h-=4;
|
||||
DrawLine(x ,y ,x+w,y ,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x ,y ,x ,y+h,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x+w,y ,x+w,y+h,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x ,y+h,x+w,y+h,r,g,b,DEFAULT_OT);
|
||||
DrawLine(x ,y ,x+w,y ,r,g,b,ot);
|
||||
DrawLine(x ,y ,x ,y+h,r,g,b,ot);
|
||||
DrawLine(x+w,y ,x+w,y+h,r,g,b,ot);
|
||||
DrawLine(x ,y+h,x+w,y+h,r,g,b,ot);
|
||||
x-=3;y-=2;w+=6;h+=4;
|
||||
|
||||
// Background
|
||||
|
@ -168,7 +189,7 @@ void CGUIObject::render()
|
|||
setRGB1(g4,250,125, 15);
|
||||
setRGB2(g4, 15,250,125);
|
||||
setRGB3(g4, 15,125,250);
|
||||
AddPrimToList(g4,DEFAULT_OT);
|
||||
AddPrimToList(g4,ot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,9 +200,21 @@ void CGUIObject::render()
|
|||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
#include "utils\utils.h"
|
||||
int wob=0;
|
||||
void CGUIObject::think(int _frames)
|
||||
{
|
||||
ASSERT(this==m_this);
|
||||
|
||||
|
||||
if(m_id==0&&++wob==20)
|
||||
{
|
||||
setObjectXYWH(16+getRndRange(10),100+getRndRange(5),512-64,120);
|
||||
wob=0;
|
||||
}
|
||||
|
||||
if(m_child)m_child->think(_frames);
|
||||
if(m_next)m_next->think(_frames);
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,20 +227,32 @@ void CGUIObject::think(int _frames)
|
|||
void CGUIObject::recalc()
|
||||
{
|
||||
ASSERT(this==m_this);
|
||||
|
||||
if(m_child)m_child->recalc();
|
||||
if(m_next)m_next->recalc();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
extern void guiOpen()
|
||||
void CGUIObjectWithFont::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
ASSERT(!CGUIObject::s_llBase);
|
||||
CGUIObject::init(_parent,_id);
|
||||
m_fontBank=new ("GUIObjectWithFont:fontBank") FontBank();
|
||||
m_fontBank->initialise(&standardFont);
|
||||
m_fontBank->setJustification(FontBank::JUST_CENTRE);
|
||||
m_fontBank->setOt(getOt());
|
||||
m_fontBank->setColour(DEFAULT_FONT_R,DEFAULT_FONT_G,DEFAULT_FONT_B);
|
||||
}
|
||||
|
||||
|
||||
|
@ -217,14 +262,27 @@ extern void guiOpen()
|
|||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
extern void guiClose()
|
||||
void CGUIObjectWithFont::shutdown()
|
||||
{
|
||||
// Dump everything automatically
|
||||
// Don't walk the linked list here but keep removing the head since frame
|
||||
// objects remove their own children (PKG or do they?)
|
||||
while(CGUIObject::s_llBase)
|
||||
CGUIObject::shutdown();
|
||||
m_fontBank->dump();
|
||||
delete(m_fontBank);
|
||||
m_fontBank=NULL;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIObjectWithFont::setFlags(GUI_FLAGS _flags)
|
||||
{
|
||||
CGUIObject::setFlags(_flags);
|
||||
if(_flags&FLAG_SELECTED)
|
||||
{
|
||||
CGUIObject::s_llBase->shutdown();
|
||||
getFontBank()->setColour(CGUIObjectWithFont::SELECTED_FONT_R,CGUIObjectWithFont::SELECTED_FONT_G,CGUIObjectWithFont::SELECTED_FONT_B);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,58 +293,34 @@ extern void guiClose()
|
|||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
extern void guiThink(int _frames)
|
||||
void CGUIObjectWithFont::clearFlags(GUI_FLAGS _flags)
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
pGUI=CGUIObject::s_llBase;
|
||||
while(pGUI)
|
||||
CGUIObject::clearFlags(_flags);
|
||||
if(_flags&FLAG_SELECTED)
|
||||
{
|
||||
pGUI->think(_frames);
|
||||
pGUI=pGUI->m_llNext;
|
||||
getFontBank()->setColour(CGUIObjectWithFont::DEFAULT_FONT_R,CGUIObjectWithFont::DEFAULT_FONT_G,CGUIObjectWithFont::DEFAULT_FONT_B);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
extern void guiRender()
|
||||
void CGUIObjectWithFont::recalc()
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
pGUI=CGUIObject::s_llBase;
|
||||
while(pGUI)
|
||||
{
|
||||
pGUI->render();
|
||||
pGUI=pGUI->m_llNext;
|
||||
}
|
||||
}
|
||||
int x,y,w,h;
|
||||
|
||||
CGUIObject::recalc();
|
||||
x=getX()+getParentX()+BORDERWIDTH;
|
||||
y=getY()+getParentY()+BORDERHEIGHT;
|
||||
w=getW()-(BORDERWIDTH*2);
|
||||
h=getH()-(BORDERHEIGHT*2);
|
||||
getFontBank()->setPrintArea(x,y,w,h);
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
extern CGUIObject *guiGetItem(CGUIObject::GUIId _searchId)
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
pGUI=CGUIObject::s_llBase;
|
||||
while(pGUI)
|
||||
{
|
||||
if(pGUI->m_id==_searchId)
|
||||
{
|
||||
return pGUI;
|
||||
}
|
||||
pGUI=pGUI->m_llNext;
|
||||
}
|
||||
|
||||
// Bwah!
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
|
||||
typedef enum
|
||||
{
|
||||
FLAG_NONE= 0,
|
||||
FLAG_SELECTED= 1<<0,
|
||||
FLAG_HIDDEN= 1<<2,
|
||||
FLAG_DRAWBORDER= 1<<3,
|
||||
|
@ -43,13 +44,13 @@ public:
|
|||
|
||||
enum
|
||||
{
|
||||
DEFAULT_OT=20,
|
||||
INITIAL_OT=200,
|
||||
BORDERWIDTH=8,
|
||||
BORDERHEIGHT=5,
|
||||
};
|
||||
|
||||
|
||||
virtual void init(GUIId _id);
|
||||
|
||||
virtual void init(CGUIObject *_parent,GUIId _id);
|
||||
virtual void shutdown();
|
||||
|
||||
void setObjectX(int _x) {m_x=_x;recalc();}
|
||||
|
@ -62,10 +63,9 @@ public:
|
|||
|
||||
virtual void render();
|
||||
virtual void think(int _frames);
|
||||
virtual void recalc();
|
||||
|
||||
void setFlags(GUI_FLAGS _flags) {m_flags|=_flags;}
|
||||
void clearFlags(GUI_FLAGS _flags) {m_flags&=_flags^-1;}
|
||||
virtual void setFlags(GUI_FLAGS _flags) {m_flags|=_flags;}
|
||||
virtual void clearFlags(GUI_FLAGS _flags) {m_flags&=_flags^-1;}
|
||||
int getFlags(GUI_FLAGS _flags) {return (m_flags&_flags)!=0;}
|
||||
|
||||
// Quick access functions to the most frequently used flags
|
||||
|
@ -76,38 +76,73 @@ public:
|
|||
void unhide() {clearFlags(FLAG_HIDDEN);}
|
||||
int isHidden() {return getFlags(FLAG_HIDDEN);}
|
||||
|
||||
|
||||
CGUIObject *getChild() {return m_child;}
|
||||
CGUIObject *getNext() {return m_next;}
|
||||
|
||||
int getId() {return m_id;}
|
||||
|
||||
protected:
|
||||
virtual GUI_FLAGS getInitialFlags() {return FLAG_DRAWBORDER;}
|
||||
virtual void recalc();
|
||||
|
||||
virtual GUI_FLAGS getInitialFlags() {return FLAG_NONE;}
|
||||
virtual int isSelectable() {return false;}
|
||||
|
||||
int getX() {return m_x;}
|
||||
int getY() {return m_y;}
|
||||
int getW() {return m_w;}
|
||||
int getH() {return m_h;}
|
||||
|
||||
|
||||
int getParentX() {if(m_parent)return m_parent->getX()+m_parent->getParentX();else return 0;}
|
||||
int getParentY() {if(m_parent)return m_parent->getY()+m_parent->getParentY();else return 0;}
|
||||
|
||||
void setOt(int _ot) {m_ot=_ot;}
|
||||
int getOt() {return m_ot;}
|
||||
|
||||
|
||||
private:
|
||||
GUIId m_id;
|
||||
int m_x,m_y,m_w,m_h;
|
||||
int m_flags;
|
||||
int m_ot;
|
||||
|
||||
CGUIObject *m_this;
|
||||
CGUIObject *m_llNext;
|
||||
static CGUIObject *s_llBase;
|
||||
|
||||
|
||||
// ..don't like using friends for this :(
|
||||
friend void guiOpen();
|
||||
friend void guiClose();
|
||||
friend void guiThink(int _frames);
|
||||
friend void guiRender();
|
||||
friend CGUIObject *guiGetItem(CGUIObject::GUIId _searchId);
|
||||
|
||||
CGUIObject *m_this; // Used to check that that the object has been initialised
|
||||
CGUIObject *m_parent; // Parent object
|
||||
CGUIObject *m_child; // First child
|
||||
CGUIObject *m_next; // Next item at this level
|
||||
};
|
||||
|
||||
|
||||
class CGUIObjectWithFont : public CGUIObject
|
||||
{
|
||||
public:
|
||||
virtual void init(CGUIObject *_parent,GUIId _id);
|
||||
virtual void shutdown();
|
||||
|
||||
virtual void setFlags(GUI_FLAGS _flags);
|
||||
virtual void clearFlags(GUI_FLAGS _flags);
|
||||
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
DEFAULT_FONT_R=150,
|
||||
DEFAULT_FONT_G=100,
|
||||
DEFAULT_FONT_B=100,
|
||||
SELECTED_FONT_R=175,
|
||||
SELECTED_FONT_G=225,
|
||||
SELECTED_FONT_B=175,
|
||||
};
|
||||
|
||||
virtual void recalc();
|
||||
|
||||
class FontBank *getFontBank() {return m_fontBank;}
|
||||
|
||||
|
||||
private:
|
||||
class FontBank *m_fontBank;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
|
@ -118,12 +153,6 @@ private:
|
|||
Functions
|
||||
--------- */
|
||||
|
||||
extern void guiOpen();
|
||||
extern void guiClose();
|
||||
extern void guiThink(int _frames);
|
||||
extern void guiRender();
|
||||
extern CGUIObject *guiGetItem(CGUIObject::GUIId _searchId);
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __GUI_GUI_H__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue