This commit is contained in:
Paul 2000-11-03 00:07:42 +00:00
parent fcaef22819
commit 4876c7760b
8 changed files with 357 additions and 54 deletions

View file

@ -26,6 +26,10 @@
#include "locale\textdbase.h"
#endif
#ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h"
#endif
/* Std Lib
------- */
@ -33,6 +37,11 @@
/* Data
---- */
#ifndef __FILE_EQUATES_H__
#include <biglump.h>
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
@ -60,7 +69,9 @@ void CGUITextReadout::init(CGUIObject *_parent,GUIId _id)
CGUIObjectWithFont::init(_parent,_id);
m_target=0;
m_data=0;
m_lastValue=-1;
m_textId=TranslationDatabase::NO_STRING;
m_textY=0;
}
@ -142,10 +153,7 @@ void CGUITextReadout::recalc()
int tmp;
m_lastValue=*m_target;
m_textId=4;
fb=getFontBank();
m_textId=STR__DUMMY;
data=m_data;
do
@ -174,5 +182,149 @@ void CGUITextReadout::recalc()
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CGUISpriteReadout::init(CGUIObject *_parent,GUIId _id)
{
CGUIObject::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;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CGUISpriteReadout::setReadoutTarget(int *_target)
{
m_target=_target;
recalc();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CGUISpriteReadout::setReadoutData(SpriteReadoutData *_data)
{
m_data=_data;
recalc();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CGUISpriteReadout::render()
{
FontBank *fb;
if(!isHidden())
{
m_sprites->printFT4(m_frame,getParentX()+m_x,getParentY()+m_y,0,0,getOt());
}
CGUIObject::render();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CGUISpriteReadout::think(int _frames)
{
CGUIObject::think(_frames);
if(*m_target!=m_lastValue)
{
recalc();
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CGUISpriteReadout::recalc()
{
CGUIObject::recalc();
if(m_data)
{
char *string;
SpriteReadoutData *data;
int tmp;
sFrameHdr *fh;
int x,y;
m_lastValue=*m_target;
m_frame=0;
data=m_data;
do
{
if(m_lastValue==data->m_value)
{
m_frame=data->m_frame;
break;
}
tmp=data->m_value;
data++;
}
while(tmp<data->m_value);
fh=m_sprites->getFrameHeader(m_frame);
#ifdef __VERSION_DEBUG__
if(fh->W>getW()-(BORDERWIDTH*2)||
fh->H>getH()-(BORDERHEIGHT*2))
{
GUI_DBGMSG("Sprite overflow in CGUISpriteReadout!");
}
#endif
m_x=getX()+(getW()-fh->W)/2;
m_y=getY()+(getH()-fh->H)/2;
}
}
/*===========================================================================
end */