Clone of Akilla's ac2d @ https://github.com/deregtd/AC2D

cInterface.h 5.4KB

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