This commit is contained in:
parent
7f1c8e2012
commit
3b2b2c2001
14 changed files with 287 additions and 272 deletions
|
@ -68,6 +68,8 @@ gfx_src := prim \
|
|||
# bilboard
|
||||
|
||||
gui_src := gui \
|
||||
gbutton \
|
||||
gframe \
|
||||
greadout \
|
||||
gtextbox
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ SpriteBank *CGameScene::s_sprites;
|
|||
|
||||
BubicleEmitterData bubData=
|
||||
{
|
||||
206,200,55,45, // m_x,m_y,m_w,m_h
|
||||
206,200,60,60, // m_x,m_y,m_w,m_h
|
||||
10,1, // m_birthRate,m_birthAmount
|
||||
-1, // m_life
|
||||
{ // m_bubicleBase
|
||||
|
@ -112,9 +112,9 @@ void CGameScene::think(int _frames)
|
|||
for(int i=0;i<_frames;i++)
|
||||
{
|
||||
X+=Dx; Y+=Dy;
|
||||
if (X<0+64) {X=0+64; Dx=getRndRange(5)+1;}
|
||||
if (X<0+4) {X=0+4; Dx=getRndRange(5)+1;}
|
||||
if (X>512-64) {X=512-64; Dx=-(getRndRange(5)+1);}
|
||||
if (Y<0+64) {Y=0+64; Dy=getRndRange(5)+1;}
|
||||
if (Y<+4) {Y=0+4; Dy=getRndRange(5)+1;}
|
||||
if (Y>256-64) {Y=256-64; Dy=-(getRndRange(5)+1);}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -44,9 +44,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)
|
||||
{
|
||||
if(m_parent->m_child)
|
||||
{
|
||||
CGUIObject *pGUI;
|
||||
pGUI=s_llBase;
|
||||
while(pGUI->m_llNext)
|
||||
pGUI=m_parent->m_child;
|
||||
while(pGUI->m_next)
|
||||
{
|
||||
ASSERT(pGUI->m_id==_id);
|
||||
pGUI=pGUI->m_llNext;
|
||||
pGUI=pGUI->m_next;
|
||||
}
|
||||
pGUI->m_llNext=this;
|
||||
pGUI->m_next=this;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_llBase=this;
|
||||
m_parent->m_child=this;
|
||||
}
|
||||
setOt(m_parent->getOt()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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 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::s_llBase->shutdown();
|
||||
CGUIObject::setFlags(_flags);
|
||||
if(_flags&FLAG_SELECTED)
|
||||
{
|
||||
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,9 +76,15 @@ 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;}
|
||||
|
@ -86,28 +92,57 @@ protected:
|
|||
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__ */
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
#ifndef __PAD_PADS_H__
|
||||
#define __PAD_PADS_H__
|
||||
|
||||
#ifndef _GLOBAL_HEADER_
|
||||
#include "system\global.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
#define DUALSHOCKMODE ((u_long *)0x80010000)
|
||||
|
||||
|
@ -40,8 +45,8 @@
|
|||
#define BUTTON_SELECT PAD_CROSS
|
||||
#define BUTTON_BACK PAD_TRIANGLE
|
||||
|
||||
#define TYPOMATIC_DELAY 75
|
||||
#define TYPOMATIC_RATE 50
|
||||
#define TYPOMATIC_DELAY 60
|
||||
#define TYPOMATIC_RATE 30
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -54,10 +54,18 @@
|
|||
#include "gui\gtextbox.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GUI_GFRAME_H__
|
||||
#include "gui\gframe.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GUI_GREADOUT_H__
|
||||
#include "gui\greadout.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GUI_GBUTTON_H__
|
||||
#include "gui\gbutton.h"
|
||||
#endif
|
||||
|
||||
#ifndef __LOCALE_TEXTDBASE_H__
|
||||
#include "locale\textdbase.h"
|
||||
#endif
|
||||
|
@ -97,33 +105,65 @@ unsigned int str=STR__PAULS_TEST_STRING_1;
|
|||
int w=150;
|
||||
int h=40;
|
||||
|
||||
int testValue=1;
|
||||
CGUITextReadout::TextReadoutData testData[]=
|
||||
int testValue=0;
|
||||
CGUITextReadout::TextReadoutData testReadoutData[]=
|
||||
{
|
||||
{ 1, STR__PAULS_TEST_STRING_1, },
|
||||
{ 2, STR__PAULS_TEST_STRING_2, },
|
||||
{ 3, STR__PAULS_TEST_STRING_3, },
|
||||
{ 0, 0, },
|
||||
};
|
||||
int testButtonData[]=
|
||||
{
|
||||
1,2,3,
|
||||
0,
|
||||
};
|
||||
|
||||
CGUIControlFrame *baseGUIObject;
|
||||
|
||||
|
||||
void CPaulScene::init()
|
||||
{
|
||||
s_fontBank.initialise(&standardFont);
|
||||
guiOpen();
|
||||
|
||||
CGUITextBox *tb;
|
||||
tb=new ("textbox") CGUITextBox();
|
||||
tb->init(1);
|
||||
tb->setObjectXY(200,130);
|
||||
|
||||
CGUITextReadout *tr;
|
||||
CGUIGroupFrame *fr;
|
||||
CGUIButton *bu;
|
||||
|
||||
s_fontBank.initialise(&standardFont);
|
||||
|
||||
baseGUIObject=new ("Uber GUI object") CGUIControlFrame();
|
||||
baseGUIObject->init(NULL,0);
|
||||
baseGUIObject->setObjectXYWH(32,100,512-64,120);
|
||||
|
||||
tb=new ("textbox") CGUITextBox();
|
||||
tb->init(baseGUIObject,1);
|
||||
tb->setObjectXYWH(10,10,400,25);
|
||||
tb->setText(STR__PAULS_TEST_STRING_1);
|
||||
|
||||
fr=new ("frame") CGUIGroupFrame();
|
||||
fr->init(baseGUIObject,2);
|
||||
fr->setObjectXYWH(10,40,400,25);
|
||||
tb=new ("textbox") CGUITextBox();
|
||||
tb->init(fr,20);
|
||||
tb->setObjectXYWH(50,1,300,22);
|
||||
tb->setText(STR__PAULS_TEST_STRING_1);
|
||||
bu=new ("button") CGUIButton();
|
||||
bu->init(fr,21);
|
||||
bu->setObjectXYWH(50,1,10,10);
|
||||
bu->setButtonTarget(&testValue);
|
||||
bu->setButtonData(testButtonData);
|
||||
|
||||
tr=new ("textreadout") CGUITextReadout();
|
||||
tr->init(2);
|
||||
tr->setObjectXYWH(40,130,120,80);
|
||||
tr->init(baseGUIObject,3);
|
||||
tr->setObjectXYWH(10,70,400,25);
|
||||
tr->setReadoutTarget(&testValue);
|
||||
tr->setReadoutData(testData);
|
||||
tr->setReadoutData(testReadoutData);
|
||||
|
||||
// Heh.. this'll actually work =)
|
||||
// baseGUIObject->shutdown();
|
||||
|
||||
|
||||
baseGUIObject->select();
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,7 +176,6 @@ void CPaulScene::init()
|
|||
void CPaulScene::shutdown()
|
||||
{
|
||||
s_fontBank.dump();
|
||||
guiClose();
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,7 +199,7 @@ void CPaulScene::render()
|
|||
y+=charHeight;
|
||||
}
|
||||
|
||||
guiRender();
|
||||
baseGUIObject->render();
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,12 +211,14 @@ void CPaulScene::render()
|
|||
---------------------------------------------------------------------- */
|
||||
void CPaulScene::think(int _frames)
|
||||
{
|
||||
/*
|
||||
CGUITextBox *tb;
|
||||
tb=(CGUITextBox *)guiGetItem(1);
|
||||
tb->setObjectWH(w,h);
|
||||
tb->setText(str);
|
||||
*/
|
||||
|
||||
guiThink(GameState::getFramesSinceLast());
|
||||
baseGUIObject->think(_frames);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,27 +21,6 @@
|
|||
#include "utils\replace.h"
|
||||
#include <gtemac.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed long s32;
|
||||
typedef long long s64;
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef s8 S8;
|
||||
typedef s16 S16;
|
||||
typedef s32 S32;
|
||||
typedef s64 S64;
|
||||
|
||||
typedef u8 U8;
|
||||
typedef u16 U16;
|
||||
typedef u32 U32;
|
||||
typedef u64 U64;
|
||||
|
||||
/*****************************************************************************/
|
||||
#define SCRATCH_RAM 0x1f800000
|
||||
#define FAST_STACK (SCRATCH_RAM+0x3f0)
|
||||
|
@ -62,6 +41,8 @@ enum DRAW_TYPE
|
|||
|
||||
|
||||
/*****************************************************************************/
|
||||
#include "system\types.h"
|
||||
|
||||
#include "mem\memory.h"
|
||||
#include "system\gte.h"
|
||||
#include "utils\cmxmacro.h"
|
||||
|
|
|
@ -357,6 +357,10 @@ SOURCE=..\..\..\source\system\main.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\system\types.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\system\vid.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -437,6 +441,14 @@ SOURCE=..\..\..\source\utils\utils.h
|
|||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\gui\gframe.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\gui\gframe.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\gui\greadout.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue