This commit is contained in:
parent
094c8850bc
commit
46791b36f4
7 changed files with 397 additions and 38 deletions
|
@ -45,6 +45,18 @@
|
|||
Vars
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIToggleButton::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIObject::init(_parent,_id);
|
||||
m_target=0;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
|
@ -95,6 +107,19 @@ void CGUIToggleButton::think(int _frames)
|
|||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUICycleButton::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIToggleButton::init(_parent,_id);
|
||||
m_data=0;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
@ -152,5 +177,90 @@ void CGUICycleButton::think(int _frames)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUISliderButton::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIToggleButton::init(_parent,_id);
|
||||
m_min=m_max=0;
|
||||
m_scrollSpeed=DEFAULT_SCROLL_SPEED;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUISliderButton::setButtonRange(int _min,int _max)
|
||||
{
|
||||
m_min=_min;
|
||||
m_max=_max;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUISliderButton::setScrollSpeed(int _scrollSpeed)
|
||||
{
|
||||
m_scrollSpeed=_scrollSpeed;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUISliderButton::think(int _frames)
|
||||
{
|
||||
ASSERT(getTarget());
|
||||
ASSERT(m_min!=m_max);
|
||||
|
||||
CGUIObject::think(_frames);
|
||||
if(isSelected())
|
||||
{
|
||||
int padRepeat,padDown;
|
||||
int *target=getTarget();
|
||||
|
||||
padRepeat=PadGetRepeat(0);
|
||||
padDown=PadGetDown(0);
|
||||
if(padDown&PAD_LEFT)
|
||||
{
|
||||
*target-=1;
|
||||
}
|
||||
else if(padDown&PAD_RIGHT)
|
||||
{
|
||||
*target+=1;
|
||||
}
|
||||
else if(padRepeat&PAD_LEFT)
|
||||
{
|
||||
*target-=(_frames*m_scrollSpeed);
|
||||
}
|
||||
else if(padRepeat&PAD_RIGHT)
|
||||
{
|
||||
*target+=(_frames*m_scrollSpeed);
|
||||
}
|
||||
|
||||
if(*target<m_min)*target=m_min;
|
||||
else if(*target>m_max)*target=m_max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
|
@ -37,6 +37,8 @@
|
|||
class CGUIToggleButton : public CGUIObject
|
||||
{
|
||||
public:
|
||||
virtual void init(CGUIObject *_parent,GUIId _id=noId);
|
||||
|
||||
virtual void setButtonTarget(int *_target);
|
||||
|
||||
virtual void think(int _frames);
|
||||
|
@ -56,6 +58,8 @@ private:
|
|||
class CGUICycleButton : public CGUIToggleButton
|
||||
{
|
||||
public:
|
||||
virtual void init(CGUIObject *_parent,GUIId _id=noId);
|
||||
|
||||
virtual void setButtonData(int *_data);
|
||||
|
||||
virtual void think(int _frames);
|
||||
|
@ -71,6 +75,29 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class CGUISliderButton : public CGUIToggleButton
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
DEFAULT_SCROLL_SPEED=10,
|
||||
};
|
||||
|
||||
virtual void init(CGUIObject *_parent,GUIId _id=noId);
|
||||
|
||||
virtual void setButtonRange(int _min,int _max);
|
||||
virtual void setScrollSpeed(int _scrollSpeed);
|
||||
|
||||
virtual void think(int _frames);
|
||||
|
||||
|
||||
private:
|
||||
int m_min,m_max;
|
||||
int m_scrollSpeed;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
#include "gfx\sprbank.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PRIM_HEADER__
|
||||
#include "gfx\prim.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
@ -194,27 +198,13 @@ void CGUITextReadout::recalc()
|
|||
---------------------------------------------------------------------- */
|
||||
void CGUISpriteReadout::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIObject::init(_parent,_id);
|
||||
CGUIObjectWithSpriteBank::init(_parent,_id);
|
||||
m_target=0;
|
||||
m_data=0;
|
||||
m_sprites=new ("SpriteReadout:sprites") SpriteBank();
|
||||
m_sprites->load(UI_UIGFX_SPR);
|
||||
m_lastValue=-1;
|
||||
m_frame=0;
|
||||
m_x=m_y=0;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUISpriteReadout::shutdown()
|
||||
{
|
||||
CGUIObject::shutdown();
|
||||
m_sprites->dump(); delete m_sprites; m_sprites=0;
|
||||
setSpriteBank(UI_UIGFX_SPR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,9 +246,9 @@ void CGUISpriteReadout::render()
|
|||
|
||||
if(!isHidden())
|
||||
{
|
||||
m_sprites->printFT4(m_frame,getParentX()+m_x,getParentY()+m_y,0,0,getOt());
|
||||
getSpriteBank()->printFT4(m_frame,getParentX()+m_x,getParentY()+m_y,0,0,getOt());
|
||||
}
|
||||
CGUIObject::render();
|
||||
CGUIObjectWithSpriteBank::render();
|
||||
}
|
||||
|
||||
|
||||
|
@ -310,7 +300,7 @@ void CGUISpriteReadout::recalc()
|
|||
data++;
|
||||
}
|
||||
while(tmp<data->m_value);
|
||||
fh=m_sprites->getFrameHeader(m_frame);
|
||||
fh=getSpriteBank()->getFrameHeader(m_frame);
|
||||
|
||||
#ifdef __VERSION_DEBUG__
|
||||
if(fh->W>getW()-(BORDERWIDTH*2)||
|
||||
|
@ -326,5 +316,117 @@ void CGUISpriteReadout::recalc()
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIBarReadout::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIObject::init(_parent,_id);
|
||||
setReadoutTarget(0);
|
||||
setReadoutRange(0,255);
|
||||
m_markerOffset=0;
|
||||
m_lastValue=-1;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIBarReadout::setReadoutTarget(int *_target)
|
||||
{
|
||||
m_target=_target;
|
||||
recalc();
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIBarReadout::setReadoutRange(int _min,int _max)
|
||||
{
|
||||
m_min=_min;
|
||||
m_max=_max;
|
||||
recalc();
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIBarReadout::render()
|
||||
{
|
||||
POLY_G4 *g4;
|
||||
int x,y,w,h;
|
||||
int r,g,b;
|
||||
int ot;
|
||||
|
||||
x=getX()+getParentX();
|
||||
y=getY()+getParentY();
|
||||
w=getW();
|
||||
h=getH();
|
||||
r=g=b=isSelected()?245:110;
|
||||
ot=getOt();
|
||||
|
||||
DrawLine(x,y+(h/2),x+w,y+(h/2),r,g,b,ot);
|
||||
DrawLine(x+m_markerOffset,y,x+m_markerOffset,y+h,r,g,b,ot);
|
||||
|
||||
CGUIObject::render();
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIBarReadout::think(int _frames)
|
||||
{
|
||||
if(m_lastValue!=*m_target)
|
||||
{
|
||||
recalc();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIBarReadout::recalc()
|
||||
{
|
||||
if(m_target)
|
||||
{
|
||||
int w,offset;
|
||||
int scaler;
|
||||
|
||||
scaler=(getW()<<8)/(m_max-m_min);
|
||||
offset=(scaler*(*m_target-m_min))>>8;
|
||||
|
||||
m_markerOffset=offset;
|
||||
|
||||
m_lastValue=*m_target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
|
@ -67,7 +67,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class CGUISpriteReadout : public CGUIObject
|
||||
class CGUISpriteReadout : public CGUIObjectWithSpriteBank
|
||||
{
|
||||
public:
|
||||
typedef struct
|
||||
|
@ -78,7 +78,6 @@ public:
|
|||
|
||||
|
||||
virtual void init(CGUIObject *_parent,GUIId _id=noId);
|
||||
virtual void shutdown();
|
||||
|
||||
virtual void setReadoutTarget(int *_target);
|
||||
virtual void setReadoutData(SpriteReadoutData *_data);
|
||||
|
@ -94,7 +93,6 @@ protected:
|
|||
private:
|
||||
int *m_target;
|
||||
SpriteReadoutData *m_data;
|
||||
class SpriteBank *m_sprites;
|
||||
int m_lastValue;
|
||||
int m_frame;
|
||||
int m_x,m_y;
|
||||
|
@ -102,6 +100,31 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class CGUIBarReadout : public CGUIObject
|
||||
{
|
||||
public:
|
||||
virtual void init(CGUIObject *_parent,GUIId _id=noId);
|
||||
|
||||
virtual void setReadoutTarget(int *_target);
|
||||
virtual void setReadoutRange(int _min,int _max);
|
||||
|
||||
virtual void render();
|
||||
virtual void think(int _frames);
|
||||
|
||||
|
||||
protected:
|
||||
void recalc();
|
||||
|
||||
|
||||
private:
|
||||
int *m_target;
|
||||
int m_min,m_max;
|
||||
int m_markerOffset;
|
||||
int m_lastValue;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -156,11 +156,11 @@ void CGUIObject::render()
|
|||
h=getH();
|
||||
if(isSelected())
|
||||
{
|
||||
r=g=b=225;
|
||||
r=g=b=245;
|
||||
}
|
||||
else
|
||||
{
|
||||
r=g=b=150;
|
||||
r=g=b=110;
|
||||
}
|
||||
ot=getOt();
|
||||
|
||||
|
@ -169,22 +169,26 @@ void CGUIObject::render()
|
|||
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;
|
||||
x+=1;y+=1;w-=2;h-=2;
|
||||
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;
|
||||
x+=1;y+=1;w+=1;h+=1;
|
||||
DrawLine(x ,y ,x+w,y ,0,0,0,ot);
|
||||
DrawLine(x ,y ,x ,y+h,0,0,0,ot);
|
||||
DrawLine(x+w,y ,x+w,y+h,0,0,0,ot);
|
||||
DrawLine(x ,y+h,x+w,y+h,0,0,0,ot);
|
||||
x-=2;y-=2;w+=1;h+=1;
|
||||
|
||||
// Background
|
||||
g4=GetPrimG4();
|
||||
setXYWH(g4,x,y,w,h);
|
||||
setSemiTrans(g4,true);
|
||||
setRGB0(g4,250, 15,125);
|
||||
setRGB1(g4,250,125, 15);
|
||||
setRGB2(g4, 15,250,125);
|
||||
setRGB3(g4, 15,125,250);
|
||||
// setSemiTrans(g4,true);
|
||||
setRGB0(g4,107,105, 98);
|
||||
setRGB1(g4,107,105, 98);
|
||||
setRGB2(g4, 0, 0, 90);
|
||||
setRGB3(g4, 0, 0, 90);
|
||||
AddPrimToList(g4,ot);
|
||||
}
|
||||
}
|
||||
|
@ -320,5 +324,52 @@ void CGUIObjectWithFont::recalc()
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIObjectWithSpriteBank::init(CGUIObject *_parent,GUIId _id)
|
||||
{
|
||||
CGUIObject::init(_parent,_id);
|
||||
m_spriteBank=0;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIObjectWithSpriteBank::shutdown()
|
||||
{
|
||||
ASSERT(m_spriteBank);
|
||||
|
||||
CGUIObject::shutdown();
|
||||
m_spriteBank->dump();
|
||||
delete m_spriteBank;
|
||||
m_spriteBank=0;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CGUIObjectWithSpriteBank::setSpriteBank(FileEquate _fe)
|
||||
{
|
||||
m_spriteBank=new ("spritebank") SpriteBank();
|
||||
m_spriteBank->load(_fe);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
|
@ -18,6 +18,11 @@
|
|||
Includes
|
||||
-------- */
|
||||
|
||||
#ifndef __FILE_EQUATES_H__
|
||||
#include <biglump.h> // just to get the bloody def for FileEquate(!)
|
||||
#endif
|
||||
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
|
@ -29,6 +34,12 @@
|
|||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
// PKG
|
||||
// None of these clasess should ever really be instantiated, but they are the basis of all other GUI objects.
|
||||
// Need a nice way to force this to be the case..
|
||||
|
||||
|
||||
|
||||
class CGUIObject
|
||||
{
|
||||
public:
|
||||
|
@ -126,12 +137,12 @@ public:
|
|||
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,
|
||||
DEFAULT_FONT_R=110,
|
||||
DEFAULT_FONT_G=110,
|
||||
DEFAULT_FONT_B=110,
|
||||
SELECTED_FONT_R=245,
|
||||
SELECTED_FONT_G=245,
|
||||
SELECTED_FONT_B=245,
|
||||
};
|
||||
|
||||
virtual void recalc();
|
||||
|
@ -146,6 +157,25 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class CGUIObjectWithSpriteBank : public CGUIObject
|
||||
{
|
||||
public:
|
||||
virtual void init(CGUIObject *_parent,GUIId _id=noId);
|
||||
virtual void shutdown();
|
||||
|
||||
virtual void setSpriteBank(FileEquate _fe);
|
||||
|
||||
|
||||
protected:
|
||||
class SpriteBank *getSpriteBank() {return m_spriteBank;}
|
||||
|
||||
|
||||
private:
|
||||
class SpriteBank *m_spriteBank;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
|
|
@ -125,6 +125,7 @@ CGUISpriteReadout::SpriteReadoutData onOffSpriteReadouts[]=
|
|||
int musicStatus=false;
|
||||
int sfxStatus=false;
|
||||
int readyToExit=false;
|
||||
int musicVol=0;
|
||||
|
||||
|
||||
|
||||
|
@ -138,6 +139,8 @@ void CPaulScene::init()
|
|||
CGUIToggleButton *tg;
|
||||
CGUITextReadout *tr;
|
||||
CGUISpriteReadout *sr;
|
||||
CGUIBarReadout *br;
|
||||
CGUISliderButton *sl;
|
||||
|
||||
s_fontBank.initialise(&standardFont);
|
||||
|
||||
|
@ -177,6 +180,19 @@ void CPaulScene::init()
|
|||
sr->setReadoutTarget(&sfxStatus);
|
||||
sr->setReadoutData(onOffSpriteReadouts);
|
||||
|
||||
fr=new ("frame") CGUIGroupFrame();
|
||||
fr->init(baseGUIObject);
|
||||
fr->setObjectXYWH(10,90,448-20,30);
|
||||
sl=new("sliderbutton") CGUISliderButton();
|
||||
sl->init(fr);
|
||||
sl->setButtonTarget(&musicVol);
|
||||
sl->setButtonRange(0,255);
|
||||
br=new ("spritereadout") CGUIBarReadout();
|
||||
br->init(fr);
|
||||
br->setObjectXYWH(0,0,448-20,30);
|
||||
br->setReadoutTarget(&musicVol);
|
||||
br->setReadoutRange(0,255);
|
||||
|
||||
fr=new ("frame") CGUIGroupFrame();
|
||||
fr->init(baseGUIObject);
|
||||
fr->setObjectXYWH(10,155,448-20,30);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue