Unit.cpp 4.3 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. // Unit.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "Unit.h"
  21. #include "resource.h"
  22. #include "mapdata.h"
  23. #include "variables.h"
  24. #include "functions.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Dialogfeld CUnit
  32. CUnit::CUnit(CWnd* pParent /*=NULL*/)
  33. : CDialog(CUnit::IDD, pParent)
  34. {
  35. //{{AFX_DATA_INIT(CUnit)
  36. m_direction = _T("");
  37. m_flag1 = _T("");
  38. m_flag2 = _T("");
  39. m_house = _T("");
  40. m_flag3 = _T("");
  41. m_flag4 = _T("");
  42. m_flag5 = _T("");
  43. m_flag6 = _T("");
  44. m_action = _T("");
  45. m_tag = _T("");
  46. //}}AFX_DATA_INIT
  47. }
  48. void CUnit::DoDataExchange(CDataExchange* pDX)
  49. {
  50. CDialog::DoDataExchange(pDX);
  51. //{{AFX_DATA_MAP(CUnit)
  52. DDX_Control(pDX, IDC_STRENGTH, m_strength_ctrl);
  53. DDX_CBString(pDX, IDC_DIRECTION, m_direction);
  54. DDX_Text(pDX, IDC_P1, m_flag1);
  55. DDX_Text(pDX, IDC_P2, m_flag2);
  56. DDX_CBString(pDX, IDC_HOUSE, m_house);
  57. DDX_Text(pDX, IDC_P3, m_flag3);
  58. DDX_Text(pDX, IDC_P4, m_flag4);
  59. DDX_Text(pDX, IDC_P5, m_flag5);
  60. DDX_Text(pDX, IDC_P6, m_flag6);
  61. DDX_CBString(pDX, IDC_STATE, m_action);
  62. DDX_CBString(pDX, IDC_TAG, m_tag);
  63. //}}AFX_DATA_MAP
  64. }
  65. BEGIN_MESSAGE_MAP(CUnit, CDialog)
  66. //{{AFX_MSG_MAP(CUnit)
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // Behandlungsroutinen für Nachrichten CUnit
  71. void CUnit::Init(CString house, CString strength, CString direction, CString action, CString tag, CString flag1, CString flag2, CString flag3, CString flag4, CString flag5, CString flag6)
  72. {
  73. CIniFile& ini=Map->GetIniFile();
  74. if(house=="")
  75. {
  76. m_house=*rules.sections["Houses"].GetValue(0);
  77. if(ini.sections.find("Houses")!=ini.sections.end())
  78. if(ini.sections["Houses"].values.size()>0)
  79. m_house=TranslateHouse(*ini.sections["Houses"].GetValue(0), TRUE);
  80. }
  81. else
  82. m_house=TranslateHouse(house, TRUE);
  83. m_flag1=flag1;
  84. m_flag2=flag2;
  85. m_flag3=flag3;
  86. m_flag4=flag4;
  87. m_flag5=flag5;
  88. m_flag6=flag6;
  89. m_action=action;
  90. m_strength=strength;
  91. m_tag=tag;
  92. m_direction=direction;
  93. }
  94. BOOL CUnit::OnInitDialog()
  95. {
  96. CDialog::OnInitDialog();
  97. // init the common (!) dialog things
  98. int i;
  99. CComboBox* house, *tag;
  100. house=(CComboBox*)GetDlgItem(IDC_HOUSE);
  101. tag=(CComboBox*)GetDlgItem(IDC_TAG);
  102. ListHouses(*house, FALSE);
  103. ListTags(*tag,TRUE);
  104. UpdateData(FALSE);
  105. m_strength_ctrl.SetRange(0,256);
  106. m_strength_ctrl.SetPos(atoi(m_strength));
  107. UpdateStrings();
  108. return TRUE;
  109. }
  110. void CUnit::OnOK()
  111. {
  112. CDialog::OnOK();
  113. m_strength=GetText(&m_strength_ctrl);
  114. UpdateData();
  115. TruncSpace(m_tag);
  116. m_house=TranslateHouse(m_house);
  117. }
  118. void CUnit::UpdateStrings()
  119. {
  120. SetWindowText(GetLanguageStringACP("UnitCap"));
  121. SetDlgItemText(IDC_DESC, GetLanguageStringACP("UnitDesc"));
  122. SetDlgItemText(IDC_LHOUSE, GetLanguageStringACP("UnitHouse"));
  123. SetDlgItemText(IDC_LSTRENGTH, GetLanguageStringACP("UnitStrength"));
  124. SetDlgItemText(IDC_LSTATE, GetLanguageStringACP("UnitState"));
  125. SetDlgItemText(IDC_LDIRECTION, GetLanguageStringACP("UnitDirection"));
  126. SetDlgItemText(IDC_LTAG, GetLanguageStringACP("UnitTag"));
  127. SetDlgItemText(IDC_LP1, GetLanguageStringACP("UnitP1"));
  128. SetDlgItemText(IDC_LP2, GetLanguageStringACP("UnitP2"));
  129. SetDlgItemText(IDC_LP3, GetLanguageStringACP("UnitP3"));
  130. SetDlgItemText(IDC_LP4, GetLanguageStringACP("UnitP4"));
  131. SetDlgItemText(IDC_LP5, GetLanguageStringACP("UnitP5"));
  132. SetDlgItemText(IDC_LP6, GetLanguageStringACP("UnitP6"));
  133. SetDlgItemText(IDOK, GetLanguageStringACP("OK"));
  134. SetDlgItemText(IDCANCEL, GetLanguageStringACP("Cancel"));
  135. }