Waypoints.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. FinalSun/FinalAlert 2 Mission Editor
  3. Copyright (C) 1999-2024 Electronic Arts, Inc.
  4. Authored by Matthias Wagner
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. // Waypoints.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "TiberianSun Mission Editor.h"
  20. #include "Waypoints.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Eigenschaftenseite CWaypoints
  28. IMPLEMENT_DYNCREATE(CWaypoints, CPropertyPage)
  29. CWaypoints::CWaypoints() : CPropertyPage(CWaypoints::IDD)
  30. {
  31. //{{AFX_DATA_INIT(CWaypoints)
  32. // HINWEIS: Der Klassen-Assistent fügt hier Elementinitialisierung ein
  33. //}}AFX_DATA_INIT
  34. }
  35. CWaypoints::~CWaypoints()
  36. {
  37. }
  38. void CWaypoints::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CPropertyPage::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CWaypoints)
  42. DDX_Control(pDX, IDC_DBG, m_dbg);
  43. DDX_Control(pDX, IDC_WAYPOINTS, m_Waypoints);
  44. DDX_Control(pDX, IDC_POS, m_Pos);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CWaypoints, CPropertyPage)
  48. //{{AFX_MSG_MAP(CWaypoints)
  49. ON_LBN_SELCHANGE(IDC_WAYPOINTS, OnSelchangeWaypoints)
  50. ON_EN_KILLFOCUS(IDC_POS, OnKillfocusPos)
  51. ON_WM_KILLFOCUS()
  52. ON_WM_SHOWWINDOW()
  53. ON_BN_CLICKED(IDC_DELETE, OnDelete)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // Behandlungsroutinen für Nachrichten CWaypoints
  58. void CWaypoints::UpdateDialog()
  59. {
  60. m_Waypoints.SetRedraw(FALSE);
  61. // first clear the list
  62. while(m_Waypoints.DeleteString(0)!=LB_ERR);
  63. // okay add all trees
  64. int i;
  65. CIniFileSection& sec=ini.sections["Waypoints"];
  66. char c[50];
  67. for(i=0;i<sec.values.size();i++)
  68. {
  69. CString str;
  70. str=sec.GetValueName(i)->data();
  71. str+=", ";
  72. str+=sec.GetValue(i)->data();
  73. int x,y,z;
  74. GetXYPos((char*)sec.GetValue(i)->data(), &x, &y);
  75. itoa(x, c,10);
  76. str+=", ";
  77. str+=c;
  78. itoa(y, c,10);
  79. str+="/";
  80. str+=c;
  81. z=GetPos(x, y, 0);
  82. itoa(z, c, 10);
  83. str+="/";
  84. str+=c;
  85. /*int pos=atoi(str);
  86. str+=(CString)" "+ sec.GetValue(i)->data();
  87. int x,y;
  88. GetXYPos(atoi(sec.GetValueName(i)->data()), x, y);
  89. char c[50];
  90. itoa(x, c, 10);
  91. str+=" (";
  92. str+=c;
  93. str+="/";
  94. itoa(y, c, 10);
  95. str+=c;
  96. str+=")";*/
  97. m_Waypoints.InsertString(-1, str);
  98. }
  99. m_Waypoints.SetRedraw(TRUE);
  100. }
  101. void CWaypoints::OnSelchangeWaypoints()
  102. {
  103. int i=m_Waypoints.GetCurSel();
  104. if(i==-1) return;
  105. CString str;
  106. m_Waypoints.GetText(i, str);
  107. str.SetAt(str.Find(",",0), 0);
  108. // ok str now specifies the waypoint id
  109. m_Pos.SetWindowText(ini.sections["Waypoints"].values[(char*)(LPCTSTR)str].data());
  110. }
  111. void CWaypoints::OnKillfocusPos()
  112. {
  113. int i=m_Waypoints.GetCurSel();
  114. if(i==-1) return;
  115. CString str;
  116. m_Waypoints.GetText(i, str);
  117. str.SetAt(str.Find(",",0), 0);
  118. // ok str now specifies the waypoint id
  119. ini.sections["Waypoints"].values[(char*)(LPCTSTR)str]=GetText(&m_Pos);
  120. UpdateDialog();
  121. m_Waypoints.SetCurSel(i);
  122. }
  123. void CWaypoints::OnKillFocus(CWnd* pNewWnd)
  124. {
  125. CPropertyPage::OnKillFocus(pNewWnd);
  126. }
  127. void CWaypoints::OnShowWindow(BOOL bShow, UINT nStatus)
  128. {
  129. CPropertyPage::OnShowWindow(bShow, nStatus);
  130. OnKillfocusPos();
  131. }
  132. void CWaypoints::OnDelete()
  133. {
  134. int pos=m_Waypoints.GetCurSel();
  135. if(pos==-1) return;
  136. CString cuwayp;
  137. //m_TreeList.GetText(pos, cutree);
  138. cuwayp=ini.sections["Waypoints"].GetValueName(pos)->data();
  139. ini.sections["Waypoints"].values.erase((string)(char*)(LPCTSTR) cuwayp);
  140. m_Waypoints.SetRedraw(FALSE);
  141. UpdateDialog();
  142. m_Waypoints.SetCurSel(pos);
  143. m_Waypoints.SetRedraw(TRUE);
  144. }
  145. BOOL CWaypoints::OnInitDialog()
  146. {
  147. CPropertyPage::OnInitDialog();
  148. CBitmap m;
  149. m.LoadBitmap(IDB_DBG);
  150. m_dbg.SetBitmap(m);
  151. return TRUE; // return TRUE unless you set the focus to a control
  152. // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
  153. }