Subversion Repositories spk

Rev

Rev 11 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 cycrow 1
#ifndef __DISPLAY_H__
2
#define __DISPLAY_H__
3
 
4
#include <spk.h>
5
#include "../../src/Visualisation/TextureFile.h"
6
#include "../Overlay.h"
7
#include "RenderObject.h"
8
 
123 cycrow 9
#ifdef FMOD
11 cycrow 10
#include <fmod.hpp>
123 cycrow 11
#endif
11 cycrow 12
 
13
typedef struct SSound {
14
	struct SSound () { iStart = 0; bStarted = false; }
15
	CyString sFilename;
16
	long	iStart;
17
	bool	bStarted;
18
} SSound;
19
 
20
typedef struct SFunction {
21
	CyString sFunction;
22
	CyString sBlock;
23
	CyStringList lVaribles;
24
	CyStringList lStrings;
25
} SFunction;
26
 
27
typedef struct SCloseOn {
28
	struct SCloseOn () { iStart = 0; iEnd = 0; iMouseCommands = 0; iKeyCommands = 0; }
29
	int iStart;
30
	int iEnd;
31
	long iMouseCommands;
32
	long iKeyCommands;
33
} SCloseOn;
34
 
35
#define COMMAND_LEFTCLICK		1
36
#define COMMAND_RIGHTCLICK		2
37
#define COMMAND_LEFTCLICKIN		4
38
#define COMMAND_RIGHTCLICKIN	8
39
 
40
#define COMMAND_KEY_ENTER		1
41
#define COMMAND_KEY_SPACE		2
42
 
43
 
44
class CDisplay
45
{
46
public:
47
	CDisplay ( COverlay *overlay, MyDirect3DDevice9 *device, CyString name );
48
	~CDisplay ();
49
 
50
	int GetBorderSizeX () { return m_iBorderSizeX; }
51
	int GetBorderSizeY () { return m_iBorderSizeY; }
52
 
53
	int GetMouseX ();
54
	int GetMouseY ();
55
 
56
	static void Log ( CyString str )
57
	{
58
		FILE *id;
59
		fopen_s ( &id, "d:/log.txt", "a" );
60
		fputs ( str.c_str(), id );
61
		fclose ( id );
62
	}
63
 
64
	bool HaltMouse () { return m_bHaltMouse; }
65
	bool IsMouseInGui ();
66
 
67
	void SetMouse ( int *x, int *y )
68
	{
69
		m_pMouseX = x;
70
		m_pMouseY = y;
71
 
72
		if ( m_bContainMouse )
73
		{
74
			*m_pMouseX = m_iWidth / 2;
75
			*m_pMouseY = m_iHeight / 2;
76
		}
77
	}
78
	void CreateSound ( CyString file, long start );
79
	virtual void SetSize ( int width, int height, int maxwidth, int maxheight );
80
 
81
	CyString ParseVaribles ( CyString str, CyStringList *varibles );
82
 
83
	void SetTimeout ( long time ) { m_lTimeout = time; }
84
	long GetTimeout () { return m_lTimeout; }
85
	void AddObject ( CRenderObject *o )	{ m_objects.push_back ( o ); }
86
	void RemoveObject ( CRenderObject *o ) { m_objects.remove ( o ); }
87
	void ClearObjects () 
88
	{
89
		for ( CRenderObject *o = m_objects.First(); o; o = m_objects.Next() )
90
			delete o;
91
		m_objects.clear();
92
	}
93
 
94
	virtual float Update ( DWORD timeNow );
95
	virtual void render ( MyDirect3DDevice9 * );
96
	virtual void RenderBorder ( MyDirect3DDevice9 * );
97
	virtual void RenderCursor ( MyDirect3DDevice9 *device );
98
	virtual void SetBorderTexture ( CyString t );
99
	virtual void SetCursorTexture ( CyString t );
100
	virtual void SetLength(int i) { m_iSizeY = i; }
101
	virtual void SetWidth(int i) { m_iSizeX = i; }
102
	virtual void SetMaxSize(int x, int y) { m_iMaxWidth = x; m_iMaxHeight = y; }
103
 
104
	virtual bool MouseClick ( int b, bool );
105
	virtual bool CheckCloseEventKey ( int key );
106
	bool Closed () { return m_bClosed; }
107
	bool CheckName(const CyString &name) { return m_sGuiName.Compare(name); }
108
	bool CheckTimeout(DWORD tNow)
109
	{
110
		if ( ((m_lTimeout != -1) && (m_lTimeout < (int)tNow)) || (m_bClosed) )
111
			return true;
112
		return false;
113
	}
114
 
115
	void SwitchRender () { m_bRender = !m_bRender; }
116
	virtual void SetPosition(int x, int y);
117
	virtual void SetSize(int width, int height);
118
 
119
protected:
120
	RECT *GetFrame ( int frame );
121
 
122
	CLinkList<CRenderObject> m_objects;
123
	CLinkList<SSound> m_lSounds;
124
	CLinkList<SCloseOn> m_lClose;
125
	CLinkList<SFunction> m_lFunctions;
126
 
127
	int m_iCornerX, m_iCornerY;
128
	int m_iSizeX, m_iSizeY;
129
 
130
	LPDIRECT3DTEXTURE9 m_borderTexture;
131
	LPDIRECT3DTEXTURE9 m_cursorTexture;
132
	LPD3DXSPRITE m_sprite;
133
 
134
	bool  m_bRender;
135
	bool	m_bNoBorder;
136
 
137
	long m_lTimeout;
138
 
139
	int m_iBorderSizeX;
140
	int m_iBorderSizeY;
141
 
142
	MyDirect3DDevice9 *m_pDevice;
143
 
144
	short m_iAlpha;
145
	long  m_iFadeIn;
146
	short m_iFadeState;
147
	long m_iStartDisplay;
148
 
149
	DWORD m_lastUpdate; // time when the world was last updated
150
 
151
	CTextureFile *m_pBorderFile;
152
	CTextureFile *m_pCursorFile;
153
 
154
	int *m_pMouseX, *m_pMouseY;
155
 
156
	bool m_bContainMouse;
157
	bool m_bHaltMouse;
158
 
159
	bool m_bClosed;
160
	bool m_bLongWait;
161
 
162
	int m_iWidth, m_iHeight;
163
	int m_iMaxWidth, m_iMaxHeight;
164
 
165
	COverlay *m_pOverlay;
166
 
167
	CyString m_sGuiName;
168
 
169
	bool m_bLog;
170
};
171
 
172
 
173
#endif //__DISPLAY_H__