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

模拟服务器

开发平台:

C/C++

  1. /*****************************************************************************************
  2. // 界面--管理窗口
  3. // Copyright : Kingsoft 2002
  4. // Author :   Wooy(Wu yue)
  5. // CreateTime: 2002-9-3
  6. *****************************************************************************************/
  7. #include "KWin32.h"
  8. #include "KIniFile.h"
  9. #include "../Elem/WndMessage.h"
  10. #include "../elem/wnds.h"
  11. #include "uimanage.h"
  12. #include "../UiBase.h"
  13. #include "../../../core/src/gamedatadef.h"
  14. #include "../../../core/src/coreshell.h"
  15. extern iCoreShell* g_pCoreShell;
  16. #define MANAGE_INI_SHEET "管理主窗口.ini"
  17. #define MANAGE_INI_CLIQUE "帮派管理.ini"
  18. #define MANAGE_INI_CONFRATERNITY "帮会管理.ini"
  19. //KUiManage g_UiManage;
  20. KUiManage* KUiManage::m_pSelf = NULL;
  21. //--------------------------------------------------------------------------
  22. // 功能:初始化
  23. //--------------------------------------------------------------------------
  24. int KUiCliqueManage::Init()
  25. {
  26. return true;
  27. }
  28. //--------------------------------------------------------------------------
  29. // 功能:载入窗口的界面方案
  30. //--------------------------------------------------------------------------
  31. void KUiCliqueManage::LoadScheme(const char* pScheme)
  32. {
  33. char Buff[128];
  34. KIniFile Ini;
  35. sprintf(Buff, "%s\%s", pScheme, MANAGE_INI_CLIQUE);
  36. if (Ini.Load(Buff))
  37. {
  38. KWndPage::Init(&Ini, "Main");
  39. }
  40. }
  41. //--------------------------------------------------------------------------
  42. // 功能:窗口函数
  43. //--------------------------------------------------------------------------
  44. int KUiCliqueManage::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)
  45. {
  46. return KWndPage::WndProc(uMsg, uParam, nParam);
  47. }
  48. //--------------------------------------------------------------------------
  49. // 功能:初始化
  50. //--------------------------------------------------------------------------
  51. int KUiConfraternityManage::Init()
  52. {
  53. return true;
  54. }
  55. //--------------------------------------------------------------------------
  56. // 功能:载入窗口的界面方案
  57. //--------------------------------------------------------------------------
  58. void KUiConfraternityManage::LoadScheme(const char* pScheme)
  59. {
  60. char Buff[128];
  61. KIniFile Ini;
  62. sprintf(Buff, "%s\%s", pScheme, MANAGE_INI_CONFRATERNITY);
  63. if (Ini.Load(Buff))
  64. {
  65. KWndPage::Init(&Ini, "Main");
  66. }
  67. }
  68. //--------------------------------------------------------------------------
  69. // 功能:窗口函数
  70. //--------------------------------------------------------------------------
  71. int KUiConfraternityManage::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)//窗口函数
  72. {
  73. return KWndPage::WndProc(uMsg, uParam, nParam);
  74. }
  75. //--------------------------------------------------------------------------
  76. // 功能:如果窗口正被显示,则返回实例指针
  77. //--------------------------------------------------------------------------
  78. KUiManage* KUiManage::GetIfVisible()
  79. {
  80. if (m_pSelf && m_pSelf->IsVisible())
  81. return m_pSelf;
  82. return NULL;
  83. }
  84. //--------------------------------------------------------------------------
  85. // 功能:打开窗口,返回唯一的一个类对象实例
  86. //--------------------------------------------------------------------------
  87. KUiManage* KUiManage::OpenWindow()
  88. {
  89. if (m_pSelf)
  90. m_pSelf->Show();
  91. else
  92. {
  93. m_pSelf = new KUiManage;
  94. if (m_pSelf)
  95. m_pSelf->Initialize();
  96. }
  97. return m_pSelf;
  98. }
  99. //--------------------------------------------------------------------------
  100. // 功能:关闭窗口,同时可以选则是否删除对象实例
  101. //--------------------------------------------------------------------------
  102. void KUiManage::CloseWindow(bool bDestroy)
  103. {
  104. if (m_pSelf)
  105. {
  106. if (bDestroy == false)
  107. m_pSelf->Hide();
  108. else
  109. {
  110. m_pSelf->Destroy();
  111. m_pSelf = NULL;
  112. }
  113. }
  114. }
  115. //--------------------------------------------------------------------------
  116. // 功能:初始化
  117. //--------------------------------------------------------------------------
  118. void KUiManage::Initialize()
  119. {
  120. AddChild(&m_Close);
  121. AddChild(&m_LeaderShipLevel);
  122. AddChild(&m_LeaderShipExperience);
  123. m_TeamPad.Init();
  124. AddPage(&m_TeamPad, &m_TeamPadBtn);
  125. m_CliquePad.Init();
  126. AddPage(&m_CliquePad, &m_CliquePadBtn);
  127. m_ConfraternityPad.Init();
  128. AddPage(&m_ConfraternityPad, &m_ConfraternityPadBtn);
  129. //帮会管理和门派管理界面暂不开放。
  130. m_CliquePadBtn.Enable(false);
  131. m_ConfraternityPadBtn.Enable(false);
  132. char Scheme[256];
  133. g_UiBase.GetCurSchemePath(Scheme, 256);
  134. LoadScheme(Scheme);
  135. UpdateLeaderData();
  136. Wnd_AddWindow(this);
  137. }
  138. //--------------------------------------------------------------------------
  139. // 功能:载入窗口的界面方案
  140. //--------------------------------------------------------------------------
  141. void KUiManage::LoadScheme(const char* pScheme)
  142. {
  143. char Buff[128];
  144. KIniFile Ini;
  145. sprintf(Buff, "%s\%s", pScheme, MANAGE_INI_SHEET);
  146. if (m_pSelf && Ini.Load(Buff))
  147. {
  148. m_pSelf->Init(&Ini, "Main");
  149. m_pSelf->m_Close .Init(&Ini, "CloseBtn");
  150. m_pSelf->m_TeamPadBtn .Init(&Ini, "TeamBtn");
  151. m_pSelf->m_CliquePadBtn .Init(&Ini, "CliqueBtn");
  152. m_pSelf->m_ConfraternityPadBtn.Init(&Ini, "ConfraternityBtn");
  153. m_pSelf->m_LeaderShipLevel     .Init(&Ini, "LeadLevel");
  154. m_pSelf->m_LeaderShipExperience.Init(&Ini, "LeadExp");
  155. Ini.Clear();
  156. m_pSelf->m_TeamPad.LoadScheme(pScheme);
  157. m_pSelf->m_CliquePad.LoadScheme(pScheme);
  158. m_pSelf->m_ConfraternityPad.LoadScheme(pScheme);
  159. }
  160. }
  161. //--------------------------------------------------------------------------
  162. // 功能:窗口函数
  163. //--------------------------------------------------------------------------
  164. int KUiManage::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)
  165. {
  166. if (uMsg == WND_N_BUTTON_CLICK &&
  167. uParam == (unsigned int)(KWndWindow*)&m_Close)
  168. {
  169. Hide();
  170. return 0;
  171. }
  172. else
  173. return KWndPageSet::WndProc(uMsg, uParam, nParam);
  174. }
  175. //--------------------------------------------------------------------------
  176. // 功能:队伍内容变更
  177. //--------------------------------------------------------------------------
  178. void KUiManage::UpdateTeamData(int nID)
  179. {
  180. m_TeamPad.UpdateDataTeam(nID);
  181. }
  182. //--------------------------------------------------------------------------
  183. // 功能:队伍成员变更
  184. //--------------------------------------------------------------------------
  185. void KUiManage::UpdateTeamChange(const KUiPlayerItem* playerItem,int bAdd)
  186. {
  187. m_TeamPad.UpdateIncrementUpdateDataTeam(playerItem,bAdd);
  188. }
  189. //--------------------------------------------------------------------------
  190. // 功能:队伍加入列表的变更
  191. //--------------------------------------------------------------------------
  192. void KUiManage::UpdateToJoinChange(const KUiPlayerItem* playerItem,int bAdd)
  193. {
  194. m_TeamPad.UpdateIncrementUpdateDataJoinList(playerItem,bAdd);
  195. }
  196. //--------------------------------------------------------------------------
  197. // 功能:玩家数值变更
  198. //--------------------------------------------------------------------------
  199. void KUiManage::UpdateLeaderData()
  200. {
  201. KUiPlayerLeaderShip Leader = { 0 };
  202. g_pCoreShell->OperationRequest(GDI_PLAYER_LEADERSHIP, (unsigned int)&Leader, 0);
  203. m_LeaderShipLevel.SetIntText(Leader.nLeaderShipLevel);
  204. m_LeaderShipExperience.SetPart(Leader.nLeaderShipExperience,
  205. Leader.nLeaderShipExperienceFull);
  206. }