UiMsgCentrePad.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:8k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /*****************************************************************************************
  2. // 界面--消息中心面板
  3. // Copyright : Kingsoft 2002
  4. // Author :   Wooy(Wu yue)
  5. // CreateTime: 2002-12-13
  6. ------------------------------------------------------------------------------------------
  7. *****************************************************************************************/
  8. #pragma once
  9. #include "../Elem/WndMessageListBox.h"
  10. int VerticalSplitTwoWindow(KWndWindow* pLeft, KWndWindow* pRight, int nAt);
  11. struct KUiMsgParam;
  12. #define MAX_CHANNELRESOURCE 10
  13. struct KChannelResourceInfo
  14. {
  15. char cTitle[32];
  16. char cShortTitle[MAX_CHANNELRESOURCE][32];
  17. KRColor uTextColor;
  18. KRColor uTextBorderColor;
  19. WORD nMenuPicIndex;
  20. WORD nMenuPicHeight;
  21. char cMenuText[32];
  22. WORD nMenuDeactivatePicIndex;
  23. WORD nMenuDeactivatePicHeight;
  24. char cMenuDeactivateText[32];
  25. KRColor uMenuBkColor;
  26. WORD nTextPicIndex;
  27. char cFormatName[32]; //用于频道订阅
  28. int nNeverClose;
  29. char szSoundFileName[80];
  30. unsigned int uSendMsgInterval; //用于发送消息的时间间隔(毫秒)
  31. unsigned int uSendMsgNum; //用于缓存待发送消息最大数目,最大10句
  32. };
  33. struct KChannelActivateInfo
  34. {
  35. DWORD nChannelID;
  36. BYTE cost;
  37. bool bSubscribe;
  38. int ResourceIndex; //-1表示无资源
  39. unsigned int uLastSendMsgTime; //上次发消息的时间
  40. unsigned int uLeftSendMsgNum; //已经缓存的代发消息
  41. unsigned int uBufferOffset; //可用空间的起始位置
  42. char Buffer[1024 * 10];
  43. };
  44. struct KMSN_ChannelInfo
  45. {
  46. KRColor uTextColorSelf;
  47. KRColor uTextBorderColorSelf;
  48. WORD nSelfTextPicIndex;
  49. KRColor uTextBKColorSelf;
  50. KRColor uTextFriendColor;
  51. KRColor uTextBorderFriendColor;
  52. WORD nFriendMenuPicIndex;
  53. WORD nFriendMenuPicHeight;
  54. KRColor uFriendMenuBkColor;
  55. WORD nFriendTextPicIndex;
  56. char szFriendSoundFileName[80];
  57. KRColor uTextColorUnknown;
  58. KRColor uTextBorderColorUnknown;
  59. WORD nStrangerMenuPicIndex;
  60. WORD nStrangerMenuPicHeight;
  61. KRColor uStrangerMenuBkColor;
  62. WORD nStrangerTextPicIndex;
  63. };
  64. class KSysMsgCentrePad : public KWndWindow
  65. {
  66. public:
  67. KWndButton m_OpenSysButton;
  68. KWndButton m_UpButton;
  69. KWndButton m_DownButton;
  70. KWndMessageListBox m_SysRoom;
  71. int WndProc(unsigned int uMsg, unsigned int uParam, int nParam);//窗口函数
  72. void ScrollBottom();
  73. };
  74. class KUiMsgCentrePad : public KWndWindow
  75. {
  76. public:
  77. //----界面面板统一的接口函数----
  78. static KUiMsgCentrePad* OpenWindow(); //打开窗口,返回唯一的一个类对象实例
  79. static void CloseWindow(bool bDestroy); //关闭窗口,同时可以选则是否删除对象实例
  80. static void Clear();
  81. static void LoadScheme(const char* pScheme);//载入界面方案
  82. static void DefaultScheme(const char* pScheme);//重新初始化界面
  83. static void HideAllMessage();//隐藏所有输出
  84. static void ShowAllMessage();//显示所有输出
  85. static void SystemMessageArrival(const char* pMsgBuff, unsigned short nMsgLength);
  86. //用于新聊天协议到达的处理
  87. static int NewChannelMessageArrival(DWORD nChannelID, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength);
  88. static void NewMSNMessageArrival(char* szSourceName, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength);
  89. static void OpenChannel(char* channelName, DWORD nChannelID, BYTE cost); //同时订阅
  90. //用于外挂的聊天
  91. static void ShowSomeoneMessage(char* szSourceName, const char* pMsgBuff, unsigned short nMsgLength);
  92. enum  SelfChannel
  93. {
  94. ch_Team = 0,
  95. ch_Faction,
  96. ch_Tong,
  97. ch_Screen,
  98. ch_GM
  99. };
  100. static void CloseSelfChannel(SelfChannel type); //同时退订
  101. static void QueryAllChannel();
  102. static void ReplaceChannelName(char* szDest, size_t nDestSize, char* szSrc);
  103. static bool GetChannelMenuinfo(int nChannelIndex, WORD* pnPicIndex = NULL, WORD* pPicHei = NULL, KRColor* puTextColor = NULL, KRColor* puBkColor = NULL, char* pszMenuText = NULL, short* pnCheckPicIndex = NULL);
  104. static bool GetPeopleMenuinfo(char* szDest, WORD* pnPicIndex = NULL, WORD* pPicHei = NULL, KRColor* puTextColor = NULL, KRColor* puBkColor = NULL);
  105. static bool ReplaceSpecialField(char* szDest, char* szSrc);
  106. static DWORD GetChannelID(int nChannelIndex);
  107. static char* GetChannelTitle(int nChannelIndex);
  108. static DWORD GetChannelCount();
  109. static int GetChannelIndex(char* channelName);
  110. static int GetChannelIndex(DWORD dwID);
  111. static int ReleaseActivateChannelAll(); //返回原来的总个数
  112. static bool GetChannelSubscribe(int nChannelIndex);
  113. static bool IsChannelType(int nChannelIndex, SelfChannel type);
  114. static int CheckChannel(int nChannelIndex, bool b);
  115. static KUiMsgCentrePad* GetSelf() {return m_pSelf;}
  116. static void SetFontSize(int nFontSize);
  117. static int GetFontSize();
  118. static int SetChannelTextColor(char* cTitle, DWORD uTextColor, DWORD uTextBorderColor);
  119. static char* GetChannelTextColor(int nIndex, DWORD& uTextColor, DWORD& uTextBorderColor);
  120. static void SetMSNTextColor(int nType, DWORD uTextColor, DWORD uTextBorderColor); //nType 0 is me, 1 is friend, 2 is stranger
  121. static void GetMSNTextColor(int nType, DWORD& uTextColor, DWORD& uTextBorderColor);
  122. static BYTE GetChannelCost(DWORD dwID);
  123. static int PushChannelData(DWORD dwID, const char* Buffer, int nLen);
  124. static int GetChannelData(DWORD& dwID, BYTE& cost, char*& Buffer, int& nLen);
  125. static int PopChannelData(DWORD dwID);
  126. void Breathe(); //活动函数
  127. private:
  128. KUiMsgCentrePad();
  129. ~KUiMsgCentrePad()
  130. {
  131. ReleaseActivateChannelAll();
  132. }
  133. void Initialize(); //初始化
  134. int WndProc(unsigned int uMsg, unsigned int uParam, int nParam);//窗口函数
  135. int ChanageHeight(int nOffsetY, bool bAtTop);
  136. void LoadScheme(KIniFile* pIni);
  137. int PtInWindow(int x, int y); //判断一个点是否落在窗口内,传入的是绝对坐标
  138. void SetAutoDelMsgInterval(unsigned int uInterval = 0); //设置自动删除消息的时间间隔
  139. //参数默认值为0,表示不按照时间间隔自动删除,时间单位毫秒
  140. void DragWndSize(int nMoveOffset);
  141. void DragWndPos(int nMoveOffset);
  142. void PaintWindow(); //绘制窗口
  143. int FindActivateChannelResourceIndex(char* cTitle);
  144. int FindActivateChannelIndex(char* cTitle);
  145. int FindActivateChannelIndex(DWORD nChannelID);
  146. BYTE FindActivateChannelCost(DWORD nChannelID);
  147. int FindChannelResourceIndex(char* cTitle);
  148. int FindActivateChannelIndexByKey(char* cKey);
  149. int IsNeverCloseActivateChannel(int nChannelIndex);
  150. void ChannelMessageArrival(int nChannelIndex, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength, KWndMessageListBox* pM, bool bName);
  151. void MSNMessageArrival(char* szSourceName, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength);
  152. void ShowMSNMessage(char* szName, const char* pMsgBuff, unsigned short nMsgLength, KRColor uColor, KRColor uBKColor, KRColor uBorderColor, WORD nPic);
  153. void SendQueryChannelID(int nChannelResourceIndex);
  154. void SendChannelSubscribe(int nChannelIndex, bool b);
  155. int AddActivateChannel(const KChannelActivateInfo& Item); //返回增加Item的Index
  156. int ReleaseActivateChannel(int nChannelIndex); //返回剩余的总个数
  157. void CloseActivateChannel(int nChannelIndex); //同时退订
  158. void PopupChannelMenu(int x, int y);
  159. int FilterTextColor(char* pMsgBuff, unsigned short nMsgLength, const KRColor& uColor);
  160. int GetMessageSendName(KWndWindow* pWnd, int nIndex, char* szCurText);
  161. int GetMessageSendName(KWndWindow* pWnd, int x, int y, char* szCurText);
  162. private:
  163. static KUiMsgCentrePad* m_pSelf;
  164. KWndImage m_BorderImg;
  165. KWndImage m_SizeBtn;
  166. KWndImage m_MoveImg;
  167. KWndButton          m_BgShadowBtn;
  168. KSysMsgCentrePad m_Sys;
  169. int m_nMinTopPos, m_nMaxBottomPos;
  170. bool m_bSizingWnd;
  171. bool m_bDockLeftSide;
  172. bool                m_bShowShadow;
  173. short m_nSizeBtnDragOffsetY;
  174. bool m_bSizeUp;
  175. #define SECOND_AUTODELMSG 20000
  176. unsigned int m_uAutoDelMsgInterval; //自动删除消息的间隔时间,单位毫秒
  177. unsigned int m_uLastDelMsgTime; //上次删除消息时的时间
  178. KScrollMessageListBox m_ChatRoom;
  179. KChannelResourceInfo m_ChannelsResource[MAX_CHANNELRESOURCE];
  180. int m_nChannelsResource;
  181. char m_DefaultChannelSendName[32];
  182. int m_nDefaultChannelResource;
  183. KChannelActivateInfo* m_pActivateChannel;
  184. int m_nActivateChannels;
  185. KMSN_ChannelInfo m_MSNInfo;
  186. short m_nCheckOnPicIndex;
  187. short m_nCheckOffPicIndex;
  188. KRColor m_NameColor;
  189. KRColor m_BorderNameColor;
  190. static int ms_DefaultHeight, ms_DefaultWidth;
  191. };