InsertSolveDialog.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  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. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LightMap *
  23. * *
  24. * $Archive:: /Commando/Code/Tool $*
  25. * *
  26. * $Author:: Ian_l $*
  27. * *
  28. * $Modtime:: 1/24/01 3:40p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. // Includes.
  36. #include "StdAfx.h"
  37. #include "LightMap.h"
  38. #include "InsertSolveDialog.h"
  39. #include "OptionsDialog.h"
  40. #ifdef _DEBUG
  41. #define new DEBUG_NEW
  42. #undef THIS_FILE
  43. static char THIS_FILE[] = __FILE__;
  44. #endif
  45. InsertSolveDialog::InsertSolveDialog (const char *initialpathname, CWnd* pParent /*=NULL*/)
  46. : CDialog(InsertSolveDialog::IDD, pParent)
  47. {
  48. InitialPathname = initialpathname;
  49. *DirectoryName = '\0';
  50. FileListBuffer = NULL;
  51. FilenameList = NULL;
  52. ApplySelective = false;
  53. InvertSelection = false;
  54. BlendNoise = false;
  55. InclusionString = NULL;
  56. //{{AFX_DATA_INIT(InsertSolveDialog)
  57. // NOTE: the ClassWizard will add member initialization here
  58. //}}AFX_DATA_INIT
  59. }
  60. void InsertSolveDialog::DoDataExchange(CDataExchange* pDX)
  61. {
  62. CDialog::DoDataExchange(pDX);
  63. //{{AFX_DATA_MAP(InsertSolveDialog)
  64. // NOTE: the ClassWizard will add DDX and DDV calls here
  65. //}}AFX_DATA_MAP
  66. }
  67. BEGIN_MESSAGE_MAP(InsertSolveDialog, CDialog)
  68. //{{AFX_MSG_MAP(InsertSolveDialog)
  69. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  70. ON_BN_CLICKED(IDC_APPLY_SELECTIVE, OnApplySelective)
  71. ON_BN_CLICKED(IDC_BLEND_NOISE, OnBlendNoise)
  72. ON_EN_CHANGE(IDC_INCLUSION_STRING, OnChangeInclusionString)
  73. ON_BN_CLICKED(IDC_MORE_OPTIONS, OnMoreOptions)
  74. ON_BN_CLICKED(IDC_CONTAINING, OnContaining)
  75. ON_BN_CLICKED(IDC_NOT_CONTAINING, OnNotContaining)
  76. //}}AFX_MSG_MAP
  77. END_MESSAGE_MAP()
  78. /***********************************************************************************************
  79. * InsertSolveDialog::OnMoreOptions -- *
  80. * *
  81. * INPUT: *
  82. * *
  83. * OUTPUT: *
  84. * *
  85. * WARNINGS: *
  86. * *
  87. * HISTORY: *
  88. * 09/06/00 IML : Created. *
  89. *=============================================================================================*/
  90. BOOL InsertSolveDialog::OnInitDialog()
  91. {
  92. char inclusionstring [2] = "^";
  93. CDialog::OnInitDialog();
  94. CheckDlgButton (IDC_APPLY_SELECTIVE, ApplySelective);
  95. CheckDlgButton (IDC_CONTAINING, true);
  96. CheckDlgButton (IDC_NOT_CONTAINING, false);
  97. CheckDlgButton (IDC_BLEND_NOISE, BlendNoise);
  98. GetDlgItem (IDC_INCLUSION_STRING)->SetWindowText (inclusionstring);
  99. GetDlgItem (IDC_INCLUSION_STRING)->EnableWindow (ApplySelective);
  100. GetDlgItem (IDC_CONTAINING)->EnableWindow (ApplySelective);
  101. GetDlgItem (IDC_NOT_CONTAINING)->EnableWindow (ApplySelective);
  102. return (TRUE); // return TRUE unless you set the focus to a control
  103. // EXCEPTION: OCX Property Pages should return FALSE
  104. }
  105. /***********************************************************************************************
  106. * InsertSolveDialog::OnBrowse -- *
  107. * *
  108. * INPUT: *
  109. * *
  110. * OUTPUT: *
  111. * *
  112. * WARNINGS: *
  113. * *
  114. * HISTORY: *
  115. * 09/06/00 IML : Created. *
  116. *=============================================================================================*/
  117. void InsertSolveDialog::OnBrowse()
  118. {
  119. const char *filefilter = "Lightscape Solution Files (*.ls)|*.ls|All Files (*.*)|*.*||"; // Filter for supported solve file formats.
  120. const unsigned filelistbuffersize = 4096;
  121. char initialdrivename [_MAX_DRIVE];
  122. char initialdirectoryname [_MAX_DIR];
  123. char initialpath [_MAX_PATH];
  124. // Select one or more solve files.
  125. CFileDialog dialog (TRUE, NULL, NULL, LightMapApp::File_Dialog_Flags() | OFN_ALLOWMULTISELECT, filefilter);
  126. // Allocate a buffer to contain the list of files selected.
  127. // NOTE: Add one to buffer size in case an extra null must be added (see below).
  128. FileListBuffer = new char [filelistbuffersize + 1];
  129. ASSERT (FileListBuffer != NULL);
  130. *FileListBuffer = '\0';
  131. dialog.m_ofn.lpstrFile = FileListBuffer;
  132. dialog.m_ofn.nMaxFile = filelistbuffersize;
  133. // Specify initial path.
  134. _splitpath (InitialPathname, initialdrivename, initialdirectoryname, NULL, NULL);
  135. _makepath (initialpath, initialdrivename, initialdirectoryname, NULL, NULL);
  136. dialog.m_ofn.lpstrInitialDir = initialpath;
  137. if (dialog.DoModal() == IDOK) {
  138. char *cptr;
  139. char *windowtext, *windowtextptr;
  140. // NOTE: Old style (not Explorer style) dialog boxes separate strings in the file list buffer
  141. // with spaces rather than null terminators.
  142. if (!LightMapApp::Explorer_Style()) {
  143. // Replace all spaces in the string with null terminators.
  144. cptr = FileListBuffer;
  145. while (*cptr != '\0') {
  146. if (*cptr == ' ') *cptr = '\0';
  147. cptr++;
  148. }
  149. // Append an extra null to indicate end of list.
  150. *(cptr + 1) = '\0';
  151. }
  152. // Must be room for directory name (including null terminator).
  153. ASSERT (dialog.m_ofn.nFileOffset < sizeof (DirectoryName));
  154. // Copy directory name from file list buffer and append a backslash.
  155. if (dialog.m_ofn.nFileOffset > 0) {
  156. strncpy (DirectoryName, FileListBuffer, dialog.m_ofn.nFileOffset);
  157. DirectoryName [dialog.m_ofn.nFileOffset - 1] = '\0';
  158. strcat (DirectoryName, "\\");
  159. } else {
  160. strcpy (DirectoryName, "");
  161. }
  162. FilenameList = FileListBuffer + dialog.m_ofn.nFileOffset;
  163. // Set the solve file list edit control.
  164. windowtext = new char [filelistbuffersize];
  165. ASSERT (windowtext != NULL);
  166. cptr = FilenameList;
  167. windowtextptr = windowtext;
  168. while (true) {
  169. if (*cptr != '\0') {
  170. *windowtextptr = *cptr;
  171. } else {
  172. if (*(cptr + 1) == '\0') {
  173. *windowtextptr = '\0';
  174. break;
  175. } else {
  176. *windowtextptr = ';';
  177. }
  178. }
  179. cptr++;
  180. windowtextptr++;
  181. }
  182. GetDlgItem (IDC_SOLVE_FILE_LIST)->SetWindowText (windowtext);
  183. // Clean-up.
  184. delete [] windowtext;
  185. GetDlgItem (IDOK)->EnableWindow();
  186. }
  187. }
  188. /***********************************************************************************************
  189. * InsertSolveDialog::OnApplySelective -- *
  190. * *
  191. * INPUT: *
  192. * *
  193. * OUTPUT: *
  194. * *
  195. * WARNINGS: *
  196. * *
  197. * HISTORY: *
  198. * 09/06/00 IML : Created. *
  199. *=============================================================================================*/
  200. void InsertSolveDialog::OnApplySelective()
  201. {
  202. ApplySelective = !ApplySelective;
  203. GetDlgItem (IDC_INCLUSION_STRING)->EnableWindow (ApplySelective);
  204. GetDlgItem (IDC_CONTAINING)->EnableWindow (ApplySelective);
  205. GetDlgItem (IDC_NOT_CONTAINING)->EnableWindow (ApplySelective);
  206. }
  207. /***********************************************************************************************
  208. * InsertSolveDialog::OnContaining -- *
  209. * *
  210. * INPUT: *
  211. * *
  212. * OUTPUT: *
  213. * *
  214. * WARNINGS: *
  215. * *
  216. * HISTORY: *
  217. * 09/06/00 IML : Created. *
  218. *=============================================================================================*/
  219. void InsertSolveDialog::OnContaining()
  220. {
  221. InvertSelection = false;
  222. }
  223. /***********************************************************************************************
  224. * InsertSolveDialog::OnNotContaining -- *
  225. * *
  226. * INPUT: *
  227. * *
  228. * OUTPUT: *
  229. * *
  230. * WARNINGS: *
  231. * *
  232. * HISTORY: *
  233. * 09/06/00 IML : Created. *
  234. *=============================================================================================*/
  235. void InsertSolveDialog::OnNotContaining()
  236. {
  237. InvertSelection = true;
  238. }
  239. /***********************************************************************************************
  240. * InsertSolveDialog::OnBlendNoise -- *
  241. * *
  242. * INPUT: *
  243. * *
  244. * OUTPUT: *
  245. * *
  246. * WARNINGS: *
  247. * *
  248. * HISTORY: *
  249. * 09/06/00 IML : Created. *
  250. *=============================================================================================*/
  251. void InsertSolveDialog::OnBlendNoise()
  252. {
  253. BlendNoise = !BlendNoise;
  254. }
  255. /***********************************************************************************************
  256. * InsertSolveDialog::OnChangeInclusionString -- *
  257. * *
  258. * INPUT: *
  259. * *
  260. * OUTPUT: *
  261. * *
  262. * WARNINGS: *
  263. * *
  264. * HISTORY: *
  265. * 09/06/00 IML : Created. *
  266. *=============================================================================================*/
  267. void InsertSolveDialog::OnChangeInclusionString()
  268. {
  269. int textlength;
  270. if (InclusionString != NULL) delete [] InclusionString;
  271. textlength = GetDlgItem (IDC_INCLUSION_STRING)->GetWindowTextLength() + 1;
  272. InclusionString = new char [textlength];
  273. ASSERT (InclusionString != NULL);
  274. GetDlgItem (IDC_INCLUSION_STRING)->GetWindowText (InclusionString, textlength);
  275. }
  276. /***********************************************************************************************
  277. * InsertSolveDialog::OnMoreOptions -- *
  278. * *
  279. * INPUT: *
  280. * *
  281. * OUTPUT: *
  282. * *
  283. * WARNINGS: *
  284. * *
  285. * HISTORY: *
  286. * 09/06/00 IML : Created. *
  287. *=============================================================================================*/
  288. void InsertSolveDialog::OnMoreOptions()
  289. {
  290. OptionsDialog options;
  291. options.DoModal();
  292. }