presetexportoptionsdialog.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Max2W3d *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/max2w3d/presetexportoptionsdialog.cpp $*
  25. * *
  26. * Original Author:: Patrick Smith *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 11/10/00 2:26p $*
  31. * *
  32. * $Revision:: 5 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #include "presetexportoptionsdialog.h"
  38. #include "dllmain.h"
  39. #include "resource.h"
  40. #include "w3dexp.h"
  41. #include "animationcompressionsettings.h"
  42. ////////////////////////////////////////////////////////////////////////////////////////
  43. // Constants
  44. ////////////////////////////////////////////////////////////////////////////////////////
  45. static const char *BROWSE_FILTER = "W3D Files (*.W3D)\0*.W3D\0WHT Files (*.WHT)\0*.WHT\0\0";
  46. ////////////////////////////////////////////////////////////////////////////////////////
  47. //
  48. // PresetExportOptionsDialogClass
  49. //
  50. ////////////////////////////////////////////////////////////////////////////////////////
  51. PresetExportOptionsDialogClass::PresetExportOptionsDialogClass (Interface *maxinterface, HWND parent_wnd) :
  52. MaxInterface (maxinterface),
  53. Options (NULL),
  54. Wnd (NULL),
  55. ParentWnd (parent_wnd),
  56. CurrentPane (-1)
  57. {
  58. ::memset (PaneWnds, 0, sizeof (PaneWnds));
  59. return ;
  60. }
  61. ////////////////////////////////////////////////////////////////////////////////////////
  62. //
  63. // ~PresetExportOptionsDialogClass
  64. //
  65. ////////////////////////////////////////////////////////////////////////////////////////
  66. PresetExportOptionsDialogClass::~PresetExportOptionsDialogClass (void)
  67. {
  68. return ;
  69. }
  70. ////////////////////////////////////////////////////////////////////////////////////////
  71. //
  72. // Do_Modal
  73. //
  74. ////////////////////////////////////////////////////////////////////////////////////////
  75. int
  76. PresetExportOptionsDialogClass::Do_Modal (void)
  77. {
  78. int retval = ::DialogBoxParam (AppInstance, MAKEINTRESOURCE (IDD_W3D_PRESET_EXPORT_OPTIONS),
  79. ParentWnd, Real_Message_Proc, (LPARAM)this);
  80. return retval;
  81. }
  82. ////////////////////////////////////////////////////////////////////////////////////////
  83. //
  84. // Real_Message_Proc
  85. //
  86. ////////////////////////////////////////////////////////////////////////////////////////
  87. BOOL CALLBACK
  88. PresetExportOptionsDialogClass::Real_Message_Proc
  89. (
  90. HWND wnd,
  91. UINT message,
  92. WPARAM wparam,
  93. LPARAM lparam
  94. )
  95. {
  96. PresetExportOptionsDialogClass *dialog_obj = NULL;
  97. //
  98. // Setup the framework we need so that the instance
  99. // can process the messages instead of this static callback.
  100. //
  101. if (message == WM_INITDIALOG) {
  102. dialog_obj = (PresetExportOptionsDialogClass *)lparam;
  103. dialog_obj->Wnd = wnd;
  104. ::SetProp (wnd, "DIALOG_OBJ", (HANDLE)dialog_obj);
  105. } else {
  106. dialog_obj = (PresetExportOptionsDialogClass *)::GetProp (wnd, "DIALOG_OBJ");
  107. }
  108. //
  109. // Allow the instance to handle the call
  110. //
  111. BOOL retval = FALSE;
  112. if (dialog_obj != NULL) {
  113. retval = dialog_obj->Message_Proc (message, wparam, lparam);
  114. }
  115. //
  116. // Cleanup the framework
  117. //
  118. if (message == WM_DESTROY) {
  119. ::RemoveProp (wnd, "DIALOG_OBJ");
  120. }
  121. return retval;
  122. }
  123. ////////////////////////////////////////////////////////////////////////////////////////
  124. //
  125. // Settings_Pane_Message_Proc
  126. //
  127. ////////////////////////////////////////////////////////////////////////////////////////
  128. BOOL CALLBACK
  129. PresetExportOptionsDialogClass::Settings_Pane_Message_Proc
  130. (
  131. HWND wnd,
  132. UINT message,
  133. WPARAM wparam,
  134. LPARAM lparam
  135. )
  136. {
  137. PresetExportOptionsDialogClass *dialog_obj = NULL;
  138. //
  139. // Setup the framework we need so that the instance
  140. // can process the messages instead of this static callback.
  141. //
  142. if (message == WM_INITDIALOG) {
  143. dialog_obj = (PresetExportOptionsDialogClass *)lparam;
  144. ::SetProp (wnd, "DIALOG_OBJ", (HANDLE)dialog_obj);
  145. } else {
  146. dialog_obj = (PresetExportOptionsDialogClass *)::GetProp (wnd, "DIALOG_OBJ");
  147. }
  148. //
  149. // Allow the instance to handle the call
  150. //
  151. BOOL retval = FALSE;
  152. if (dialog_obj != NULL) {
  153. retval = dialog_obj->Pane_Message_Proc (message, wparam, lparam);
  154. }
  155. //
  156. // Cleanup the framework
  157. //
  158. if (message == WM_DESTROY) {
  159. ::RemoveProp (wnd, "DIALOG_OBJ");
  160. }
  161. return retval;
  162. }
  163. ////////////////////////////////////////////////////////////////////////////////////////
  164. //
  165. // Pane_Message_Proc
  166. //
  167. ////////////////////////////////////////////////////////////////////////////////////////
  168. BOOL
  169. PresetExportOptionsDialogClass::Pane_Message_Proc
  170. (
  171. UINT message,
  172. WPARAM wparam,
  173. LPARAM lparam
  174. )
  175. {
  176. BOOL retval = FALSE;
  177. switch (message)
  178. {
  179. case WM_CUSTEDIT_ENTER:
  180. switch (wparam)
  181. {
  182. case IDC_RANGE_LOW_EDIT:
  183. {
  184. //
  185. // Update the start frame
  186. //
  187. ICustEdit *edit_ctrl = GetICustEdit ((HWND)lparam);
  188. if (edit_ctrl != NULL) {
  189. Options->StartFrame = edit_ctrl->GetInt ();
  190. //
  191. // Bounds check the value
  192. //
  193. if (Options->StartFrame > Options->EndFrame) {
  194. Options->StartFrame = Options->EndFrame;
  195. }
  196. Update_Controls ();
  197. }
  198. }
  199. break;
  200. case IDC_RANGE_HIGH_EDIT:
  201. {
  202. //
  203. // Update the end frame
  204. //
  205. ICustEdit *edit_ctrl = GetICustEdit ((HWND)lparam);
  206. if (edit_ctrl != NULL) {
  207. Options->EndFrame = edit_ctrl->GetInt ();
  208. //
  209. // Bounds check the value
  210. //
  211. if (Options->EndFrame < Options->StartFrame) {
  212. Options->EndFrame = Options->StartFrame;
  213. }
  214. Update_Controls ();
  215. }
  216. }
  217. break;
  218. }
  219. break;
  220. case CC_SPINNER_BUTTONUP:
  221. {
  222. ISpinnerControl *spin_ctrl = (ISpinnerControl *)lparam;
  223. if (spin_ctrl != NULL) {
  224. switch (LOWORD (wparam))
  225. {
  226. //
  227. // Update the start frame
  228. //
  229. case IDC_RANGE_LOW_SPIN:
  230. Options->StartFrame = spin_ctrl->GetIVal ();
  231. //
  232. // Bounds check the value
  233. //
  234. if (Options->StartFrame > Options->EndFrame) {
  235. Options->StartFrame = Options->EndFrame;
  236. }
  237. Update_Controls ();
  238. break;
  239. //
  240. // Update the end frame
  241. //
  242. case IDC_RANGE_HIGH_SPIN:
  243. Options->EndFrame = spin_ctrl->GetIVal ();
  244. //
  245. // Bounds check the value
  246. //
  247. if (Options->EndFrame < Options->StartFrame) {
  248. Options->EndFrame = Options->StartFrame;
  249. }
  250. Update_Controls ();
  251. break;
  252. }
  253. }
  254. }
  255. break;
  256. case WM_COMMAND:
  257. {
  258. HWND control_wnd = reinterpret_cast <HWND> (lparam);
  259. bool update_controls = true;
  260. switch (LOWORD (wparam))
  261. {
  262. case IDC_EXPORT_MESH_SMOOTH_CHECK:
  263. Options->SmoothBetweenMeshes = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1);
  264. break;
  265. case IDC_EXPORT_MESH_AABTREES:
  266. Options->DisableExportAABTrees = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) != 1);
  267. break;
  268. #if 0
  269. case IDC_EXPORT_MESH_OPTIMIZE:
  270. Options->EnableOptimizeMeshData = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1);
  271. break;
  272. #endif
  273. case IDC_USE_SKELETON_CHECK:
  274. Options->LoadHierarchy = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1);
  275. break;
  276. case IDC_COMPRESS_ANIMATION_CHECK:
  277. Options->CompressAnimation = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1);
  278. break;
  279. case IDC_WHT_BROWSE_BUTTON:
  280. {
  281. OPENFILENAME ofn = { sizeof (OPENFILENAME), 0 };
  282. ofn.lpstrFilter = BROWSE_FILTER;
  283. ofn.nMaxFile = _MAX_PATH;
  284. ofn.nMaxFileTitle = _MAX_FNAME + _MAX_EXT;
  285. ofn.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT;
  286. ofn.lpstrDefExt = "wht";
  287. ofn.hwndOwner = Wnd;
  288. ofn.lpstrFile = Options->HierarchyFilename;
  289. if (::GetOpenFileName (&ofn)) {
  290. //
  291. // Get the relative path between the current export path
  292. // and the full file path to the hierarchy file:
  293. //
  294. Create_Relative_Path (Options->RelativeHierarchyFilename,
  295. W3dExportClass::CurrentExportPath,
  296. ofn.lpstrFile);
  297. }
  298. }
  299. break;
  300. case IDC_COMPRESSION_SETTINGS:
  301. {
  302. //
  303. // Display the compression options dialog
  304. //
  305. AnimationCompressionSettingsDialogClass dialog (MaxInterface, Wnd);
  306. dialog.Set_Options (Options);
  307. dialog.Do_Modal ();
  308. }
  309. break;
  310. case IDC_EXPORT_MESH_MAT_TO_TEXTURE:
  311. Options->EnableMaterialColorToTextureConversion = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1);
  312. break;
  313. default:
  314. update_controls = false;
  315. break;
  316. }
  317. if (update_controls) {
  318. Update_Controls ();
  319. }
  320. }
  321. break;
  322. }
  323. return retval;
  324. }
  325. ////////////////////////////////////////////////////////////////////////////////////////
  326. //
  327. // Message_Proc
  328. //
  329. ////////////////////////////////////////////////////////////////////////////////////////
  330. BOOL
  331. PresetExportOptionsDialogClass::Message_Proc
  332. (
  333. UINT message,
  334. WPARAM wparam,
  335. LPARAM lparam
  336. )
  337. {
  338. BOOL retval = FALSE;
  339. switch (message)
  340. {
  341. case WM_INITDIALOG:
  342. {
  343. //
  344. // Center the dialog
  345. //
  346. RECT parent_rect = { 0 };
  347. RECT rect = { 0 };
  348. ::GetWindowRect (ParentWnd, &parent_rect);
  349. ::GetWindowRect (Wnd, &rect);
  350. int width = parent_rect.right - parent_rect.left;
  351. int height = parent_rect.bottom - parent_rect.top;
  352. ::SetWindowPos ( Wnd, NULL,
  353. parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2),
  354. parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2),
  355. 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  356. //
  357. // Initialize the controls
  358. //
  359. Create_Settings_Panes ();
  360. Initialize_Controls ();
  361. Update_Controls ();
  362. Determine_Preset_Type ();
  363. retval = TRUE;
  364. }
  365. break;
  366. case WM_COMMAND:
  367. retval = On_Command (wparam, lparam);
  368. break;
  369. }
  370. return retval;
  371. }
  372. ////////////////////////////////////////////////////////////////////////////////////////
  373. //
  374. // On_Command
  375. //
  376. ////////////////////////////////////////////////////////////////////////////////////////
  377. BOOL
  378. PresetExportOptionsDialogClass::On_Command (WPARAM wparam, LPARAM lparam)
  379. {
  380. BOOL retval = FALSE;
  381. switch (LOWORD (wparam))
  382. {
  383. case IDC_HLOD_RADIO:
  384. Show_Settings_Pane (PANE_HLOD);
  385. break;
  386. case IDC_ANIM_HLOD_RADIO:
  387. Show_Settings_Pane (PANE_ANIM_HLOD);
  388. break;
  389. case IDC_ANIM_RADIO:
  390. Show_Settings_Pane (PANE_ANIM);
  391. break;
  392. case IDC_TERRAIN_RADIO:
  393. Show_Settings_Pane (PANE_TERRAIN);
  394. break;
  395. case IDC_SKELETON_RADIO:
  396. Show_Settings_Pane (PANE_SKELETON);
  397. break;
  398. case IDC_MESH_RADIO:
  399. Show_Settings_Pane (PANE_MESH);
  400. break;
  401. case IDCANCEL:
  402. ::memcpy (Options, &OrigOptions, sizeof (OrigOptions));
  403. EndDialog (Wnd, IDCANCEL);
  404. break;
  405. case IDOK:
  406. Save_Settings ();
  407. EndDialog (Wnd, IDOK);
  408. break;
  409. }
  410. return retval;
  411. }
  412. ////////////////////////////////////////////////////////////////////////////////////////
  413. //
  414. // Show_Settings_Pane
  415. //
  416. ////////////////////////////////////////////////////////////////////////////////////////
  417. void
  418. PresetExportOptionsDialogClass::Show_Settings_Pane (int pane_id)
  419. {
  420. if (pane_id != CurrentPane) {
  421. //
  422. // Show the new pane and hide the old pane
  423. //
  424. ::ShowWindow (PaneWnds[pane_id], SW_SHOW);
  425. if (CurrentPane >= 0) {
  426. ::ShowWindow (PaneWnds[CurrentPane], SW_HIDE);
  427. }
  428. CurrentPane = pane_id;
  429. }
  430. return ;
  431. }
  432. ////////////////////////////////////////////////////////////////////////////////////////
  433. //
  434. // Create_Settings_Panes
  435. //
  436. ////////////////////////////////////////////////////////////////////////////////////////
  437. void
  438. PresetExportOptionsDialogClass::Create_Settings_Panes (void)
  439. {
  440. PaneWnds[PANE_HLOD] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_HLOD),
  441. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  442. PaneWnds[PANE_ANIM_HLOD] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_ANIMATED_HLOD),
  443. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  444. PaneWnds[PANE_ANIM] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_ANIMATION),
  445. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  446. PaneWnds[PANE_TERRAIN] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_TERRAIN),
  447. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  448. PaneWnds[PANE_SKELETON] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_SKELETON),
  449. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  450. PaneWnds[PANE_MESH] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_MESH),
  451. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  452. //
  453. // Get the position and size of the group box the settings panes will be
  454. // displayed inside
  455. //
  456. RECT group_rect = { 0 };
  457. ::GetWindowRect (::GetDlgItem (Wnd, IDC_GROUP_BOX), &group_rect);
  458. ::ScreenToClient (Wnd, (LPPOINT)&group_rect);
  459. ::ScreenToClient (Wnd, ((LPPOINT)&group_rect) + 1);
  460. int width = group_rect.right - group_rect.left;
  461. int height = group_rect.bottom - group_rect.top;
  462. //
  463. // Loop over all the panes and make sure they are in the proper location
  464. //
  465. for (int index = 0; index < PANE_MAX; index ++) {
  466. HWND pane_wnd = PaneWnds[index];
  467. //
  468. // Get the size of this pane
  469. //
  470. RECT rect = { 0 };
  471. ::GetWindowRect (pane_wnd, &rect);
  472. //
  473. // Center the pane inside of the group box
  474. //
  475. ::SetWindowPos ( pane_wnd, ::GetDlgItem (Wnd, IDC_GROUP_BOX),
  476. group_rect.left + (width / 2) - ((rect.right - rect.left) / 2),
  477. group_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2),
  478. 0, 0, SWP_NOSIZE);
  479. }
  480. return ;
  481. }
  482. ////////////////////////////////////////////////////////////////////////////////////////
  483. //
  484. // Destroy_Settings_Panes
  485. //
  486. ////////////////////////////////////////////////////////////////////////////////////////
  487. void
  488. PresetExportOptionsDialogClass::Destroy_Settings_Panes (void)
  489. {
  490. //
  491. // Loop over all the panes and destroy them
  492. //
  493. for (int index = 0; index < PANE_MAX; index ++) {
  494. ::DestroyWindow (PaneWnds[index]);
  495. PaneWnds[index] = NULL;
  496. }
  497. return ;
  498. }
  499. ////////////////////////////////////////////////////////////////////////////////////////
  500. //
  501. // Determine_Preset_Type
  502. //
  503. ////////////////////////////////////////////////////////////////////////////////////////
  504. void
  505. PresetExportOptionsDialogClass::Determine_Preset_Type (void)
  506. {
  507. //
  508. // Examine the current options and try to determine which
  509. // preset best matches this configuration.
  510. //
  511. if (Options->EnableTerrainMode) {
  512. //
  513. // Select the terrain UI
  514. //
  515. Show_Settings_Pane (PANE_TERRAIN);
  516. SendDlgItemMessage (Wnd, IDC_TERRAIN_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  517. } else if (Options->ExportGeometry == false) {
  518. if (Options->ExportAnimation == false) {
  519. //
  520. // Select the skeleton UI
  521. //
  522. Show_Settings_Pane (PANE_SKELETON);
  523. SendDlgItemMessage (Wnd, IDC_SKELETON_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  524. } else {
  525. //
  526. // Select the anim UI
  527. //
  528. Show_Settings_Pane (PANE_ANIM);
  529. SendDlgItemMessage (Wnd, IDC_ANIM_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  530. }
  531. } else if (Options->ExportHierarchy == false && Options->LoadHierarchy == false) {
  532. //
  533. // Select the mesh UI
  534. //
  535. Show_Settings_Pane (PANE_MESH);
  536. SendDlgItemMessage (Wnd, IDC_MESH_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  537. } else if (Options->ExportAnimation == false) {
  538. //
  539. // Select the HLOD UI
  540. //
  541. Show_Settings_Pane (PANE_HLOD);
  542. SendDlgItemMessage (Wnd, IDC_HLOD_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  543. } else {
  544. //
  545. // Select the HLOD anim UI
  546. //
  547. Show_Settings_Pane (PANE_ANIM_HLOD);
  548. SendDlgItemMessage (Wnd, IDC_ANIM_HLOD_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  549. }
  550. return ;
  551. }
  552. ////////////////////////////////////////////////////////////////////////////////////////
  553. //
  554. // Initialize_Controls
  555. //
  556. ////////////////////////////////////////////////////////////////////////////////////////
  557. void
  558. PresetExportOptionsDialogClass::Initialize_Controls (void)
  559. {
  560. //
  561. // Check the review log file button if necessary
  562. //
  563. CheckDlgButton (Wnd, IDC_REVIEW_LOG, Options->ReviewLog);
  564. //
  565. // Precompute some of the animation data
  566. //
  567. int ticksperframe = ::GetTicksPerFrame();
  568. int startframe = MaxInterface->GetAnimRange ().Start () / ticksperframe;
  569. int endframe = MaxInterface->GetAnimRange ().End () / ticksperframe;
  570. //
  571. // Clamp the real options the same way the displayed values are clamped
  572. //
  573. if (startframe > Options->StartFrame) {
  574. Options->StartFrame = startframe;
  575. }
  576. if (endframe < Options->EndFrame) {
  577. Options->EndFrame = endframe;
  578. }
  579. //
  580. // Loop over all the panes and update any of the controls therein
  581. //
  582. for (int index = 0; index < PANE_MAX; index ++) {
  583. HWND pane_wnd = PaneWnds[index];
  584. //
  585. // Are there any animation controls on this pane to initialize?
  586. //
  587. if (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN) != NULL) {
  588. ISpinnerControl *low_spin = NULL;
  589. ISpinnerControl *high_spin = NULL;
  590. low_spin = ::SetupIntSpinner (pane_wnd, IDC_RANGE_LOW_SPIN, IDC_RANGE_LOW_EDIT,
  591. startframe, endframe, 0);
  592. high_spin = ::SetupIntSpinner (pane_wnd, IDC_RANGE_HIGH_SPIN, IDC_RANGE_HIGH_EDIT,
  593. startframe, endframe, 0);
  594. ::SetProp (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN), "ISpinnerControl", (HANDLE)low_spin);
  595. ::SetProp (::GetDlgItem (pane_wnd, IDC_RANGE_HIGH_SPIN), "ISpinnerControl", (HANDLE)high_spin);
  596. }
  597. }
  598. return ;
  599. }
  600. ////////////////////////////////////////////////////////////////////////////////////////
  601. //
  602. // Update_Controls
  603. //
  604. ////////////////////////////////////////////////////////////////////////////////////////
  605. void
  606. PresetExportOptionsDialogClass::Update_Controls (void)
  607. {
  608. //
  609. // Loop over all the panes and update any of the controls therein
  610. //
  611. for (int index = 0; index < PANE_MAX; index ++) {
  612. HWND pane_wnd = PaneWnds[index];
  613. //
  614. // Handle the check boxes
  615. //
  616. CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_SMOOTH_CHECK, Options->SmoothBetweenMeshes);
  617. CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_AABTREES, !Options->DisableExportAABTrees);
  618. #if ENABLE_MESH_OPTIMIZING
  619. CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_OPTIMIZE, Options->EnableOptimizeMeshData);
  620. #endif
  621. CheckDlgButton (pane_wnd, IDC_USE_SKELETON_CHECK, Options->LoadHierarchy);
  622. CheckDlgButton (pane_wnd, IDC_COMPRESS_ANIMATION_CHECK, Options->CompressAnimation);
  623. CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_MAT_TO_TEXTURE, Options->EnableMaterialColorToTextureConversion);
  624. //
  625. // Enable/disable the compression settings button
  626. //
  627. HWND compress_settings_btn = ::GetDlgItem (pane_wnd, IDC_COMPRESSION_SETTINGS);
  628. if (compress_settings_btn != NULL) {
  629. ::EnableWindow (compress_settings_btn, Options->CompressAnimation);
  630. }
  631. //
  632. // Setup the skeleton browse button
  633. //
  634. HWND skeleten_browse_btn = ::GetDlgItem (pane_wnd, IDC_WHT_BROWSE_BUTTON);
  635. if (skeleten_browse_btn != NULL) {
  636. //
  637. // Honor the relative path if it is present
  638. //
  639. if (Options->RelativeHierarchyFilename[0] != 0) {
  640. SetWindowText (skeleten_browse_btn, Options->RelativeHierarchyFilename);
  641. ::Create_Full_Path (Options->HierarchyFilename,
  642. W3dExportClass::CurrentExportPath,
  643. Options->RelativeHierarchyFilename);
  644. } else if (Options->HierarchyFilename[0] != 0) {
  645. SetWindowText (skeleten_browse_btn, Options->HierarchyFilename);
  646. ::Create_Relative_Path (Options->RelativeHierarchyFilename,
  647. W3dExportClass::CurrentExportPath,
  648. Options->HierarchyFilename);
  649. }
  650. //
  651. // Set the enable state of the window
  652. //
  653. ::EnableWindow (skeleten_browse_btn, Options->LoadHierarchy);
  654. }
  655. //
  656. // Are there any animation controls on this pane to update?
  657. //
  658. HWND low_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN);
  659. HWND high_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_HIGH_SPIN);
  660. if (low_spin_wnd != NULL && high_spin_wnd != NULL) {
  661. //
  662. // Peek at the spinner control objects
  663. //
  664. ISpinnerControl *low_spin = NULL;
  665. ISpinnerControl *high_spin = NULL;
  666. low_spin = (ISpinnerControl *)::GetProp (low_spin_wnd, "ISpinnerControl");
  667. high_spin = (ISpinnerControl *)::GetProp (high_spin_wnd, "ISpinnerControl");
  668. //
  669. // Update the spin controls
  670. //
  671. low_spin->SetValue (Options->StartFrame, FALSE);
  672. high_spin->SetValue (Options->EndFrame, FALSE);
  673. }
  674. }
  675. return ;
  676. }
  677. ////////////////////////////////////////////////////////////////////////////////////////
  678. //
  679. // Save_Settings
  680. //
  681. ////////////////////////////////////////////////////////////////////////////////////////
  682. void
  683. PresetExportOptionsDialogClass::Save_Settings (void)
  684. {
  685. //
  686. // Force settings that certain preset types need
  687. //
  688. if (::IsDlgButtonChecked (Wnd, IDC_TERRAIN_RADIO)) {
  689. //
  690. // Force some settings for the "Renegade Terrain" preset
  691. //
  692. Options->ExportHierarchy = true;
  693. Options->LoadHierarchy = false;
  694. Options->ExportAnimation = false;
  695. Options->ExportGeometry = true;
  696. Options->CompressAnimation = false;
  697. Options->ReduceAnimation = false;
  698. Options->EnableTerrainMode = true;
  699. Options->DisableExportAABTrees = false;
  700. Options->EnableMaterialColorToTextureConversion = false;
  701. } else if (::IsDlgButtonChecked (Wnd, IDC_SKELETON_RADIO)) {
  702. //
  703. // Force some settings for the "Skeleton" preset
  704. //
  705. Options->ExportHierarchy = true;
  706. Options->LoadHierarchy = false;
  707. Options->ExportAnimation = false;
  708. Options->ExportGeometry = false;
  709. Options->CompressAnimation = false;
  710. Options->ReduceAnimation = false;
  711. Options->EnableTerrainMode = false;
  712. Options->EnableOptimizeMeshData = false;
  713. Options->DisableExportAABTrees = true;
  714. Options->SmoothBetweenMeshes = false;
  715. Options->EnableTerrainMode = false;
  716. Options->EnableMaterialColorToTextureConversion = false;
  717. } else if (::IsDlgButtonChecked (Wnd, IDC_MESH_RADIO)) {
  718. //
  719. // Force some settings for the "Simple Mesh" preset
  720. //
  721. Options->ExportHierarchy = false;
  722. Options->LoadHierarchy = false;
  723. Options->ExportAnimation = false;
  724. Options->ExportGeometry = true;
  725. Options->CompressAnimation = false;
  726. Options->ReduceAnimation = false;
  727. Options->EnableTerrainMode = false;
  728. Options->EnableOptimizeMeshData = false;
  729. Options->SmoothBetweenMeshes = false;
  730. Options->EnableTerrainMode = false;
  731. } else if (::IsDlgButtonChecked (Wnd, IDC_HLOD_RADIO)) {
  732. //
  733. // Force some settings for the "Hierarchical Model" preset
  734. //
  735. Options->ExportHierarchy = !Options->LoadHierarchy;
  736. Options->ExportAnimation = false;
  737. Options->ExportGeometry = true;
  738. Options->CompressAnimation = false;
  739. Options->ReduceAnimation = false;
  740. Options->EnableTerrainMode = false;
  741. } else if (::IsDlgButtonChecked (Wnd, IDC_ANIM_HLOD_RADIO)) {
  742. //
  743. // Force some settings for the "Hierarchical Animated Model" preset
  744. //
  745. Options->ExportHierarchy = !Options->LoadHierarchy;
  746. Options->ExportAnimation = true;
  747. Options->ExportGeometry = true;
  748. Options->EnableTerrainMode = false;
  749. } else if (::IsDlgButtonChecked (Wnd, IDC_ANIM_RADIO)) {
  750. //
  751. // Force some settings for the "Pure Animation" preset
  752. //
  753. Options->ExportHierarchy = !Options->LoadHierarchy;
  754. Options->ExportAnimation = true;
  755. Options->ExportGeometry = false;
  756. Options->EnableTerrainMode = false;
  757. Options->EnableOptimizeMeshData = false;
  758. Options->DisableExportAABTrees = true;
  759. Options->SmoothBetweenMeshes = false;
  760. Options->EnableMaterialColorToTextureConversion = false;
  761. }
  762. //
  763. // Record the "Review Log File" option
  764. //
  765. Options->ReviewLog = (::IsDlgButtonChecked (Wnd, IDC_REVIEW_LOG) == 1);
  766. //
  767. // Check to see if anything has changed
  768. //
  769. if (::memcmp (Options, &OrigOptions, sizeof (OrigOptions)) != 0) {
  770. SetSaveRequiredFlag (true);
  771. }
  772. return ;
  773. }