ImportINI.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. // ImportINI.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "ImportINI.h"
  21. #include "mapdata.h"
  22. #include "variables.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // Dialogfeld CImportINI
  30. CImportINI::CImportINI(CWnd* pParent /*=NULL*/)
  31. : CDialog(CImportINI::IDD, pParent)
  32. {
  33. //{{AFX_DATA_INIT(CImportINI)
  34. //}}AFX_DATA_INIT
  35. m_inicount=0;
  36. }
  37. void CImportINI::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CImportINI)
  41. DDX_Control(pDX, IDC_AVAILABLE, m_Available);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CImportINI, CDialog)
  45. //{{AFX_MSG_MAP(CImportINI)
  46. ON_BN_CLICKED(IDC_ALLSECTIONS, OnAllsections)
  47. ON_BN_CLICKED(IDC_SPECIFYSECTIONS, OnSpecifysections)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // Behandlungsroutinen für Nachrichten CImportINI
  52. void CImportINI::OnAllsections()
  53. {
  54. this->m_Available.EnableWindow(FALSE);
  55. //this->m_Sections.EnableWindow(FALSE);
  56. }
  57. void CImportINI::OnSpecifysections()
  58. {
  59. this->m_Available.EnableWindow();
  60. //this->m_Sections.EnableWindow();
  61. }
  62. BOOL CImportINI::OnInitDialog()
  63. {
  64. CDialog::OnInitDialog();
  65. CButton* all;
  66. all=(CButton*)GetDlgItem(IDC_ALLSECTIONS);
  67. all->SetCheck(1);
  68. this->OnAllsections();
  69. CIniFile inifile;
  70. inifile.LoadFile(this->m_FileName);
  71. if(inifile.sections.size()<1){MessageBox("File does not have any ini content, abort.","Error");EndDialog(IDCANCEL);return TRUE;}
  72. m_inicount=inifile.sections.size();
  73. int i;
  74. for(i=0;i<inifile.sections.size();i++)
  75. {
  76. if(!Map->IsMapSection(*inifile.GetSectionName(i)))
  77. m_Available.InsertString(-1, *inifile.GetSectionName(i));
  78. }
  79. return TRUE; // return TRUE unless you set the focus to a control
  80. // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
  81. }
  82. void CImportINI::OnOK()
  83. {
  84. CIniFile& ini=Map->GetIniFile();
  85. CButton* all;
  86. all=(CButton*)GetDlgItem(IDC_ALLSECTIONS);
  87. if(all->GetCheck())
  88. {
  89. // all...
  90. ini.InsertFile(m_FileName, NULL);
  91. }
  92. else
  93. {
  94. // only the chosen sections
  95. int i;
  96. for(i=0;i<m_Available.GetCount();i++)
  97. {
  98. if(m_Available.GetSel(i)>0)
  99. {
  100. // ok the user wants to add that section!
  101. CString name;
  102. m_Available.GetText(i, name);
  103. ini.InsertFile(m_FileName, (char*)(LPCTSTR)name);
  104. }
  105. }
  106. }
  107. CDialog::OnOK();
  108. }