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