-
Notifications
You must be signed in to change notification settings - Fork 6
/
cInterface.h
193 lines (156 loc) · 5.35 KB
/
cInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#pragma once
#include "cThread.h"
#include "cObjectDB.h"
#include "cCharInfo.h"
#include "WindowLib/cWindowManager.h"
#include "cCellManager.h"
#include "Landblocks.h"
//widgets
#include "cProgressBar.h"
#include "cPictureBox.h"
#include "cStaticText.h"
#include "cEditBox.h"
#include "cScrollBar.h"
#include "cMovableWindow.h"
#include "cCustomWindows.h"
struct stCharList {
struct CharInfo {
char Name[32];
DWORD GUID;
DWORD DelTimeout;
};
int CharCount, CharSlots, Reserved;
std::vector<CharInfo> Chars;
std::string ZoneName;
};
enum eInterfaceMode {
eConnecting,
eMOTD,
eEnteringGame,
eGame
};
class cNetwork;
class cInterface : public cLockable, public CWindow,
private KeyboardEventsAbstractor< cInterface >,
private RenderEventAbstractor< cInterface >,
private MouseEventsAbstractor< cInterface >
{
public:
cInterface();
~cInterface();
void SetNetwork(cNetwork *Network);
void SetObjectDB(cObjectDB *ObjectDB);
void SetCharInfo(cCharInfo *CharInfo);
void WindowsMessage(UINT Message, WPARAM wParam, LPARAM lParam);
int Draw(RECT rRect, HDC hDC);
void Resize(int iWidth, int iHeight);
void OutputConsoleString(std::string & Output);
void OutputConsoleString(char *format, ...);
void OutputString(eColor Color, std::string & Output);
void OutputString(eColor Color, char *format, ...);
void SetInterfaceMode(eInterfaceMode Mode);
void SetConnProgress(float NewProgress);
void SetCharList(stCharList *CharList);
void SetMOTD(char *MOTD);
void SetWorldPlayers(char *WorldName, DWORD Players, DWORD MaxPlayers);
void SetLastAttacker(DWORD GUID);
float GetZoomSpeed() { return fSpeed; }
WORD GetPosition()
{
int dwBlockX = 1.25f*(101.95+FlyerCenter.x);
if (dwBlockX < 0) dwBlockX = 0;
if (dwBlockX > 255) dwBlockX = 255;
int dwBlockY = 1.25f*(101.95+FlyerCenter.y);
if (dwBlockY < 0) dwBlockY = 0;
if (dwBlockY > 255) dwBlockY = 255;
DWORD LBX = dwBlockX;
DWORD LBY = dwBlockY;
return (LBX << 8) | LBY;
}
// void SetStance(WORD NewStance);
void AddLandblock(cPortalFile *NewLB);
DWORD GetCurrentSelection();
private:
bool MouseEventsAbstractor< cInterface >::OnClick( IWindow & Window, float X, float Y, unsigned long Button );
bool MouseEventsAbstractor< cInterface >::OnDoubleClick( IWindow & Window, float X, float Y, unsigned long Button );
bool MouseEventsAbstractor< cInterface >::OnMouseEnter( IWindow & Window, float X, float Y, unsigned long Button );
bool MouseEventsAbstractor< cInterface >::OnMouseExit( IWindow & Window, float X, float Y, unsigned long Button );
bool MouseEventsAbstractor< cInterface >::OnMouseWheel( IWindow & Window, float X, float Y, unsigned long Button );
bool MouseEventsAbstractor< cInterface >::OnMouseDown( IWindow & Window, float X, float Y, unsigned long Button );
bool MouseEventsAbstractor< cInterface >::OnMouseMove( IWindow & Window, float X, float Y, unsigned long Button );
bool MouseEventsAbstractor< cInterface >::OnMouseUp( IWindow & Window, float X, float Y, unsigned long Button );
bool KeyboardEventsAbstractor< cInterface >::OnKeyDown( IWindow & Window, unsigned long KeyCode );
bool KeyboardEventsAbstractor< cInterface >::OnKeyPress( IWindow & Window, unsigned long KeyCode );
bool KeyboardEventsAbstractor< cInterface >::OnKeyUp( IWindow & Window, unsigned long KeyCode );
bool RenderEventAbstractor< cInterface >::OnRender( IWindow & Window, double TimeSlice );
void LoadLandblocks();
bool FindLandblocks(FILE *cell, DWORD dirPos);
void DrawLandblockFFFF(DWORD Landblock);
void DrawLandblockFFFE(DWORD Landblock);
void DispatchMessages();
void ParseEditInput( std::string &szInput );
cNetwork *m_Network;
cObjectDB *m_ObjectDB;
cCharInfo *m_CharInfo;
//main display interface stuff
eInterfaceMode m_InterfaceMode;
int m_iWidth, m_iHeight;
float m_fConnProgress;
stCharList m_CharList;
char m_MOTD[2048];
DWORD m_dwSelChar;
DWORD m_dwNumPlayers;
char m_sWorldName[128];
DWORD m_dwLastAttacker;
bool m_bCombatMode;
// WORD m_wStance;
DWORD m_dwCurSelect;
bool m_bFirstSize;
bool m_bShowConsole;
int m_iTriCount;
std::vector <std::string> m_vConsoleHistory;
CRITICAL_SECTION csChat;
//camera
float m_fCamDist;
float m_fCamRotX, m_fCamRotY;
int m_iRenderRadius;
cPoint3D FlyerCenter;
float fLastX, fLastY, fStartX, fStartY;
bool bRotating;
bool bForward, bBack, bLeft, bRight, bShift, bStrLeft, bStrRight;
bool bAnimUpdate;
float fSpeed;
std::map<WORD, cLandblock *> m_mLandblocks;
std::unordered_set<WORD> m_mCurrentLandblocks, m_mNeedToLoadBlocks, m_mDownloadingLandblocks;
LARGE_INTEGER liFreq, liLast;
//window message queue to keep threads from crossing
struct stWindowsMessage {
UINT Message;
WPARAM wParam;
LPARAM lParam;
};
std::list<stWindowsMessage> m_vWMessages;
//window manager stuff
CWindowManager *m_WindowManager;
//connecting screen
cProgressBar * m_pbConnecting;
cStaticText * m_stConnecting;
cModelGroup * m_mgBZ, * m_mgAsh;
//MOTD screen
cPictureBox * m_picEnterGame, * m_picCharList, *m_picCharListTop, * m_picSelChar, *m_picMap;
cStaticText * m_stCharList[5], * m_stMOTD;
cModelGroup * m_mgChars[5], * m_mgPlatforms[5];
//Texture viewer
cPictureBox * m_pbTex[6][6];
DWORD m_dwBaseTex;
//In game
cChatWindow *m_mwChat;
cVitalsWindow *m_mwVitals;
cRadar *m_mwRadar;
cMinimap *m_mwMinimap;
cStatWindow *m_mwStats;
cSkillWindow *m_mwSkills;
cWindowToolbar *m_mwWindowToolbar;
cSpellBar *m_mwSpellBar;
};
#include "cNetwork.h"