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

模拟服务器

开发平台:

C/C++

  1. /*****************************************************************************************
  2. // 界面--消息中心面板
  3. // Copyright : Kingsoft 2002
  4. // Author :   Wooy(Wu yue)
  5. // CreateTime: 2002-12-13
  6. *****************************************************************************************/
  7. #include "KWin32.h"
  8. #include "KIniFile.h"
  9. #include "../elem/wnds.h"
  10. #include "../Elem/WndMessage.h"
  11. #include "UiMsgCentrePad.h"
  12. #include "UiChatCentre.h"
  13. #include "../UiBase.h"
  14. #include "../../../core/src/gamedatadef.h"
  15. #include "../../../core/src/coreshell.h"
  16. #include "../../../Engine/src/Text.h"
  17. #include "../../../Represent/iRepresent/iRepresentShell.h"
  18. #include "../UiSoundSetting.h"
  19. #include "UIPlayerBar.h"
  20. #include "KRelayProtocol.h"
  21. #include "KProtocolDef.h"
  22. #include "UIGame.h"
  23. #define SEL_CHANNEL_MENU 1
  24. extern iCoreShell* g_pCoreShell;
  25. extern iRepresentShell* g_pRepresentShell;
  26. int VerticalSplitTwoWindow(KWndWindow* pLeft, KWndWindow* pRight, int nAt)
  27. {
  28. if (pLeft == NULL || pRight == NULL)
  29. return 0;
  30. int nL_x, nL_y;
  31. pLeft->GetPosition(&nL_x, &nL_y);
  32. int nR_x, nR_y;
  33. pRight->GetPosition(&nR_x, &nR_y);
  34. int nL_w, nL_h;
  35. pLeft->GetSize(&nL_w, &nL_h);
  36. int nR_w, nR_h;
  37. pRight->GetSize(&nR_w, &nR_h);
  38. if (nL_x + nL_w > nR_x + nR_w)
  39. return 0;
  40. if ((nAt - nL_x < 0) || (nR_w - (nAt - nL_x - nL_w) < 0))
  41. return 0;
  42. if (nAt - nL_x - nL_w == 0) //不用调整了,偏移量为0
  43. return 0;
  44. pLeft->SetSize(nAt - nL_x, nL_h);
  45. pRight->SetPosition(nR_x + (nAt - nL_x - nL_w), nR_y);
  46. pRight->SetSize(nR_w - (nAt - nL_x - nL_w), nR_h);
  47. return nAt;
  48. }
  49. ///////////////////////////////////////////////////////////////////////////////////////////
  50. int KSysMsgCentrePad::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)
  51. {
  52. static int nUpSpeed = 0;
  53. static int nDownSpeed = 0;
  54. if (uMsg == WND_N_BUTTON_CLICK)
  55. {
  56. if (uParam == (unsigned int)(KWndWindow*)&m_OpenSysButton)
  57. {
  58. if (m_OpenSysButton.IsButtonChecked())
  59. m_SysRoom.Show();
  60. else
  61. m_SysRoom.Hide();
  62. return 1;
  63. }
  64. if (uParam == (unsigned int)(KWndWindow*)&m_UpButton)
  65. {
  66. nUpSpeed = 0;
  67. return 1;
  68. }
  69. if (uParam == (unsigned int)(KWndWindow*)&m_DownButton)
  70. {
  71. nDownSpeed = 0;
  72. return 1;
  73. }
  74. }
  75. else if (uMsg == WND_N_BUTTON_DOWN || WND_N_BUTTON_HOLD)
  76. {
  77. if (uParam == (unsigned int)(KWndWindow*)&m_UpButton)
  78. {
  79. if (nUpSpeed % 5 == 0)
  80. {
  81. m_SysRoom.ClearHideLine();
  82. m_SysRoom.SetFirstShowLine(max(m_SysRoom.GetFirstShowLine() - 1, 0));
  83. }
  84. nUpSpeed++;
  85. return 1;
  86. }
  87. if (uParam == (unsigned int)(KWndWindow*)&m_DownButton)
  88. {
  89. if (nDownSpeed % 5 == 0)
  90. {
  91. m_SysRoom.ClearHideLine();
  92. int nLine = m_SysRoom.GetItemLineCount(m_SysRoom.GetMsgCount()) - m_SysRoom.GetMaxShowLine();
  93. m_SysRoom.SetFirstShowLine(min(m_SysRoom.GetFirstShowLine() + 1, nLine));
  94. }
  95. nDownSpeed++;
  96. return 1;
  97. }
  98. }
  99. return KWndWindow::WndProc(uMsg, uParam, nParam);
  100. }
  101. void KSysMsgCentrePad::ScrollBottom()
  102. {
  103. m_SysRoom.ClearHideLine();
  104. int nCount = m_SysRoom.GetMsgCount();
  105. if (nCount > 0)
  106. {
  107. int nLine = m_SysRoom.GetItemLineCount(nCount) - m_SysRoom.GetMaxShowLine();
  108. m_SysRoom.SetFirstShowLine(max(nLine, 0));
  109. }
  110. }
  111. ///////////////////////////////////////////////////////////////////////////////////////////
  112. #define SCHEME_INI_LEFT "消息集合面板_左.ini"
  113. #define SCHEME_INI_RIGHT "消息集合面板_右.ini"
  114. KUiMsgCentrePad* KUiMsgCentrePad::m_pSelf = NULL;
  115. //--------------------------------------------------------------------------
  116. // 功能:打开窗口,返回唯一的一个类对象实例
  117. //--------------------------------------------------------------------------
  118. KUiMsgCentrePad* KUiMsgCentrePad::OpenWindow()
  119. {
  120. if (m_pSelf == NULL)
  121. {
  122. m_pSelf = new KUiMsgCentrePad;
  123. if (m_pSelf)
  124. m_pSelf->Initialize();
  125. }
  126. if (m_pSelf)
  127. {
  128. m_pSelf->m_Sys.Show();
  129. m_pSelf->Show();
  130. }
  131. return m_pSelf;
  132. }
  133. //--------------------------------------------------------------------------
  134. // 功能:关闭窗口,同时可以选则是否删除对象实例
  135. //--------------------------------------------------------------------------
  136. void KUiMsgCentrePad::CloseWindow(bool bDestroy)
  137. {
  138. if (m_pSelf)
  139. {
  140. if (bDestroy == false)
  141. {
  142. m_pSelf->Clear();
  143. m_pSelf->m_Sys.Hide();
  144. m_pSelf->Hide();
  145. }
  146. else
  147. {
  148. m_pSelf->m_Sys.SplitSmaleFamily();
  149. m_pSelf->Destroy();
  150. m_pSelf = NULL;
  151. }
  152. }
  153. }
  154. KUiMsgCentrePad::KUiMsgCentrePad()
  155. {
  156. m_uAutoDelMsgInterval = 0;
  157. m_nSizeBtnDragOffsetY = 0;
  158. m_bSizingWnd = false;
  159. m_bShowShadow = false;
  160. m_bDockLeftSide = true;
  161. m_nMinTopPos = 20;
  162. m_nMaxBottomPos = 500;
  163. m_nChannelsResource = 0;
  164. m_nActivateChannels = 0;
  165. m_pActivateChannel = NULL;
  166. m_nCheckOnPicIndex = -1;
  167. m_nCheckOffPicIndex = -1;
  168. m_NameColor.Color_dw = 0;
  169. m_BorderNameColor.Color_dw = 0;
  170. }
  171. //设置自动删除消息的时间间隔,默认值为0,表示不按照时间间隔自动删除
  172. void KUiMsgCentrePad::SetAutoDelMsgInterval(unsigned int uInterval /*= 0*/)
  173. {
  174. m_uAutoDelMsgInterval = uInterval;
  175. if (m_uAutoDelMsgInterval)
  176. m_uLastDelMsgTime = IR_GetCurrentTime();
  177. }
  178. // 加入一条消息
  179. void KUiMsgCentrePad::SystemMessageArrival(const char* pMsgBuff, unsigned short nMsgLength)
  180. {
  181. if (m_pSelf && pMsgBuff && nMsgLength > 0)
  182. {
  183. if (m_pSelf->m_nDefaultChannelResource >= 0 && m_pSelf->m_nDefaultChannelResource < m_pSelf->m_nChannelsResource)
  184. {
  185. m_pSelf->ChannelMessageArrival(m_pSelf->FindActivateChannelIndex(m_pSelf->m_ChannelsResource[m_pSelf->m_nDefaultChannelResource].cTitle),
  186. m_pSelf->m_DefaultChannelSendName,
  187. pMsgBuff, nMsgLength, &m_pSelf->m_Sys.m_SysRoom, false);
  188. m_pSelf->m_Sys.ScrollBottom();
  189. }
  190. }
  191. }
  192. void KUiMsgCentrePad::ChannelMessageArrival(int nChannelIndex, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength, KWndMessageListBox* pM, bool bName)
  193. {
  194. if (nChannelIndex < 0 || nChannelIndex >= m_nActivateChannels)
  195. return;
  196. char Buffer[560];
  197. int nLen = 0;
  198. if (szSendName)
  199. nLen = strlen(szSendName);
  200. if (nLen <= 0) //不允许空的发送者
  201. {
  202. return;
  203. }
  204. if (!m_pActivateChannel[nChannelIndex].bSubscribe)
  205. return;
  206. int nOffset = 0;
  207. KRColor uColor;
  208. uColor.Color_dw = 0xFFFFFFFF;
  209. if (m_pActivateChannel[nChannelIndex].ResourceIndex >= 0)
  210. {
  211. Buffer[nOffset++] = KTC_INLINE_PIC;
  212. *((WORD*)(Buffer + nOffset)) = m_ChannelsResource[m_pActivateChannel[nChannelIndex].ResourceIndex].nTextPicIndex;
  213. nOffset += 2;
  214. uColor = m_ChannelsResource[m_pActivateChannel[nChannelIndex].ResourceIndex].uTextColor;
  215. Buffer[nOffset++] = uColor.Color_b.a;
  216. Buffer[nOffset++] = uColor.Color_b.r;
  217. Buffer[nOffset++] = uColor.Color_b.g;
  218. Buffer[nOffset++] = uColor.Color_b.b;
  219. uColor = m_ChannelsResource[m_pActivateChannel[nChannelIndex].ResourceIndex].uTextBorderColor;
  220. Buffer[nOffset++] = uColor.Color_b.a;
  221. Buffer[nOffset++] = uColor.Color_b.r;
  222. Buffer[nOffset++] = uColor.Color_b.g;
  223. Buffer[nOffset++] = uColor.Color_b.b;
  224. if (m_ChannelsResource[m_pActivateChannel[nChannelIndex].ResourceIndex].szSoundFileName[0] != 0)
  225. UiSoundPlay(m_ChannelsResource[m_pActivateChannel[nChannelIndex].ResourceIndex].szSoundFileName);
  226. }
  227. if (pMsgBuff[0] != 't' && //表情动作不显示名字
  228. bName)
  229. {
  230. Buffer[nOffset++] = m_NameColor.Color_b.a;
  231. Buffer[nOffset++] = m_NameColor.Color_b.r;
  232. Buffer[nOffset++] = m_NameColor.Color_b.g;
  233. Buffer[nOffset++] = m_NameColor.Color_b.b;
  234. Buffer[nOffset++] = m_BorderNameColor.Color_b.a;
  235. Buffer[nOffset++] = m_BorderNameColor.Color_b.r;
  236. Buffer[nOffset++] = m_BorderNameColor.Color_b.g;
  237. Buffer[nOffset++] = m_BorderNameColor.Color_b.b;
  238.      memcpy(Buffer + nOffset, szSendName, nLen);
  239.      nOffset += nLen;
  240.      Buffer[nOffset++] = ':';
  241. Buffer[nOffset++] = KTC_COLOR_RESTORE;
  242. Buffer[nOffset++] = KTC_BORDER_RESTORE;
  243. }
  244. memcpy(&Buffer[nOffset], pMsgBuff, nMsgLength);
  245. nOffset += FilterTextColor(Buffer + nOffset, nMsgLength, uColor);
  246. Buffer[nOffset] = 0;
  247. if (pM)
  248. {
  249. pM->AddOneMessage(Buffer, nOffset);
  250. }
  251. m_uLastDelMsgTime = IR_GetCurrentTime();
  252. }
  253. void KUiMsgCentrePad::MSNMessageArrival(char* szSourceName, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength)
  254. {
  255. KRColor uColor;
  256. KRColor uBKColor;
  257. KRColor uBorderColor;
  258. WORD nPic = 0;
  259. bool bSelf = false;
  260. if (KUiPlayerBar::IsSelfName(szSourceName))
  261. {
  262. bSelf = true;
  263. uColor = m_MSNInfo.uTextColorSelf;
  264. nPic = m_MSNInfo.nSelfTextPicIndex;
  265. uBKColor = m_MSNInfo.uTextBKColorSelf;
  266. uBorderColor = m_MSNInfo.uTextBorderColorSelf;
  267. }
  268. else
  269. {
  270. bool bFriend = KUiChatCentre::IsMyFriend(szSourceName);
  271. if (bFriend)
  272. {
  273. uColor = m_MSNInfo.uTextFriendColor;
  274. nPic = m_MSNInfo.nFriendTextPicIndex;
  275. uBorderColor = m_MSNInfo.uTextBorderFriendColor;
  276. if (m_MSNInfo.szFriendSoundFileName[0] != 0)
  277. UiSoundPlay(m_MSNInfo.szFriendSoundFileName);
  278. }
  279. else
  280. {
  281. uColor = m_MSNInfo.uTextColorUnknown;
  282. nPic = m_MSNInfo.nStrangerTextPicIndex;
  283. uBorderColor = m_MSNInfo.uTextBorderColorUnknown;
  284. }
  285. uBKColor.Color_dw = 0;
  286. }
  287. ShowMSNMessage(bSelf ? szSendName : szSourceName, pMsgBuff, nMsgLength, uColor, uBKColor, uBorderColor, nPic);
  288. }
  289. void KUiMsgCentrePad::ShowMSNMessage(char* szName, const char* pMsgBuff, unsigned short nMsgLength, KRColor uColor, KRColor uBKColor, KRColor uBorderColor, WORD nPic)
  290. {
  291. char Buffer[560];
  292. int nOffset = 0;
  293. Buffer[nOffset++] = KTC_INLINE_PIC;
  294. *((WORD*)(Buffer + nOffset)) = nPic;
  295. nOffset += 2;
  296. Buffer[nOffset++] = uColor.Color_b.a;
  297. Buffer[nOffset++] = uColor.Color_b.r;
  298. Buffer[nOffset++] = uColor.Color_b.g;
  299. Buffer[nOffset++] = uColor.Color_b.b;
  300. Buffer[nOffset++] = uBorderColor.Color_b.a;
  301. Buffer[nOffset++] = uBorderColor.Color_b.r;
  302. Buffer[nOffset++] = uBorderColor.Color_b.g;
  303. Buffer[nOffset++] = uBorderColor.Color_b.b;
  304. Buffer[nOffset++] = m_NameColor.Color_b.a;
  305. Buffer[nOffset++] = m_NameColor.Color_b.r;
  306. Buffer[nOffset++] = m_NameColor.Color_b.g;
  307. Buffer[nOffset++] = m_NameColor.Color_b.b;
  308. Buffer[nOffset++] = m_BorderNameColor.Color_b.a;
  309. Buffer[nOffset++] = m_BorderNameColor.Color_b.r;
  310. Buffer[nOffset++] = m_BorderNameColor.Color_b.g;
  311. Buffer[nOffset++] = m_BorderNameColor.Color_b.b;
  312. int nLen = 0;
  313. nLen = strlen(szName);
  314. memcpy(Buffer + nOffset, szName, nLen);
  315. nOffset += nLen;
  316. Buffer[nOffset++] = ':';
  317. Buffer[nOffset++] = KTC_COLOR_RESTORE;
  318. Buffer[nOffset++] = KTC_BORDER_RESTORE;
  319. memcpy(&Buffer[nOffset], pMsgBuff, nMsgLength);
  320. nOffset += FilterTextColor(Buffer + nOffset, nMsgLength, uColor);
  321. Buffer[nOffset] = 0;
  322. m_ChatRoom.GetMessageListBox()->AddOneMessage(Buffer, nOffset, uBKColor.Color_dw);
  323. m_ChatRoom.GetScrollBar()->SetScrollPos(m_ChatRoom.GetScrollBar()->GetMaxValue());
  324. m_uLastDelMsgTime = IR_GetCurrentTime();
  325. }
  326. int KUiMsgCentrePad::NewChannelMessageArrival(DWORD nChannelID, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength)
  327. {
  328. if (m_pSelf && pMsgBuff)
  329. {
  330. int nChannelIndex = m_pSelf->FindActivateChannelIndex(nChannelID);
  331. if (nChannelIndex >= 0)
  332. {
  333. m_pSelf->ChannelMessageArrival(nChannelIndex, szSendName, pMsgBuff, nMsgLength, m_pSelf->m_ChatRoom.GetMessageListBox(), true);
  334. m_pSelf->m_ChatRoom.GetScrollBar()->SetScrollPos(
  335. m_pSelf->m_ChatRoom.GetScrollBar()->GetMaxValue());
  336. }
  337. return nChannelIndex;
  338. }
  339. return -1;
  340. }
  341. void KUiMsgCentrePad::NewMSNMessageArrival(char* szSourceName, char* szSendName, const char* pMsgBuff, unsigned short nMsgLength)
  342. {
  343. if (m_pSelf && pMsgBuff)
  344. {
  345. m_pSelf->MSNMessageArrival(szSourceName, szSendName, pMsgBuff, nMsgLength);
  346. }
  347. }
  348. void KUiMsgCentrePad::ShowSomeoneMessage(char* szSourceName, const char* pMsgBuff, unsigned short nMsgLength)
  349. {
  350. if (m_pSelf && pMsgBuff)
  351. {
  352. KRColor uColor;
  353. KRColor uBKColor;
  354. KRColor uBorderColor;
  355. WORD nPic = 0;
  356. bool bFriend = KUiChatCentre::IsMyFriend(szSourceName);
  357. if (bFriend)
  358. {
  359. uColor = m_pSelf->m_MSNInfo.uTextFriendColor;
  360. nPic = m_pSelf->m_MSNInfo.nFriendTextPicIndex;
  361. uBorderColor = m_pSelf->m_MSNInfo.uTextBorderFriendColor;
  362. if (m_pSelf->m_MSNInfo.szFriendSoundFileName[0] != 0)
  363. UiSoundPlay(m_pSelf->m_MSNInfo.szFriendSoundFileName);
  364. }
  365. else
  366. {
  367. uColor = m_pSelf->m_MSNInfo.uTextColorUnknown;
  368. nPic = m_pSelf->m_MSNInfo.nStrangerTextPicIndex;
  369. uBorderColor = m_pSelf->m_MSNInfo.uTextBorderColorUnknown;
  370. }
  371. uBKColor.Color_dw = 0;
  372. m_pSelf->ShowMSNMessage(szSourceName, pMsgBuff, nMsgLength, uColor, uBKColor, uBorderColor, nPic);
  373. }
  374. }
  375. void KUiMsgCentrePad::OpenChannel(char* channelName, DWORD nChannelID, BYTE cost)
  376. {
  377. if (nChannelID == -1)
  378. return;
  379. if (m_pSelf)
  380. {
  381. char ChannelName[__X_NAME_LEN_];
  382. int nChannelIndex = -1;
  383. for (int n = 0; n < m_pSelf->m_nChannelsResource; n++)
  384. {
  385. ChannelName[0];
  386. if (m_pSelf->m_ChannelsResource[n].cFormatName[0] == 0)
  387. return;
  388. if (!m_pSelf->ReplaceSpecialField(ChannelName, m_pSelf->m_ChannelsResource[n].cFormatName))
  389. continue;
  390. if (ChannelName[0] == 0)
  391. continue;
  392. if (strcmp(channelName, ChannelName) == 0)
  393. {
  394. nChannelIndex = n;
  395. break;
  396. }
  397. }
  398. if (nChannelIndex >= 0)
  399. {
  400. KChannelActivateInfo Info;
  401. Info.nChannelID = nChannelID;
  402. Info.cost = cost;
  403. Info.ResourceIndex = nChannelIndex;
  404. Info.bSubscribe = true;
  405. m_pSelf->SendChannelSubscribe(m_pSelf->AddActivateChannel(Info), true);
  406. }
  407. }
  408. }
  409. void KUiMsgCentrePad::CloseActivateChannel(int nChannelIndex)
  410. {
  411. if (nChannelIndex < 0 || nChannelIndex >= m_nActivateChannels)
  412. return;
  413. if (m_pActivateChannel[nChannelIndex].bSubscribe)
  414. SendChannelSubscribe(nChannelIndex, false);
  415. ReleaseActivateChannel(nChannelIndex);
  416. }
  417. void KUiMsgCentrePad::QueryAllChannel()
  418. {
  419. if (m_pSelf)
  420. {
  421. for (int n = 0; n < m_pSelf->m_nChannelsResource; n++)
  422. {
  423. m_pSelf->SendQueryChannelID(n);
  424. }
  425. }
  426. }
  427. void KUiMsgCentrePad::ReplaceChannelName(char* szDest, size_t nDestSize, char* szSrc)
  428. {
  429. if (m_pSelf && szSrc[0] != 0)
  430. {
  431. for (int n = 0; n < m_pSelf->m_nChannelsResource; n++)
  432. {
  433. for (int m = 0; m < MAX_CHANNELRESOURCE; m++)
  434. {
  435. if (m_pSelf->m_ChannelsResource[n].cShortTitle[m][0] != 0)
  436. {
  437. if (strcmpi(szSrc, m_pSelf->m_ChannelsResource[n].cShortTitle[m]) == 0)
  438. {
  439. strncpy(szDest, m_pSelf->m_ChannelsResource[n].cTitle, nDestSize);
  440. return;
  441. }
  442. }
  443. }
  444. }
  445. }
  446. strncpy(szDest, szSrc, nDestSize);
  447. }
  448. static char s_keys [][__X_NAME_LEN_] =
  449. {
  450. "Team#",
  451. "Faction#",
  452. "Tong#",
  453. "\S",
  454. "GM",
  455. };
  456. bool KUiMsgCentrePad::ReplaceSpecialField(char* szDest, char* szSrc)
  457. {
  458. char s_keyDests [][__X_NAME_LEN_] =
  459. {
  460. "",
  461. "",
  462. ""
  463. "",
  464. "",
  465. };
  466. KUiPlayerTeam Team;
  467. Team.nTeamServerID = -1;
  468. g_pCoreShell->TeamOperation(TEAM_OI_GD_INFO, (unsigned int)&Team, 0);
  469. if (Team.nTeamServerID >= 0)
  470. {
  471. sprintf(s_keyDests[0], "%d", Team.nTeamServerID);
  472. }
  473. KUiPlayerBaseInfo self;
  474. self.nCurFaction = -1;
  475. g_pCoreShell->GetGameData(GDI_PLAYER_BASE_INFO, (unsigned int)&self, 0);
  476. if (self.nCurFaction >= 0)
  477. {
  478. sprintf(s_keyDests[1], "%d", self.nCurFaction);
  479. }
  480. else if (self.nCurTong != 0)
  481. {
  482. sprintf(s_keyDests[2], "%d", self.nCurTong);
  483. }
  484. int nKeySize = sizeof(s_keys) / __X_NAME_LEN_;
  485. char key[__X_NAME_LEN_];
  486. if (m_pSelf)
  487. {
  488. int n = 0;
  489. int m = 0;
  490. int nKey = -1;
  491. while(szSrc[n] != 0)
  492. {
  493. if (szSrc[n] == '<')
  494. {
  495. nKey = 0;
  496. memset(key, 0, sizeof(key));
  497. }
  498. else if (szSrc[n] == '>')
  499. {
  500. for (int i = 0; i < nKeySize; i++)
  501. {
  502. if (strcmpi(s_keys[i], key) == 0) //支持的关键字
  503. {
  504. if (s_keyDests[i][0] == 0)
  505. return false;
  506. strcpy(szDest + m, s_keyDests[i]);
  507. m += strlen(s_keyDests[i]);
  508. nKey = -1;
  509. break;
  510. }
  511. }
  512. if (nKey >= 0) //不支持的关键字
  513. {
  514. strcpy(szDest + m, key);
  515. m += nKey;
  516. nKey = -1;
  517. return false;
  518. }
  519. }
  520. else
  521. {
  522. if (nKey >= 0)
  523. {
  524. key[nKey++] = szSrc[n];
  525. }
  526. else
  527. {
  528. szDest[m++] = szSrc[n];
  529. }
  530. }
  531. n++;
  532. }
  533. szDest[m] = 0;
  534. }
  535. return true;
  536. }
  537. void KUiMsgCentrePad::CloseSelfChannel(SelfChannel type)
  538. {
  539. if (m_pSelf)
  540. {
  541. switch (type)
  542. {
  543. case ch_Team:
  544. case ch_Faction:
  545. case ch_Tong:
  546. case ch_Screen:
  547. //case ch_GM: //GM不能退
  548. {
  549. m_pSelf->CloseActivateChannel(m_pSelf->FindActivateChannelIndexByKey(s_keys[type]));
  550. }
  551. break;
  552. default:
  553. return;
  554. }
  555. }
  556. }
  557. bool KUiMsgCentrePad::GetChannelSubscribe(int nChannelIndex)
  558. {
  559. if (m_pSelf && nChannelIndex >= 0 && nChannelIndex < m_pSelf->m_nActivateChannels)
  560. {
  561. return m_pSelf->m_pActivateChannel[nChannelIndex].bSubscribe;
  562. }
  563. return false;
  564. }
  565. bool KUiMsgCentrePad::IsChannelType(int nChannelIndex, SelfChannel type)
  566. {
  567. if (m_pSelf && nChannelIndex >= 0 && nChannelIndex < m_pSelf->m_nActivateChannels)
  568. {
  569. switch (type)
  570. {
  571. case ch_Team:
  572. case ch_Faction:
  573. case ch_Tong:
  574. case ch_Screen:
  575. case ch_GM:
  576. {
  577. return m_pSelf->FindActivateChannelIndexByKey(s_keys[type]) == nChannelIndex;
  578. }
  579. break;
  580. default:
  581. return false;
  582. }
  583. }
  584. return false;
  585. }
  586. int KUiMsgCentrePad::FindActivateChannelResourceIndex(char* cTitle)
  587. {
  588. if (cTitle == NULL || cTitle[0] == 0)
  589. return -1;
  590. for (int n = 0; n < m_nActivateChannels; n++)
  591. {
  592. if (m_pActivateChannel[n].ResourceIndex < 0)
  593. continue;
  594. if (strcmp(cTitle, m_ChannelsResource[m_pActivateChannel[n].ResourceIndex].cTitle) == 0)
  595. return m_pActivateChannel[n].ResourceIndex;
  596. }
  597. return -1;
  598. }
  599. int KUiMsgCentrePad::FindActivateChannelIndex(char* cTitle)
  600. {
  601. if (cTitle == NULL || cTitle[0] == 0)
  602. return -1;
  603. for (int n = 0; n < m_nActivateChannels; n++)
  604. {
  605. if (m_pActivateChannel[n].ResourceIndex < 0)
  606. continue;
  607. if (strcmp(cTitle, m_ChannelsResource[m_pActivateChannel[n].ResourceIndex].cTitle) == 0)
  608. return n;
  609. }
  610. return -1;
  611. }
  612. int KUiMsgCentrePad::FindActivateChannelIndex(DWORD nChannelID)
  613. {
  614. for (int n = 0; n < m_nActivateChannels; n++)
  615. {
  616. if (m_pActivateChannel[n].nChannelID == nChannelID)
  617. return n;
  618. }
  619. return -1;
  620. }
  621. BYTE KUiMsgCentrePad::FindActivateChannelCost(DWORD nChannelID)
  622. {
  623. for (int n = 0; n < m_nActivateChannels; n++)
  624. {
  625. if (m_pActivateChannel[n].nChannelID == nChannelID)
  626. return m_pActivateChannel[n].cost;
  627. }
  628. return -1;
  629. }
  630. int KUiMsgCentrePad::FindChannelResourceIndex(char* cTitle)
  631. {
  632. if (cTitle == NULL || cTitle[0] == 0)
  633. return -1;
  634. for (int n = 0; n < m_nChannelsResource; n++)
  635. {
  636. if (strcmp(cTitle, m_ChannelsResource[n].cTitle) == 0)
  637. return n;
  638. }
  639. return -1;
  640. }
  641. int KUiMsgCentrePad::FindActivateChannelIndexByKey(char* cKey)
  642. {
  643. if (cKey == NULL || cKey[0] == 0)
  644. return -1;
  645. for (int n = 0; n < m_nActivateChannels; n++)
  646. {
  647. if (m_pActivateChannel[n].ResourceIndex >= 0)
  648. {
  649. if (m_ChannelsResource[m_pActivateChannel[n].ResourceIndex].cFormatName[0] != 0)
  650. {
  651. char *pdest = strstr(m_ChannelsResource[m_pActivateChannel[n].ResourceIndex].cFormatName, cKey);
  652. if (pdest)
  653. return n;
  654. }
  655. }
  656. }
  657. return -1;
  658. }
  659. int KUiMsgCentrePad::IsNeverCloseActivateChannel(int nChannelIndex)
  660. {
  661. if (nChannelIndex < 0 || nChannelIndex >= m_nActivateChannels)
  662. return 0;
  663. int n = m_pActivateChannel[nChannelIndex].ResourceIndex;
  664. if (n >= 0 && m_ChannelsResource[n].nNeverClose) //不能关闭的频道
  665. return 1;
  666. return 0;
  667. }
  668. bool KUiMsgCentrePad::GetChannelMenuinfo(int nChannelIndex, WORD* pnPicIndex, WORD* pPicHei, KRColor* puTextColor, KRColor* puBkColor, char* pszMenuText, short* pnCheckPicIndex)
  669. {
  670. if (m_pSelf && nChannelIndex >= 0 && nChannelIndex < m_pSelf->m_nActivateChannels)
  671. {
  672. int n = m_pSelf->m_pActivateChannel[nChannelIndex].ResourceIndex;
  673. if (n >= 0)
  674. {
  675. if (m_pSelf->m_ChannelsResource[n].nNeverClose)
  676. {
  677. if (pnCheckPicIndex)
  678. *pnCheckPicIndex = -1;
  679. }
  680. else
  681. {
  682. if (pnCheckPicIndex)
  683. *pnCheckPicIndex = m_pSelf->m_pActivateChannel[nChannelIndex].bSubscribe ? m_pSelf->m_nCheckOnPicIndex : m_pSelf->m_nCheckOffPicIndex;
  684. }
  685. if (pnPicIndex)
  686. *pnPicIndex = m_pSelf->m_pActivateChannel[nChannelIndex].bSubscribe ? m_pSelf->m_ChannelsResource[n].nMenuPicIndex : m_pSelf->m_ChannelsResource[n].nMenuDeactivatePicIndex;
  687. if (puTextColor)
  688. *puTextColor = m_pSelf->m_ChannelsResource[n].uTextColor;
  689. if (pPicHei)
  690. *pPicHei = m_pSelf->m_pActivateChannel[nChannelIndex].bSubscribe ? m_pSelf->m_ChannelsResource[n].nMenuPicHeight : m_pSelf->m_ChannelsResource[n].nMenuDeactivatePicHeight;
  691. if (puBkColor)
  692. *puBkColor = m_pSelf->m_ChannelsResource[n].uMenuBkColor;
  693. if (pszMenuText)
  694. strcpy(pszMenuText, m_pSelf->m_pActivateChannel[nChannelIndex].bSubscribe ? m_pSelf->m_ChannelsResource[n].cMenuText : m_pSelf->m_ChannelsResource[n].cMenuDeactivateText);
  695. return true;
  696. }
  697. }
  698. return false;
  699. }
  700. DWORD KUiMsgCentrePad::GetChannelID(int nChannelIndex)
  701. {
  702. if (m_pSelf && nChannelIndex >= 0 && nChannelIndex < m_pSelf->m_nActivateChannels)
  703. {
  704. return m_pSelf->m_pActivateChannel[nChannelIndex].nChannelID;
  705. }
  706. return -1;
  707. }
  708. char* KUiMsgCentrePad::GetChannelTitle(int nChannelIndex)
  709. {
  710. if (m_pSelf && nChannelIndex >= 0 && nChannelIndex < m_pSelf->m_nActivateChannels)
  711. {
  712. if (m_pSelf->m_pActivateChannel[nChannelIndex].ResourceIndex >= 0)
  713. return m_pSelf->m_ChannelsResource[m_pSelf->m_pActivateChannel[nChannelIndex].ResourceIndex].cTitle;
  714. }
  715. return NULL;
  716. }
  717. DWORD KUiMsgCentrePad::GetChannelCount()
  718. {
  719. if (m_pSelf)
  720. return m_pSelf->m_nActivateChannels;
  721. return 0;
  722. }
  723. int KUiMsgCentrePad::GetChannelIndex(char* channelName)
  724. {
  725. if (m_pSelf)
  726. return m_pSelf->FindActivateChannelIndex(channelName);
  727. return -1;
  728. }
  729. int KUiMsgCentrePad::GetChannelIndex(DWORD dwID)
  730. {
  731. if (m_pSelf)
  732. return m_pSelf->FindActivateChannelIndex(dwID);
  733. return -1;
  734. }
  735. BYTE KUiMsgCentrePad::GetChannelCost(DWORD dwID)
  736. {
  737. if (m_pSelf)
  738. return m_pSelf->FindActivateChannelCost(dwID);
  739. return -1;
  740. }
  741. int KUiMsgCentrePad::PushChannelData(DWORD dwID, const char* Buffer, int nLen)
  742. {
  743. int nIndex = KUiMsgCentrePad::GetChannelIndex(dwID);
  744. if (nIndex >= 0 && m_pSelf && Buffer && nLen > 0)
  745. {
  746. int nRes = m_pSelf->m_pActivateChannel[nIndex].ResourceIndex;
  747. if (nRes >= 0 &&
  748. m_pSelf->m_pActivateChannel[nIndex].uLeftSendMsgNum < m_pSelf->m_ChannelsResource[nRes].uSendMsgNum)
  749. {
  750. int nCur = IR_GetCurrentTime();
  751. int nLeft = (nCur - m_pSelf->m_pActivateChannel[nIndex].uLastSendMsgTime) > m_pSelf->m_ChannelsResource[nRes].uSendMsgInterval ? 0 : (nCur - m_pSelf->m_pActivateChannel[nIndex].uLastSendMsgTime);
  752. nLeft += m_pSelf->m_pActivateChannel[nIndex].uLeftSendMsgNum * m_pSelf->m_ChannelsResource[nRes].uSendMsgInterval;
  753. int nOffset = m_pSelf->m_pActivateChannel[nIndex].uBufferOffset;
  754. unsigned int nSendTime = nCur + nLeft;
  755. memcpy(m_pSelf->m_pActivateChannel[nIndex].Buffer + nOffset, &nSendTime, sizeof(nSendTime));
  756. nOffset += sizeof(nSendTime);
  757. memcpy(m_pSelf->m_pActivateChannel[nIndex].Buffer + nOffset, &nLen, sizeof(nLen));
  758. nOffset += sizeof(nLen);
  759. memcpy(m_pSelf->m_pActivateChannel[nIndex].Buffer + nOffset, Buffer, nLen);
  760. nOffset += nLen;
  761. m_pSelf->m_pActivateChannel[nIndex].uLeftSendMsgNum++;
  762. m_pSelf->m_pActivateChannel[nIndex].uBufferOffset = nOffset;
  763. return nLeft;
  764. }
  765. }
  766. return -1;
  767. }
  768. int KUiMsgCentrePad::GetChannelData(DWORD& dwID, BYTE& cost, char*& Buffer, int& nLen)
  769. {
  770. if (m_pSelf)
  771. {
  772. unsigned int nSendTime = IR_GetCurrentTime();
  773. for (int i = 0; i < m_pSelf->m_nActivateChannels; i++)
  774. {
  775. if (m_pSelf->m_pActivateChannel[i].uLeftSendMsgNum > 0)
  776. {
  777. unsigned int* pST = (unsigned int*)(m_pSelf->m_pActivateChannel[i].Buffer);
  778. if (*pST <= nSendTime)
  779. {
  780. dwID = m_pSelf->m_pActivateChannel[i].nChannelID;
  781. cost = m_pSelf->m_pActivateChannel[i].cost;
  782. nLen = *((int *)(m_pSelf->m_pActivateChannel[i].Buffer + sizeof(unsigned int)));
  783. Buffer = m_pSelf->m_pActivateChannel[i].Buffer + sizeof(unsigned int) + sizeof(int);
  784. return 1;
  785. }
  786. }
  787. }
  788. }
  789. return 0;
  790. }
  791. int KUiMsgCentrePad::PopChannelData(DWORD dwID)
  792. {
  793. if (m_pSelf)
  794. {
  795. unsigned int nSendTime = IR_GetCurrentTime();
  796. for (int i = 0; i < m_pSelf->m_nActivateChannels; i++)
  797. {
  798. if (m_pSelf->m_pActivateChannel[i].nChannelID == dwID &&
  799. m_pSelf->m_pActivateChannel[i].uLeftSendMsgNum > 0)
  800. {
  801. int nLen = *((int *)(m_pSelf->m_pActivateChannel[i].Buffer + sizeof(unsigned int)));
  802. int nMem = nLen + sizeof(unsigned int) + sizeof(int);
  803. memmove(m_pSelf->m_pActivateChannel[i].Buffer,
  804. m_pSelf->m_pActivateChannel[i].Buffer + nMem,
  805. m_pSelf->m_pActivateChannel[i].uBufferOffset - nMem);
  806. m_pSelf->m_pActivateChannel[i].uBufferOffset -= nMem;
  807. m_pSelf->m_pActivateChannel[i].uLeftSendMsgNum--;
  808. m_pSelf->m_pActivateChannel[i].uLastSendMsgTime = nSendTime;
  809. return 1;
  810. }
  811. }
  812. }
  813. return 0;
  814. }
  815. bool KUiMsgCentrePad::GetPeopleMenuinfo(char* szDest, WORD* pnPicIndex, WORD* pPicHei, KRColor* puTextColor, KRColor* puBkColor)
  816. {
  817. if (m_pSelf)
  818. {
  819. bool bFriend = KUiChatCentre::IsMyFriend(szDest);
  820. if (bFriend)
  821. {
  822. if (pnPicIndex)
  823. *pnPicIndex = m_pSelf->m_MSNInfo.nFriendMenuPicIndex;
  824. if (pPicHei)
  825. *pPicHei = m_pSelf->m_MSNInfo.nFriendMenuPicHeight;
  826. if (puBkColor)
  827. *puBkColor = m_pSelf->m_MSNInfo.uFriendMenuBkColor;
  828. if (puTextColor)
  829. *puTextColor = m_pSelf->m_MSNInfo.uTextColorSelf;
  830. }
  831. else
  832. {
  833. if (pnPicIndex)
  834. *pnPicIndex = m_pSelf->m_MSNInfo.nStrangerMenuPicIndex;
  835. if (pPicHei)
  836. *pPicHei = m_pSelf->m_MSNInfo.nStrangerMenuPicHeight;
  837. if (puBkColor)
  838. *puBkColor = m_pSelf->m_MSNInfo.uStrangerMenuBkColor;
  839. if (puTextColor)
  840. *puTextColor = m_pSelf->m_MSNInfo.uTextColorUnknown;
  841. }
  842. return true;
  843. }
  844. return false;
  845. }
  846. void KUiMsgCentrePad::SendQueryChannelID(int nChannelResourceIndex)
  847. {
  848. if (nChannelResourceIndex < 0 || nChannelResourceIndex >= m_nChannelsResource)
  849. return;
  850. if (FindActivateChannelResourceIndex(m_ChannelsResource[nChannelResourceIndex].cTitle) >= 0) //已申请过了
  851. return;
  852. char ChannelName[__X_NAME_LEN_];
  853. ChannelName[0];
  854. if (m_ChannelsResource[nChannelResourceIndex].cFormatName[0] == 0)
  855. return;
  856. if (!ReplaceSpecialField(ChannelName, m_ChannelsResource[nChannelResourceIndex].cFormatName))
  857. return;
  858. if (ChannelName[0] == 0)
  859. return;
  860. char ProtocolBuffer[sizeof(tagExtendProtoHeader) + sizeof(PLAYERCOMM_QUERYCHANNELID)];
  861. int nProtocolOffset = 0;
  862. tagExtendProtoHeader* pHead = (tagExtendProtoHeader*)ProtocolBuffer;
  863. pHead->ProtocolType = c2s_extend;
  864. nProtocolOffset += sizeof(tagExtendProtoHeader);
  865. PLAYERCOMM_QUERYCHANNELID* pdata = (PLAYERCOMM_QUERYCHANNELID*)(ProtocolBuffer + nProtocolOffset);
  866. pdata->ProtocolFamily = pf_playercommunity;
  867. pdata->ProtocolID = playercomm_c2s_querychannelid;
  868. strncpy(pdata->channel, ChannelName, __X_NAME_LEN_);
  869. nProtocolOffset += sizeof(PLAYERCOMM_QUERYCHANNELID);
  870. pHead->wLength = nProtocolOffset - 1;
  871. g_pCoreShell->SendNewDataToServer(ProtocolBuffer, nProtocolOffset);
  872. }
  873. void KUiMsgCentrePad::SendChannelSubscribe(int nChannelIndex, bool b)
  874. {
  875. if (nChannelIndex < 0 || nChannelIndex >= m_nActivateChannels)
  876. return;
  877. char ProtocolBuffer[sizeof(tagExtendProtoHeader) + sizeof(PLAYERCOMM_SUBSCRIBE)];
  878. int nProtocolOffset = 0;
  879. tagExtendProtoHeader* pHead = (tagExtendProtoHeader*)ProtocolBuffer;
  880. pHead->ProtocolType = c2s_extend;
  881. nProtocolOffset += sizeof(tagExtendProtoHeader);
  882. PLAYERCOMM_SUBSCRIBE* pdata = (PLAYERCOMM_SUBSCRIBE*)(ProtocolBuffer + nProtocolOffset);
  883. pdata->ProtocolFamily = pf_playercommunity;
  884. pdata->ProtocolID = playercomm_c2s_subscribe;
  885. pdata->channelid = m_pActivateChannel[nChannelIndex].nChannelID;
  886. pdata->subscribe = b;
  887. nProtocolOffset += sizeof(PLAYERCOMM_SUBSCRIBE);
  888. pHead->wLength = nProtocolOffset - 1;
  889. g_pCoreShell->SendNewDataToServer(ProtocolBuffer, nProtocolOffset);
  890. }
  891. int KUiMsgCentrePad::AddActivateChannel(const KChannelActivateInfo& Item)
  892. {
  893. int n = FindActivateChannelIndex(Item.nChannelID);
  894. if (n >= 0)
  895. return n;
  896. //新增频道
  897. KChannelActivateInfo* pChannels = new KChannelActivateInfo[m_nActivateChannels + 1];
  898. if (m_nActivateChannels > 0 && m_pActivateChannel)
  899. {
  900. memcpy(pChannels, m_pActivateChannel, m_nActivateChannels * sizeof(KChannelActivateInfo));
  901. m_nActivateChannels = ReleaseActivateChannelAll();
  902. }
  903. m_pActivateChannel = pChannels;
  904. pChannels = m_pActivateChannel + m_nActivateChannels;
  905. *pChannels = Item;
  906. pChannels->uLastSendMsgTime = IR_GetCurrentTime() - m_ChannelsResource[Item.ResourceIndex].uSendMsgInterval; //确保第一条肯定能发
  907. pChannels->uLeftSendMsgNum = 0;
  908. pChannels->uBufferOffset = 0;
  909. memset(pChannels->Buffer, 0, sizeof(pChannels->Buffer));
  910. m_nActivateChannels++;
  911. return m_nActivateChannels - 1;
  912. }
  913. int KUiMsgCentrePad::ReleaseActivateChannel(int nChannelIndex)
  914. {
  915. if (nChannelIndex < 0 || nChannelIndex >= m_nActivateChannels)
  916. return -1;
  917. if (nChannelIndex + 1 < m_nActivateChannels)
  918. {
  919. memmove(m_pActivateChannel + nChannelIndex, m_pActivateChannel + nChannelIndex + 1, (m_nActivateChannels - nChannelIndex - 1) * sizeof(KChannelActivateInfo));
  920. }
  921. m_nActivateChannels--;
  922. return m_nActivateChannels;
  923. }
  924. int KUiMsgCentrePad::ReleaseActivateChannelAll()
  925. {
  926. if (m_pSelf)
  927. {
  928. int nOld = m_pSelf->m_nActivateChannels;
  929. if (m_pSelf->m_pActivateChannel)
  930. delete [] m_pSelf->m_pActivateChannel;
  931. m_pSelf->m_pActivateChannel = NULL;
  932. m_pSelf->m_nActivateChannels = 0;
  933. return nOld;
  934. }
  935. return 0;
  936. }
  937. //初始化
  938. void KUiMsgCentrePad::Initialize()
  939. {
  940. AddChild(&m_ChatRoom);
  941. AddChild(&m_MoveImg);
  942. AddChild(&m_SizeBtn);
  943. AddChild(&m_BgShadowBtn);
  944. char Scheme[256];
  945. g_UiBase.GetCurSchemePath(Scheme, 256);
  946. LoadScheme(Scheme);
  947. Wnd_AddWindow(this, WL_LOWEST);
  948. Wnd_AddWindow(&m_Sys, WL_LOWEST); //在KUiMsgCentrePad之后加入,要等背景先画
  949. m_Sys.AddChild(&m_Sys.m_SysRoom);
  950. m_Sys.AddChild(&m_Sys.m_UpButton);
  951. m_Sys.AddChild(&m_Sys.m_OpenSysButton);
  952. m_Sys.AddChild(&m_Sys.m_DownButton);
  953. m_Sys.m_OpenSysButton.CheckButton(1);
  954. }
  955. // -------------------------------------------------------------------------
  956. // 功能 : 活动函数
  957. // -------------------------------------------------------------------------
  958. void KUiMsgCentrePad::Breathe()
  959. {
  960. if (m_uAutoDelMsgInterval &&
  961. IR_IsTimePassed(m_uAutoDelMsgInterval, m_uLastDelMsgTime))
  962. {
  963. m_ChatRoom.GetMessageListBox()->HideNextLine();
  964. m_Sys.m_SysRoom.HideNextLine();
  965. m_uLastDelMsgTime = IR_GetCurrentTime();
  966. }
  967. }
  968. //载入界面方案
  969. void KUiMsgCentrePad::LoadScheme(const char* pScheme)
  970. {
  971. char Buff[128];
  972. KIniFile Ini;
  973. if (m_pSelf)
  974. {
  975. sprintf(Buff, "%s\%s", pScheme,
  976. (m_pSelf->m_bDockLeftSide ? SCHEME_INI_LEFT : SCHEME_INI_RIGHT));
  977. if (Ini.Load(Buff))
  978. m_pSelf->LoadScheme(&Ini);
  979. }
  980. }
  981. //重新初始化界面
  982. void KUiMsgCentrePad::DefaultScheme(const char* pScheme)
  983. {
  984. char Buff[128];
  985. KIniFile Ini;
  986. if (m_pSelf)
  987. {
  988. sprintf(Buff, "%s\%s", pScheme,
  989. (m_pSelf->m_bDockLeftSide ? SCHEME_INI_LEFT : SCHEME_INI_RIGHT));
  990. if (Ini.Load(Buff))
  991. {
  992. int nValue1, nValue2;
  993. Ini.GetInteger("Main", "Left",  0, &nValue1);
  994. Ini.GetInteger("Main", "Top",   0, &nValue2);
  995. m_pSelf->SetPosition(nValue1, nValue2);
  996. m_pSelf->SetSize(ms_DefaultWidth, ms_DefaultHeight);
  997. }
  998. }
  999. }
  1000. //隐藏所有输出
  1001. void KUiMsgCentrePad::HideAllMessage()
  1002. {
  1003. if (m_pSelf)
  1004. {
  1005. m_pSelf->m_ChatRoom.GetMessageListBox()->HideAllLine();
  1006. m_pSelf->m_Sys.m_SysRoom.HideAllLine();
  1007. }
  1008. }
  1009. //显示所有输出
  1010. void KUiMsgCentrePad::ShowAllMessage()
  1011. {
  1012. if (m_pSelf)
  1013. {
  1014. m_pSelf->m_ChatRoom.GetMessageListBox()->ClearHideLine();
  1015. m_pSelf->m_Sys.m_SysRoom.ClearHideLine();
  1016. }
  1017. }
  1018. extern IInlinePicEngineSink *g_pIInlinePicSink;
  1019. int KUiMsgCentrePad::ms_DefaultWidth = 0;
  1020. int KUiMsgCentrePad::ms_DefaultHeight = 0;
  1021. void KUiMsgCentrePad::LoadScheme(KIniFile* pIni)
  1022. {
  1023. //_ASSERT(pIni);
  1024. Init(pIni, "Main");
  1025. pIni->GetInteger2("Main", "WindowRange", &m_nMinTopPos, &m_nMaxBottomPos);
  1026. m_MoveImg .Init(pIni, "MoveImg");
  1027. m_BgShadowBtn   .Init(pIni, "ShadowBtn");
  1028. m_SizeBtn .Init(pIni, "SizeBtn");
  1029. int nV;
  1030. pIni->GetInteger("Main", "SizeUp", 0, &nV);
  1031. m_bSizeUp = (nV != 0);
  1032. if (m_bSizeUp)
  1033. m_SizeBtn.SetStyle(m_SizeBtn.GetStyle() & ~WND_S_MOVE_WITH_R_EDGE & ~WND_S_MOVE_WITH_B_EDGE);
  1034. m_BorderImg .Init(pIni, "BorderImg");
  1035. char szImage[MAX_PATH];
  1036. m_nCheckOnPicIndex = -1;
  1037. if (pIni->GetString("Main", "CheckOnImage", "", szImage, MAX_PATH))
  1038. {
  1039. if (g_pIInlinePicSink)
  1040. {
  1041. g_pIInlinePicSink->AddCustomInlinePic((WORD&)m_nCheckOnPicIndex, szImage);
  1042. }
  1043. }
  1044. m_nCheckOffPicIndex = -1;
  1045. if (pIni->GetString("Main", "CheckOffImage", "", szImage, MAX_PATH))
  1046. {
  1047. if (g_pIInlinePicSink)
  1048. {
  1049. g_pIInlinePicSink->AddCustomInlinePic((WORD&)m_nCheckOffPicIndex, szImage);
  1050. }
  1051. }
  1052. m_ChatRoom.Init(pIni, "ChatRoom");
  1053. m_Sys.Init(pIni, "SysRoom");
  1054. m_Sys.m_OpenSysButton.Init(pIni, "SysRoom_Open");
  1055. m_Sys.m_OpenSysButton.CheckButton(1);
  1056. m_Sys.m_SysRoom.Init(pIni, "SysRoom_List");
  1057. m_Sys.m_UpButton.Init(pIni, "SysRoom_Up");
  1058. m_Sys.m_DownButton.Init(pIni, "SysRoom_Down");
  1059. char ChName[64];
  1060. pIni->GetString("MSNRoom", "TextColorSelf", "0,0,0", ChName, sizeof(ChName));
  1061. m_MSNInfo.uTextColorSelf.Color_dw = GetColor(ChName);
  1062. m_MSNInfo.uTextColorSelf.Color_b.a = KTC_COLOR;
  1063. pIni->GetString("MSNRoom", "TextBorderColorSelf", "0,0,0", ChName, sizeof(ChName));
  1064. m_MSNInfo.uTextBorderColorSelf.Color_dw = GetColor(ChName);
  1065. m_MSNInfo.uTextBorderColorSelf.Color_b.a = KTC_BORDER_COLOR;
  1066. pIni->GetString("MSNRoom", "TextBKColorSelf", "0,0,0", ChName, sizeof(ChName));
  1067. m_MSNInfo.uTextBKColorSelf.Color_dw = (GetColor(ChName) & 0xffffff);
  1068. int nAlpha;
  1069. pIni->GetInteger("MSNRoom", "TextBKColorSelfAlpha", 128, &nAlpha);
  1070. if (nAlpha > 255 || nAlpha < 0)
  1071. m_MSNInfo.uTextBKColorSelf.Color_dw |= 0x16000000;
  1072. else
  1073. m_MSNInfo.uTextBKColorSelf.Color_dw |= (((255 - nAlpha) << 21) & 0xff000000);
  1074. pIni->GetString("MSNRoom", "TextColorUnknown", "0,0,0", ChName, sizeof(ChName));
  1075. m_MSNInfo.uTextColorUnknown.Color_dw = GetColor(ChName);
  1076. m_MSNInfo.uTextColorUnknown.Color_b.a = KTC_COLOR;
  1077. pIni->GetString("MSNRoom", "TextBorderColorUnknown", "0,0,0", ChName, sizeof(ChName));
  1078. m_MSNInfo.uTextBorderColorUnknown.Color_dw = GetColor(ChName);
  1079. m_MSNInfo.uTextBorderColorUnknown.Color_b.a = KTC_BORDER_COLOR;
  1080. pIni->GetString("MSNRoom", "TextColorFriend", "0,0,0", ChName, sizeof(ChName));
  1081. m_MSNInfo.uTextFriendColor.Color_dw = GetColor(ChName);
  1082. m_MSNInfo.uTextFriendColor.Color_b.a = KTC_COLOR;
  1083. pIni->GetString("MSNRoom", "TextBorderColorFriend", "0,0,0", ChName, sizeof(ChName));
  1084. m_MSNInfo.uTextBorderFriendColor.Color_dw = GetColor(ChName);
  1085. m_MSNInfo.uTextBorderFriendColor.Color_b.a = KTC_BORDER_COLOR;
  1086. m_MSNInfo.nFriendMenuPicIndex = -1;
  1087. if (pIni->GetString("MSNRoom", "Friend_MenuImage", "", szImage, MAX_PATH))
  1088. {
  1089. if (g_pIInlinePicSink)
  1090. {
  1091. m_MSNInfo.nFriendMenuPicHeight = 0;
  1092. KImageParam Param;
  1093. Param.nHeight = 0;
  1094. if (g_pRepresentShell &&
  1095. g_pRepresentShell->GetImageParam(szImage, &Param, ISI_T_SPR))
  1096. {
  1097. m_MSNInfo.nFriendMenuPicHeight = Param.nHeight;
  1098. }
  1099. g_pIInlinePicSink->AddCustomInlinePic(m_MSNInfo.nFriendMenuPicIndex, szImage);
  1100. }
  1101. }
  1102. m_MSNInfo.nFriendTextPicIndex = -1;
  1103. if (pIni->GetString("MSNRoom", "Friend_TextImage", "", szImage, MAX_PATH))
  1104. {
  1105. if (g_pIInlinePicSink)
  1106. {
  1107. g_pIInlinePicSink->AddCustomInlinePic(m_MSNInfo.nFriendTextPicIndex, szImage);
  1108. }
  1109. }
  1110. pIni->GetString("MSNRoom", "Friend_MenuBkColor", "0,0,0", ChName, sizeof(ChName));
  1111. m_MSNInfo.uFriendMenuBkColor.Color_dw = GetColor(ChName);
  1112. m_MSNInfo.uFriendMenuBkColor.Color_b.a = 0;
  1113. pIni->GetString("MSNRoom", "Friend_Sound", "", m_MSNInfo.szFriendSoundFileName, sizeof(m_MSNInfo.szFriendSoundFileName));
  1114. m_MSNInfo.nStrangerMenuPicIndex = -1;
  1115. if (pIni->GetString("MSNRoom", "Stranger_MenuImage", "", szImage, MAX_PATH))
  1116. {
  1117. if (g_pIInlinePicSink)
  1118. {
  1119. m_MSNInfo.nStrangerMenuPicHeight = 0;
  1120. KImageParam Param;
  1121. Param.nHeight = 0;
  1122. if (g_pRepresentShell &&
  1123. g_pRepresentShell->GetImageParam(szImage, &Param, ISI_T_SPR))
  1124. {
  1125. m_MSNInfo.nStrangerMenuPicHeight = Param.nHeight;
  1126. }
  1127. g_pIInlinePicSink->AddCustomInlinePic(m_MSNInfo.nStrangerMenuPicIndex, szImage);
  1128. }
  1129. }
  1130. m_MSNInfo.nStrangerTextPicIndex = -1;
  1131. if (pIni->GetString("MSNRoom", "Stranger_TextImage", "", szImage, MAX_PATH))
  1132. {
  1133. if (g_pIInlinePicSink)
  1134. {
  1135. g_pIInlinePicSink->AddCustomInlinePic(m_MSNInfo.nStrangerTextPicIndex, szImage);
  1136. }
  1137. }
  1138. m_MSNInfo.nSelfTextPicIndex = -1;
  1139. if (pIni->GetString("MSNRoom", "Self_TextImage", "", szImage, MAX_PATH))
  1140. {
  1141. if (g_pIInlinePicSink)
  1142. {
  1143. g_pIInlinePicSink->AddCustomInlinePic(m_MSNInfo.nSelfTextPicIndex, szImage);
  1144. }
  1145. }
  1146. pIni->GetString("MSNRoom", "Stranger_MenuBkColor", "0,0,0", ChName, sizeof(ChName));
  1147. m_MSNInfo.uStrangerMenuBkColor.Color_dw = GetColor(ChName);
  1148. m_MSNInfo.uStrangerMenuBkColor.Color_b.a = 0;
  1149. SetAutoDelMsgInterval(SECOND_AUTODELMSG);
  1150. for (int nCh = 0; nCh < MAX_CHANNELRESOURCE; nCh++)
  1151. {
  1152. sprintf(ChName, "%s%d", "Channel", nCh);
  1153. if (pIni->GetString("Channels", ChName, "", m_ChannelsResource[nCh].cTitle, 32))
  1154. {
  1155. pIni->GetString(m_ChannelsResource[nCh].cTitle, "TextColor", "0,0,0", ChName, sizeof(ChName));
  1156. m_ChannelsResource[nCh].uTextColor.Color_dw = GetColor(ChName);
  1157. m_ChannelsResource[nCh].uTextColor.Color_b.a = KTC_COLOR;
  1158. pIni->GetString(m_ChannelsResource[nCh].cTitle, "TextBorderColor", "0,0,0", ChName, sizeof(ChName));
  1159. m_ChannelsResource[nCh].uTextBorderColor.Color_dw = GetColor(ChName);
  1160. m_ChannelsResource[nCh].uTextBorderColor.Color_b.a = KTC_BORDER_COLOR;
  1161. for (int m = 0; m < MAX_CHANNELRESOURCE; m++)
  1162. {
  1163. m_ChannelsResource[nCh].cShortTitle[m][0] = 0;
  1164. sprintf(ChName, "%s%d", "ShortName", m);
  1165. pIni->GetString(m_ChannelsResource[nCh].cTitle, ChName, "", m_ChannelsResource[nCh].cShortTitle[m], sizeof(m_ChannelsResource[nCh].cShortTitle[m]));
  1166. }
  1167. pIni->GetString(m_ChannelsResource[nCh].cTitle, "FormatName", "", m_ChannelsResource[nCh].cFormatName, sizeof(m_ChannelsResource[nCh].cFormatName));
  1168. pIni->GetString(m_ChannelsResource[nCh].cTitle, "MenuText", "", m_ChannelsResource[nCh].cMenuText, sizeof(m_ChannelsResource[nCh].cMenuText));
  1169. pIni->GetString(m_ChannelsResource[nCh].cTitle, "DeactivateMenuText", m_ChannelsResource[nCh].cMenuText, m_ChannelsResource[nCh].cMenuDeactivateText, sizeof(m_ChannelsResource[nCh].cMenuDeactivateText));
  1170. m_ChannelsResource[nCh].nMenuPicIndex = -1;
  1171. if (pIni->GetString(m_ChannelsResource[nCh].cTitle, "MenuImage", "", szImage, MAX_PATH))
  1172. {
  1173. if (g_pIInlinePicSink)
  1174. {
  1175. m_ChannelsResource[nCh].nMenuPicHeight = 0;
  1176. KImageParam Param;
  1177. Param.nHeight = 0;
  1178. if (g_pRepresentShell &&
  1179. g_pRepresentShell->GetImageParam(szImage, &Param, ISI_T_SPR))
  1180. {
  1181. m_ChannelsResource[nCh].nMenuPicHeight = Param.nHeight;
  1182. }
  1183. g_pIInlinePicSink->AddCustomInlinePic(m_ChannelsResource[nCh].nMenuPicIndex, szImage);
  1184. }
  1185. }
  1186. m_ChannelsResource[nCh].nMenuDeactivatePicIndex = m_ChannelsResource[nCh].nMenuPicIndex;
  1187. m_ChannelsResource[nCh].nMenuDeactivatePicHeight = m_ChannelsResource[nCh].nMenuPicHeight;
  1188. if (pIni->GetString(m_ChannelsResource[nCh].cTitle, "DeactivateMenuImage", "", szImage, MAX_PATH))
  1189. {
  1190. if (g_pIInlinePicSink)
  1191. {
  1192. m_ChannelsResource[nCh].nMenuDeactivatePicHeight = 0;
  1193. KImageParam Param;
  1194. Param.nHeight = 0;
  1195. if (g_pRepresentShell &&
  1196. g_pRepresentShell->GetImageParam(szImage, &Param, ISI_T_SPR))
  1197. {
  1198. m_ChannelsResource[nCh].nMenuDeactivatePicHeight = Param.nHeight;
  1199. }
  1200. g_pIInlinePicSink->AddCustomInlinePic(m_ChannelsResource[nCh].nMenuDeactivatePicIndex, szImage);
  1201. }
  1202. }
  1203. m_ChannelsResource[nCh].nTextPicIndex = -1;
  1204. if (pIni->GetString(m_ChannelsResource[nCh].cTitle, "TextImage", "", szImage, MAX_PATH))
  1205. {
  1206. if (g_pIInlinePicSink)
  1207. {
  1208. g_pIInlinePicSink->AddCustomInlinePic(m_ChannelsResource[nCh].nTextPicIndex, szImage);
  1209. }
  1210. }
  1211. pIni->GetString(m_ChannelsResource[nCh].cTitle, "MenuBkColor", "0,0,0", ChName, sizeof(ChName));
  1212. m_ChannelsResource[nCh].uMenuBkColor.Color_dw = GetColor(ChName);
  1213. m_ChannelsResource[nCh].uMenuBkColor.Color_b.a = 0;
  1214. pIni->GetInteger(m_ChannelsResource[nCh].cTitle, "NeverClose", 0, &m_ChannelsResource[nCh].nNeverClose);
  1215. pIni->GetString(m_ChannelsResource[nCh].cTitle, "Sound", "", m_ChannelsResource[nCh].szSoundFileName, sizeof(m_ChannelsResource[nCh].szSoundFileName));
  1216. pIni->GetInteger(m_ChannelsResource[nCh].cTitle, "SendMsgInterval", 0, (int*)(&m_ChannelsResource[nCh].uSendMsgInterval));
  1217. pIni->GetInteger(m_ChannelsResource[nCh].cTitle, "SendMsgNum", 0, (int*)(&m_ChannelsResource[nCh].uSendMsgNum));
  1218. m_ChannelsResource[nCh].uSendMsgNum++;
  1219. if (m_ChannelsResource[nCh].uSendMsgNum > 10)
  1220. m_ChannelsResource[nCh].uSendMsgNum = 10;
  1221. if (m_ChannelsResource[nCh].uSendMsgNum <= 0)
  1222. m_ChannelsResource[nCh].uSendMsgNum = 1;
  1223. }
  1224. else
  1225. break;
  1226. }
  1227. if (nCh < MAX_CHANNELRESOURCE)
  1228. {
  1229. m_ChannelsResource[nCh].cTitle[0] = 0;
  1230. for (int m = 0; m < MAX_CHANNELRESOURCE; m++)
  1231. {
  1232. m_ChannelsResource[nCh].cShortTitle[m][0] = 0;
  1233. }
  1234. }
  1235. m_nChannelsResource = nCh;
  1236. m_nDefaultChannelResource = -1;
  1237. if (pIni->GetString("Channels", "DefaultChannel", "", ChName, 32))
  1238. {
  1239. m_nDefaultChannelResource = FindChannelResourceIndex(ChName);
  1240. }
  1241. pIni->GetString("Channels", "DefaultChannelSendName", "系统", m_DefaultChannelSendName, 32);
  1242. pIni->GetString("Main", "NameTextColor", "0,0,0", ChName, sizeof(ChName));
  1243. m_NameColor.Color_dw = GetColor(ChName);
  1244. m_NameColor.Color_b.a = KTC_COLOR;
  1245. pIni->GetString("Main", "NameTextBorderColor", "0,0,0", ChName, sizeof(ChName));
  1246. m_BorderNameColor.Color_dw = GetColor(ChName);
  1247. m_BorderNameColor.Color_b.a = KTC_BORDER_COLOR;
  1248. RECT rc;
  1249. if (m_Style & WND_S_SIZE_WITH_ALL_CHILD)
  1250. {
  1251. GetAllChildLayoutRect(&rc);
  1252. m_Width = rc.right - rc.left;;
  1253. m_Height = rc.bottom - rc.top;
  1254. }
  1255. ms_DefaultWidth = m_Width;
  1256. ms_DefaultHeight = m_Height;
  1257. }
  1258. //判断一个点是否落在窗口内,传入的是绝对坐标
  1259. int KUiMsgCentrePad::PtInWindow(int x, int y)
  1260. {
  1261. int nRet = 0;
  1262. if (KWndWindow::PtInWindow(x, y))
  1263. {
  1264. nRet =  (
  1265. m_MoveImg.PtInWindow(x, y) ||
  1266. m_SizeBtn.PtInWindow(x, y) ||
  1267. m_ChatRoom.PtInWindow(x, y) ||
  1268. m_BgShadowBtn.PtInWindow(x, y)
  1269. );
  1270. }
  1271. return nRet;
  1272. }
  1273. //窗口函数
  1274. int KUiMsgCentrePad::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)
  1275. {
  1276. switch(uMsg)
  1277. {
  1278. //case WND_M_POPUPMENU:
  1279. // if (uParam == (unsigned int)(KWndWindow*)(m_ChatRoom.GetMessageListBox()))
  1280. // PopupChannelMenu(LOWORD(nParam), HIWORD(nParam));
  1281. // break;
  1282. case WND_M_MENUITEM_SELECTED:
  1283. if (uParam == (unsigned int)(KWndWindow*)this)
  1284. {
  1285. if (HIWORD(nParam) == SEL_CHANNEL_MENU)
  1286. {
  1287. if (short(LOWORD(nParam)) >= 0)
  1288. {
  1289. CheckChannel(LOWORD(nParam), !m_pActivateChannel[LOWORD(nParam)].bSubscribe);
  1290. KPopupMenuData* p = KPopupMenu::GetMenuData();
  1291. if (p)
  1292. {
  1293. PopupChannelMenu(p->nXX, p->nYY);
  1294. }
  1295. }
  1296. else
  1297. KPopupMenu::Cancel();
  1298. }
  1299. }
  1300. break;
  1301. case WND_N_CHILD_MOVE:
  1302. if (uParam == (unsigned int)(KWndWindow*)&m_SizeBtn)
  1303. DragWndSize(nParam);
  1304. else if (uParam == (unsigned int)(KWndWindow*)&m_MoveImg)
  1305. DragWndPos(nParam);
  1306. break;
  1307. case WND_N_LIST_ITEM_SEL:
  1308. if (GetKeyState(VK_CONTROL) & 0x8000)
  1309. {
  1310. char szCurText[256];
  1311. szCurText[0] = 0;
  1312. int nLen = GetMessageSendName((KWndWindow*)uParam, nParam, szCurText);
  1313. if (nLen > 0)
  1314. {
  1315. char cName[32];
  1316. ReplaceChannelName(cName, 31, szCurText);
  1317. bool bChannel = (GetChannelIndex(cName) >= 0);
  1318. KUiPlayerBar::InputNameMsg(bChannel, cName, TRUE);
  1319. }
  1320. }
  1321. break;
  1322. case WND_M_POPUPMENU:
  1323. {
  1324. char szCurText[256];
  1325. szCurText[0] = 0;
  1326. int nLen = GetMessageSendName((KWndWindow*)uParam, LOWORD(nParam), HIWORD(nParam), szCurText);
  1327. if (nLen > 0)
  1328. {
  1329. char cName[32];
  1330. ReplaceChannelName(cName, 31, szCurText);
  1331. bool bChannel = (GetChannelIndex(cName) >= 0);
  1332. if (!bChannel) //不是频道
  1333. {
  1334. if (GetKeyState(VK_CONTROL) & 0x8000)
  1335. {
  1336. KUiPlayerItem SelectPlayer;
  1337. int nKind = -1;
  1338. if (!(g_pCoreShell &&
  1339.   g_pCoreShell->FindSpecialNPC(cName, &SelectPlayer, nKind) &&
  1340.   nKind == kind_player
  1341.  )
  1342.    )
  1343. {
  1344. strncpy(SelectPlayer.Name, cName, 32);
  1345. SelectPlayer.Name[31] = 0;
  1346. SelectPlayer.nIndex = -1;
  1347. SelectPlayer.uId = 0;
  1348. }
  1349. PopUpContextPeopleMenu(SelectPlayer, LOWORD(nParam), HIWORD(nParam));
  1350. }
  1351. else if (GetKeyState(VK_MENU) & 0x8000)
  1352. {
  1353. PopUpContextEmoteMenu(cName, LOWORD(nParam), HIWORD(nParam));
  1354. }
  1355. }
  1356. }
  1357. }
  1358. break;
  1359. case WND_N_BUTTON_CLICK:
  1360. if (uParam == (unsigned int)(KWndWindow*)&m_BgShadowBtn)
  1361. {
  1362. ShowAllMessage();
  1363. m_bShowShadow = m_BgShadowBtn.IsButtonChecked();
  1364. }
  1365. break;
  1366. default:
  1367. return KWndWindow::WndProc(uMsg, uParam, nParam);
  1368. }
  1369. return 0;
  1370. }
  1371. int KUiMsgCentrePad::GetMessageSendName(KWndWindow* pWnd, int nIndex, char* szCurText)
  1372. {
  1373. if (nIndex < 0)
  1374. return 0;
  1375. int nLen = 0;
  1376. if (pWnd == (KWndWindow*)&m_ChatRoom)
  1377. {
  1378. nLen = m_ChatRoom.GetMessageListBox()->GetOneMessage(nIndex, szCurText, 256, TRUE);
  1379. }
  1380. int nName = 0;
  1381. if (nLen >= 0)
  1382. {
  1383. szCurText[nLen] = 0;
  1384. while (nName < nLen)
  1385. {
  1386. if (szCurText[nName] == ':')
  1387. {
  1388. szCurText[nName] = 0;
  1389. break;
  1390. }
  1391. nName++;
  1392. }
  1393. }
  1394. return nName;
  1395. }
  1396. int KUiMsgCentrePad::GetMessageSendName(KWndWindow* pWnd, int x, int y, char* szCurText)
  1397. {
  1398. int nIndex = -1;
  1399. if (pWnd == (KWndWindow*)&m_ChatRoom)
  1400. {
  1401. nIndex = m_ChatRoom.GetMessageListBox()->HitTextAtPoint(x, y);
  1402. }
  1403. return GetMessageSendName(pWnd, nIndex, szCurText);
  1404. }
  1405. //绘制窗口
  1406. void KUiMsgCentrePad::PaintWindow()
  1407. {
  1408. KWndWindow::PaintWindow();
  1409. if ((m_bSizingWnd || m_bShowShadow) && g_pRepresentShell)
  1410. {
  1411. KRUShadow bg;
  1412. m_ChatRoom.GetMessageListBox()->GetAbsolutePos(&bg.oPosition.nX, &bg.oPosition.nY);
  1413. bg.Color.Color_dw = 0x16000000;
  1414. m_ChatRoom.GetMessageListBox()->GetSize(&bg.oEndPos.nX, &bg.oEndPos.nY);
  1415. bg.oEndPos.nX += bg.oPosition.nX;
  1416. bg.oEndPos.nY += bg.oPosition.nY;
  1417. g_pRepresentShell->DrawPrimitives(1, &bg, RU_T_SHADOW, true);
  1418. if (m_bShowShadow)
  1419. {
  1420. m_Sys.m_SysRoom.GetAbsolutePos(&bg.oPosition.nX, &bg.oPosition.nY);
  1421. bg.Color.Color_dw = 0x16000000;
  1422. m_Sys.m_SysRoom.GetSize(&bg.oEndPos.nX, &bg.oEndPos.nY);
  1423. bg.oEndPos.nX += bg.oPosition.nX;
  1424. bg.oEndPos.nY += bg.oPosition.nY;
  1425. g_pRepresentShell->DrawPrimitives(1, &bg, RU_T_SHADOW, true);
  1426. }
  1427. int cy;
  1428. m_BorderImg.GetSize(NULL, &cy);
  1429. m_BorderImg.SetPosition(bg.oPosition.nX, bg.oPosition.nY - cy);
  1430. m_BorderImg.PaintWindow();
  1431. m_BorderImg.SetPosition(bg.oPosition.nX, bg.oEndPos.nY);
  1432. m_BorderImg.PaintWindow();
  1433. m_BorderImg.NextFrame();
  1434. }
  1435. }
  1436. void KUiMsgCentrePad::DragWndPos(int nMoveOffset)
  1437. {
  1438. if (nMoveOffset)
  1439. {
  1440. int nMoveOffsetX = (short)(nMoveOffset & 0xffff);
  1441. int nMoveOffsetY = (short)((nMoveOffset >> 16) & 0xffff);
  1442. int x, y;
  1443. m_MoveImg.GetPosition(&x, &y);
  1444. x -= nMoveOffsetX;
  1445. y -= nMoveOffsetY;
  1446. m_MoveImg.SetPosition(x, y); //按钮跟着窗口变化,所以要先变回原样
  1447. y = m_Top + nMoveOffsetY;
  1448. // int sx, sy;
  1449. // Wnd_GetCursorPos(&x, NULL);
  1450. // Wnd_GetScreenSize(sx, sy);
  1451. //
  1452. // if ((m_bDockLeftSide && x > (sx / 2 + 20)) ||
  1453. // (m_bDockLeftSide == false && x < (sx / 2 - 20)))
  1454. // {
  1455. // m_bDockLeftSide = !m_bDockLeftSide;
  1456. // char Scheme[256];
  1457. // g_UiBase.GetCurSchemePath(Scheme, 256);
  1458. // LoadScheme(Scheme);
  1459. // }
  1460. if (y < m_nMinTopPos)
  1461. y = m_nMinTopPos;
  1462. else if (y + m_Height > m_nMaxBottomPos)
  1463. y = m_nMaxBottomPos - m_Height;
  1464. //int sysx, sysy;
  1465. //m_SysRoom.GetPosition(&sysx, &sysy);
  1466. //m_SysRoom.SetPosition(sysx, sysy + y - m_Top);
  1467. SetPosition(m_Left, y);
  1468. }
  1469. }
  1470. void KUiMsgCentrePad::DragWndSize(int nMoveOffset)
  1471. {
  1472. if (nMoveOffset == 0)
  1473. {
  1474. m_bSizingWnd = false;
  1475. //m_MsgList.EnableTextLineShadow(true);
  1476. m_nSizeBtnDragOffsetY = 0;
  1477. }
  1478. else
  1479. {
  1480. if (m_nSizeBtnDragOffsetY == 0)
  1481. {
  1482. m_bSizingWnd = true;
  1483. //m_MsgList.EnableTextLineShadow(false);
  1484. }
  1485. int nMoveOffsetX = (short)(nMoveOffset & 0xffff);
  1486. int nMoveOffsetY = (short)((nMoveOffset >> 16) & 0xffff);
  1487. int x, y;
  1488. m_SizeBtn.GetPosition(&x, &y);
  1489. x -= nMoveOffsetX;
  1490. y -= nMoveOffsetY;
  1491. m_SizeBtn.SetPosition(x, y); //按钮跟着窗口变化,所以要先变回原样
  1492. m_nSizeBtnDragOffsetY += nMoveOffsetY;
  1493. if (ChanageHeight(m_nSizeBtnDragOffsetY, m_bSizeUp)) //改变Height成功后,就不用积累了
  1494. m_nSizeBtnDragOffsetY = 0;
  1495. }
  1496. }
  1497. int KUiMsgCentrePad::ChanageHeight(int nOffsetY, bool bAtTop)
  1498. {
  1499. if (bAtTop)
  1500. nOffsetY = m_ChatRoom.HeightToLineHeight(-nOffsetY);
  1501. else
  1502. nOffsetY = m_ChatRoom.HeightToLineHeight(nOffsetY);
  1503. if (nOffsetY != 0)
  1504. {
  1505. int x, y;
  1506. GetSize(&x, &y);
  1507. if (y + nOffsetY >= m_ChatRoom.GetMinHeight())
  1508. {
  1509. if (bAtTop)
  1510. {
  1511. if (m_Top - nOffsetY < m_nMinTopPos)
  1512. SetPosition(m_Left, m_nMinTopPos);
  1513. else
  1514. SetPosition(m_Left, m_Top - nOffsetY);
  1515. }
  1516. if (m_Top + y + nOffsetY > m_nMaxBottomPos)
  1517. nOffsetY = m_nMaxBottomPos - m_Top - y;
  1518. SetSize(x, y + nOffsetY);
  1519. }
  1520. }
  1521. return nOffsetY;
  1522. }
  1523. void KUiMsgCentrePad::Clear()
  1524. {
  1525. if (m_pSelf)
  1526. {
  1527. m_pSelf->m_ChatRoom.GetMessageListBox()->Clear();
  1528. m_pSelf->m_Sys.m_SysRoom.Clear();
  1529. }
  1530. }
  1531. void KUiMsgCentrePad::PopupChannelMenu(int x, int y)
  1532. {
  1533. if (m_pSelf == NULL)
  1534. return;
  1535. if (m_pSelf->m_nActivateChannels <= 0)
  1536. return;
  1537. int nChannelDataCount = m_pSelf->m_nActivateChannels;
  1538. KPopupMenuData* pMenuData = (KPopupMenuData*)malloc(MENU_DATA_SIZE(nChannelDataCount));
  1539. if (pMenuData == NULL)
  1540. {
  1541. return;
  1542. }
  1543. KPopupMenu::InitMenuData(pMenuData, nChannelDataCount);
  1544. pMenuData->usMenuFlag &= ~PM_F_HAVE_HEAD_TAIL_IMG;
  1545. pMenuData->usMenuFlag |= (PM_F_AUTO_DEL_WHEN_HIDE | PM_F_CANCEL_BY_CALLER);
  1546. pMenuData->nItemTitleIndent = 0;
  1547. pMenuData->byItemTitleUpSpace = 0;
  1548. pMenuData->nItemHeight = 0;
  1549. WORD nHei = 0;
  1550. char szText[64];
  1551. int iC = 0;
  1552. for (int i = 0; i < nChannelDataCount; i++)
  1553. {
  1554. WORD nPicIndex = -1;
  1555. int nOffset = 0;
  1556. KRColor uColor;
  1557. KRColor uBKColor;
  1558. short nCheckPicIndex = -1;
  1559. if (GetChannelMenuinfo(iC, &nPicIndex, &nHei, &uColor, &uBKColor, szText, &nCheckPicIndex) && nCheckPicIndex != -1)
  1560. {
  1561. pMenuData->Items[iC].szData[0] = KTC_INLINE_PIC;
  1562. *((WORD*)(pMenuData->Items[iC].szData + 1)) = nPicIndex;
  1563. pMenuData->Items[iC].szData[3] = uColor.Color_b.a;
  1564. pMenuData->Items[iC].szData[4] = uColor.Color_b.r;
  1565. pMenuData->Items[iC].szData[5] = uColor.Color_b.g;
  1566. pMenuData->Items[iC].szData[6] = uColor.Color_b.b;
  1567. nOffset = 7;
  1568. if (nHei > pMenuData->nItemHeight)
  1569. pMenuData->nItemHeight = nHei;
  1570. strcpy(pMenuData->Items[iC].szData + nOffset, szText);
  1571. pMenuData->Items[iC].uDataLen = strlen(szText) + nOffset;
  1572. iC++;
  1573. }
  1574. pMenuData->Items[i].uBgColor = uBKColor.Color_dw;
  1575. }
  1576. pMenuData->nNumItem = iC;
  1577. pMenuData->nX = x;
  1578. pMenuData->nY = y;
  1579. KPopupMenu::Popup(pMenuData, (KWndWindow*)m_pSelf, SEL_CHANNEL_MENU);
  1580. }
  1581. int KUiMsgCentrePad::CheckChannel(int nChannelIndex, bool b)
  1582. {
  1583. if (m_pSelf == NULL)
  1584. return 0;
  1585. if (nChannelIndex < 0 || nChannelIndex >= m_pSelf->m_nActivateChannels)
  1586. return 0;
  1587. if (m_pSelf->IsNeverCloseActivateChannel(nChannelIndex)) //不能关闭的频道不能改变状态
  1588. return 0;
  1589. if (m_pSelf->m_pActivateChannel[nChannelIndex].bSubscribe == b)
  1590. return 1;
  1591. m_pSelf->m_pActivateChannel[nChannelIndex].bSubscribe = b;
  1592. m_pSelf->SendChannelSubscribe(nChannelIndex, b);
  1593. int n = m_pSelf->m_pActivateChannel[nChannelIndex].ResourceIndex;
  1594. if (n >= 0)
  1595. {
  1596. char Buffer[32];
  1597. strncpy(Buffer, b ? m_pSelf->m_ChannelsResource[n].cMenuText : m_pSelf->m_ChannelsResource[n].cMenuDeactivateText, 32);
  1598. strcat(Buffer, b ? "打开" : "关闭");
  1599. SystemMessageArrival(Buffer, strlen(Buffer));
  1600. }
  1601. return 1;
  1602. }
  1603. int KUiMsgCentrePad::FilterTextColor(char* pMsgBuff, unsigned short nMsgLength, const KRColor& uColor)
  1604. {
  1605. nMsgLength = TClearSpecialCtrlInEncodedText(pMsgBuff, nMsgLength, KTC_COLOR);
  1606. nMsgLength = TClearSpecialCtrlInEncodedText(pMsgBuff, nMsgLength, KTC_COLOR_RESTORE);
  1607. return nMsgLength;
  1608. }
  1609. void KUiMsgCentrePad::SetFontSize(int nFontSize)
  1610. {
  1611. if (m_pSelf)
  1612. {
  1613. m_pSelf->m_ChatRoom.GetMessageListBox()->SetFontSize(nFontSize);
  1614. }
  1615. }
  1616. int KUiMsgCentrePad::GetFontSize()
  1617. {
  1618. if (m_pSelf)
  1619. {
  1620. m_pSelf->m_ChatRoom.GetMessageListBox()->GetFontSize();
  1621. }
  1622. return 12;
  1623. }
  1624. int KUiMsgCentrePad::SetChannelTextColor(char* cTitle, DWORD uTextColor, DWORD uTextBorderColor)
  1625. {
  1626. if (m_pSelf)
  1627. {
  1628. int nRIndex = m_pSelf->FindChannelResourceIndex(cTitle);
  1629. if (nRIndex >= 0)
  1630. {
  1631. m_pSelf->m_ChannelsResource[nRIndex].uTextColor.Color_dw = uTextColor;
  1632. m_pSelf->m_ChannelsResource[nRIndex].uTextColor.Color_b.a = KTC_COLOR;
  1633. m_pSelf->m_ChannelsResource[nRIndex].uTextBorderColor.Color_dw = uTextBorderColor;
  1634. m_pSelf->m_ChannelsResource[nRIndex].uTextBorderColor.Color_b.a = KTC_BORDER_COLOR;
  1635. }
  1636. return nRIndex;
  1637. }
  1638. return -1;
  1639. }
  1640. char* KUiMsgCentrePad::GetChannelTextColor(int nIndex, DWORD& uTextColor, DWORD& uTextBorderColor)
  1641. {
  1642. if (m_pSelf && nIndex >= 0 && nIndex < m_pSelf->m_nChannelsResource)
  1643. {
  1644. uTextColor = m_pSelf->m_ChannelsResource[nIndex].uTextColor.Color_dw;
  1645. uTextBorderColor = m_pSelf->m_ChannelsResource[nIndex].uTextBorderColor.Color_dw;
  1646. return m_pSelf->m_ChannelsResource[nIndex].cTitle;
  1647. }
  1648. return NULL;
  1649. }
  1650. //nType 0 is me, 1 is friend, 2 is stranger
  1651. void KUiMsgCentrePad::SetMSNTextColor(int nType, DWORD uTextColor, DWORD uTextBorderColor)
  1652. {
  1653. if (m_pSelf)
  1654. {
  1655. if (nType == 0)
  1656. {
  1657. m_pSelf->m_MSNInfo.uTextColorSelf.Color_dw = uTextColor;
  1658. m_pSelf->m_MSNInfo.uTextColorSelf.Color_b.a = KTC_COLOR;
  1659. m_pSelf->m_MSNInfo.uTextBorderColorSelf.Color_dw = uTextBorderColor;
  1660. m_pSelf->m_MSNInfo.uTextBorderColorSelf.Color_b.a = KTC_BORDER_COLOR;
  1661. }
  1662. else if (nType == 1)
  1663. {
  1664. m_pSelf->m_MSNInfo.uTextFriendColor.Color_dw = uTextColor;
  1665. m_pSelf->m_MSNInfo.uTextFriendColor.Color_b.a = KTC_COLOR;
  1666. m_pSelf->m_MSNInfo.uTextBorderFriendColor.Color_dw = uTextBorderColor;
  1667. m_pSelf->m_MSNInfo.uTextBorderFriendColor.Color_b.a = KTC_BORDER_COLOR;
  1668. }
  1669. else if (nType == 2)
  1670. {
  1671. m_pSelf->m_MSNInfo.uTextColorUnknown.Color_dw = uTextColor;
  1672. m_pSelf->m_MSNInfo.uTextColorUnknown.Color_b.a = KTC_COLOR;
  1673. m_pSelf->m_MSNInfo.uTextBorderColorUnknown.Color_dw = uTextBorderColor;
  1674. m_pSelf->m_MSNInfo.uTextBorderColorUnknown.Color_b.a = KTC_BORDER_COLOR;
  1675. }
  1676. }
  1677. }
  1678. //nType 0 is me, 1 is friend, 2 is stranger
  1679. void KUiMsgCentrePad::GetMSNTextColor(int nType, DWORD& uTextColor, DWORD& uTextBorderColor)
  1680. {
  1681. if (m_pSelf)
  1682. {
  1683. if (nType == 0)
  1684. {
  1685. uTextColor = m_pSelf->m_MSNInfo.uTextColorSelf.Color_dw;
  1686. uTextBorderColor = m_pSelf->m_MSNInfo.uTextBorderColorSelf.Color_dw;
  1687. }
  1688. else if (nType == 1)
  1689. {
  1690. uTextColor = m_pSelf->m_MSNInfo.uTextFriendColor.Color_dw;
  1691. uTextBorderColor = m_pSelf->m_MSNInfo.uTextBorderFriendColor.Color_dw;
  1692. }
  1693. else if (nType == 2)
  1694. {
  1695. uTextColor = m_pSelf->m_MSNInfo.uTextColorUnknown.Color_dw;
  1696. uTextBorderColor = m_pSelf->m_MSNInfo.uTextBorderColorUnknown.Color_dw;
  1697. }
  1698. }
  1699. }