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

模拟服务器

开发平台:

C/C++

  1. /*****************************************************************************************
  2. // 剑侠应用界面窗口的公共接口
  3. // Copyright : Kingsoft 2002
  4. // Author :   Wooy(Wu yue)
  5. // CreateTime: 2002-7-17
  6. *****************************************************************************************/
  7. #include "KWin32.h"
  8. #include "KIniFile.h"
  9. #include "Elem/Wnds.h"
  10. #include "Elem/UiImage.h"
  11. #include "UiShell.h"
  12. #include "UiBase.h"
  13. //#include "../../../core/src/gamedatadef.h"
  14. #include "../../core/src/coreshell.h"
  15. #include "UiCase/UiInit.h"
  16. #include "UiCase/UiConnectInfo.h"
  17. #include "UiCase/UiInformation.h"
  18. #include "UiCase/UiInformation2.h"
  19. #include "UiCase/UiPlayerBar.h"
  20. #include "UiCase/UiStatus.h"
  21. #include "UiCase/UiParadeItem.h"
  22. #include "UiCase/UiItem.h"
  23. #include "UiCase/UiSkills.h"
  24. #include "UiCase/UiSkillTree.h"
  25. #include "UiCase/UiEscDlg.h"
  26. #include "UiCase/UiGame.h"
  27. #include "UiCase/UiOptions.h"
  28. #include "UiCase/UiMsgCentrePad.h"
  29. #include "UiCase/UiLoginBg.h"
  30. #include "UiCase/UiLogin.h"
  31. #include "UiCase/UiSelPlayer.h"
  32. #include "UiCase/UiSelServer.h"
  33. #include "UiCase/UiNewPlayer.h"
  34. #include "UiCase/UiSelNativePlace.h"
  35. #include "UiCase/UiChatCentre.h"
  36. #include "UiCase/UiChatStatus.h"
  37. #include "UiCase/UiSysMsgCentre.h"
  38. #include "UiCase/UiHeaderControlBar.h"
  39. #include "UiCase/UiToolsControlBar.h"
  40. #include "UiCase/UiStoreBox.h"
  41. #include "UiCase/UiChannelSubscibe.h"
  42. #include "UiCase/UiSelPlayerNearby.h"
  43. #include "UiCase/UiMsgSel.h"
  44. #include "UiCase/UiTeamManage.h"
  45. #include "UiCase/UiShop.h"
  46. #include "UiCase/UiMiniMap.h"
  47. #include "UiCase/UiTrade.h"
  48. #include "UiCase/UiTradeConfirmWnd.h"
  49. #include "UiCase/UiNewsMessage.h"
  50. #include "ShortcutKey.h"
  51. #include "UiSoundSetting.h"
  52. #include "../../Represent/iRepresent/iRepresentShell.h"
  53. #include "../NetConnect/NetConnectAgent.h"
  54. #include "../Login/Login.h"
  55. #include "UiCase/UiNewPlayerStartMsg.h"
  56. #include "UiCase/UiHelper.h"
  57. #include "UiCase/UiHelper2.h"
  58. #include "UiCase/UiTaskNote.h"
  59. #include "UiCase/UiReconnect.h"
  60. #include "UiCase/UiFaceSelector.h"
  61. #include "UiCase/UiStrengthRank.h"
  62. #include "UiCase/UiTongManager.h"
  63. #include "UiCase/UiTongCreateSheet.h"
  64. #include "UiChatPhrase.h"
  65. extern iCoreShell* g_pCoreShell;
  66. extern iRepresentShell* g_pRepresentShell;
  67. extern KUiChatPhrase    g_UiChatPhrase;
  68. enum UI_LIVING_STATUS
  69. {
  70. UI_LIVING_S_DEAD, //该退出程序了
  71. UI_LIVING_S_OUTGAME, //不是游戏运行中
  72. UI_LIVING_S_INGAME, //游戏运行中
  73. };
  74. static UI_LIVING_STATUS s_UiLiveSeed = UI_LIVING_S_DEAD;
  75. int g_bDisconnect = false;
  76. #ifdef _DEBUG
  77. #include "KTimer.h"
  78. static KTimer s_Timer;
  79. static int s_nFrameRate = 30;
  80. #endif
  81. #ifdef SWORDONLINE_SHOW_DBUG_INFO
  82. #include <shlwapi.h>
  83. char s_VersionInfo[60];
  84. int g_nShowDebugInfo = true;
  85. #endif
  86. //是否动态连接Represent连接库
  87. #define DYNAMIC_LINK_REPRESENT_LIBRARY
  88. #ifdef DYNAMIC_LINK_REPRESENT_LIBRARY
  89. extern  int g_bRepresent3;
  90. #endif
  91. void UiCloseWndsOutGame(bool bAll);
  92. bool UiCloseWndsInGame(bool bAll);
  93. #ifdef SWORDONLINE_SHOW_DBUG_INFO
  94. bool GetFileTimeVersionString(const char* pszFile, char* pszVersionString, int nSize)
  95. {
  96. if (pszVersionString)
  97. pszVersionString[0] = 0;
  98. //---打开文件----
  99. HANDLE hFile = CreateFile(pszFile, GENERIC_READ, 0, NULL,
  100. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  101. if (hFile == INVALID_HANDLE_VALUE)
  102. return false;
  103. FILETIME time, FileTime;
  104. SYSTEMTIME SysTime;
  105. if (::GetFileTime(hFile, NULL, NULL, &time) == FALSE)
  106. {
  107. CloseHandle(hFile);
  108. return false;
  109. }
  110. CloseHandle(hFile);
  111. hFile = NULL;
  112. FileTimeToLocalFileTime(&time, &FileTime);
  113. FileTimeToSystemTime(&FileTime, &SysTime);
  114. int nLen = GetDateFormat(LOCALE_USER_DEFAULT, 0, &SysTime, "M-d ", pszVersionString, nSize);
  115. if (nLen)
  116. nLen --;
  117. GetTimeFormat(LOCALE_USER_DEFAULT, 0, &SysTime, "H:mm", &pszVersionString[nLen], nSize - nLen);
  118. return true;
  119. }
  120. #endif
  121. //--------------------------------------------------------------------------
  122. // 功能:发送推出消息
  123. //--------------------------------------------------------------------------
  124. void UiPostQuitMsg()
  125. {
  126. s_UiLiveSeed = UI_LIVING_S_DEAD;
  127. }
  128. //是否已经选择退出程序
  129. bool UiIsAlreadyQuit()
  130. {
  131. return (s_UiLiveSeed == UI_LIVING_S_DEAD);
  132. }
  133. //--------------------------------------------------------------------------
  134. // 功能:界面系统初始化
  135. //--------------------------------------------------------------------------
  136. int UiInit()
  137. {
  138. Player_Life::RegisterSelfClass();
  139. Player_Mana::RegisterSelfClass();
  140. Player_Stamina::RegisterSelfClass();
  141. Player_Exp::RegisterSelfClass();
  142. Player_Level::RegisterSelfClass();
  143. Player_WorldSort::RegisterSelfClass();
  144. Player_Status::RegisterSelfClass();
  145. Player_Items::RegisterSelfClass();
  146. Player_Skills::RegisterSelfClass();
  147. Player_Team::RegisterSelfClass();
  148. Player_Sit::RegisterSelfClass();
  149. Player_Run::RegisterSelfClass();
  150. Player_Horse::RegisterSelfClass();
  151. Player_Exchange::RegisterSelfClass();
  152. Player_PK::RegisterSelfClass();
  153. Player_Faction::RegisterSelfClass();
  154. // KWndEdit::Initialize(hInstance);
  155. Wnd_ShowCursor(false);
  156. if (g_UiBase.Init() == false)
  157. return false;
  158. IR_UpdateTime();
  159. g_UiInformation.Initialize();
  160. g_UiInformation2.Initialize();
  161. KUiLoginBackGround::OpenWindow("Init");
  162. Wnd_SetGameSpaceWnd(&g_WndGameSpace);
  163. UiSoundLoadSetting();
  164. KUiFaceSelector::LoadFaceList();
  165. KShortcutKeyCentre::InitScript(); //要放到KUiFaceSelector之后
  166. #ifdef SWORDONLINE_SHOW_DBUG_INFO
  167. char szFile[MAX_PATH];
  168. GetModuleFileName(NULL, szFile, MAX_PATH);
  169. strcpy(s_VersionInfo, PathFindFileName(szFile));
  170. PathRemoveExtension(s_VersionInfo);
  171. strcat(s_VersionInfo, ":");
  172. int nLen = strlen(s_VersionInfo);
  173. GetFileTimeVersionString(szFile, &s_VersionInfo[nLen], sizeof(s_VersionInfo) - nLen);
  174. PathRemoveFileSpec(szFile);
  175. strcat(szFile, "\CoreClient.dll");
  176. strcat(s_VersionInfo, " CoreClient:");
  177. nLen = strlen(s_VersionInfo);
  178. GetFileTimeVersionString(szFile, &s_VersionInfo[nLen], sizeof(s_VersionInfo) - nLen);
  179. #endif
  180. g_UiChatPhrase.LoadEntireEmote();
  181. g_UiBase.NotifyEvent(APP_START);
  182. return true;
  183. }
  184. //--------------------------------------------------------------------------
  185. // 功能:界面系统退出
  186. //--------------------------------------------------------------------------
  187. void UiExit()
  188. {
  189. if (s_UiLiveSeed == UI_LIVING_S_INGAME)
  190. {
  191. g_UiBase.SavePrivateConfig();
  192. }
  193. KReconnectWnd::Exit(false);
  194. KUiInit::StopTitleMusic();
  195. //各种界面删除自己的临时文件
  196. KUiStrengthRank::RemoveTempFile();
  197. KUiTongManager::RemoveTempFile();
  198. //删除完毕
  199. UiCloseWndsInGame(true);
  200. UiCloseWndsOutGame(true);
  201. Wnd_SetGameSpaceWnd(NULL);
  202. g_LoginLogic.ReturnToIdle();
  203. g_LoginLogic.SaveLoginChoice();
  204. g_UiBase.Exit();
  205. KShortcutKeyCentre::UninitScript();//要在g_UiBase.Exit();后,因为要存盘
  206. s_UiLiveSeed = UI_LIVING_S_DEAD;
  207. KUiFaceSelector::Clear();
  208. Wnd_Cleanup();
  209. g_UiBase.NotifyEvent(APP_EXIT);
  210. g_UiBase.CleanTempDataFolder();
  211. }
  212. //--------------------------------------------------------------------------
  213. // 功能:開始界面控制流程
  214. //--------------------------------------------------------------------------
  215. int UiStart()
  216. {
  217. s_UiLiveSeed = UI_LIVING_S_OUTGAME;
  218. Wnd_ShowCursor(true);
  219. Wnd_SwitchCursor(CURSOR_NORMAL);
  220. return (KUiInit::OpenWindow(true, true) != NULL);
  221. }
  222. //--------------------------------------------------------------------------
  223. // 功能:绘制界面
  224. //--------------------------------------------------------------------------
  225. void UiPaint(int nGameLoop)
  226. {
  227. if (g_pRepresentShell == NULL || 
  228. g_pRepresentShell->RepresentBegin(false, 0) == false)
  229. {
  230. if (g_pCoreShell)
  231. g_pCoreShell->SetRepresentShell(g_pRepresentShell);
  232. return;
  233. }
  234. Wnd_RenderWindows();
  235. #ifdef _DEBUG
  236. DWORD dwPing = 0;
  237. char Info[128];
  238. s_Timer.GetFPS(&s_nFrameRate);
  239. if (g_pCoreShell)
  240. dwPing = g_pCoreShell->GetPing();
  241. #endif
  242. #ifdef SWORDONLINE_SHOW_DBUG_INFO
  243. if (g_nShowDebugInfo)
  244. {
  245. sprintf(Info,"FPS=%d LOOP=%d PING=%d", s_nFrameRate, nGameLoop, dwPing);
  246. g_pRepresentShell->OutputText(12, Info, -1, 10, 20, 0xffffffff, 0);
  247. g_pRepresentShell->OutputText(12, s_VersionInfo, -1, 2, 510, 0xffffffff, 0);
  248. #ifdef DYNAMIC_LINK_REPRESENT_LIBRARY
  249. {
  250. int nWidth, nHeight;
  251. Wnd_GetScreenSize(nWidth, nHeight);
  252. g_pRepresentShell->OutputText(12, g_bRepresent3 ? "Represent3" : "Represent2",
  253. -1, nWidth - 100, 10, 0xffffffff, 0);
  254. }
  255. #endif
  256. }
  257. #endif
  258. g_pRepresentShell->RepresentEnd();
  259. }
  260. //--------------------------------------------------------------------------
  261. // 功能:界面活动
  262. //--------------------------------------------------------------------------
  263. int UiHeartBeat()
  264. {
  265. if (s_UiLiveSeed != UI_LIVING_S_DEAD)
  266. {
  267. if (g_bDisconnect == false)
  268. {
  269. IR_UpdateTime();
  270. Wnd_Heartbeat();
  271. }
  272. else
  273. {
  274. if (s_UiLiveSeed == UI_LIVING_S_INGAME &&
  275. KReconnectWnd::IsReconnecttingGoingOn() == false)
  276. {
  277. g_UiBase.SavePrivateConfig();
  278. g_pCoreShell->OperationRequest(GOI_GAMESPACE_DISCONNECTED, 0, 0);
  279. KReconnectWnd::LaunchReconnect();
  280. }
  281. else
  282. {
  283. g_LoginLogic.NotifyDisconnect();
  284. }
  285. g_bDisconnect = false;
  286. }
  287. return true;
  288. }
  289. return false;
  290. }
  291. //--------------------------------------------------------------------------
  292. // 功能:处理输入
  293. //--------------------------------------------------------------------------
  294. void UiProcessInput(unsigned int uMsg, unsigned int uParam, int nParam)
  295. {
  296. if (uMsg == WM_COPYDATA)
  297. {
  298. if (nParam)
  299. {
  300. COPYDATASTRUCT* pData = (COPYDATASTRUCT*)nParam;
  301. if (pData && pData->cbData > 0 && pData->lpData && ((char*)pData->lpData)[pData->cbData - 1] == 0)
  302. { //有数据,而且数据长度不等于0, 而且数据是以0结尾的字符串
  303. KShortcutKeyCentre::ExcuteHWNDScript((const char *)pData->lpData);
  304. }
  305. }
  306. }
  307. else if (uMsg != WM_ACTIVATEAPP)
  308.         Wnd_ProcessInput(uMsg, uParam, nParam);
  309. else if (uParam)
  310. {
  311. Wnd_RestoreCursor();
  312. KUiOptions::LoadSetting(false, true);
  313. }
  314. }
  315. void UiCloseWndsOutGame(bool bAll)
  316. {
  317. KUiLogin::CloseWindow(true);
  318. KUiSelServer::CloseWindow(true);
  319. KUiOptions::CloseWindow();
  320. KUiInit::CloseWindow();
  321. KUiSelPlayer::CloseWindow();
  322. KUiNewPlayer::CloseWindow(true);
  323. KUiSelNativePlace::CloseWindow(true);
  324. KUiConnectInfo::CloseWindow(true);
  325. g_UiInformation.Close();
  326. g_UiInformation2.Close();
  327. if (bAll)
  328. KUiLoginBackGround::CloseWindow(true);
  329. }
  330. //--------------------------------------------------------------------------
  331. // 功能:进入游戏运行时
  332. //--------------------------------------------------------------------------
  333. void UiStartGame()
  334. {
  335. UiOnGameServerConnected();
  336. g_UiBase.CleanTempDataFolder();
  337. KUiInit::StopTitleMusic();
  338. UiCloseWndsOutGame(true);
  339. KUiLoginBackGround::CloseWindow(false);
  340. KUiConnectInfo::CloseWindow(true);
  341. KUiMsgCentrePad::OpenWindow();
  342. KUiPlayerBar::OpenWindow();
  343. KUiSysMsgCentre::OpenWindow();
  344. KUiHeaderControlBar::OpenWindow();
  345. KUiToolsControlBar::OpenWindow();
  346. KUiNewsMessage::OpenWindow();
  347. Wnd_ShowHideGameSpace(true);
  348. g_UiBase.SetStatus(UIS_S_IDLE);
  349. Wnd_GameSpaceHandleInput(true);
  350. KShortcutKeyCentre::Enable(true);
  351. if (g_LoginLogic.IsRoleNewCreated())
  352.     {   
  353.         KUiNewPlayerStartMsg::OpenWindow();
  354.     }
  355. KUiMsgCentrePad::ReleaseActivateChannelAll();
  356. KUiMsgCentrePad::QueryAllChannel();
  357. MapSetMode(MINIMAP_M_BRIEF_PIC);
  358. g_UiBase.LoadPrivateConfig();
  359. s_UiLiveSeed = UI_LIVING_S_INGAME;
  360. char szRole[64];
  361. szRole[0] = 0;
  362. g_LoginLogic.GetLoginAccount(szRole);
  363. if (szRole[0] != 0)
  364. {
  365. char szEvent[256];
  366. sprintf(szEvent, APP_STARTGAME, szRole);
  367. g_UiBase.NotifyEvent(szEvent);
  368. }
  369. }
  370. //游戏(断线后)继续
  371. void UiResumeGame()
  372. {
  373. s_UiLiveSeed = UI_LIVING_S_INGAME;
  374. }
  375. bool UiCloseWndsInGame(bool bAll)
  376. {
  377. if (bAll == false)
  378. {
  379. if (KUiStatus::GetIfVisible() == NULL &&
  380. KUiItem::GetIfVisible() == NULL &&
  381. KUiSkills::GetIfVisible() == NULL &&
  382. KUiSkillTree::GetIfVisible() == NULL &&
  383. KUiOptions::GetIfVisible() == NULL &&
  384. KUiChatStatus::GetIfVisible() == NULL &&
  385. KUiStoreBox::GetIfVisible() == NULL &&
  386. KUiTeamManage::GetIfVisible() == NULL &&
  387. KUiTradeConfirm::GetIfVisible() == NULL &&
  388. KUiShop::GetIfVisible() == NULL &&
  389. KUiHelper::GetIfVisible() == NULL &&
  390. KUiHelper2::GetIfVisible() == NULL &&
  391. KUiTaskNote::GetIfVisible() == NULL &&
  392. KUiSelPlayerNearby::DoesHaveVisibleWnd() == false &&
  393. KUiParadeItem::GetIfVisible() == NULL &&
  394. KUiFaceSelector::GetIfVisible() == NULL &&
  395. KUiStrengthRank::GetIfVisible() == NULL &&
  396. KUiTongManager::GetIfVisible() == NULL &&
  397. KUiTongCreateSheet::GetIfVisible() == NULL
  398. //KUiManage::GetIfVisible() ||
  399. )
  400. {
  401. return false;
  402. }
  403. }
  404. else
  405. {
  406. KUiMsgSel::CloseWindow(true);
  407. KUiTrade::CloseWindow();
  408. KUiPlayerBar::CloseWindow(true);
  409. KUiMsgCentrePad::CloseWindow(true);
  410. KUiHeaderControlBar::CloseWindow();
  411. KUiToolsControlBar::CloseWindow();
  412. KUiESCDlg::CloseWindow(true);
  413. KUiSysMsgCentre::CloseWindow();
  414. KUiChatCentre::CloseWindow(true);
  415. //KUiManage::CloseWindow();
  416. MapSetMode(MINIMAP_M_NONE);
  417. KUiNewsMessage::CloseWindow(TRUE);
  418. g_UiInformation.Close();
  419. g_UiInformation2.Close();
  420. }
  421. KUiFaceSelector::CloseWindow(bAll);
  422. KUiStatus::CloseWindow(bAll);
  423. KUiItem::CloseWindow(bAll);
  424. KUiSkills::CloseWindow(bAll);
  425. KUiSkillTree::CloseWindow(bAll);
  426. KUiOptions::CloseWindow();
  427. KUiChatStatus::CloseWindow();
  428. KUiStoreBox::CloseWindow();
  429. KUiTeamManage::CloseWindow();
  430. KUiTradeConfirm::CloseWindow(bAll);
  431. KUiShop::CloseWindow();
  432. KUiSelPlayerNearby::CloseWindow(bAll);
  433. // Of cause i should add this line   -- flying
  434. KUiHelper::CloseWindow(bAll);
  435. KUiHelper2::CloseWindow(bAll);
  436. KUiTaskNote::CloseWindow(bAll);
  437. KUiParadeItem::CloseWindow(bAll);
  438. KUiStrengthRank::CloseWindow();
  439. KUiTongManager::CloseWindow();
  440. KUiTongCreateSheet::CloseWindow();
  441. return true;
  442. }
  443. //--------------------------------------------------------------------------
  444. // 功能:离开游戏运行时
  445. //--------------------------------------------------------------------------
  446. void UiEndGame()
  447. {
  448. KReconnectWnd::Exit(false);
  449. g_UiBase.SavePrivateConfig();
  450. Wnd_DragFinished();
  451. Wnd_SwitchCursor(CURSOR_NORMAL);
  452. g_NetConnectAgent.DisconnectClient();
  453. s_UiLiveSeed = UI_LIVING_S_OUTGAME;
  454. KShortcutKeyCentre::Enable(false);
  455. UiCloseWndsInGame(true);
  456. Wnd_ShowHideGameSpace(false);
  457. Wnd_GameSpaceHandleInput(false);
  458. KUiLoginBackGround::OpenWindow("Init");
  459. g_UiBase.SetStatus(UIS_S_IDLE);
  460. g_UiBase.NotifyEvent(APP_EXITGAME);
  461. }
  462. //设置屏幕范围大小
  463. void UiSetScreenSize(int nWidth, int nHeight)
  464. {
  465. Wnd_SetScreenSize(nWidth, nHeight);
  466. }
  467. //与一个新的GameServer建立连接
  468. void UiOnGameServerConnected()
  469. {
  470. g_UiBase.SavePrivateConfig();
  471. }
  472. //与一个新的GameServer建立连接,启动同步完毕
  473. void UiOnGameServerStartSyncEnd()
  474. {
  475. KUiChatCentre::OpenWindow(false);
  476. KUiChatCentre::CreateSeverUnit();
  477. g_UiBase.LoadPrivateConfig(); //不太好:-(
  478. }
  479. /////////////////////////////////////////////////////////////////////////////////
  480. IMPLEMENT_COMCLASS(Player_Life)
  481. bool Player_Life::m_bText = true;
  482. void Player_Life::UpdateData()
  483. {
  484. if (g_pCoreShell)
  485. {
  486. KUiPlayerRuntimeInfo Info;
  487. memset(&Info, 0, sizeof(KUiPlayerRuntimeInfo));
  488. g_pCoreShell->GetGameData(GDI_PLAYER_RT_INFO, (int)&Info, 0);
  489. Info.nLife = max(Info.nLife, 0);
  490. Info.nLifeFull = max(Info.nLifeFull, 0);
  491. Set2IntValue(Info.nLife, Info.nLifeFull);
  492. if (m_bText)
  493. Set2IntText(Info.nLife, Info.nLifeFull, '/');
  494. else
  495. SetText(NULL, 0);
  496. }
  497. }
  498. void Player_Life::OnButtonClick()
  499. {
  500. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_SHOWPLAYERNUMBER);
  501. UpdateData();
  502. }
  503. IMPLEMENT_COMCLASS(Player_Mana)
  504. bool Player_Mana::m_bText = true;
  505. void Player_Mana::UpdateData()
  506. {
  507. if (g_pCoreShell)
  508. {
  509. KUiPlayerRuntimeInfo Info;
  510. memset(&Info, 0, sizeof(KUiPlayerRuntimeInfo));
  511. g_pCoreShell->GetGameData(GDI_PLAYER_RT_INFO, (int)&Info, 0);
  512. Info.nMana = max(Info.nMana, 0);
  513. Info.nManaFull = max(Info.nManaFull, 0);
  514. Set2IntValue(Info.nMana, Info.nManaFull);
  515. if (m_bText)
  516. Set2IntText(Info.nMana, Info.nManaFull, '/');
  517. else
  518. SetText(NULL, 0);
  519. }
  520. }
  521. void Player_Mana::OnButtonClick()
  522. {
  523. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_SHOWPLAYERNUMBER);
  524. UpdateData();
  525. }
  526. IMPLEMENT_COMCLASS(Player_Stamina)
  527. bool Player_Stamina::m_bText = true;
  528. void Player_Stamina::UpdateData()
  529. {
  530. if (g_pCoreShell)
  531. {
  532. KUiPlayerRuntimeInfo Info;
  533. memset(&Info, 0, sizeof(KUiPlayerRuntimeInfo));
  534. g_pCoreShell->GetGameData(GDI_PLAYER_RT_INFO, (int)&Info, 0);
  535. Info.nStamina = max(Info.nStamina, 0);
  536. Info.nStaminaFull = max(Info.nStaminaFull, 0);
  537. Set2IntValue(Info.nStamina, Info.nStaminaFull);
  538. if (m_bText)
  539. Set2IntText(Info.nStamina, Info.nStaminaFull, '/');
  540. else
  541. SetText(NULL, 0);
  542. }
  543. }
  544. void Player_Stamina::OnButtonClick()
  545. {
  546. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_SHOWPLAYERNUMBER);
  547. UpdateData();
  548. }
  549. IMPLEMENT_COMCLASS(Player_Exp)
  550. bool Player_Exp::m_bText = true;
  551. void Player_Exp::UpdateData()
  552. {
  553. int nFull, nCurrLevelExp, nCurrent;
  554. if (KUiPlayerBar::GetExp(nFull, nCurrLevelExp, nCurrent))
  555. {
  556. int np = 100;
  557. if (nCurrLevelExp != 0)
  558. np = (int)(((nCurrent - nFull + nCurrLevelExp) * 100.0) / nCurrLevelExp);
  559. np = max(np, 0);
  560. np = min(np, 100);
  561. Set2IntValue(np, 100);
  562. if (m_bText)
  563. {
  564. char szExp[32];
  565. int nLen = sprintf(szExp, "%d%%", np);
  566. SetText(szExp, nLen);
  567. }
  568. else
  569. SetText(NULL, 0);
  570. }
  571. }
  572. void Player_Exp::OnButtonClick()
  573. {
  574. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_SHOWPLAYERNUMBER);
  575. UpdateData();
  576. }
  577. int Player_Exp::GetToolTipInfo(char* szTip, int nMax)
  578. {
  579. int nFull, nCurrLevelExp, nCurrent;
  580. int nLen = 0;
  581. if (KUiPlayerBar::GetExp(nFull, nCurrLevelExp, nCurrent) && szTip && nMax > 0)
  582. {
  583. char szBuffer[64];
  584. nLen = sprintf(szBuffer, "经验 %d/%d", nCurrent, nFull);
  585. if (nLen <= nMax)
  586. memcpy(szTip, szBuffer, nLen);
  587. else
  588. nLen = 0;
  589. }
  590. return nLen;
  591. }
  592. IMPLEMENT_COMCLASS(Player_Level)
  593. void Player_Level::UpdateData()
  594. {
  595. if (g_pCoreShell)
  596. {
  597. KUiPlayerAttribute Info;
  598. memset(&Info, 0, sizeof(KUiPlayerAttribute));
  599. g_pCoreShell->GetGameData(GDI_PLAYER_RT_ATTRIBUTE, (unsigned int)&Info, 0);
  600. SetIntText(Info.nLevel, 0);
  601. }
  602. }
  603. IMPLEMENT_COMCLASS(Player_WorldSort)
  604. void Player_WorldSort::UpdateData()
  605. {
  606. if (g_pCoreShell)
  607. {
  608. KUiPlayerBaseInfo Info;
  609. memset(&Info, 0, sizeof(KUiPlayerBaseInfo));
  610. g_pCoreShell->GetGameData(GDI_PLAYER_BASE_INFO, (unsigned int)&Info, 0);
  611. SetIntText(Info.nRankInWorld, 0);
  612. }
  613. }
  614. void Player_WorldSort::OnButtonClick()
  615. {
  616. KUiStrengthRank::OpenDefaultWindow();
  617. }
  618. IMPLEMENT_COMCLASS(Player_Status)
  619. void Player_Status::OnButtonClick()
  620. {
  621. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_STATUS);
  622. }
  623. const char* Player_Status::GetShortKey()
  624. {
  625. return KShortcutKeyCentre::GetKeyName(
  626. KShortcutKeyCentre::GetCommandKey(
  627. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_STATUS)));
  628. }
  629. IMPLEMENT_COMCLASS(Player_Items)
  630. void Player_Items::OnButtonClick()
  631. {
  632. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_ITEMS);
  633. }
  634. const char* Player_Items::GetShortKey()
  635. {
  636. return KShortcutKeyCentre::GetKeyName(
  637. KShortcutKeyCentre::GetCommandKey(
  638. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_ITEMS)));
  639. }
  640. IMPLEMENT_COMCLASS(Player_Skills)
  641. void Player_Skills::OnButtonClick()
  642. {
  643. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_SKILLS);
  644. }
  645. const char* Player_Skills::GetShortKey()
  646. {
  647. return KShortcutKeyCentre::GetKeyName(
  648. KShortcutKeyCentre::GetCommandKey(
  649. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_SKILLS)));
  650. }
  651. IMPLEMENT_COMCLASS(Player_Team)
  652. void Player_Team::OnButtonClick()
  653. {
  654. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_TEAM);
  655. }
  656. const char* Player_Team::GetShortKey()
  657. {
  658. return KShortcutKeyCentre::GetKeyName(
  659. KShortcutKeyCentre::GetCommandKey(
  660. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_TEAM)));
  661. }
  662. IMPLEMENT_COMCLASS(Player_Faction)
  663. void Player_Faction::OnButtonClick()
  664. {
  665. KUiTongManager::OpenWindow(NULL);
  666. }
  667. const char* Player_Faction::GetShortKey()
  668. {
  669. return NULL;
  670. }
  671. IMPLEMENT_COMCLASS(Player_Sit)
  672. void Player_Sit::OnButtonClick()
  673. {
  674. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_SIT);
  675. }
  676. void Player_Sit::UpdateData()
  677. {
  678. if (g_pCoreShell)
  679. {
  680. KUiPlayerRuntimeInfo Info;
  681. memset(&Info, 0, sizeof(KUiPlayerRuntimeInfo));
  682. g_pCoreShell->GetGameData(GDI_PLAYER_RT_INFO, (int)&Info, 0);
  683. CheckButton(Info.byAction & PA_SIT);
  684. }
  685. }
  686. const char* Player_Sit::GetShortKey()
  687. {
  688. return KShortcutKeyCentre::GetKeyName(
  689. KShortcutKeyCentre::GetCommandKey(
  690. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_SIT)));
  691. }
  692. IMPLEMENT_COMCLASS(Player_Run)
  693. void Player_Run::OnButtonClick()
  694. {
  695. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_RUN);
  696. }
  697. void Player_Run::UpdateData()
  698. {
  699. if (g_pCoreShell)
  700. {
  701. KUiPlayerRuntimeInfo Info;
  702. memset(&Info, 0, sizeof(KUiPlayerRuntimeInfo));
  703. g_pCoreShell->GetGameData(GDI_PLAYER_RT_INFO, (int)&Info, 0);
  704. CheckButton(Info.byAction & PA_RUN);
  705. }
  706. }
  707. const char* Player_Run::GetShortKey()
  708. {
  709. return KShortcutKeyCentre::GetKeyName(
  710. KShortcutKeyCentre::GetCommandKey(
  711. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_RUN)));
  712. }
  713. IMPLEMENT_COMCLASS(Player_Horse)
  714. void Player_Horse::OnButtonClick()
  715. {
  716. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_HORSE);
  717. }
  718. void Player_Horse::UpdateData()
  719. {
  720. if (g_pCoreShell)
  721. {
  722. KUiPlayerRuntimeInfo Info;
  723. memset(&Info, 0, sizeof(KUiPlayerRuntimeInfo));
  724. g_pCoreShell->GetGameData(GDI_PLAYER_RT_INFO, (int)&Info, 0);
  725. CheckButton(Info.byAction & PA_RIDE);
  726. }
  727. }
  728. const char* Player_Horse::GetShortKey()
  729. {
  730. return KShortcutKeyCentre::GetKeyName(
  731. KShortcutKeyCentre::GetCommandKey(
  732. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_HORSE)));
  733. }
  734. IMPLEMENT_COMCLASS(Player_Exchange)
  735. void Player_Exchange::OnButtonClick()
  736. {
  737. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_TRADE);
  738. }
  739. void Player_Exchange::UpdateData()
  740. {
  741. if (g_pCoreShell)
  742. {
  743. CheckButton(g_pCoreShell->GetGameData(GDI_TRADE_OPER_DATA, UTOD_IS_WILLING, 0));
  744. }
  745. }
  746. const char* Player_Exchange::GetShortKey()
  747. {
  748. return KShortcutKeyCentre::GetKeyName(
  749. KShortcutKeyCentre::GetCommandKey(
  750. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_TRADE)));
  751. }
  752. IMPLEMENT_COMCLASS(Player_PK)
  753. void Player_PK::OnButtonClick()
  754. {
  755. KShortcutKeyCentre::ExcuteScript(SCK_SHORTCUT_PK);
  756. }
  757. void Player_PK::UpdateData()
  758. {
  759. if (g_pCoreShell)
  760. {
  761. CheckButton(g_pCoreShell->GetGameData(GDI_PK_SETTING, 0, 0));
  762. }
  763. }
  764. const char* Player_PK::GetShortKey()
  765. {
  766. return KShortcutKeyCentre::GetKeyName(
  767. KShortcutKeyCentre::GetCommandKey(
  768. KShortcutKeyCentre::FindCommandByScript(SCK_SHORTCUT_PK)));
  769. }