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

模拟服务器

开发平台:

C/C++

  1. /* 
  2.  * File:     UiWorldMap.cpp
  3.  * Desc:     世界地图
  4.  * Author:   flying
  5.  * Creation: 2003/7/22
  6.  */
  7. //-----------------------------------------------------------------------------
  8. #include "KWin32.h"
  9. #include "KIniFile.h"
  10. #include "../elem/wnds.h"
  11. #include "../Elem/WndMessage.h"
  12. #include <crtdbg.h>
  13. //#include "../ShortcutKey.h"
  14. #include "UiWorldMap.h"
  15. #include "../UiBase.h"
  16. #include "../UiSoundSetting.h"
  17. #include "../../../Represent/iRepresent/iRepresentShell.h"
  18. #include "../../../Represent/iRepresent/KRepresentUnit.h"
  19. #include "../../../core/src/CoreShell.h"
  20. #include "../../../core/src/GameDataDef.h"
  21. extern iRepresentShell* g_pRepresentShell;
  22. extern iCoreShell* g_pCoreShell;
  23. KUiWorldmap* KUiWorldmap::m_pSelf = NULL;
  24. #define SCHEME_INI_WORLD "小地图_世界地图版.ini"
  25. #define WORLD_MAP_INFO_FILE "\Settings\MapList.ini"
  26. void MapToggleStatus();
  27. KUiWorldmap* KUiWorldmap::OpenWindow()
  28. {
  29. if (m_pSelf == NULL)
  30. {
  31. m_pSelf = new KUiWorldmap;
  32. if (m_pSelf)
  33. m_pSelf->Initialize();
  34. }
  35. if (m_pSelf)
  36. {
  37. UiSoundPlay(UI_SI_WND_OPENCLOSE);
  38. m_pSelf->UpdateData();
  39. m_pSelf->Show();
  40. m_pSelf->BringToTop();
  41. Wnd_SetExclusive(m_pSelf);
  42. }
  43. return m_pSelf;
  44. }
  45. void KUiWorldmap::CloseWindow()
  46. {
  47. if (m_pSelf)
  48. {
  49. Wnd_ReleaseExclusive(m_pSelf);
  50. m_pSelf->Destroy();
  51. m_pSelf = NULL;
  52. MapToggleStatus();
  53. }
  54. }
  55. KUiWorldmap* KUiWorldmap::GetIfVisible()
  56. {
  57. if (m_pSelf && m_pSelf->IsVisible())
  58. return m_pSelf;
  59. else
  60. return NULL;
  61. }
  62. //初始化
  63. void KUiWorldmap::Initialize()
  64. {
  65. AddChild(&m_Sign);
  66. char szBuffer[128];
  67. g_UiBase.GetCurSchemePath(szBuffer, sizeof(szBuffer));
  68. strcat(szBuffer, "\"SCHEME_INI_WORLD);
  69. KIniFile Ini;
  70. if (Ini.Load(szBuffer))
  71. {
  72. Init(&Ini, "WorldMap");
  73. m_Sign.Init(&Ini, "Sign");
  74. }
  75. Wnd_AddWindow(this, WL_TOPMOST);
  76. return;
  77. }
  78. int KUiWorldmap::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)
  79. {
  80. int nResult = false;
  81. switch(uMsg)
  82. {
  83. case WM_LBUTTONDOWN:
  84. case WM_RBUTTONDOWN:
  85. case WM_KEYDOWN:
  86. CloseWindow();
  87. nResult = true;
  88. break;
  89. default:
  90. nResult = KWndWindow::WndProc(uMsg, uParam, nParam);
  91. break;
  92. }
  93. return nResult;
  94. }
  95. void KUiWorldmap::UpdateData()
  96. {
  97. m_Sign.Hide();
  98. if (g_pCoreShell)
  99. {
  100. KIniFile Ini;
  101. if (Ini.Load(WORLD_MAP_INFO_FILE))
  102. {
  103. //取得世界地图的图形文件明
  104. char szBuffer[128];
  105. if (Ini.GetString("List", "WorldMapImage", "", szBuffer, sizeof(szBuffer)))
  106. {
  107. SetImage(ISI_T_BITMAP16, szBuffer, true);
  108. int nAreaX = -1, nAreaY = 0;
  109. KUiSceneTimeInfo Info;
  110. g_pCoreShell->SceneMapOperation(GSMOI_SCENE_TIME_INFO, (unsigned int)&Info, 0);
  111. sprintf(szBuffer, "%d_MapPos", Info.nSceneId);
  112. Ini.GetInteger2("List", szBuffer, &nAreaX, &nAreaY);
  113. if (nAreaX != -1)
  114. {
  115. int nWidth, nHeight;
  116. m_Sign.GetSize(&nWidth,  &nHeight);
  117. m_Sign.SetPosition(nAreaX - nWidth / 2,
  118. nAreaY - nHeight / 2);
  119. m_Sign.Show();
  120. }
  121. }
  122. }
  123. }
  124. }
  125. //活动函数
  126. void KUiWorldmap::Breathe()
  127. {
  128. if (m_Sign.IsVisible())
  129. m_Sign.NextFrame();
  130. }