MapD.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. // MapD.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "MapD.h"
  21. #include "resource.h"
  22. #include "mapdata.h"
  23. #include "variables.h"
  24. #include "functions.h"
  25. #include "changesizedlg.h"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // Eigenschaftenseite CMapD
  33. IMPLEMENT_DYNCREATE(CMapD, CDialog)
  34. CMapD::CMapD() : CDialog(CMapD::IDD)
  35. {
  36. //{{AFX_DATA_INIT(CMapD)
  37. m_Width = _T("");
  38. m_Height = _T("");
  39. //}}AFX_DATA_INIT
  40. }
  41. CMapD::~CMapD()
  42. {
  43. }
  44. void CMapD::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CMapD)
  48. DDX_Control(pDX, IDC_USESIZE, m_LocalSize);
  49. DDX_Control(pDX, IDC_THEATER, m_Theater);
  50. DDX_Text(pDX, IDC__SIZEX, m_Width);
  51. DDX_Text(pDX, IDC__SIZEY, m_Height);
  52. //}}AFX_DATA_MAP
  53. }
  54. BEGIN_MESSAGE_MAP(CMapD, CDialog)
  55. //{{AFX_MSG_MAP(CMapD)
  56. ON_EN_CHANGE(IDC_USESIZE, OnChangeUsesize)
  57. ON_CBN_EDITCHANGE(IDC_THEATER, OnEditchangeTheater)
  58. ON_BN_CLICKED(IDC_CHANGELOCAL, OnChangelocal)
  59. ON_CBN_SELCHANGE(IDC_THEATER, OnEditchangeTheater)
  60. ON_BN_CLICKED(IDC_CHANGE, OnChange)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Behandlungsroutinen für Nachrichten CMapD
  65. void CMapD::UpdateDialog()
  66. {
  67. CIniFile& ini=Map->GetIniFile();
  68. m_LocalSize.SetWindowText( ini.sections["Map"].values["LocalSize"] );
  69. //m_Size.SetWindowText( ini.sections["Map"].values["Size"] );
  70. m_Theater.SetWindowText( ini.sections["Map"].values["Theater"] );
  71. char c[50];
  72. itoa(Map->GetWidth(), c, 10);
  73. m_Width=c;
  74. itoa(Map->GetHeight(), c, 10);
  75. m_Height=c;
  76. CDialog::UpdateData(FALSE);
  77. }
  78. void CMapD::UpdateData()
  79. {
  80. //MessageBox("This function ( UpdateData() ) should not be called, please contact the author.");
  81. }
  82. void CMapD::OnChangeUsesize()
  83. {
  84. }
  85. void CMapD::OnEditchangeTheater()
  86. {
  87. CIniFile& ini=Map->GetIniFile();
  88. ini.sections["Map"].values["Theater"]=GetText(&m_Theater);
  89. }
  90. void CMapD::UpdateStrings()
  91. {
  92. GetDlgItem(IDC_DESC)->SetWindowText(GetLanguageStringACP("MapDesc"));
  93. GetDlgItem(IDC_SIZEFRAME)->SetWindowText(GetLanguageStringACP("MapSizeFrame"));
  94. GetDlgItem(IDC_LSIZE)->SetWindowText(GetLanguageStringACP("MapSize"));
  95. GetDlgItem(IDC_USEABLEFRAME)->SetWindowText(GetLanguageStringACP("MapVisibleSizeFrame"));
  96. GetDlgItem(IDC_LUSEABLE)->SetWindowText(GetLanguageStringACP("MapVisibleSize"));
  97. GetDlgItem(IDC_LTHEATER)->SetWindowText(GetLanguageStringACP("MapTheater"));
  98. }
  99. void CMapD::OnChangelocal()
  100. {
  101. CIniFile& ini=Map->GetIniFile();
  102. ini.sections["Map"].values["LocalSize"]=GetText(&m_LocalSize);
  103. Map->CalcMapRect();
  104. ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  105. }
  106. void CMapD::OnChange()
  107. {
  108. /*
  109. CDialog::UpdateData(TRUE);
  110. int width, height;
  111. width=atoi(m_Width);
  112. height=atoi(m_Height);
  113. Map->ResizeMap(width, height);
  114. ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  115. */
  116. CChangeSizeDlg dlg;
  117. if(dlg.DoModal()==IDCANCEL) return;
  118. if(dlg.m_Width<16 || dlg.m_Width>400 || dlg.m_Height<16 || dlg.m_Height>400 || (dlg.m_Width + dlg.m_Height) > 512)
  119. {
  120. MessageBox("Width and Height must both be between 16 and 400 and both added must be less than 512.", "Error");
  121. return;
  122. }
  123. Map->ResizeMap(dlg.m_Left, dlg.m_Top, dlg.m_Width, dlg.m_Height);
  124. ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  125. ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_minimap.UpdateView();
  126. char c[50];
  127. itoa(dlg.m_Width, c, 10);
  128. m_Width=c;
  129. itoa(dlg.m_Height, c, 10);
  130. m_Height=c;
  131. CDialog::UpdateData(FALSE);
  132. }