NewMapImportDlg.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. // NewMapImportDlg.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "finalsun.h"
  20. #include "NewMapImportDlg.h"
  21. #include "variables.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. /////////////////////////////////////////////////////////////////////////////
  28. // Dialogfeld CNewMapImportDlg
  29. CNewMapImportDlg::CNewMapImportDlg(CWnd* pParent /*=NULL*/)
  30. : CDialog(CNewMapImportDlg::IDD, pParent)
  31. {
  32. //{{AFX_DATA_INIT(CNewMapImportDlg)
  33. m_ImportFile = _T("");
  34. m_ImportOverlay = FALSE;
  35. m_ImportTrees = FALSE;
  36. m_ImportUnits = FALSE;
  37. //}}AFX_DATA_INIT
  38. }
  39. void CNewMapImportDlg::DoDataExchange(CDataExchange* pDX)
  40. {
  41. CDialog::DoDataExchange(pDX);
  42. //{{AFX_DATA_MAP(CNewMapImportDlg)
  43. DDX_CBString(pDX, IDC_IMPORTFILE, m_ImportFile);
  44. DDX_Check(pDX, IDC_IMPORTOVERLAY, m_ImportOverlay);
  45. DDX_Check(pDX, IDC_IMPORTTREES, m_ImportTrees);
  46. DDX_Check(pDX, IDC_IMPORTUNITS, m_ImportUnits);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CNewMapImportDlg, CDialog)
  50. //{{AFX_MSG_MAP(CNewMapImportDlg)
  51. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Behandlungsroutinen für Nachrichten CNewMapImportDlg
  56. void CNewMapImportDlg::OnBrowse()
  57. {
  58. UpdateData();
  59. //CComboBox* m_ImportFile=(CComboBox*)GetDlgItem(IDC_IMPORTFILE);
  60. CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST, "All files|*.mpr;*.map;*.bmp|TS/RA2 multi maps|*.mpr|TS/RA2 single maps|*.map|Windows bitmaps|*.bmp|");
  61. char cuPath[MAX_PATH];
  62. GetCurrentDirectory(MAX_PATH, cuPath);
  63. dlg.m_ofn.lpstrInitialDir=cuPath;
  64. if(theApp.m_Options.TSExe.GetLength()) dlg.m_ofn.lpstrInitialDir=(char*)(LPCTSTR)theApp.m_Options.TSExe;
  65. if(dlg.DoModal()==IDCANCEL) return;
  66. m_ImportFile=dlg.GetPathName();
  67. UpdateData(FALSE);
  68. }
  69. BOOL CNewMapImportDlg::OnInitDialog()
  70. {
  71. CDialog::OnInitDialog();
  72. CComboBox* m_ImportFile=(CComboBox*)GetDlgItem(IDC_IMPORTFILE);
  73. CString maps = CString(u8AppDataPath.c_str()) + "\\stdmaps\\*.mpr";
  74. CFileFind ff;
  75. if(ff.FindFile(maps))
  76. {
  77. BOOL bFileAvailable=TRUE;
  78. while(bFileAvailable) {
  79. bFileAvailable=ff.FindNextFile();
  80. CString file=ff.GetFileName();
  81. m_ImportFile->AddString(file);
  82. }
  83. m_ImportFile->SetCurSel(0);
  84. }
  85. return TRUE; // return TRUE unless you set the focus to a control
  86. // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
  87. }