2000-10-31 17:20:53 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
2000-11-02 18:16:10 +01:00
|
|
|
greadout.cpp
|
2000-10-31 17:20:53 +01:00
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#include "gui\greadout.h"
|
|
|
|
|
|
|
|
#ifndef __GFX_FONT_H__
|
|
|
|
#include "gfx\font.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __LOCALE_TEXTDBASE_H__
|
|
|
|
#include "locale\textdbase.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-03 01:07:42 +01:00
|
|
|
#ifndef __GFX_SPRBANK_H__
|
|
|
|
#include "gfx\sprbank.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-03 22:22:27 +01:00
|
|
|
#ifndef __PRIM_HEADER__
|
|
|
|
#include "gfx\prim.h"
|
|
|
|
#endif
|
|
|
|
|
2000-10-31 17:20:53 +01:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
2000-11-03 01:07:42 +01:00
|
|
|
#ifndef __FILE_EQUATES_H__
|
|
|
|
#include <biglump.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-10-31 17:20:53 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2000-11-02 18:16:10 +01:00
|
|
|
void CGUITextReadout::init(CGUIObject *_parent,GUIId _id)
|
2000-10-31 17:20:53 +01:00
|
|
|
{
|
2000-11-02 18:16:10 +01:00
|
|
|
CGUIObjectWithFont::init(_parent,_id);
|
2000-10-31 17:20:53 +01:00
|
|
|
m_target=0;
|
|
|
|
m_data=0;
|
2000-11-03 01:07:42 +01:00
|
|
|
m_lastValue=-1;
|
2000-10-31 17:20:53 +01:00
|
|
|
m_textId=TranslationDatabase::NO_STRING;
|
2000-11-03 01:07:42 +01:00
|
|
|
m_textY=0;
|
2000-10-31 17:20:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUITextReadout::setReadoutTarget(int *_target)
|
|
|
|
{
|
|
|
|
m_target=_target;
|
|
|
|
recalc();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUITextReadout::setReadoutData(TextReadoutData *_data)
|
|
|
|
{
|
|
|
|
m_data=_data;
|
|
|
|
recalc();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUITextReadout::render()
|
|
|
|
{
|
|
|
|
FontBank *fb;
|
|
|
|
|
|
|
|
if(!isHidden())
|
|
|
|
{
|
|
|
|
getFontBank()->print((getW()-(BORDERWIDTH*2))/2,m_textY,m_textId);
|
|
|
|
}
|
2000-11-02 18:16:10 +01:00
|
|
|
CGUIObjectWithFont::render();
|
2000-10-31 17:20:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUITextReadout::think(int _frames)
|
|
|
|
{
|
2000-11-02 18:16:10 +01:00
|
|
|
CGUIObjectWithFont::think(_frames);
|
2000-10-31 17:20:53 +01:00
|
|
|
if(*m_target!=m_lastValue)
|
|
|
|
{
|
|
|
|
recalc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUITextReadout::recalc()
|
|
|
|
{
|
2000-11-02 18:16:10 +01:00
|
|
|
CGUIObjectWithFont::recalc();
|
2000-10-31 17:20:53 +01:00
|
|
|
|
|
|
|
if(m_data)
|
|
|
|
{
|
|
|
|
FontBank *fb;
|
|
|
|
char *string;
|
|
|
|
TextReadoutData *data;
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
m_lastValue=*m_target;
|
|
|
|
fb=getFontBank();
|
|
|
|
m_textId=STR__DUMMY;
|
|
|
|
data=m_data;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(m_lastValue==data->m_value)
|
|
|
|
{
|
|
|
|
m_textId=data->m_textId;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp=data->m_value;
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
while(tmp<data->m_value);
|
|
|
|
string=(char*)TranslationDatabase::getString(m_textId);
|
|
|
|
|
|
|
|
#ifdef __VERSION_DEBUG__
|
|
|
|
if(fb->getStringWidth(string)>getW()-(BORDERWIDTH*2)||
|
|
|
|
fb->getStringHeight(string)>getH()-(BORDERHEIGHT*2))
|
|
|
|
{
|
|
|
|
GUI_DBGMSG("Text overflow in CGUITextReadout!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_textY=(getH()-(BORDERHEIGHT*2)-fb->getStringHeight(string))/2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-03 01:07:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUISpriteReadout::init(CGUIObject *_parent,GUIId _id)
|
|
|
|
{
|
2000-11-03 22:22:27 +01:00
|
|
|
CGUIObjectWithSpriteBank::init(_parent,_id);
|
2000-11-03 01:07:42 +01:00
|
|
|
m_target=0;
|
|
|
|
m_data=0;
|
|
|
|
m_lastValue=-1;
|
|
|
|
m_frame=0;
|
|
|
|
m_x=m_y=0;
|
2001-04-20 16:53:35 +02:00
|
|
|
setSpriteBank(SPRITES_SPRITES_SPR);
|
2000-11-03 01:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
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())
|
|
|
|
{
|
2000-11-03 22:22:27 +01:00
|
|
|
getSpriteBank()->printFT4(m_frame,getParentX()+m_x,getParentY()+m_y,0,0,getOt());
|
2000-11-03 01:07:42 +01:00
|
|
|
}
|
2000-11-03 22:22:27 +01:00
|
|
|
CGUIObjectWithSpriteBank::render();
|
2000-11-03 01:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
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);
|
2000-11-03 22:22:27 +01:00
|
|
|
fh=getSpriteBank()->getFrameHeader(m_frame);
|
2000-11-03 01:07:42 +01:00
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-03 22:22:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-31 17:20:53 +01:00
|
|
|
/*===========================================================================
|
|
|
|
end */
|