AiTriggerTypesEnable.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. // AiTriggerTypesEnable.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "AiTriggerTypesEnable.h"
  21. #include "mapdata.h"
  22. #include "variables.h"
  23. #include "inlines.h"
  24. #include "aitriggeradddlg.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Eigenschaftenseite CAiTriggerTypesEnable
  32. IMPLEMENT_DYNCREATE(CAiTriggerTypesEnable, CDialog)
  33. CAiTriggerTypesEnable::CAiTriggerTypesEnable() : CDialog(CAiTriggerTypesEnable::IDD)
  34. {
  35. //{{AFX_DATA_INIT(CAiTriggerTypesEnable)
  36. // HINWEIS: Der Klassen-Assistent fügt hier Elementinitialisierung ein
  37. //}}AFX_DATA_INIT
  38. }
  39. CAiTriggerTypesEnable::~CAiTriggerTypesEnable()
  40. {
  41. }
  42. void CAiTriggerTypesEnable::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CAiTriggerTypesEnable)
  46. DDX_Control(pDX, IDC_AITRIGGERTYPE, m_AITriggerType);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CAiTriggerTypesEnable, CDialog)
  50. //{{AFX_MSG_MAP(CAiTriggerTypesEnable)
  51. ON_BN_CLICKED(IDC_ENABLEALL, OnEnableall)
  52. ON_CBN_SELCHANGE(IDC_AITRIGGERTYPE, OnSelchangeAitriggertype)
  53. ON_BN_CLICKED(IDC_DELETE, OnDelete)
  54. ON_BN_CLICKED(IDC_ADD, OnAdd)
  55. //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Behandlungsroutinen für Nachrichten CAiTriggerTypesEnable
  59. void CAiTriggerTypesEnable::UpdateDialog()
  60. {
  61. int sel=m_AITriggerType.GetCurSel();
  62. if(sel<0) sel=0;
  63. while(m_AITriggerType.DeleteString(0)!=CB_ERR);
  64. CIniFile& ini=Map->GetIniFile();
  65. int i;
  66. for(i=0;i<ini.sections["AITriggerTypesEnable"].values.size();i++)
  67. {
  68. CString aitrigger=*ini.sections["AITriggerTypesEnable"].GetValueName(i);
  69. CString str=aitrigger;
  70. str+=" (";
  71. if(ai.sections["AITriggerTypes"].values.find(aitrigger)!=ai.sections["AITriggerTypes"].values.end())
  72. {
  73. // standard ai trigger
  74. str+=GetParam(ai.sections["AITriggerTypes"].values[aitrigger],0);
  75. str+=" -> ";
  76. str+=*ini.sections["AITriggerTypesEnable"].GetValue(i);
  77. }
  78. if(ini.sections["AITriggerTypes"].values.find(aitrigger)!=ini.sections["AITriggerTypes"].values.end())
  79. {
  80. str+=GetParam(ini.sections["AITriggerTypes"].values[aitrigger],0);
  81. str+=" -> ";
  82. str+=*ini.sections["AITriggerTypesEnable"].GetValue(i);
  83. }
  84. str+=")";
  85. m_AITriggerType.AddString(str);
  86. }
  87. if(m_AITriggerType.SetCurSel(sel)==CB_ERR)
  88. m_AITriggerType.SetCurSel(0);
  89. OnSelchangeAitriggertype();
  90. }
  91. void CAiTriggerTypesEnable::OnEnableall()
  92. {
  93. // enable all standard ai triggers
  94. CIniFile& ini=Map->GetIniFile();
  95. int i;
  96. for(i=0;i<ai.sections["AITriggerTypes"].values.size();i++)
  97. {
  98. ini.sections["AITriggerTypesEnable"].values[*ai.sections["AITriggerTypes"].GetValueName(i)]="yes";
  99. }
  100. UpdateDialog();
  101. }
  102. void CAiTriggerTypesEnable::OnSelchangeAitriggertype()
  103. {
  104. int sel=m_AITriggerType.GetCurSel();
  105. if(sel<0) return;
  106. }
  107. void CAiTriggerTypesEnable::OnDelete()
  108. {
  109. int sel=m_AITriggerType.GetCurSel();
  110. if(sel<0) return;
  111. CString aitrigger;
  112. m_AITriggerType.GetLBText(sel,aitrigger);
  113. if(aitrigger.Find(" ")>=0) aitrigger.SetAt(aitrigger.Find(" "), 0);
  114. CIniFile& ini=Map->GetIniFile();
  115. ini.sections["AITriggerTypesEnable"].values.erase((LPCTSTR)aitrigger);
  116. UpdateDialog();
  117. }
  118. void CAiTriggerTypesEnable::OnAdd()
  119. {
  120. //CString p=InputBox("Please enter the ID of the AITriggerType (for a list of all AITriggerType-IDs use the All-Section)","Enable AITriggerType");
  121. CAITriggerAddDlg dlg;
  122. if(dlg.DoModal()==IDCANCEL) return;
  123. CString p=dlg.m_AITrigger;
  124. TruncSpace(p);
  125. if(p.GetLength()==0) return;
  126. CIniFile& ini=Map->GetIniFile();
  127. ini.sections["AITriggerTypesEnable"].values[p]="yes";
  128. UpdateDialog();
  129. }