TSOptions.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. // TSOptions.cpp: implementation
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "TSOptions.h"
  21. #include "resource.h"
  22. #include "mapdata.h"
  23. #include "variables.h"
  24. #include "functions.h"
  25. extern CFinalSunApp theApp;
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // Dialogfeld CTSOptions
  33. CTSOptions::CTSOptions(CWnd* pParent /*=NULL*/)
  34. : CDialog(CTSOptions::IDD, pParent)
  35. , m_PreferLocalTheaterFiles(FALSE)
  36. {
  37. //{{AFX_DATA_INIT(CTSOptions)
  38. m_LikeTS = -1;
  39. //}}AFX_DATA_INIT
  40. }
  41. void CTSOptions::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(CTSOptions)
  45. DDX_Control(pDX, IDC_LANGUAGE, m_Language);
  46. DDX_Control(pDX, IDC_EDIT1, m_TSExe);
  47. DDX_Radio(pDX, IDC_RULESLIKETS, m_LikeTS);
  48. DDX_Check(pDX, IDC_PREFER_LOCAL_THEATER_FILES, m_PreferLocalTheaterFiles);
  49. //}}AFX_DATA_MAP
  50. }
  51. BEGIN_MESSAGE_MAP(CTSOptions, CDialog)
  52. //{{AFX_MSG_MAP(CTSOptions)
  53. ON_BN_CLICKED(IDC_CHOOSE, OnChoose)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // Behandlungsroutinen für Nachrichten CTSOptions
  58. void CTSOptions::OnChoose()
  59. {
  60. #ifndef RA2_MODE
  61. CFileDialog fd(TRUE, NULL, "Sun.exe", OFN_FILEMUSTEXIST, "Tiberian Sun EXE|Sun.exe|");
  62. #else
  63. CFileDialog fd(TRUE, NULL, "ra2.exe", OFN_FILEMUSTEXIST, "Red Alert 2 EXE|ra2.exe|");
  64. #endif
  65. fd.DoModal();
  66. this->GetDlgItem(IDC_EDIT1)->SetWindowText((LPCTSTR)fd.GetPathName());
  67. delete fd;
  68. }
  69. void CTSOptions::OnOK()
  70. {
  71. this->GetDlgItem(IDC_EDIT1)->GetWindowText(m_TSEXE);
  72. int n=m_Language.GetItemData(m_Language.GetCurSel());
  73. m_LanguageName=*language.sections["Languages"].GetValue(n);
  74. CDialog::OnOK();
  75. }
  76. BOOL CTSOptions::OnInitDialog()
  77. {
  78. CDialog::OnInitDialog();
  79. m_TSExe.SetWindowText((LPCTSTR)theApp.m_Options.TSExe);
  80. if(theApp.m_Options.bSearchLikeTS) m_LikeTS=0;
  81. else m_LikeTS=1;
  82. m_PreferLocalTheaterFiles = theApp.m_Options.bPreferLocalTheaterFiles ? TRUE : FALSE;
  83. UpdateData(FALSE);
  84. int i;
  85. for(i=0;i<language.sections["Languages"].values.size();i++)
  86. {
  87. CString lang=*language.sections["Languages"].GetValue(i);
  88. lang=language.sections[lang+"Header"].values["Name"];
  89. m_Language.SetItemData(m_Language.AddString(lang),i);
  90. if (lang=="English")
  91. m_Language.SetCurSel(i);
  92. }
  93. return TRUE;
  94. }