Subversion Repositories spk

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 cycrow 1
#ifndef __RENDEROBJECT_H__
2
#define __RENDEROBJECT_H__
3
 
4
#include <spk.h>
5
#include "../X3Overlay.h"
6
 
7
enum {FADE_NONE, FADE_AFTER, FADE_ALL};
8
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};
9
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};
10
 
11
typedef struct SAnimate {
12
	struct SAnimate () { iType = ANIM_NONE; iStartTime = 0; iDone = 0; bRemove = false; }
13
	int iType;
14
	int iStartTime;
15
	int iDone;
16
	bool bRemove;
17
} SAnimate;
18
 
19
typedef struct SAnimateFadeIn : public SAnimate {
20
	struct SAnimateFadeIn () : SAnimate() { iType = ANIM_FADEIN; iTime = 0; }
21
	short iTime;
22
} SAnimateFadeIn;
23
 
24
typedef struct SAnimateFadeOut : public SAnimate {
25
	struct SAnimateFadeOut () : SAnimate() { iType = ANIM_FADEOUT; iTime = 0; }
26
	short iTime;
27
} SAnimateFadeOut;
28
 
29
typedef struct SAnimateFlash : public SAnimate {
30
	struct SAnimateFlash () : SAnimate() { iType = ANIM_FLASH; iTime = 0; iCycle = 0; bIn = false; iDoneCycle = 0; }
31
	int iTime;
32
	int iCycle; 
33
	int iDoneCycle;
34
	bool  bIn;
35
} SAnimateFlash;
36
 
37
typedef struct SAnimatePos : public SAnimate {
38
	struct SAnimatePos () : SAnimate() { iType = ANIM_MOVE; iX = 0; iY = 0; }
39
	int iX;
40
	int iY;
41
} SAnimatePos;
42
 
43
typedef struct SAnimateColour : public SAnimate {
44
	struct SAnimateColour () : SAnimate() { iType = ANIM_CHANGECOLOUR; iR = 0; iG = 0; iB = 0; }
45
	short iR;
46
	short iG;
47
	short iB;
48
} SAnimateColour;
49
 
50
typedef struct SAnimateFrame : public SAnimate {
51
	struct SAnimateFrame () : SAnimate() { iType = ANIM_FRAME; iFrame = 0; }
52
	int iFrame;
53
} SAnimateFrame;
54
 
55
typedef struct SAnimateAnim : public SAnimate {
56
	struct SAnimateAnim () : SAnimate() { iType = ANIM_ANIMATION; iAnimation = 0; }
57
	int iAnimation;
58
} SAnimateAnim;
59
 
60
typedef struct SAnimateAnimStop : public SAnimate {
61
	struct SAnimateAnimStop () : SAnimate() { iType = ANIM_ANIMATIONSTOP; }
62
} SAnimateAnimStop;
63
 
64
typedef struct SAnimateAnimCont : public SAnimate {
65
	struct SAnimateAnimCont () : SAnimate() { iType = ANIM_ANIMATIONCONT; }
66
} SAnimateAnimCont;
67
 
68
typedef struct SAnimateText : public SAnimate {
69
	struct SAnimateText () : SAnimate() { iType = ANIM_CHANGETEXT; }
70
	CyString sText;
71
} SAnimateText;
72
 
73
typedef struct SAnimateLinear : public SAnimatePos {
74
	struct SAnimateLinear () : SAnimatePos() { iType = ANIM_MOVELINEAR; iTime = 0; }
75
	int iTime;
76
} SAnimateLinear;
77
 
78
typedef struct SMouseOver {
79
	struct SMouseOver () { iType = MO_NONE; bStarted = false; }
80
	int	iType;
81
	bool	bStarted;
82
} SMouseOver;
83
 
84
typedef struct SMOColour : public SMouseOver {
85
	struct SMOColour () : SMouseOver() { iType = MO_COLOUR; iColour[0] = 0; iColour[1] = 0; iColour[2] = 0; }
86
	short iColour[3];
87
} SMOColour;
88
 
89
typedef struct SMOSound : public SMouseOver {
90
	struct SMOSound () : SMouseOver() { iType = MO_SOUND; }
91
	CyString sFilename;
92
} SMOSound;
93
 
94
typedef struct SMOSet : public SMouseOver {
95
	struct SMOSet () : SMouseOver() { iType = MO_SETVARIABLE; }
96
	CyString sVariable;
97
	CyString sSet;
98
} SMOSet;
99
 
100
typedef struct SMOSwitchV : public SMouseOver {
101
	struct SMOSwitchV () : SMouseOver() { iType = MO_SWITCHVARIABLE; }
102
	CyString sVariable;
103
	CyStringList lSwitch;
104
} SMOSwitchV;
105
 
106
typedef struct SMOTextAppend : public SMouseOver {
107
	struct SMOTextAppend () : SMouseOver() { iType = MO_TEXTAPPEND; }
108
	CyString sText;
109
} SMOTextAppend;
110
 
111
typedef struct SMOTextPrepend : public SMouseOver {
112
	struct SMOTextPrepend () : SMouseOver() { iType = MO_TEXTPREPEND; }
113
	CyString sText;
114
} SMOTextPrepend;
115
 
116
typedef struct SMOTexture : public SMouseOver {
117
	struct SMOTexture () : SMouseOver() { iType = MO_TEXTURE; }
118
	LPDIRECT3DTEXTURE9 pTexture;
119
} SMOTexture;
120
 
121
typedef struct SMOFrame : public SMouseOver {
122
	struct SMOFrame () : SMouseOver() { iType = MO_FRAME; iFrame = 1; }
123
	int iFrame;
124
} SMOFrame;
125
 
126
typedef struct SMOAnimation : public SMouseOver {
127
	struct SMOAnimation () : SMouseOver() { iType = MO_ANIMATION; iAnimation = 1; bStop = true; }
128
	int iAnimation;
129
	bool bStop;
130
} SMOAnimation;
131
 
132
typedef struct SMOSend : public SMouseOver {
133
	struct SMOSend () : SMouseOver() { iType = MO_SEND; }
134
	CyString sData;
135
	CyString sName;
136
} SMOSend;
137
 
138
class CDisplay;
139
 
140
class CRenderObject 
141
{
142
public:
143
	CRenderObject ();
144
	~CRenderObject ();
145
 
146
	bool StartHidden() { return m_bStartHidden; }
147
	bool MouseOver() { return m_bMouseOver; }
148
	bool MouseClicked () { return m_bClicked; }
149
 
150
	virtual bool DoReopen () { return false; }
151
 
152
	virtual int SetMouseClicked ( COverlay *overlay, CyString name, int but, bool b );
153
	void SetAlpha ( short a ) { if ( a > m_iMaxAlpha ) a = m_iMaxAlpha; m_iAlpha = a; }
154
	void SetDevice ( MyDirect3DDevice9 *device ) { m_pDevice = device; }
155
 
156
	virtual void AddMouseEvent ( CyString section, SMouseOver *e );
157
 
158
	virtual void render ( MyDirect3DDevice9 *device, int x, int y, LPD3DXSPRITE sprite ) = 0;
159
	virtual void Update ( COverlay *overlay, float dt, int mousex, int mousey, int offsetx, int offsety ) ;
160
 
161
	virtual bool CheckMouse ( int x, int y, int offsetx, int offsety ) { return false; }
162
 
163
	virtual bool Fade ( int end, int current, int maxtime, bool reverse = false );
164
	virtual void DoAnimation ( SAnimate *anim, int iDt );
165
	virtual void StartAnimation ( SAnimate *anim );
166
	virtual void EndAnimation ( SAnimate *anim );
167
 
168
	virtual void SetPosition ( int x, int y ) {	m_iX = x; m_iY = y;	}
169
	virtual void ParseSetting ( COverlay *overlay, CyString cmd, CyString rest, CyString section );
170
 
171
	virtual int ConvertAnimationTime ( CyString t );
172
	CyString ParseVaribles ( CyString str, CyStringList *varibles );
173
 
174
	void FinishedLoad ()
175
	{
176
		if ( (m_iFadeTo) || (m_bStartHidden) )
177
			m_iAlpha = 0;
178
		else
179
			m_iAlpha = m_iMaxAlpha;
180
	}
181
 
182
	static void Log ( CyString str )
183
	{
184
		FILE *id;
185
		if ( !fopen_s ( &id, "c:/log.txt", "a" ) )
186
		{
187
			fputs ( str.c_str(), id );
188
			fclose ( id );
189
		}
190
	}
191
 
192
protected:
193
	int		m_iX;
194
	int		m_iY;
195
 
196
	int m_iStartX, m_iStartY;
197
 
198
	MyDirect3DDevice9 *m_pDevice;
199
	int m_iStarted;
200
	int m_iStartFade;
201
	int m_iFadeTo;
202
	short m_iAlpha;
203
	short m_iMaxAlpha;
204
 
205
	bool m_bStartHidden;
206
 
207
	CLinkList<SAnimate> m_lAnimations;
208
	CLinkList<SMouseOver> m_lMouseOver;
209
	CLinkList<SMouseOver> m_lMouseClick;
210
 
211
	CyStringList m_lVaribles;
212
 
213
	bool m_bMouseOver;
214
	bool m_bClicked;
215
 
216
	bool m_bDontRender;
217
 
218
	short m_iColour[3];
219
};
220
 
221
#endif //__RENDEROBJECT_H__