Blame | Last modification | View Log | RSS feed
#ifndef __RENDEROBJECT_H__
#define __RENDEROBJECT_H__
#include <spk.h>
#include "../X3Overlay.h"
enum {FADE_NONE, FADE_AFTER, FADE_ALL};
enum {ANIM_NONE, ANIM_FADEIN, ANIM_FADEOUT, ANIM_FLASH, ANIM_MOVE, ANIM_MOVELINEAR, ANIM_CHANGETEXT, ANIM_CHANGECOLOUR, ANIM_FRAME, ANIM_ANIMATION, ANIM_ANIMATIONCONT, ANIM_ANIMATIONSTOP};
enum {MO_NONE, MO_COLOUR, MO_SOUND, MO_TEXTAPPEND, MO_TEXTPREPEND, MO_TEXTURE, MO_SETVARIABLE, MO_SWITCHVARIABLE, MO_CLOSE, MO_SEND, MO_FRAME, MO_ANIMATION};
typedef struct SAnimate {
struct SAnimate () { iType = ANIM_NONE; iStartTime = 0; iDone = 0; bRemove = false; }
int iType;
int iStartTime;
int iDone;
bool bRemove;
} SAnimate;
typedef struct SAnimateFadeIn : public SAnimate {
struct SAnimateFadeIn () : SAnimate() { iType = ANIM_FADEIN; iTime = 0; }
short iTime;
} SAnimateFadeIn;
typedef struct SAnimateFadeOut : public SAnimate {
struct SAnimateFadeOut () : SAnimate() { iType = ANIM_FADEOUT; iTime = 0; }
short iTime;
} SAnimateFadeOut;
typedef struct SAnimateFlash : public SAnimate {
struct SAnimateFlash () : SAnimate() { iType = ANIM_FLASH; iTime = 0; iCycle = 0; bIn = false; iDoneCycle = 0; }
int iTime;
int iCycle;
int iDoneCycle;
bool bIn;
} SAnimateFlash;
typedef struct SAnimatePos : public SAnimate {
struct SAnimatePos () : SAnimate() { iType = ANIM_MOVE; iX = 0; iY = 0; }
int iX;
int iY;
} SAnimatePos;
typedef struct SAnimateColour : public SAnimate {
struct SAnimateColour () : SAnimate() { iType = ANIM_CHANGECOLOUR; iR = 0; iG = 0; iB = 0; }
short iR;
short iG;
short iB;
} SAnimateColour;
typedef struct SAnimateFrame : public SAnimate {
struct SAnimateFrame () : SAnimate() { iType = ANIM_FRAME; iFrame = 0; }
int iFrame;
} SAnimateFrame;
typedef struct SAnimateAnim : public SAnimate {
struct SAnimateAnim () : SAnimate() { iType = ANIM_ANIMATION; iAnimation = 0; }
int iAnimation;
} SAnimateAnim;
typedef struct SAnimateAnimStop : public SAnimate {
struct SAnimateAnimStop () : SAnimate() { iType = ANIM_ANIMATIONSTOP; }
} SAnimateAnimStop;
typedef struct SAnimateAnimCont : public SAnimate {
struct SAnimateAnimCont () : SAnimate() { iType = ANIM_ANIMATIONCONT; }
} SAnimateAnimCont;
typedef struct SAnimateText : public SAnimate {
struct SAnimateText () : SAnimate() { iType = ANIM_CHANGETEXT; }
CyString sText;
} SAnimateText;
typedef struct SAnimateLinear : public SAnimatePos {
struct SAnimateLinear () : SAnimatePos() { iType = ANIM_MOVELINEAR; iTime = 0; }
int iTime;
} SAnimateLinear;
typedef struct SMouseOver {
struct SMouseOver () { iType = MO_NONE; bStarted = false; }
int iType;
bool bStarted;
} SMouseOver;
typedef struct SMOColour : public SMouseOver {
struct SMOColour () : SMouseOver() { iType = MO_COLOUR; iColour[0] = 0; iColour[1] = 0; iColour[2] = 0; }
short iColour[3];
} SMOColour;
typedef struct SMOSound : public SMouseOver {
struct SMOSound () : SMouseOver() { iType = MO_SOUND; }
CyString sFilename;
} SMOSound;
typedef struct SMOSet : public SMouseOver {
struct SMOSet () : SMouseOver() { iType = MO_SETVARIABLE; }
CyString sVariable;
CyString sSet;
} SMOSet;
typedef struct SMOSwitchV : public SMouseOver {
struct SMOSwitchV () : SMouseOver() { iType = MO_SWITCHVARIABLE; }
CyString sVariable;
CyStringList lSwitch;
} SMOSwitchV;
typedef struct SMOTextAppend : public SMouseOver {
struct SMOTextAppend () : SMouseOver() { iType = MO_TEXTAPPEND; }
CyString sText;
} SMOTextAppend;
typedef struct SMOTextPrepend : public SMouseOver {
struct SMOTextPrepend () : SMouseOver() { iType = MO_TEXTPREPEND; }
CyString sText;
} SMOTextPrepend;
typedef struct SMOTexture : public SMouseOver {
struct SMOTexture () : SMouseOver() { iType = MO_TEXTURE; }
LPDIRECT3DTEXTURE9 pTexture;
} SMOTexture;
typedef struct SMOFrame : public SMouseOver {
struct SMOFrame () : SMouseOver() { iType = MO_FRAME; iFrame = 1; }
int iFrame;
} SMOFrame;
typedef struct SMOAnimation : public SMouseOver {
struct SMOAnimation () : SMouseOver() { iType = MO_ANIMATION; iAnimation = 1; bStop = true; }
int iAnimation;
bool bStop;
} SMOAnimation;
typedef struct SMOSend : public SMouseOver {
struct SMOSend () : SMouseOver() { iType = MO_SEND; }
CyString sData;
CyString sName;
} SMOSend;
class CDisplay;
class CRenderObject
{
public:
CRenderObject ();
~CRenderObject ();
bool StartHidden() { return m_bStartHidden; }
bool MouseOver() { return m_bMouseOver; }
bool MouseClicked () { return m_bClicked; }
virtual bool DoReopen () { return false; }
virtual int SetMouseClicked ( COverlay *overlay, CyString name, int but, bool b );
void SetAlpha ( short a ) { if ( a > m_iMaxAlpha ) a = m_iMaxAlpha; m_iAlpha = a; }
void SetDevice ( MyDirect3DDevice9 *device ) { m_pDevice = device; }
virtual void AddMouseEvent ( CyString section, SMouseOver *e );
virtual void render ( MyDirect3DDevice9 *device, int x, int y, LPD3DXSPRITE sprite ) = 0;
virtual void Update ( COverlay *overlay, float dt, int mousex, int mousey, int offsetx, int offsety ) ;
virtual bool CheckMouse ( int x, int y, int offsetx, int offsety ) { return false; }
virtual bool Fade ( int end, int current, int maxtime, bool reverse = false );
virtual void DoAnimation ( SAnimate *anim, int iDt );
virtual void StartAnimation ( SAnimate *anim );
virtual void EndAnimation ( SAnimate *anim );
virtual void SetPosition ( int x, int y ) { m_iX = x; m_iY = y; }
virtual void ParseSetting ( COverlay *overlay, CyString cmd, CyString rest, CyString section );
virtual int ConvertAnimationTime ( CyString t );
CyString ParseVaribles ( CyString str, CyStringList *varibles );
void FinishedLoad ()
{
if ( (m_iFadeTo) || (m_bStartHidden) )
m_iAlpha = 0;
else
m_iAlpha = m_iMaxAlpha;
}
static void Log ( CyString str )
{
FILE *id;
if ( !fopen_s ( &id, "c:/log.txt", "a" ) )
{
fputs ( str.c_str(), id );
fclose ( id );
}
}
protected:
int m_iX;
int m_iY;
int m_iStartX, m_iStartY;
MyDirect3DDevice9 *m_pDevice;
int m_iStarted;
int m_iStartFade;
int m_iFadeTo;
short m_iAlpha;
short m_iMaxAlpha;
bool m_bStartHidden;
CLinkList<SAnimate> m_lAnimations;
CLinkList<SMouseOver> m_lMouseOver;
CLinkList<SMouseOver> m_lMouseClick;
CyStringList m_lVaribles;
bool m_bMouseOver;
bool m_bClicked;
bool m_bDontRender;
short m_iColour[3];
};
#endif //__RENDEROBJECT_H__