This commit is contained in:
parent
500f5f6776
commit
bbf0e5ae16
7 changed files with 186 additions and 33 deletions
|
@ -91,7 +91,7 @@ UI_GFX_FONT_IN := $(GRAF_DIR)/ui/font/font.anm
|
|||
UI_GFX_NONTRANS :=
|
||||
UI_GFX_NONTRANS_IN := $(foreach FILE,$(UI_GFX_NONTRANS),$(UI_GFX_DIR)/$(FILE))
|
||||
|
||||
UI_GFX_TRANS := +cross.bmp +tick.bmp
|
||||
UI_GFX_TRANS := +vbamboo.bmp +cross.bmp +tick.bmp +hbamboo.bmp
|
||||
UI_GFX_TRANS_IN := $(foreach FILE,$(UI_GFX_TRANS),$(UI_GFX_DIR)/$(FILE))
|
||||
|
||||
UI_GFX_TEX_IN := $(UI_GFX_FONT_IN) ${UI_GFX_NONTRANS_IN} ${UI_GFX_TRANS_IN}
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
Vars
|
||||
---- */
|
||||
|
||||
int FontBank::s_wobbleValue=0;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
@ -86,6 +89,7 @@ void FontBank::initialise( FontData *_fontData )
|
|||
setSMode( 0 );
|
||||
|
||||
m_initialised=true;
|
||||
m_wobble=false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,6 +126,9 @@ void FontBank::print( int _x, int _y, s32 _textId )
|
|||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int wstep=50;
|
||||
int wspeed=100;
|
||||
int wscale=1000;
|
||||
void FontBank::print( int _x, int _y, char *_text )
|
||||
{
|
||||
ASSERT( m_initialised );
|
||||
|
@ -161,9 +168,14 @@ void FontBank::print( int _x, int _y, char *_text )
|
|||
break;
|
||||
}
|
||||
|
||||
int fy=_y;
|
||||
while(*_text && Length>0)
|
||||
{
|
||||
Size=printChar(*_text++,_x,_y)+m_fontData->charGapX;
|
||||
if(m_wobble)
|
||||
{
|
||||
fy=_y+(msin((s_wobbleValue+(_x*wstep))&4095)/wscale);
|
||||
}
|
||||
Size=printChar(*_text++,_x,fy)+m_fontData->charGapX;
|
||||
_x+=Size;
|
||||
Length-=Size;
|
||||
}
|
||||
|
@ -338,6 +350,19 @@ int FontBank::getStringWidth( char * text )
|
|||
return getStrWrapLen( text, m_printArea.w );
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void FontBank::think(int _frames)
|
||||
{
|
||||
s_wobbleValue+=(_frames*wspeed)&4095;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
|
|
@ -67,6 +67,8 @@ public:
|
|||
|
||||
int getStrWrapLen( char *_text,int _maxWidth );
|
||||
|
||||
void setWobble(int _wobble) {m_wobble=_wobble;}
|
||||
|
||||
private:
|
||||
virtual int printChar( char _char,int _x,int _y );
|
||||
|
||||
|
@ -79,6 +81,10 @@ private:
|
|||
DEFAULT_OT=1,
|
||||
};
|
||||
|
||||
|
||||
static void think(int _frames); // Needed for the wobble only.. call once from main loop or summink..
|
||||
friend void MainLoop();
|
||||
|
||||
protected:
|
||||
FontData *m_fontData;
|
||||
u8 m_r, m_g, m_b; // Font colour
|
||||
|
@ -90,6 +96,9 @@ protected:
|
|||
|
||||
int m_trans, m_sMode;
|
||||
|
||||
int m_wobble;
|
||||
static int s_wobbleValue;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
|
||||
protected:
|
||||
GUI_FLAGS getInitialFlags() {return FLAG_DRAWBORDER;}
|
||||
GUI_FLAGS getInitialFlags() {return FLAG_NONE;}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -37,6 +37,11 @@
|
|||
/* Data
|
||||
---- */
|
||||
|
||||
#ifndef __SPR_UIGFX_H__
|
||||
#include <uigfx.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
@ -53,6 +58,8 @@
|
|||
Vars
|
||||
---- */
|
||||
|
||||
static SpriteBank *s_uiSpriteBank=0;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
@ -140,32 +147,63 @@ void CGUIObject::render()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef __USER_paul__
|
||||
if(getFlags(FLAG_DRAWBORDER)||forceBorderDraw)
|
||||
#else
|
||||
if(getFlags(FLAG_DRAWBORDER))
|
||||
#endif
|
||||
{
|
||||
POLY_G4 *g4;
|
||||
POLY_F4 *f4;
|
||||
int x,y,w,h;
|
||||
int r,g,b;
|
||||
int ot;
|
||||
|
||||
x=getX()+getParentX();
|
||||
y=getY()+getParentY();
|
||||
w=getW();
|
||||
h=getH();
|
||||
if(isSelected())
|
||||
{
|
||||
r=g=b=245;
|
||||
}
|
||||
else
|
||||
{
|
||||
r=g=b=110;
|
||||
}
|
||||
ot=getOt();
|
||||
|
||||
// Border
|
||||
drawBambooBorder(x,y,w,h,ot);
|
||||
|
||||
// Background
|
||||
f4=GetPrimF4();
|
||||
setXYWH(f4,x,y,w,h);
|
||||
setRGB0(f4, 0, 0, 90);
|
||||
setSemiTrans(f4,true);
|
||||
AddPrimToList(f4,ot);
|
||||
|
||||
/*
|
||||
g4=GetPrimG4();
|
||||
setXYWH(g4,x,y,w,h/2);
|
||||
setRGB0(g4,107,105, 98);
|
||||
setRGB1(g4,107,105, 98);
|
||||
setRGB2(g4, 0, 0, 90);
|
||||
setRGB3(g4, 0, 0, 90);
|
||||
setSemiTrans(g4,true);
|
||||
AddPrimToList(g4,ot);
|
||||
|
||||
g4=GetPrimG4();
|
||||
setXYWH(g4,x,y+h/2,w,h/2);
|
||||
setRGB0(g4, 0, 0, 90);
|
||||
setRGB1(g4, 0, 0, 90);
|
||||
setRGB2(g4,107,105, 98);
|
||||
setRGB3(g4,107,105, 98);
|
||||
setSemiTrans(g4,true);
|
||||
AddPrimToList(g4,ot);
|
||||
*/
|
||||
}
|
||||
|
||||
#ifdef __USER_paul__
|
||||
if(forceBorderDraw)
|
||||
{
|
||||
int x,y,w,h;
|
||||
int ot;
|
||||
int r,g,b;
|
||||
|
||||
x=getX()+getParentX();
|
||||
y=getY()+getParentY();
|
||||
w=getW();
|
||||
h=getH();
|
||||
ot=getOt();
|
||||
r=g=b=200;
|
||||
|
||||
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);
|
||||
|
@ -180,18 +218,8 @@ void CGUIObject::render()
|
|||
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,107,105, 98);
|
||||
setRGB1(g4,107,105, 98);
|
||||
setRGB2(g4, 0, 0, 90);
|
||||
setRGB3(g4, 0, 0, 90);
|
||||
AddPrimToList(g4,ot);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,7 +311,10 @@ void CGUIObjectWithFont::setFlags(GUI_FLAGS _flags)
|
|||
CGUIObject::setFlags(_flags);
|
||||
if(_flags&FLAG_SELECTED)
|
||||
{
|
||||
getFontBank()->setColour(CGUIObjectWithFont::SELECTED_FONT_R,CGUIObjectWithFont::SELECTED_FONT_G,CGUIObjectWithFont::SELECTED_FONT_B);
|
||||
FontBank *fb=getFontBank();
|
||||
fb->setColour(CGUIObjectWithFont::SELECTED_FONT_R,CGUIObjectWithFont::SELECTED_FONT_G,CGUIObjectWithFont::SELECTED_FONT_B);
|
||||
fb->setWobble(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +330,9 @@ void CGUIObjectWithFont::clearFlags(GUI_FLAGS _flags)
|
|||
CGUIObject::clearFlags(_flags);
|
||||
if(_flags&FLAG_SELECTED)
|
||||
{
|
||||
getFontBank()->setColour(CGUIObjectWithFont::DEFAULT_FONT_R,CGUIObjectWithFont::DEFAULT_FONT_G,CGUIObjectWithFont::DEFAULT_FONT_B);
|
||||
FontBank *fb=getFontBank();
|
||||
fb->setColour(CGUIObjectWithFont::DEFAULT_FONT_R,CGUIObjectWithFont::DEFAULT_FONT_G,CGUIObjectWithFont::DEFAULT_FONT_B);
|
||||
fb->setWobble(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,5 +416,78 @@ void CGUIObjectWithSpriteBank::setSpriteBank(FileEquate _fe)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose: NB: This permenantly keeps a copy of the UI sprite bank
|
||||
loaded in vram! Can be changed if necessary.. (PKG)
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void initGUIStuff()
|
||||
{
|
||||
ASSERT(!s_uiSpriteBank);
|
||||
|
||||
s_uiSpriteBank=new ("UI Sprites") SpriteBank();
|
||||
s_uiSpriteBank->load(UI_UIGFX_SPR);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void drawBambooBorder(int _x,int _y,int _w,int _h,int _ot)
|
||||
{
|
||||
sFrameHdr *vbam,*hbam;
|
||||
int totalSize,numSprites,step;
|
||||
int x1,y1,x2,y2;
|
||||
int i;
|
||||
|
||||
|
||||
vbam=s_uiSpriteBank->getFrameHeader(FRM__VBAMBOO);
|
||||
hbam=s_uiSpriteBank->getFrameHeader(FRM__HBAMBOO);
|
||||
|
||||
// Top & bottom
|
||||
totalSize=_w-vbam->W-hbam->W;
|
||||
numSprites=(totalSize/hbam->W)+1;
|
||||
if(numSprites>1)
|
||||
{
|
||||
step=(totalSize<<4)/(numSprites-1);
|
||||
x1=(_x+(vbam->W/2)+(hbam->W/2))<<4;
|
||||
y1=_y-(hbam->H/2);
|
||||
y2=y1+_h;
|
||||
for(i=0;i<numSprites;i++)
|
||||
{
|
||||
s_uiSpriteBank->printFT4(hbam,(x1>>4)-(hbam->W/2),y1,0,0,_ot);
|
||||
s_uiSpriteBank->printFT4(hbam,(x1>>4)-(hbam->W/2),y2,0,0,_ot);
|
||||
x1+=step;
|
||||
}
|
||||
}
|
||||
|
||||
// Left & right
|
||||
totalSize=_h-hbam->H-vbam->H;
|
||||
numSprites=(totalSize/vbam->H)+1;
|
||||
if(numSprites>1)
|
||||
{
|
||||
step=(totalSize<<4)/(numSprites-1);
|
||||
y1=(_y+(hbam->H/2)+(vbam->H/2))<<4;
|
||||
x1=_x-(vbam->W/2);
|
||||
x2=x1+_w;
|
||||
for(i=0;i<numSprites;i++)
|
||||
{
|
||||
s_uiSpriteBank->printFT4(vbam,x1,(y1>>4)-(vbam->H/2),0,0,_ot);
|
||||
s_uiSpriteBank->printFT4(vbam,x2,(y1>>4)-(vbam->H/2),0,0,_ot);
|
||||
y1+=step;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
|
|
@ -189,6 +189,10 @@ private:
|
|||
Functions
|
||||
--------- */
|
||||
|
||||
extern void initGUIStuff();
|
||||
extern void drawBambooBorder(int _x,int _y,int _w,int _h,int _ot);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __GUI_GUI_H__ */
|
||||
|
|
|
@ -38,7 +38,13 @@ CPaulScene s_paulScene;
|
|||
#include "system\except.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GFX_FONT_H__
|
||||
#include "gfx\font.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GUI_GUI_H__
|
||||
#include "gui\gui.h"
|
||||
#endif
|
||||
|
||||
#define SCREEN_GRAB
|
||||
|
||||
|
@ -81,6 +87,8 @@ void InitSystem() // reordered to reduce black screen (hope all is well
|
|||
|
||||
CSoundMediator::initialise();
|
||||
|
||||
initGUIStuff();
|
||||
|
||||
#ifdef __USER_paul__
|
||||
s_paulScene.init();
|
||||
#endif
|
||||
|
@ -100,6 +108,7 @@ void MainLoop()
|
|||
|
||||
frames=GameState::getFramesSinceLast();
|
||||
|
||||
FontBank::think(frames);
|
||||
GameState::think();
|
||||
GameState::render();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue