PageRenderTime 56ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Sources/S3Client/Ui/ShortcutKey.cpp

https://bitbucket.org/ichenq/sword3
C++ | 2753 lines | 2254 code | 475 blank | 24 comment | 528 complexity | 65ac3ca4bba179793f19e40e41cbdcff MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*****************************************************************************************
  2. // 快捷键系统
  3. // Copyright : Kingsoft 2002
  4. // Author : Wooy(Wu yue)
  5. // CreateTime: 2003-1-13
  6. *****************************************************************************************/
  7. #include "KWin32.h"
  8. #include "KIniFile.h"
  9. #include "ShortcutKey.h"
  10. #include "UiBase.h"
  11. #include "UiCase/UiTeamManage.h"
  12. #include "UiCase/UiOptions.h"
  13. #include "UiCase/UiStatus.h"
  14. #include "UiCase/UiItem.h"
  15. #include "UiCase/UiSkills.h"
  16. #include "UiCase/UiChannelSubscibe.h"
  17. #include "UiCase/UiPlayerBar.h"
  18. #include "UiCase/UiESCDlg.h"
  19. #include "UiCase/UiSkillTree.h"
  20. #include "UiCase/UiMiniMap.h"
  21. #include "UiCase/UiMsgCentrePad.h"
  22. #include "UiCase/UiChatCentre.h"
  23. #include "UICase/UiFaceSelector.h"
  24. #include "UICase/UiHelper.h"
  25. #include "UICase/UiHelper2.h"
  26. #include "UICase/UiTaskNote.h"
  27. #include "UiCase/UiTrade.h"
  28. #include "UiCase/UiShop.h"
  29. #include "UiCase/UiStoreBox.h"
  30. #include "UiCase/UiHeaderControlBar.h"
  31. #include "UiCase/UiToolsControlBar.h"
  32. #include "UiCase/UiGame.h"
  33. #include "UiCase/UiNewsMessage.h"
  34. #include "UiCase/UiTongCreateSheet.h"
  35. #include "UiCase/uisysmsgcentre.h"
  36. #include "Elem/SpecialFuncs.h"
  37. #include "UiShell.h"
  38. #include "KProtocol.h"
  39. #include "KRelayProtocol.h"
  40. #include "KTongProtocol.h"
  41. #include "../../core/Src/KPlayerMenuState.h"
  42. #include "../../core/src/coreshell.h"
  43. extern iCoreShell* g_pCoreShell;
  44. #include <crtdbg.h>
  45. KLuaScript KShortcutKeyCentre::ms_Script;
  46. COMMAND_SETTING* KShortcutKeyCentre::ms_pCommands = NULL;
  47. int KShortcutKeyCentre::ms_nCommands = 0;
  48. bool KShortcutKeyCentre::ms_Enable = false;
  49. SHORTFUNCMAP KShortcutKeyCentre::ms_FunsMap;
  50. bool KShortcutKeyCentre::ms_bMouse = false;
  51. int KShortcutKeyCentre::ms_MouseX = 0;
  52. int KShortcutKeyCentre::ms_MouseY = 0;
  53. #define UI_AUTOEXEC_SETTING_FILE "\\Ui\\autoexec.lua"
  54. #define GAME_CONFIG_FILE "\\config.ini"
  55. enum SCREEN_MODE
  56. {
  57. SCREEN_MODE_1D = 1,
  58. SCREEN_MODE_2D = 2,
  59. SCREEN_MODE_3D = 3,
  60. };
  61. //////////////////////////////////////
  62. //x assist funcs
  63. static inline bool __x_isgraph(char c)
  64. {
  65. return c < 0 || isgraph(c);
  66. }
  67. inline bool __x_memcpy_n(void* d, size_t l, const void* s, size_t n)
  68. {
  69. if (l < n)
  70. return false;
  71. memcpy(d, s, n);
  72. return true;
  73. }
  74. //////////////////////////////////////
  75. int KShortcutKeyCentre::HandleKeyInput(unsigned int uKey, int nModifier)
  76. {
  77. int nIndex = FindCommand(MAKELONG(uKey, nModifier));
  78. if (nIndex >= 0)
  79. {
  80. return ExcuteScript(ms_pCommands[nIndex].szDo);
  81. }
  82. return false;
  83. }
  84. int KShortcutKeyCentre::HandleMouseInput(unsigned int uKey, int nModifier, int x, int y)
  85. {
  86. if (ms_bMouse)
  87. return false;
  88. ms_bMouse = true;
  89. ms_MouseX = x;
  90. ms_MouseY = y;
  91. int nIndex = FindCommand(MAKELONG(uKey, nModifier));
  92. int nRet = false;
  93. if (nIndex >= 0)
  94. {
  95. nRet = ExcuteScript(ms_pCommands[nIndex].szDo);
  96. }
  97. ms_bMouse = false;
  98. return nRet;
  99. }
  100. void KShortcutKeyCentre::Enable(bool b)
  101. {
  102. ms_Enable = b;
  103. }
  104. /////////////////////////////////////////////////////////////////////////
  105. //窗口列表
  106. char* l_WindowList[] =
  107. {
  108. "team", //0 队伍
  109. "map", //1 地图
  110. "status", //2 状态
  111. "Items", //3 物品
  112. "skills", //4 技能
  113. "system", //5 系统
  114. "friend", //6 好友
  115. "help", //7 详细帮助
  116. "tasknote", //8 任务记事
  117. "leftskill", //9 左手技能
  118. "rightskill", //10 右手技能
  119. "commandline", //11 命令行
  120. "options", //12 选项
  121. "statustool", //13 状态工具条
  122. "normaltool", //14 常用工具条
  123. "chatroom", //15 聊天窗口
  124. "newsmessage", //16 新闻窗口
  125. "debug", //17 调试用的,搞好删掉...
  126. };
  127. int FindWindow(const char* szname)
  128. {
  129. for (int i = 0; i < sizeof(l_WindowList) / sizeof(char*); i++)
  130. {
  131. if (strcmpi(l_WindowList[i], szname) == 0)
  132. return i;
  133. }
  134. return -1;
  135. }
  136. bool UiCloseWndsInGame(bool bAll);
  137. int LuaOpenWindow(Lua_State * L)
  138. {
  139. if (Lua_GetTopIndex(L) != 1)
  140. return 0;
  141. char * strWindow = (char *)Lua_ValueToString(L, 1);
  142. if (strWindow)
  143. {
  144. switch(FindWindow(strWindow))
  145. {
  146. case 0: //队伍
  147. if (KUiTeamManage::GetIfVisible())
  148. KUiTeamManage::CloseWindow();
  149. else
  150. {
  151. KUiTeamManage::OpenWindow();
  152. }
  153. break;
  154. case 1: //地图
  155. MapToggleStatus();
  156. break;
  157. case 2: //状态
  158. if (KUiStatus::GetIfVisible())
  159. KUiStatus::CloseWindow(false);
  160. else
  161. KUiStatus::OpenWindow();
  162. break;
  163. case 3: //物品
  164. if (KUiItem::GetIfVisible())
  165. KUiItem::CloseWindow(false);
  166. else
  167. KUiItem::OpenWindow();
  168. break;
  169. case 4: //技能
  170. if (KUiSkills::GetIfVisible())
  171. KUiSkills::CloseWindow(false);
  172. else
  173. KUiSkills::OpenWindow();
  174. break;
  175. case 5: //系统
  176. if (UiCloseWndsInGame(false) == false)
  177. KUiESCDlg::OpenWindow();
  178. break;
  179. //选项
  180. case 6: //好友
  181. if (KUiChatCentre::GetIfVisible())
  182. KUiChatCentre::CloseWindow(false);
  183. else
  184. KUiChatCentre::OpenWindow(true);
  185. break;
  186. case 7: //详细帮助
  187. if (KUiHelper2::GetIfVisible())
  188. KUiHelper2::CloseWindow(false);
  189. else
  190. KUiHelper2::OpenWindow(true);
  191. break;
  192. case 8: //任务记事
  193. if (KUiTaskNote::GetIfVisible())
  194. KUiTaskNote::CloseWindow(false);
  195. else
  196. KUiTaskNote::OpenWindow();
  197. break;
  198. case 9: //左手技能
  199. if (KUiSkillTree::GetIfVisible())
  200. KUiSkillTree::CloseWindow(false);
  201. else
  202. KUiSkillTree::OpenWindow(true);
  203. break;
  204. case 10: //右手技能
  205. if (KUiSkillTree::GetIfVisible())
  206. KUiSkillTree::CloseWindow(false);
  207. else
  208. KUiSkillTree::OpenWindow(false);
  209. break;
  210. case 12: //选项
  211. if (KUiOptions::GetIfVisible())
  212. KUiOptions::CloseWindow();
  213. else
  214. KUiOptions::OpenWindow();
  215. break;
  216. case 16: //新闻
  217. if (KUiNewsMessage::GetIfVisible())
  218. KUiNewsMessage::CloseWindow();
  219. else
  220. KUiNewsMessage::OpenWindow();
  221. break;
  222. case 17: //调试用的
  223. if (KUiTongCreateSheet::GetIfVisible())
  224. KUiTongCreateSheet::CloseWindow();
  225. else
  226. KUiTongCreateSheet::OpenWindow();
  227. break;
  228. }
  229. }
  230. return 0;
  231. }
  232. KWndWindow* FindWndWindow(const char* szname)
  233. {
  234. KWndWindow* pWin = NULL;
  235. switch(FindWindow(szname))
  236. {
  237. case 1: //1 地图
  238. pWin = KUiMiniMap::GetSelf();
  239. break;
  240. case 13: //13 状态工具条
  241. pWin = KUiHeaderControlBar::GetSelf();
  242. break;
  243. case 14: //14 常用工具条
  244. pWin = KUiToolsControlBar::GetSelf();
  245. break;
  246. case 15: //15 聊天窗口
  247. pWin = KUiMsgCentrePad::GetSelf();
  248. break;
  249. }
  250. return pWin;
  251. }
  252. int LuaMoveWindow(Lua_State * L)
  253. {
  254. if (Lua_GetTopIndex(L) != 3)
  255. return 0;
  256. char * strWindow = (char *)Lua_ValueToString(L, 1);
  257. int nX = (int)(Lua_ValueToNumber(L, 2));
  258. int nY = (int)(Lua_ValueToNumber(L, 3));
  259. KWndWindow* pWin = FindWndWindow(strWindow);
  260. if (pWin)
  261. {
  262. pWin->SetPosition(nX, nY);
  263. }
  264. return 0;
  265. }
  266. int LuaSizeWindow(Lua_State * L)
  267. {
  268. if (Lua_GetTopIndex(L) != 3)
  269. return 0;
  270. char * strWindow = (char *)Lua_ValueToString(L, 1);
  271. int nW = (int)(Lua_ValueToNumber(L, 2));
  272. int nH = (int)(Lua_ValueToNumber(L, 3));
  273. KWndWindow* pWin = FindWndWindow(strWindow);
  274. if (pWin)
  275. {
  276. pWin->SetSize(nW, nH);
  277. }
  278. return 0;
  279. }
  280. int LuaShowWindow(Lua_State * L)
  281. {
  282. if (Lua_GetTopIndex(L) != 2)
  283. return 0;
  284. char * strWindow = (char *)Lua_ValueToString(L, 1);
  285. int nShow = (int)(Lua_ValueToNumber(L, 2));
  286. if (strWindow)
  287. {
  288. KWndWindow* pWin = FindWndWindow(strWindow);
  289. if (pWin)
  290. {
  291. if (nShow)
  292. pWin->Show();
  293. else
  294. pWin->Hide();
  295. }
  296. }
  297. return 0;
  298. }
  299. int LuaFocusWindow(Lua_State * L)
  300. {
  301. if (Lua_GetTopIndex(L) != 1)
  302. return 0;
  303. char * strWindow = (char *)Lua_ValueToString(L, 1);
  304. if (strWindow)
  305. {
  306. switch(FindWindow(strWindow))
  307. {
  308. case 11: // 命令行
  309. KUiPlayerBar::InputNameMsg(false, "", true);
  310. break;
  311. }
  312. }
  313. return 0;
  314. }
  315. int LuaShortcutSkill(Lua_State * L)
  316. {
  317. if (Lua_GetTopIndex(L) != 1)
  318. return 0;
  319. int nIndex = (int)Lua_ValueToNumber(L, 1);
  320. KUiSkillTree::HandleShortcutKey(nIndex);
  321. return 0;
  322. }
  323. int LuaDirectShortcutSkill(Lua_State * L)
  324. {
  325. if (Lua_GetTopIndex(L) != 1)
  326. return 0;
  327. int nIndex = (int)Lua_ValueToNumber(L, 1);
  328. KUiSkillTree::DirectHandleShortcutKey(nIndex);
  329. return 0;
  330. }
  331. int LuaShortcutUseItem(Lua_State * L)
  332. {
  333. if (Lua_GetTopIndex(L) != 1)
  334. return 0;
  335. int nIndex = (int)Lua_ValueToNumber(L, 1);
  336. //快捷物品的使用
  337. KUiPlayerBar::OnUseItem(nIndex);
  338. return 0;
  339. }
  340. //状态列表
  341. char* l_StatusList[] =
  342. {
  343. "run", //0 跑步
  344. "sit", //1 打坐
  345. "trade", //2 交易
  346. "pk", //3 PK
  347. "horse", //4 马
  348. "showplayername", //5 显示玩家名字
  349. "showplayerlife", //6 显示玩家生命
  350. "showplayermana", //7 显示玩家内力
  351. "showplayernumber", //8 界面显示玩家数字
  352. };
  353. int FindStatus(const char* szname)
  354. {
  355. for (int i = 0; i < sizeof(l_StatusList) / sizeof(char*); i++)
  356. {
  357. if (strcmpi(l_StatusList[i], szname) == 0)
  358. return i;
  359. }
  360. return -1;
  361. }
  362. int LuaSwitchStatus(Lua_State * L)
  363. {
  364. if (Lua_GetTopIndex(L) != 1)
  365. return 0;
  366. char * strStatus = (char *)Lua_ValueToString(L, 1);
  367. if (strStatus)
  368. {
  369. switch(FindStatus(strStatus))
  370. {
  371. case 0: //跑步
  372. if (g_pCoreShell)
  373. g_pCoreShell->OperationRequest(GOI_PLAYER_ACTION, PA_RUN, 0);
  374. break;
  375. case 1: //打坐
  376. if (g_pCoreShell)
  377. g_pCoreShell->OperationRequest(GOI_PLAYER_ACTION, PA_SIT, 0);
  378. break;
  379. case 2: //交易
  380. if (g_pCoreShell)
  381. g_pCoreShell->OperationRequest(GOI_TRADE_WILLING, 0, true);
  382. break;
  383. case 3: //PK
  384. if (g_pCoreShell)
  385. {
  386. g_pCoreShell->OperationRequest(GOI_PK_SETTING, 0,
  387. !g_pCoreShell->GetGameData(GDI_PK_SETTING, 0, 0));
  388. }
  389. break;
  390. case 4: //马
  391. //if (g_pCoreShell)
  392. // g_pCoreShell->OperationRequest(GOI_PK_SETTING, 0, Player_PK::ms_bPK);
  393. break;
  394. case 5: //显示玩家名字
  395. if (g_pCoreShell)
  396. {
  397. g_pCoreShell->OperationRequest(GOI_SHOW_PLAYERS_NAME, 0,
  398. !g_pCoreShell->GetGameData(GDI_SHOW_PLAYERS_NAME, 0, 0));
  399. }
  400. break;
  401. case 6: //显示玩家生命
  402. if (g_pCoreShell)
  403. {
  404. g_pCoreShell->OperationRequest(GOI_SHOW_PLAYERS_LIFE, 0,
  405. !g_pCoreShell->GetGameData(GDI_SHOW_PLAYERS_LIFE, 0, 0));
  406. }
  407. break;
  408. case 7: //显示玩家内力
  409. if (g_pCoreShell)
  410. {
  411. g_pCoreShell->OperationRequest(GOI_SHOW_PLAYERS_MANA, 0,
  412. !g_pCoreShell->GetGameData(GDI_SHOW_PLAYERS_MANA, 0, 0));
  413. }
  414. break;
  415. case 8: //界面显示玩家数字
  416. Player_Life::m_bText = !Player_Life::m_bText;
  417. Player_Mana::m_bText = !Player_Mana::m_bText;
  418. Player_Stamina::m_bText = !Player_Stamina::m_bText;
  419. Player_Exp::m_bText = !Player_Exp::m_bText;
  420. break;
  421. case 9:
  422. KUiPlayerBar::SwitchChannel();
  423. break;
  424. }
  425. }
  426. return 0;
  427. }
  428. int LuaSwitchChannel(Lua_State * L)
  429. {
  430. int nbUp = 0;
  431. if (Lua_GetTopIndex(L) == 1)
  432. {
  433. nbUp = (int)Lua_ValueToNumber(L, 1);
  434. }
  435. KUiPlayerBar::SwitchChannel(nbUp);
  436. return 0;
  437. }
  438. int LuaRegisterEvent(Lua_State * L)
  439. {
  440. if (Lua_GetTopIndex(L) == 2)
  441. {
  442. char * szName = (char *)Lua_ValueToString(L, 1);
  443. int hWnd = (int)Lua_ValueToNumber(L, 2);
  444. g_UiBase.RegisterEvent(szName, (HANDLE)hWnd);
  445. }
  446. return 0;
  447. }
  448. int LuaUnregisterEvent(Lua_State * L)
  449. {
  450. if (Lua_GetTopIndex(L) == 2)
  451. {
  452. char * szName = (char *)Lua_ValueToString(L, 1);
  453. int hWnd = (int)Lua_ValueToNumber(L, 2);
  454. g_UiBase.UnregisterEvent(szName, (HANDLE)hWnd);
  455. }
  456. return 0;
  457. }
  458. int LuaSendEvent(Lua_State * L)
  459. {
  460. if (Lua_GetTopIndex(L) == 2)
  461. {
  462. char * szName = (char *)Lua_ValueToString(L, 1);
  463. int nType = Lua_GetValueType(L, 2);
  464. char * szEvent = NULL;
  465. if (nType == LUA_TSTRING)
  466. szEvent = (char *)Lua_ValueToString(L, 2);
  467. else if (nType == LUA_TNUMBER)
  468. {
  469. int nNum = (int)Lua_ValueToNumber(L, 2);
  470. static char szNum[64];
  471. sprintf(szNum, "%d", nNum);
  472. szEvent = szNum;
  473. }
  474. if (szEvent)
  475. g_UiBase.NotifyOneEvent(szName, szEvent);
  476. }
  477. return 0;
  478. }
  479. extern int g_bRepresent3;
  480. extern int g_bScreen;
  481. int LuaGetAppStatus(Lua_State * L)
  482. {
  483. int nRet = -1;
  484. if (Lua_GetTopIndex(L) == 1)
  485. {
  486. char * szName = (char *)Lua_ValueToString(L, 1);
  487. if (szName)
  488. {
  489. if (strcmpi(szName, "FullWindow") == 0)
  490. {
  491. nRet = g_bScreen ? 1 : 0;
  492. }
  493. else if (strcmpi(szName, "3D") == 0)
  494. {
  495. nRet = g_bRepresent3 ? 1 : 0;
  496. }
  497. else if (strcmpi(szName, "2D") == 0)
  498. {
  499. nRet = !g_bRepresent3 ? 1 : 0;
  500. }
  501. }
  502. }
  503. Lua_PushNumber(L, nRet);
  504. return 1;
  505. }
  506. namespace hotkey_str
  507. {
  508. std::string DescHotKey(DWORD hk)
  509. {
  510. static const char* modidesc_table[] = {
  511. // 0 1 2 3 4 5 6 7
  512. "Shift", "Ctrl", "Alt", "Ext", "", "", "", ""
  513. };
  514. static const char* vkeydesc_table[] = {
  515. // 0 1 2 3 4 5 6 7
  516. // 8 9 A B C D E F
  517. "", "LButton", "RButton", "Cancel", "MButton", "", "", "", //0
  518. "BackSpace","Tab", "", "", "Clear", "Enter", "", "",
  519. "", "", "", "Pause", "CapLock", "", "", "", //1
  520. "", "", "", "ESC", "Convert", "NonConvert","Accept", "ModeChange",
  521. "Space", "PageUp", "PageDown", "End", "Home", "Left", "Up", "Right", //2
  522. "Down", "Select", "Print", "Execute", "PrintScreen", "Insert", "Delete", "Help",
  523. "0", "1", "2", "3", "4", "5", "6", "7", //3
  524. "8", "9", "", "", "", "", "", "",
  525. "", "A", "B", "C", "D", "E", "F", "G", //4
  526. "H", "I", "J", "K", "L", "M", "N", "O",
  527. "P", "Q", "R", "S", "T", "U", "V", "W", //5
  528. "X", "Y", "Z", "Windows", "", "Menu", "", "",
  529. "Num0", "Num1", "Num2", "Num3", "Num4", "Num5", "Num6", "Num7", //6
  530. "Num8", "Num9", "Num*", "Num+", "Separator","Num-", "Num.", "Num/",
  531. "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", //7
  532. "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16",
  533. "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", //8
  534. "", "", "", "", "", "", "", "",
  535. "NumLock", "ScrollLock","", "", "", "", "", "", //9
  536. "", "", "", "", "", "", "", "",
  537. "", "", "", "", "", "", "", "", //A
  538. "", "", "", "", "", "", "", "",
  539. "", "", "", "", "", "", "", "", //B
  540. "", "", ";", "=", ",", "-", ".", "/",
  541. "`", "", "", "", "", "", "", "", //C
  542. "", "", "", "", "", "", "", "",
  543. "", "", "", "", "", "", "", "", //D
  544. "", "", "", "[", "\\", "]", "'", "",
  545. "", "", "", "", "", "", "", "", //E
  546. "", "", "", "", "", "", "", "",
  547. "", "", "", "", "", "", "", "", //F
  548. "", "", "", "", "", "", "", "",
  549. "LDButton", "RDButton", "MDButton", "", "", "", "", "", //10
  550. "", "", "", "", "", "", "", "",
  551. };
  552. static const size_t count_moditbl = sizeof(modidesc_table) / sizeof(modidesc_table[0]);
  553. static const size_t count_vkeytbl = sizeof(vkeydesc_table) / sizeof(vkeydesc_table[0]);
  554. static const char STR_DELIMITER[] = " + ";
  555. static const size_t LEN_DELIMITER = sizeof(STR_DELIMITER) - sizeof(STR_DELIMITER[0]);
  556. const WORD modi = HIWORD(hk);
  557. const WORD vkey = LOWORD(hk);
  558. if ((modi & 0xFF00) || (vkey >= count_vkeytbl))
  559. return "";
  560. const char* szVkDesc = vkeydesc_table[vkey];
  561. if (!szVkDesc[0])
  562. return "";
  563. std::string desc;
  564. {{
  565. for (size_t pos = 0; pos <= count_moditbl; pos++)
  566. {
  567. const char* szDesc = NULL;
  568. if (pos < count_moditbl)
  569. {
  570. if (!(modi & (0x01 << pos)))
  571. continue;
  572. szDesc = modidesc_table[pos];
  573. if (!szDesc[0])
  574. return "";
  575. }
  576. else
  577. {
  578. szDesc = szVkDesc;
  579. }
  580. if (!desc.empty())
  581. desc += STR_DELIMITER;
  582. desc += szDesc;
  583. }
  584. }}
  585. return desc;
  586. }
  587. DWORD ParseHotKey(const std::string& desc)
  588. {
  589. static const struct PATTERNMAP
  590. {
  591. enum {MASK_VKEY = 0x0000FFFF};
  592. typedef std::pair<DWORD, DWORD> HOTKEYPART;
  593. typedef std::map<std::string, HOTKEYPART, string_iless> DESC2HKPMAP;
  594. DESC2HKPMAP theMap;
  595. PATTERNMAP()
  596. {
  597. const struct _PATTERN
  598. {
  599. char* desc;
  600. DWORD mask;
  601. DWORD value;
  602. } pattern_table[] = {
  603. //modifier
  604. {"Shift", HOTKEYF_SHIFT<<16, HOTKEYF_SHIFT<<16}, {"Control", HOTKEYF_CONTROL<<16, HOTKEYF_CONTROL<<16},
  605. {"Alt", HOTKEYF_ALT<<16, HOTKEYF_ALT<<16}, {"Ext", HOTKEYF_EXT<<16, HOTKEYF_EXT<<16},
  606. //vk
  607. {"LButton", MASK_VKEY, VK_LBUTTON}, {"RButton", MASK_VKEY, VK_RBUTTON},
  608. {"Cancel", MASK_VKEY, VK_CANCEL}, {"MButton", MASK_VKEY, VK_MBUTTON},
  609. {"BackSpace", MASK_VKEY, VK_BACK}, {"Tab", MASK_VKEY, VK_TAB}, {"Clear", MASK_VKEY, VK_CLEAR},
  610. {"Return", MASK_VKEY, VK_RETURN}, {"Pause", MASK_VKEY, VK_PAUSE},
  611. {"Convert", MASK_VKEY, VK_CONVERT}, {"NonConvert", MASK_VKEY, VK_NONCONVERT},
  612. {"Accept", MASK_VKEY, VK_ACCEPT}, {"ModeChange", MASK_VKEY, VK_MODECHANGE},
  613. {"Escape", MASK_VKEY, VK_ESCAPE}, {"Space", MASK_VKEY, VK_SPACE},
  614. {"Prior", MASK_VKEY, VK_PRIOR}, {"Next", MASK_VKEY, VK_NEXT}, {"End", MASK_VKEY, VK_END}, {"Home", MASK_VKEY, VK_HOME},
  615. {"Left", MASK_VKEY, VK_LEFT}, {"Up", MASK_VKEY, VK_UP}, {"Right", MASK_VKEY, VK_RIGHT}, {"Down", MASK_VKEY, VK_DOWN},
  616. {"Insert", MASK_VKEY, VK_INSERT}, {"Delete", MASK_VKEY, VK_DELETE},
  617. {"Select", MASK_VKEY, VK_SELECT}, {"Print", MASK_VKEY, VK_PRINT}, {"Execute", MASK_VKEY, VK_EXECUTE},
  618. {"SnapShot", MASK_VKEY, VK_SNAPSHOT}, {"Help", MASK_VKEY, VK_HELP},
  619. {"0", MASK_VKEY, '0'}, {"1", MASK_VKEY, '1'}, {"2", MASK_VKEY, '2'}, {"3", MASK_VKEY, '3'},
  620. {"4", MASK_VKEY, '4'}, {"5", MASK_VKEY, '5'}, {"6", MASK_VKEY, '6'}, {"7", MASK_VKEY, '7'},
  621. {"8", MASK_VKEY, '8'}, {"9", MASK_VKEY, '9'},
  622. {"A", MASK_VKEY, 'A'}, {"B", MASK_VKEY, 'B'}, {"C", MASK_VKEY, 'C'}, {"D", MASK_VKEY, 'D'},
  623. {"E", MASK_VKEY, 'E'}, {"F", MASK_VKEY, 'F'}, {"G", MASK_VKEY, 'G'}, {"H", MASK_VKEY, 'H'},
  624. {"I", MASK_VKEY, 'I'}, {"J", MASK_VKEY, 'J'}, {"K", MASK_VKEY, 'K'}, {"L", MASK_VKEY, 'L'},
  625. {"M", MASK_VKEY, 'M'}, {"N", MASK_VKEY, 'N'}, {"O", MASK_VKEY, 'O'}, {"P", MASK_VKEY, 'P'},
  626. {"Q", MASK_VKEY, 'Q'}, {"R", MASK_VKEY, 'R'}, {"S", MASK_VKEY, 'S'}, {"T", MASK_VKEY, 'T'},
  627. {"U", MASK_VKEY, 'U'}, {"V", MASK_VKEY, 'V'}, {"W", MASK_VKEY, 'W'}, {"X", MASK_VKEY, 'X'},
  628. {"Y", MASK_VKEY, 'Y'}, {"Z", MASK_VKEY, 'Z'},
  629. {"Num0", MASK_VKEY, VK_NUMPAD0}, {"Num1", MASK_VKEY, VK_NUMPAD1}, {"Num2", MASK_VKEY, VK_NUMPAD2}, {"Num3", MASK_VKEY, VK_NUMPAD3},
  630. {"Num4", MASK_VKEY, VK_NUMPAD4}, {"Num5", MASK_VKEY, VK_NUMPAD5}, {"Num6", MASK_VKEY, VK_NUMPAD6}, {"Num7", MASK_VKEY, VK_NUMPAD7},
  631. {"Num8", MASK_VKEY, VK_NUMPAD8}, {"Num9", MASK_VKEY, VK_NUMPAD9},
  632. {"Num+", MASK_VKEY, VK_ADD}, {"Num-", MASK_VKEY, VK_SUBTRACT}, {"Num*", MASK_VKEY, VK_MULTIPLY}, {"Num/", MASK_VKEY, VK_DIVIDE},
  633. {"Separator", MASK_VKEY, VK_SEPARATOR}, {"Num.", MASK_VKEY, VK_DECIMAL},
  634. {"F1", MASK_VKEY, VK_F1}, {"F2", MASK_VKEY, VK_F2}, {"F3", MASK_VKEY, VK_F3}, {"F4", MASK_VKEY, VK_F4},
  635. {"F5", MASK_VKEY, VK_F5}, {"F6", MASK_VKEY, VK_F6}, {"F7", MASK_VKEY, VK_F7}, {"F8", MASK_VKEY, VK_F8},
  636. {"F9", MASK_VKEY, VK_F9}, {"F10", MASK_VKEY, VK_F10}, {"F11", MASK_VKEY, VK_F11}, {"F12", MASK_VKEY, VK_F12},
  637. {"F13", MASK_VKEY, VK_F13}, {"F14", MASK_VKEY, VK_F14}, {"F15", MASK_VKEY, VK_F15}, {"F16", MASK_VKEY, VK_F16},
  638. {"F17", MASK_VKEY, VK_F17}, {"F18", MASK_VKEY, VK_F18}, {"F19", MASK_VKEY, VK_F19}, {"F20", MASK_VKEY, VK_F20},
  639. {"F21", MASK_VKEY, VK_F21}, {"F22", MASK_VKEY, VK_F22}, {"F23", MASK_VKEY, VK_F23}, {"F24", MASK_VKEY, VK_F24},
  640. {"CapLock", MASK_VKEY, VK_CAPITAL}, {"NumLock", MASK_VKEY, VK_NUMLOCK}, {"ScrollLock", MASK_VKEY, VK_SCROLL},
  641. {";", MASK_VKEY, 0x00BA}, {"=", MASK_VKEY, 0x00BB}, {",", MASK_VKEY, 0x00BC}, {"-", MASK_VKEY, 0x00BD},
  642. {".", MASK_VKEY, 0x00BE}, {"/", MASK_VKEY, 0x00BF}, {"`", MASK_VKEY, 0x00C0},
  643. {"[", MASK_VKEY, 0x00DB},
  644. {"\\", MASK_VKEY, 0x00DC}, {"]", MASK_VKEY, 0x00DD}, {"'", MASK_VKEY, 0x00DE},
  645. //modifier alias
  646. {"Ctrl", HOTKEYF_CONTROL<<16, HOTKEYF_CONTROL<<16}, {"Menu", HOTKEYF_ALT<<16, HOTKEYF_ALT<<16},
  647. {"Break", MASK_VKEY, VK_PAUSE},
  648. //vk alias
  649. {"ESC", MASK_VKEY, VK_ESCAPE}, {"Enter", MASK_VKEY, VK_RETURN},
  650. {"BACK", MASK_VKEY, VK_BACK},
  651. {"INS", MASK_VKEY, VK_INSERT}, {"DEL", MASK_VKEY, VK_DELETE},
  652. {"PageUp", MASK_VKEY, VK_PRIOR}, {"PageDown", MASK_VKEY, VK_NEXT},
  653. {"ScrlLock", MASK_VKEY, VK_SCROLL},
  654. {"NumAdd", MASK_VKEY, VK_ADD}, {"NumSub", MASK_VKEY, VK_SUBTRACT}, {"NumMul", MASK_VKEY, VK_MULTIPLY}, {"NumDiv", MASK_VKEY, VK_DIVIDE},
  655. {"NumDecimal", MASK_VKEY, VK_DECIMAL},
  656. {"PrintScreen", MASK_VKEY, VK_SNAPSHOT},
  657. {"LDButton", MASK_VKEY, VK_LDBUTTON}, {"RDButton", MASK_VKEY, VK_RDBUTTON}, {"MDButton", MASK_VKEY, VK_MDBUTTON},
  658. };
  659. for (size_t i = 0; i < sizeof(pattern_table)/sizeof(pattern_table[0]); i++)
  660. {
  661. const _PATTERN& pat = pattern_table[i];
  662. theMap[std::string(pat.desc)] = std::make_pair(pat.mask, pat.value);
  663. }
  664. }
  665. } s_mapPattern;
  666. static const char CH_DELIMITER = '+';
  667. if (desc.empty())
  668. return 0;
  669. DWORD hkcode = 0;
  670. const char* szToken = desc.c_str(), * szLimit = NULL, * szNext = NULL;
  671. for ( ; *szToken; szToken = szNext)
  672. {
  673. for (szNext = NULL, szLimit = szToken; *szLimit; szLimit++)
  674. {
  675. if (*szLimit == CH_DELIMITER)
  676. {
  677. for (szNext = szLimit + 1; ; szNext++)
  678. {
  679. if (!*szNext)
  680. {
  681. szLimit ++;
  682. break;
  683. }
  684. if (*szNext == CH_DELIMITER)
  685. szLimit ++;
  686. else if (__x_isgraph(*szNext))
  687. break;
  688. }
  689. if (szLimit <= szToken)
  690. return 0;
  691. break;
  692. }
  693. }
  694. while (!__x_isgraph(*szToken))
  695. {
  696. szToken ++;
  697. if (szToken >= szLimit)
  698. return 0;
  699. }
  700. const char* pe = szLimit - 1;
  701. while (!__x_isgraph(*pe))
  702. pe --;
  703. size_t toklen = pe - szToken + 1;
  704. PATTERNMAP::DESC2HKPMAP::const_iterator it = s_mapPattern.theMap.find(std::string(szToken, toklen));
  705. if (it == s_mapPattern.theMap.end())
  706. return 0;
  707. const PATTERNMAP::HOTKEYPART& hkp = (*it).second;
  708. if (hkcode & hkp.first)
  709. return 0;
  710. hkcode |= hkp.second;
  711. if (szNext == NULL)
  712. break;
  713. }
  714. if (!(hkcode & PATTERNMAP::MASK_VKEY))
  715. return 0;
  716. return hkcode;
  717. }
  718. } //namespace hotkey_str
  719. int LuaAddCommand(Lua_State * L)
  720. {
  721. if (Lua_GetTopIndex(L) != 3)
  722. return 0;
  723. char * strUKey = (char *)Lua_ValueToString(L, 1);
  724. char * strName = (char *)Lua_ValueToString(L, 2);
  725. char * strDo = (char *)Lua_ValueToString(L, 3);
  726. COMMAND_SETTING cs;
  727. cs.uKey = hotkey_str::ParseHotKey(strUKey);
  728. strncpy(cs.szCommand, strName, 31);
  729. cs.szCommand[31] = 0;
  730. strncpy(cs.szDo, strDo, 127);
  731. cs.szDo[127] = 0;
  732. KShortcutKeyCentre::AddCommand(&cs);
  733. return 0;
  734. }
  735. int LuaRemoveCommand(Lua_State * L)
  736. {
  737. if (Lua_GetTopIndex(L) != 2)
  738. return 0;
  739. char * strUKey = (char *)Lua_ValueToString(L, 1);
  740. char * strName = (char *)Lua_ValueToString(L, 2);
  741. COMMAND_SETTING cs;
  742. cs.uKey = hotkey_str::ParseHotKey(strUKey);
  743. if (cs.uKey != 0)
  744. KShortcutKeyCentre::RemoveCommand(KShortcutKeyCentre::FindCommand(cs.uKey));
  745. else if (strName && strName[0] != 0)
  746. {
  747. strncpy(cs.szCommand, strName, 31);
  748. cs.szCommand[31] = 0;
  749. KShortcutKeyCentre::RemoveCommand(KShortcutKeyCentre::FindCommand(cs.szCommand));
  750. }
  751. else //清除所有命令
  752. {
  753. KShortcutKeyCentre::RemoveCommandAll();
  754. }
  755. return 0;
  756. }
  757. int LuaMakeFriend(Lua_State * L)
  758. {
  759. if (Lua_GetTopIndex(L) != 1)
  760. return 0;
  761. char * strName = (char *)Lua_ValueToString(L, 1);
  762. if (strName && strName[0] != 0)
  763. {
  764. KUiPlayerItem SelectPlayer;
  765. strncpy(SelectPlayer.Name, strName, 32);
  766. int nKind = -1;
  767. if (g_pCoreShell)
  768. {
  769. ProcessPeople(&SelectPlayer, ACTION_MAKEFRIEND);
  770. }
  771. }
  772. return 0;
  773. }
  774. int LuaCreateTeam(Lua_State * L)
  775. {
  776. if (g_pCoreShell)
  777. {
  778. g_pCoreShell->TeamOperation(TEAM_OI_CREATE, 0, 0);
  779. }
  780. return 0;
  781. }
  782. int LuaJoinTeam(Lua_State * L)
  783. {
  784. if (Lua_GetTopIndex(L) != 1)
  785. return 0;
  786. char * strName = (char *)Lua_ValueToString(L, 1);
  787. if (strName && strName[0] != 0)
  788. {
  789. KUiPlayerItem SelectPlayer;
  790. int nKind = -1;
  791. if (g_pCoreShell &&
  792. g_pCoreShell->FindSpecialNPC(strName, &SelectPlayer, nKind) && nKind == kind_player)
  793. {
  794. ProcessPeople(&SelectPlayer, ACTION_JOINTEAM);
  795. }
  796. }
  797. return 0;
  798. }
  799. int LuaInviteTeam(Lua_State * L)
  800. {
  801. if (Lua_GetTopIndex(L) != 1)
  802. return 0;
  803. char * strName = (char *)Lua_ValueToString(L, 1);
  804. if (strName && strName[0] != 0)
  805. {
  806. KUiPlayerItem SelectPlayer;
  807. int nKind = -1;
  808. if (g_pCoreShell &&
  809. g_pCoreShell->FindSpecialNPC(strName, &SelectPlayer, nKind) && nKind == kind_player)
  810. {
  811. ProcessPeople(&SelectPlayer, ACTION_INVITETEAM);
  812. }
  813. }
  814. return 0;
  815. }
  816. int LuaTrade(Lua_State * L)
  817. {
  818. if (Lua_GetTopIndex(L) != 1)
  819. return 0;
  820. char * strName = (char *)Lua_ValueToString(L, 1);
  821. if (strName && strName[0] != 0)
  822. {
  823. KUiPlayerItem SelectPlayer;
  824. int nKind = -1;
  825. if (g_pCoreShell &&
  826. g_pCoreShell->FindSpecialNPC(strName, &SelectPlayer, nKind) && nKind == kind_player)
  827. {
  828. ProcessPeople(&SelectPlayer, ACTION_TRADE);
  829. }
  830. }
  831. return 0;
  832. }
  833. int LuaRevenge(Lua_State * L)
  834. {
  835. if (Lua_GetTopIndex(L) != 1)
  836. return 0;
  837. char * strName = (char *)Lua_ValueToString(L, 1);
  838. if (strName && strName[0] != 0)
  839. {
  840. KUiPlayerItem SelectPlayer;
  841. int nKind = -1;
  842. if (g_pCoreShell &&
  843. g_pCoreShell->FindSpecialNPC(strName, &SelectPlayer, nKind) && nKind == kind_player)
  844. {
  845. ProcessPeople(&SelectPlayer, ACTION_REVENGE);
  846. }
  847. }
  848. return 0;
  849. }
  850. int LuaFollow(Lua_State * L)
  851. {
  852. if (Lua_GetTopIndex(L) != 1)
  853. return 0;
  854. char * strName = (char *)Lua_ValueToString(L, 1);
  855. if (strName && strName[0] != 0)
  856. {
  857. KUiPlayerItem SelectPlayer;
  858. int nKind = -1;
  859. if (g_pCoreShell &&
  860. g_pCoreShell->FindSpecialNPC(strName, &SelectPlayer, nKind) && nKind == kind_player)
  861. {
  862. ProcessPeople(&SelectPlayer, ACTION_FOLLOW);
  863. }
  864. }
  865. return 0;
  866. }
  867. int LuaViewItem(Lua_State * L)
  868. {
  869. if (Lua_GetTopIndex(L) != 1)
  870. return 0;
  871. char * strName = (char *)Lua_ValueToString(L, 1);
  872. if (strName && strName[0] != 0)
  873. {
  874. KUiPlayerItem SelectPlayer;
  875. int nKind = -1;
  876. if (g_pCoreShell &&
  877. g_pCoreShell->FindSpecialNPC(strName, &SelectPlayer, nKind) && nKind == kind_player)
  878. {
  879. ProcessPeople(&SelectPlayer, ACTION_VIEWITEM);
  880. }
  881. }
  882. return 0;
  883. }
  884. int LuaPrintScreen(Lua_State * L)
  885. {
  886. SaveScreenToFile();
  887. return 0;
  888. }
  889. int LuaClearMessage(Lua_State * L)
  890. {
  891. KUiMsgCentrePad::Clear();
  892. return 0;
  893. }
  894. #include "../../Engine/src/Text.h"
  895. int LuaSay(Lua_State * L)
  896. {
  897. if (Lua_GetTopIndex(L) != 2)
  898. return 0;
  899. char * strName = (char *)Lua_ValueToString(L, 1);
  900. char * strMessage = (char *)Lua_ValueToString(L, 2);
  901. int nLen = strlen(strMessage);
  902. if (strName && strName[0] != 0 && !KUiPlayerBar::IsSelfName(strName))
  903. {
  904. if (KUiPlayerBar::IsCanSendMessage(strMessage, nLen, strName, -1))
  905. {
  906. char Buffer[1536];
  907. nLen = KUiFaceSelector::ConvertFaceText(Buffer, strMessage, nLen);
  908. nLen = TEncodeText(Buffer, nLen);
  909. KUiPlayerBar::OnSendSomeoneMessage(strName, Buffer, nLen);
  910. }
  911. }
  912. return 0;
  913. }
  914. int LuaChat(Lua_State * L)
  915. {
  916. if (Lua_GetTopIndex(L) != 2)
  917. return 0;
  918. char * strChannelName = (char *)Lua_ValueToString(L, 1);
  919. char * strMessage = (char *)Lua_ValueToString(L, 2);
  920. int nLen = strlen(strMessage);
  921. if (strChannelName && strChannelName[0] != 0)
  922. {
  923. int nIndex = KUiMsgCentrePad::GetChannelIndex(strChannelName);
  924. DWORD nChannelID = KUiMsgCentrePad::GetChannelID(nIndex);
  925. if (nChannelID != -1)
  926. {
  927. if (KUiPlayerBar::IsCanSendMessage(strMessage, nLen, strChannelName, nChannelID))
  928. {
  929. char Buffer[1536];
  930. nLen = KUiFaceSelector::ConvertFaceText(Buffer, strMessage, nLen);
  931. nLen = TEncodeText(Buffer, nLen);
  932. KUiMsgCentrePad::CheckChannel(nIndex, true);
  933. KUiPlayerBar::OnSendChannelMessage(nChannelID, Buffer, nLen);
  934. }
  935. }
  936. }
  937. return 0;
  938. }
  939. int LuaRegisterFunctionAlias(Lua_State * L)
  940. {
  941. int nCount = Lua_GetTopIndex(L);
  942. if (nCount < 2)
  943. return 0;
  944. char * strFunAlias = (char *)Lua_ValueToString(L, 1);
  945. char * strFun = (char *)Lua_ValueToString(L, 2);
  946. int nParam = 0;
  947. if (nCount >= 3)
  948. {
  949. nParam = (int)Lua_ValueToNumber(L, 3);
  950. }
  951. PARAMLIST List;
  952. for(int i = 4; i <= nCount; i++)
  953. {
  954. char* sDefault = (char *)Lua_ValueToString(L, i);
  955. if (sDefault == NULL || sDefault[0] == 0)
  956. List.push_back("\"\"");
  957. else
  958. List.push_back(sDefault);
  959. }
  960. KShortcutKeyCentre::RegisterFunctionAlias(strFunAlias, strFun, nParam, List);
  961. return 0;
  962. }
  963. #include "UiChatPhrase.h"
  964. extern KUiChatPhrase g_UiChatPhrase;
  965. int LuaSayPhrase(Lua_State * L)
  966. {
  967. if (Lua_GetTopIndex(L) != 1)
  968. return 0;
  969. int nIndex = (int)Lua_ValueToNumber(L, 1);
  970. char szPhrase[64];
  971. int nLen = g_UiChatPhrase.GetPhrase(nIndex, szPhrase);
  972. if (nLen > 0)
  973. {
  974. DWORD nChannelID = -1;
  975. //附近玩家
  976. int nChannelDataCount = KUiMsgCentrePad::GetChannelCount();
  977. for (int n = 0; n < nChannelDataCount; n++)
  978. {
  979. if (KUiMsgCentrePad::IsChannelType(n, KUiMsgCentrePad::ch_Screen))
  980. {
  981. nChannelID = KUiMsgCentrePad::GetChannelID(n);
  982. break;
  983. }
  984. }
  985. if (nChannelID != -1)
  986. {
  987. if (KUiPlayerBar::IsCanSendMessage(szPhrase, nLen, KUiMsgCentrePad::GetChannelTitle(KUiMsgCentrePad::GetChannelIndex(nChannelID)), nChannelID))
  988. {
  989. char Buffer[1536];
  990. nLen = KUiFaceSelector::ConvertFaceText(Buffer, szPhrase, nLen);
  991. nLen = TEncodeText(Buffer, nLen);
  992. KUiMsgCentrePad::CheckChannel(n, true);
  993. KUiPlayerBar::OnSendChannelMessage(nChannelID, Buffer, nLen);
  994. }
  995. }
  996. }
  997. return 0;
  998. }
  999. int LuaSayEmote(Lua_State * L)
  1000. {
  1001. char *pszDestName, *pszDestChannel;
  1002. int nEmoteIndex;
  1003. if (Lua_GetTopIndex(L) != 3)
  1004. return 0;
  1005. nEmoteIndex = (int)Lua_ValueToNumber(L, 3);
  1006. pszDestName = (char *)Lua_ValueToString(L, 1);
  1007. pszDestChannel = (char *)Lua_ValueToString(L, 2);
  1008. ProcessEmote(pszDestName, pszDestChannel, nEmoteIndex);
  1009. return 0;
  1010. }
  1011. int LuaGetCurrentChannelName(Lua_State * L)
  1012. {
  1013. int nCurChannel = KUiPlayerBar::GetCurChannel();
  1014. if(nCurChannel >= 0 && nCurChannel < KUiMsgCentrePad::GetChannelCount())
  1015. {
  1016. Lua_PushString(L, KUiMsgCentrePad::GetChannelTitle(nCurChannel));
  1017. }
  1018. else
  1019. {
  1020. Lua_PushString(L, "");
  1021. }
  1022. return 1;
  1023. }
  1024. int LuaGetRecentPlayerName(Lua_State * L)
  1025. {
  1026. int nCurChannel = KUiPlayerBar::GetCurChannel();
  1027. if(nCurChannel >= KUiMsgCentrePad::GetChannelCount())
  1028. {
  1029. Lua_PushString(L, KUiPlayerBar::GetRecentPlayerName(nCurChannel));
  1030. }
  1031. else
  1032. {
  1033. Lua_PushString(L, "");
  1034. }
  1035. return 1;
  1036. }
  1037. int LuaConvertEmotes(Lua_State * L)
  1038. {
  1039. g_UiChatPhrase.ConstructFunctionAlias();
  1040. return 0;
  1041. }
  1042. int LuaSetEmote(Lua_State *L)
  1043. {
  1044. int nIndex = -1, nParamCount = Lua_GetTopIndex(L);
  1045. char *pszCmd, *pszName, *pszStringTarget, *pszStringSelf;
  1046. switch(nParamCount)
  1047. {
  1048. case 5:
  1049. nIndex = (int)Lua_ValueToNumber(L, 5);
  1050. case 4:
  1051. pszCmd = (char *)Lua_ValueToString(L, 1);
  1052. pszName = (char *)Lua_ValueToString(L, 2);
  1053. pszStringSelf = (char *)Lua_ValueToString(L, 4);
  1054. pszStringTarget = (char *)Lua_ValueToString(L, 3);
  1055. break;
  1056. default:
  1057. return 0;
  1058. }
  1059. g_UiChatPhrase.SetEmote(pszCmd, pszName, pszStringTarget, pszStringSelf, nIndex);
  1060. return 0;
  1061. }
  1062. int LuaSetScreenShotFolder(Lua_State * L)
  1063. {
  1064. if(Lua_GetTopIndex(L) == 1)
  1065. {
  1066. char *pszFolder = (char *)Lua_ValueToString(L, 1);
  1067. char szPath[256], Buff[128];
  1068. if(pszFolder[0] == '$' && pszFolder[1] == '\\')
  1069. {
  1070. g_GetRootPath(Buff);
  1071. sprintf(szPath, "%s\\%s", Buff, pszFolder + 2);
  1072. }
  1073. else
  1074. {
  1075. memcpy(szPath, pszFolder, strlen(pszFolder) + 1);
  1076. }
  1077. SetScrPicPath(szPath);
  1078. }
  1079. return 0;
  1080. }
  1081. int LuaSetPhrase(Lua_State * L)
  1082. {
  1083. if (Lua_GetTopIndex(L) != 2)
  1084. return 0;
  1085. int nIndex = (int)Lua_ValueToNumber(L, 1);
  1086. char * strPhrase = (char *)Lua_ValueToString(L, 2);
  1087. int nLen = strlen(strPhrase);
  1088. if (nIndex >= 0 && nIndex < g_UiChatPhrase.GetPhraseCount())
  1089. {
  1090. g_UiChatPhrase.SetPhrase(nIndex, strPhrase, nLen);
  1091. }
  1092. return 0;
  1093. }
  1094. #include "../Login/Login.h"
  1095. #include "UiCase/UiInit.h"
  1096. int LuaExitGame(Lua_State * L)
  1097. {
  1098. if (KUiESCDlg::GetIfVisible())
  1099. KUiESCDlg::CloseWindow(false);
  1100. if (g_pCoreShell)
  1101. g_pCoreShell->OperationRequest(GOI_EXIT_GAME, 0, 0);
  1102. g_LoginLogic.ReturnToIdle();
  1103. UiEndGame();
  1104. KUiInit::OpenWindow(true, false);
  1105. return 0;
  1106. }
  1107. int LuaExit(Lua_State * L)
  1108. {
  1109. UiPostQuitMsg();
  1110. return 0;
  1111. }
  1112. #define GAME_CONFIG_STRING_INI "\\Ui\\杂烩.ini"
  1113. int LuaSet3D(Lua_State * L)
  1114. {
  1115. if (Lua_GetTopIndex(L) != 1)
  1116. return 0;
  1117. KIniFile Ini, IniString;
  1118. KSystemMessage Msg;
  1119. int nBool = (int)Lua_ValueToNumber(L, 1);
  1120. Msg.eType = SMT_NORMAL;
  1121. Msg.byConfirmType = SMCT_NONE;
  1122. Msg.byPriority = 0;
  1123. Msg.byParamSize = 0;
  1124. Ini.Load(GAME_CONFIG_FILE);
  1125. IniString.Load(GAME_CONFIG_STRING_INI);
  1126. if (nBool)
  1127. {
  1128. IniString.GetString("Config", "3D", "游戏设为3D模式,重新启动游戏后生效。", Msg.szMessage, sizeof(Msg.szMessage));
  1129. Ini.WriteInteger("Client", "Represent", SCREEN_MODE_3D);
  1130. }
  1131. else
  1132. {
  1133. IniString.GetString("Config", "2D", "游戏设为2D模式,重新启动游戏后生效。", Msg.szMessage, sizeof(Msg.szMessage));
  1134. Ini.WriteInteger("Client", "Represent", SCREEN_MODE_2D);
  1135. }
  1136. KUiSysMsgCentre::AMessageArrival(&Msg, NULL);
  1137. Ini.Save(GAME_CONFIG_FILE);
  1138. return 0;
  1139. }
  1140. int LuaSetFullWindow(Lua_State * L)
  1141. {
  1142. if (Lua_GetTopIndex(L) != 1)
  1143. return 0;
  1144. KIniFile Ini, IniString;
  1145. KSystemMessage Msg;
  1146. int nBool = (int)Lua_ValueToNumber(L, 1);
  1147. Msg.eType = SMT_NORMAL;
  1148. Msg.byConfirmType = SMCT_NONE;
  1149. Msg.byPriority = 0;
  1150. Msg.byParamSize = 0;
  1151. Ini.Load(GAME_CONFIG_FILE);
  1152. IniString.Load(GAME_CONFIG_STRING_INI);
  1153. if (nBool)
  1154. {
  1155. IniString.GetString("Config", "FullWindow", "游戏设定改变为全屏运行,将在下次启动游戏的时候生效。", Msg.szMessage, sizeof(Msg.szMessage));
  1156. Ini.WriteInteger("Client", "FullScreen", 1);
  1157. }
  1158. else
  1159. {
  1160. IniString.GetString("Config", "Window", "游戏设定改变为窗口运行,将在下次启动游戏的时候生效。", Msg.szMessage, sizeof(Msg.szMessage));
  1161. Ini.WriteInteger("Client", "FullScreen", 0);
  1162. }
  1163. KUiSysMsgCentre::AMessageArrival(&Msg, NULL);
  1164. Ini.Save(GAME_CONFIG_FILE);
  1165. return 0;
  1166. }
  1167. int LuaMoveTo(Lua_State * L)
  1168. {
  1169. if (Lua_GetTopIndex(L) != 2)
  1170. return 0;
  1171. int nDir = (int)Lua_ValueToNumber(L, 1);
  1172. int nM = (int)Lua_ValueToNumber(L, 2);
  1173. if (nDir < 0)
  1174. nDir = 0;
  1175. if (nDir > 63)
  1176. nDir = 63;
  1177. if (nM < 0)
  1178. nM = 0;
  1179. if (nM > 2)
  1180. nM = 2;
  1181. if (g_pCoreShell)
  1182. g_pCoreShell->Goto(nDir, nM);
  1183. return 0;
  1184. }
  1185. int LuaTurnTo(Lua_State * L)
  1186. {
  1187. if (Lua_GetTopIndex(L) != 1)
  1188. return 0;
  1189. int nDir = (int)Lua_ValueToNumber(L, 1);
  1190. if (nDir < 0)
  1191. nDir = 0;
  1192. if (nDir > 2)
  1193. nDir = 2;
  1194. if (g_pCoreShell)
  1195. g_pCoreShell->Turn(nDir);
  1196. return 0;
  1197. }
  1198. int Mouse_Action(Lua_State * L)
  1199. {
  1200. if (!KShortcutKeyCentre::ms_bMouse)
  1201. return 0;
  1202. if (g_pCoreShell == NULL)
  1203. return 0;
  1204. if (g_pCoreShell->ThrowAwayItem()) //先扔掉手里的物品
  1205. return 0;
  1206. KUiPlayerItem SelectPlayer;
  1207. int nNPCKind = -1;
  1208. if (g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_all, false, &SelectPlayer, nNPCKind))
  1209. {
  1210. int nRelation = g_pCoreShell->GetNPCRelation(SelectPlayer.nIndex);
  1211. if (nRelation == relation_enemy)
  1212. {
  1213. KUiPlayerImmedItemSkill immedItemSkillInfo;
  1214. memset(&immedItemSkillInfo, 0, sizeof(KUiPlayerImmedItemSkill));
  1215. g_pCoreShell->GetGameData(GDI_PLAYER_IMMED_ITEMSKILL, (int)&immedItemSkillInfo, 0);
  1216. if (!g_pCoreShell->LockSomeoneUseSkill(SelectPlayer.nIndex, immedItemSkillInfo.IMmediaSkill[0].uId)) //锁定失败
  1217. g_pCoreShell->LockSomeoneAction(0); //解锁
  1218. }
  1219. else if (nRelation == relation_dialog)
  1220. {
  1221. g_pCoreShell->LockSomeoneAction(SelectPlayer.nIndex);
  1222. }
  1223. }
  1224. else
  1225. g_pCoreShell->LockSomeoneAction(0);
  1226. int nObjKind = -1;
  1227. int nObjectIdx = 0;
  1228. if (g_pCoreShell->FindSelectObject(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, false, nObjectIdx, nObjKind))
  1229. {
  1230. g_pCoreShell->LockObjectAction(nObjectIdx);
  1231. }
  1232. else
  1233. g_pCoreShell->LockObjectAction(0);
  1234. g_pCoreShell->GotoWhere(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, 0);
  1235. return 0;
  1236. }
  1237. int Mouse_Force0(Lua_State * L)
  1238. {
  1239. if (!KShortcutKeyCentre::ms_bMouse)
  1240. return 0;
  1241. if (g_pCoreShell == NULL)
  1242. return 0;
  1243. if (g_pCoreShell->ThrowAwayItem()) //先扔掉手里的物品
  1244. return 0;
  1245. KUiPlayerImmedItemSkill immedItemSkillInfo;
  1246. memset(&immedItemSkillInfo, 0, sizeof(KUiPlayerImmedItemSkill));
  1247. g_pCoreShell->GetGameData(GDI_PLAYER_IMMED_ITEMSKILL, (int)&immedItemSkillInfo, 0);
  1248. g_pCoreShell->UseSkill(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, immedItemSkillInfo.IMmediaSkill[0].uId);
  1249. return 0;
  1250. }
  1251. int Mouse_Force1(Lua_State * L)
  1252. {
  1253. if (!KShortcutKeyCentre::ms_bMouse)
  1254. return 0;
  1255. if (g_pCoreShell == NULL)
  1256. return 0;
  1257. if (g_pCoreShell->ThrowAwayItem()) //先扔掉手里的物品
  1258. return 0;
  1259. KUiPlayerImmedItemSkill immedItemSkillInfo;
  1260. memset(&immedItemSkillInfo, 0, sizeof(KUiPlayerImmedItemSkill));
  1261. g_pCoreShell->GetGameData(GDI_PLAYER_IMMED_ITEMSKILL, (int)&immedItemSkillInfo, 0);
  1262. g_pCoreShell->UseSkill(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, immedItemSkillInfo.IMmediaSkill[1].uId);
  1263. return 0;
  1264. }
  1265. int Mouse_MoveTo(Lua_State * L)
  1266. {
  1267. if (!KShortcutKeyCentre::ms_bMouse)
  1268. return 0;
  1269. if (g_pCoreShell == NULL)
  1270. return 0;
  1271. if (Lua_GetTopIndex(L) != 1)
  1272. return 0;
  1273. int nM = (int)Lua_ValueToNumber(L, 1);
  1274. if (nM < 0)
  1275. nM = 0;
  1276. if (nM > 2)
  1277. nM = 2;
  1278. g_pCoreShell->GotoWhere(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, nM);
  1279. return 0;
  1280. }
  1281. int Mouse_Menu(Lua_State * L)
  1282. {
  1283. if (!KShortcutKeyCentre::ms_bMouse)
  1284. return 0;
  1285. if (g_pCoreShell == NULL)
  1286. return 0;
  1287. KUiPlayerItem SelectPlayer;
  1288. int nKind = -1;
  1289. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1290. && kind_player == nKind))
  1291. return 0;
  1292. PopUpContextPeopleMenu(SelectPlayer, KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY);
  1293. return 0;
  1294. }
  1295. int Mouse_Emote_Menu(Lua_State * L)
  1296. {
  1297. if (!KShortcutKeyCentre::ms_bMouse)
  1298. return 0;
  1299. if (g_pCoreShell == NULL)
  1300. return 0;
  1301. KUiPlayerItem SelectPlayer;
  1302. int nKind = -1;
  1303. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1304. && kind_player == nKind))
  1305. return 0;
  1306. PopUpContextEmoteMenu(SelectPlayer.Name, KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY);
  1307. return 0;
  1308. }
  1309. int Mouse_Say(Lua_State * L)
  1310. {
  1311. if (!KShortcutKeyCentre::ms_bMouse)
  1312. return 0;
  1313. if (g_pCoreShell == NULL)
  1314. return 0;
  1315. KUiPlayerItem SelectPlayer;
  1316. int nKind = -1;
  1317. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1318. && kind_player == nKind))
  1319. return 0;
  1320. ProcessPeople(&SelectPlayer, ACTION_CHAT);
  1321. return 0;
  1322. }
  1323. int Mouse_MakeFriend(Lua_State * L)
  1324. {
  1325. if (!KShortcutKeyCentre::ms_bMouse)
  1326. return 0;
  1327. if (g_pCoreShell == NULL)
  1328. return 0;
  1329. KUiPlayerItem SelectPlayer;
  1330. int nKind = -1;
  1331. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1332. && kind_player == nKind))
  1333. return 0;
  1334. ProcessPeople(&SelectPlayer, ACTION_MAKEFRIEND);
  1335. return 0;
  1336. }
  1337. int Mouse_JoinTeam(Lua_State * L)
  1338. {
  1339. if (!KShortcutKeyCentre::ms_bMouse)
  1340. return 0;
  1341. if (g_pCoreShell == NULL)
  1342. return 0;
  1343. KUiPlayerItem SelectPlayer;
  1344. int nKind = -1;
  1345. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1346. && kind_player == nKind))
  1347. return 0;
  1348. ProcessPeople(&SelectPlayer, ACTION_JOINTEAM);
  1349. return 0;
  1350. }
  1351. int Mouse_InviteTeam(Lua_State * L)
  1352. {
  1353. if (!KShortcutKeyCentre::ms_bMouse)
  1354. return 0;
  1355. if (g_pCoreShell == NULL)
  1356. return 0;
  1357. KUiPlayerItem SelectPlayer;
  1358. int nKind = -1;
  1359. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1360. && kind_player == nKind))
  1361. return 0;
  1362. ProcessPeople(&SelectPlayer, ACTION_INVITETEAM);
  1363. return 0;
  1364. }
  1365. int Mouse_Trade(Lua_State * L)
  1366. {
  1367. if (!KShortcutKeyCentre::ms_bMouse)
  1368. return 0;
  1369. if (g_pCoreShell == NULL)
  1370. return 0;
  1371. KUiPlayerItem SelectPlayer;
  1372. int nKind = -1;
  1373. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1374. && kind_player == nKind))
  1375. return 0;
  1376. ProcessPeople(&SelectPlayer, ACTION_TRADE);
  1377. return 0;
  1378. }
  1379. int Mouse_Revenge(Lua_State * L)
  1380. {
  1381. if (!KShortcutKeyCentre::ms_bMouse)
  1382. return 0;
  1383. if (g_pCoreShell == NULL)
  1384. return 0;
  1385. KUiPlayerItem SelectPlayer;
  1386. int nKind = -1;
  1387. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1388. && kind_player == nKind))
  1389. return 0;
  1390. ProcessPeople(&SelectPlayer, ACTION_REVENGE);
  1391. return 0;
  1392. }
  1393. int Mouse_Follow(Lua_State * L)
  1394. {
  1395. if (!KShortcutKeyCentre::ms_bMouse)
  1396. return 0;
  1397. if (g_pCoreShell == NULL)
  1398. return 0;
  1399. KUiPlayerItem SelectPlayer;
  1400. int nKind = -1;
  1401. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1402. && kind_player == nKind))
  1403. return 0;
  1404. ProcessPeople(&SelectPlayer, ACTION_FOLLOW);
  1405. return 0;
  1406. }
  1407. int Mouse_ViewItem(Lua_State * L)
  1408. {
  1409. if (!KShortcutKeyCentre::ms_bMouse)
  1410. return 0;
  1411. if (g_pCoreShell == NULL)
  1412. return 0;
  1413. KUiPlayerItem SelectPlayer;
  1414. int nKind = -1;
  1415. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1416. && kind_player == nKind))
  1417. return 0;
  1418. ProcessPeople(&SelectPlayer, ACTION_VIEWITEM);
  1419. return 0;
  1420. }
  1421. int Mouse_BlackList(Lua_State * L)
  1422. {
  1423. if (!KShortcutKeyCentre::ms_bMouse)
  1424. return 0;
  1425. if (g_pCoreShell == NULL)
  1426. return 0;
  1427. KUiPlayerItem SelectPlayer;
  1428. int nKind = -1;
  1429. if (!(g_pCoreShell->FindSelectNPC(KShortcutKeyCentre::ms_MouseX, KShortcutKeyCentre::ms_MouseY, relation_none | relation_ally | relation_enemy, false, &SelectPlayer, nKind)
  1430. && kind_player == nKind))
  1431. return 0;
  1432. ProcessPeople(&SelectPlayer, ACTION_BLACKLIST);
  1433. return 0;
  1434. }
  1435. int LuaThrowAwayItem(Lua_State * L)
  1436. {
  1437. if (g_pCoreShell == NULL)
  1438. return 0;
  1439. g_pCoreShell->ThrowAwayItem();
  1440. return 0;
  1441. }
  1442. int LuaSetChatFontSzie(Lua_State * L)
  1443. {
  1444. if (Lua_GetTopIndex(L) != 1)
  1445. return 0;
  1446. int nF = (int)Lua_ValueToNumber(L, 1);
  1447. KUiMsgCentrePad::SetFontSize(nF);
  1448. return 0;
  1449. }
  1450. int LuaSetChannelTextColor(Lua_State * L)
  1451. {
  1452. if (Lua_GetTopIndex(L) != 3)
  1453. return 0;
  1454. char * strName = (char *)Lua_ValueToString(L, 1);
  1455. char * strColor = (char *)Lua_ValueToString(L, 2);
  1456. char * strBColor = (char *)Lua_ValueToString(L, 3);
  1457. if (strName && strColor)
  1458. {
  1459. KUiMsgCentrePad::SetChannelTextColor(strName, GetColor(strColor), GetColor(strBColor));
  1460. }
  1461. return 0;
  1462. }
  1463. int LuaSetMeTextColor(Lua_State * L)
  1464. {
  1465. if (Lua_GetTopIndex(L) != 2)
  1466. return 0;
  1467. char * strColor = (char *)Lua_ValueToString(L, 1);
  1468. char * strBColor = (char *)Lua_ValueToString(L, 2);
  1469. if (strColor)
  1470. {
  1471. KUiMsgCentrePad::SetMSNTextColor(0, GetColor(strColor), GetColor(strBColor));
  1472. }
  1473. return 0;
  1474. }
  1475. int LuaSetFriendTextColor(Lua_State * L)
  1476. {
  1477. if (Lua_GetTopIndex(L) != 2)
  1478. return 0;
  1479. char * strColor = (char *)Lua_ValueToString(L, 1);
  1480. char * strBColor = (char *)Lua_ValueToString(L, 2);
  1481. if (strColor)
  1482. {
  1483. KUiMsgCentrePad::SetMSNTextColor(1, GetColor(strColor), GetColor(strBColor));
  1484. }
  1485. return 0;
  1486. }
  1487. int LuaSetStrangerTextColor(Lua_State * L)
  1488. {
  1489. if (Lua_GetTopIndex(L) != 2)
  1490. return 0;
  1491. char * strColor = (char *)Lua_ValueToString(L, 1);
  1492. char * strBColor = (char *)Lua_ValueToString(L, 2);
  1493. if (strColor)
  1494. {
  1495. KUiMsgCentrePad::SetMSNTextColor(2, GetColor(strColor), GetColor(strBColor));
  1496. }
  1497. return 0;
  1498. }
  1499. extern int WND_SHOW_MOUSE_OVER_WND;
  1500. int LuaDebug(Lua_State * L)
  1501. {
  1502. if (Lua_GetTopIndex(L) != 1)
  1503. return 0;
  1504. char * strMode = (char *)Lua_ValueToString(L, 1);
  1505. if (strcmpi(strMode, "ShowMouseWnd") == 0)
  1506. {
  1507. WND_SHOW_MOUSE_OVER_WND = !WND_SHOW_MOUSE_OVER_WND;
  1508. }
  1509. return 0;
  1510. }
  1511. void AddBlackList(const char* strName, const char* strGroup);
  1512. int LuaAddBlackList(Lua_State * L)
  1513. {
  1514. if (Lua_GetTopIndex(L) != 1 && Lua_GetTopIndex(L) != 2)
  1515. return 0;
  1516. char * strName = (char *)Lua_ValueToString(L, 1);
  1517. char * strGroup = (char *)Lua_ValueToString(L, 2);
  1518. std::string group;
  1519. if (strGroup)
  1520. group = strGroup;
  1521. AddBlackList(strName, group.c_str());
  1522. return 0;
  1523. }
  1524. void RemoveBlackList(char* strName);
  1525. void ClearBlackList();
  1526. int LuaRemoveBlackList(Lua_State * L)
  1527. {
  1528. if (Lua_GetTopIndex(L) != 1)
  1529. return 0;
  1530. char * strName = (char *)Lua_ValueToString(L, 1);
  1531. if (strName == NULL || strName[0] == 0)
  1532. ClearBlackList();
  1533. else
  1534. RemoveBlackList(strName);
  1535. return 0;
  1536. }
  1537. void CreateAddinUnit(const char* UnitName);
  1538. int LuaCreateAddinUnit(Lua_State * L)
  1539. {
  1540. if (Lua_GetTopIndex(L) != 1)
  1541. return 0;
  1542. char * strName = (char *)Lua_ValueToString(L, 1);
  1543. CreateAddinUnit(strName);
  1544. return 0;
  1545. }
  1546. void DeleteAddinUnit(const char* UnitName);
  1547. int LuaDeleteAddinUnit(Lua_State * L)
  1548. {
  1549. if (Lua_GetTopIndex(L) != 1)
  1550. return 0;
  1551. char * strName = (char *)Lua_ValueToString(L, 1);
  1552. DeleteAddinUnit(strName);
  1553. return 0;
  1554. }
  1555. int LuaCreateUnitGroup(Lua_State * L)
  1556. {
  1557. if (Lua_GetTopIndex(L) != 2)
  1558. return 0;
  1559. char * strName = (char *)Lua_ValueToString(L, 1);
  1560. char * strGroup = (char *)Lua_ValueToString(L, 2);
  1561. int nUint = KUiChatCentre::FindUnitIndex(strName);
  1562. if (nUint >= 0)
  1563. {
  1564. KUiChatCentre::NewGroup(nUint, strGroup);
  1565. }
  1566. return 0;
  1567. }
  1568. int LuaRenameUnitGroup(Lua_State * L)
  1569. {
  1570. if (Lua_GetTopIndex(L) != 3)
  1571. return 0;
  1572. char * strName = (char *)Lua_ValueToString(L, 1);
  1573. char * strGroup = (char *)Lua_ValueToString(L, 2);
  1574. char * strNewGroup = (char *)Lua_ValueToString(L, 3);
  1575. int nUint = KUiChatCentre::FindUnitIndex(strName);
  1576. if (nUint >= 0)
  1577. {
  1578. KUiChatCentre::ReplaceGroupName(nUint, strGroup, strNewGroup);
  1579. }
  1580. return 0;
  1581. }
  1582. int LuaMoveUnitGroup(Lua_State * L)
  1583. {
  1584. if (Lua_GetTopIndex(L) != 3)
  1585. return 0;
  1586. char * strName = (char *)Lua_ValueToString(L, 1);
  1587. char * strGroup = (char *)Lua_ValueToString(L, 2);
  1588. char * strNewGroup = (char *)Lua_ValueToString(L, 3);
  1589. int nUint = KUiChatCentre::FindUnitIndex(strName);
  1590. if (nUint >= 0)
  1591. {
  1592. KUiChatCentre::MoveGroupToGroup(nUint, strGroup, strNewGroup, false);
  1593. }
  1594. return 0;
  1595. }
  1596. int LuaDeleteUnitGroup(Lua_State * L)
  1597. {
  1598. if (Lua_GetTopIndex(L) != 2)
  1599. return 0;
  1600. char * strName = (char *)Lua_ValueToString(L, 1);
  1601. char * strGroup = (char *)Lua_ValueToString(L, 2);
  1602. int nUint = KUiChatCentre::FindUnitIndex(strName);
  1603. if (nUint >= 0)
  1604. {
  1605. KUiChatCentre::MoveGroupToGroup(nUint, strGroup, "", true);
  1606. }
  1607. return 0;
  1608. }
  1609. int LuaMoveUnitMember(Lua_State * L)
  1610. {
  1611. if (Lua_GetTopIndex(L) != 3)
  1612. return 0;
  1613. char * strName = (char *)Lua_ValueToString(L, 1);
  1614. char * strMember = (char *)Lua_ValueToString(L, 2);
  1615. char * strGroup = (char *)Lua_ValueToString(L, 3);
  1616. int nUint = KUiChatCentre::FindUnitIndex(strName);
  1617. if (nUint >= 0)
  1618. {
  1619. KUiChatCentre::MoveFriendToGroup(nUint, strMember, strGroup);
  1620. }
  1621. return 0;
  1622. }
  1623. int LuaCreateAddinUnitMember(Lua_State * L)
  1624. {
  1625. if (Lua_GetTopIndex(L) != 3)
  1626. return 0;
  1627. char * strName = (char *)Lua_ValueToString(L, 1);
  1628. char * strMember = (char *)Lua_ValueToString(L, 2);
  1629. char * strGroup = (char *)Lua_ValueToString(L, 3);
  1630. int nUint = KUiChatCentre::FindAddinUnitIndex(strName);
  1631. if (nUint >= 0)
  1632. {
  1633. KUiChatCentre::AddFriendInfo(nUint, strMember, strGroup);
  1634. }
  1635. return 0;
  1636. }
  1637. int LuaDeleteAddinUnitMember(Lua_State * L)
  1638. {
  1639. if (Lua_GetTopIndex(L) != 2)
  1640. return 0;
  1641. char * strName = (char *)Lua_ValueToString(L, 1);
  1642. char * strMember = (char *)Lua_ValueToString(L, 2);
  1643. int nUint = KUiChatCentre::FindAddinUnitIndex(strName);
  1644. if (nUint >= 0)
  1645. {
  1646. KUiChatCentre::DeleteFriend(nUint, strMember, true);
  1647. }
  1648. return 0;
  1649. }
  1650. int LuaSetAddinUnitMemberStatus(Lua_State * L)
  1651. {
  1652. if (Lua_GetTopIndex(L) != 3)
  1653. return 0;
  1654. char * strName = (char *)Lua_ValueToString(L, 1);
  1655. char * strMember = (char *)Lua_ValueToString(L, 2);
  1656. char * strStatus = (char *)Lua_ValueToString(L, 3);
  1657. int nUint = KUiChatCen

Large files files are truncated, but you can click here to view the full file