presetexportoptionsdialog.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  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. *** 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. default:
  311. update_controls = false;
  312. break;
  313. }
  314. if (update_controls) {
  315. Update_Controls ();
  316. }
  317. }
  318. break;
  319. }
  320. return retval;
  321. }
  322. ////////////////////////////////////////////////////////////////////////////////////////
  323. //
  324. // Message_Proc
  325. //
  326. ////////////////////////////////////////////////////////////////////////////////////////
  327. BOOL
  328. PresetExportOptionsDialogClass::Message_Proc
  329. (
  330. UINT message,
  331. WPARAM wparam,
  332. LPARAM lparam
  333. )
  334. {
  335. BOOL retval = FALSE;
  336. switch (message)
  337. {
  338. case WM_INITDIALOG:
  339. {
  340. //
  341. // Center the dialog
  342. //
  343. RECT parent_rect = { 0 };
  344. RECT rect = { 0 };
  345. ::GetWindowRect (ParentWnd, &parent_rect);
  346. ::GetWindowRect (Wnd, &rect);
  347. int width = parent_rect.right - parent_rect.left;
  348. int height = parent_rect.bottom - parent_rect.top;
  349. ::SetWindowPos ( Wnd, NULL,
  350. parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2),
  351. parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2),
  352. 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  353. //
  354. // Initialize the controls
  355. //
  356. Create_Settings_Panes ();
  357. Initialize_Controls ();
  358. Update_Controls ();
  359. Determine_Preset_Type ();
  360. retval = TRUE;
  361. }
  362. break;
  363. case WM_COMMAND:
  364. retval = On_Command (wparam, lparam);
  365. break;
  366. }
  367. return retval;
  368. }
  369. ////////////////////////////////////////////////////////////////////////////////////////
  370. //
  371. // On_Command
  372. //
  373. ////////////////////////////////////////////////////////////////////////////////////////
  374. BOOL
  375. PresetExportOptionsDialogClass::On_Command (WPARAM wparam, LPARAM lparam)
  376. {
  377. BOOL retval = FALSE;
  378. switch (LOWORD (wparam))
  379. {
  380. case IDC_HLOD_RADIO:
  381. Show_Settings_Pane (PANE_HLOD);
  382. break;
  383. case IDC_ANIM_HLOD_RADIO:
  384. Show_Settings_Pane (PANE_ANIM_HLOD);
  385. break;
  386. case IDC_ANIM_RADIO:
  387. Show_Settings_Pane (PANE_ANIM);
  388. break;
  389. case IDC_TERRAIN_RADIO:
  390. Show_Settings_Pane (PANE_TERRAIN);
  391. break;
  392. case IDC_SKELETON_RADIO:
  393. Show_Settings_Pane (PANE_SKELETON);
  394. break;
  395. case IDC_MESH_RADIO:
  396. Show_Settings_Pane (PANE_MESH);
  397. break;
  398. case IDCANCEL:
  399. ::memcpy (Options, &OrigOptions, sizeof (OrigOptions));
  400. EndDialog (Wnd, IDCANCEL);
  401. break;
  402. case IDOK:
  403. Save_Settings ();
  404. EndDialog (Wnd, IDOK);
  405. break;
  406. }
  407. return retval;
  408. }
  409. ////////////////////////////////////////////////////////////////////////////////////////
  410. //
  411. // Show_Settings_Pane
  412. //
  413. ////////////////////////////////////////////////////////////////////////////////////////
  414. void
  415. PresetExportOptionsDialogClass::Show_Settings_Pane (int pane_id)
  416. {
  417. if (pane_id != CurrentPane) {
  418. //
  419. // Show the new pane and hide the old pane
  420. //
  421. ::ShowWindow (PaneWnds[pane_id], SW_SHOW);
  422. if (CurrentPane >= 0) {
  423. ::ShowWindow (PaneWnds[CurrentPane], SW_HIDE);
  424. }
  425. CurrentPane = pane_id;
  426. }
  427. return ;
  428. }
  429. ////////////////////////////////////////////////////////////////////////////////////////
  430. //
  431. // Create_Settings_Panes
  432. //
  433. ////////////////////////////////////////////////////////////////////////////////////////
  434. void
  435. PresetExportOptionsDialogClass::Create_Settings_Panes (void)
  436. {
  437. PaneWnds[PANE_HLOD] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_HLOD),
  438. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  439. PaneWnds[PANE_ANIM_HLOD] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_ANIMATED_HLOD),
  440. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  441. PaneWnds[PANE_ANIM] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_ANIMATION),
  442. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  443. PaneWnds[PANE_TERRAIN] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_TERRAIN),
  444. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  445. PaneWnds[PANE_SKELETON] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_SKELETON),
  446. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  447. PaneWnds[PANE_MESH] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_MESH),
  448. Wnd, Settings_Pane_Message_Proc, (LPARAM)this);
  449. //
  450. // Get the position and size of the group box the settings panes will be
  451. // displayed inside
  452. //
  453. RECT group_rect = { 0 };
  454. ::GetWindowRect (::GetDlgItem (Wnd, IDC_GROUP_BOX), &group_rect);
  455. ::ScreenToClient (Wnd, (LPPOINT)&group_rect);
  456. ::ScreenToClient (Wnd, ((LPPOINT)&group_rect) + 1);
  457. int width = group_rect.right - group_rect.left;
  458. int height = group_rect.bottom - group_rect.top;
  459. //
  460. // Loop over all the panes and make sure they are in the proper location
  461. //
  462. for (int index = 0; index < PANE_MAX; index ++) {
  463. HWND pane_wnd = PaneWnds[index];
  464. //
  465. // Get the size of this pane
  466. //
  467. RECT rect = { 0 };
  468. ::GetWindowRect (pane_wnd, &rect);
  469. //
  470. // Center the pane inside of the group box
  471. //
  472. ::SetWindowPos ( pane_wnd, ::GetDlgItem (Wnd, IDC_GROUP_BOX),
  473. group_rect.left + (width / 2) - ((rect.right - rect.left) / 2),
  474. group_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2),
  475. 0, 0, SWP_NOSIZE);
  476. }
  477. return ;
  478. }
  479. ////////////////////////////////////////////////////////////////////////////////////////
  480. //
  481. // Destroy_Settings_Panes
  482. //
  483. ////////////////////////////////////////////////////////////////////////////////////////
  484. void
  485. PresetExportOptionsDialogClass::Destroy_Settings_Panes (void)
  486. {
  487. //
  488. // Loop over all the panes and destroy them
  489. //
  490. for (int index = 0; index < PANE_MAX; index ++) {
  491. ::DestroyWindow (PaneWnds[index]);
  492. PaneWnds[index] = NULL;
  493. }
  494. return ;
  495. }
  496. ////////////////////////////////////////////////////////////////////////////////////////
  497. //
  498. // Determine_Preset_Type
  499. //
  500. ////////////////////////////////////////////////////////////////////////////////////////
  501. void
  502. PresetExportOptionsDialogClass::Determine_Preset_Type (void)
  503. {
  504. //
  505. // Examine the current options and try to determine which
  506. // preset best matches this configuration.
  507. //
  508. if (Options->EnableTerrainMode) {
  509. //
  510. // Select the terrain UI
  511. //
  512. Show_Settings_Pane (PANE_TERRAIN);
  513. SendDlgItemMessage (Wnd, IDC_TERRAIN_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  514. } else if (Options->ExportGeometry == false) {
  515. if (Options->ExportAnimation == false) {
  516. //
  517. // Select the skeleton UI
  518. //
  519. Show_Settings_Pane (PANE_SKELETON);
  520. SendDlgItemMessage (Wnd, IDC_SKELETON_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  521. } else {
  522. //
  523. // Select the anim UI
  524. //
  525. Show_Settings_Pane (PANE_ANIM);
  526. SendDlgItemMessage (Wnd, IDC_ANIM_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  527. }
  528. } else if (Options->ExportHierarchy == false && Options->LoadHierarchy == false) {
  529. //
  530. // Select the mesh UI
  531. //
  532. Show_Settings_Pane (PANE_MESH);
  533. SendDlgItemMessage (Wnd, IDC_MESH_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  534. } else if (Options->ExportAnimation == false) {
  535. //
  536. // Select the HLOD UI
  537. //
  538. Show_Settings_Pane (PANE_HLOD);
  539. SendDlgItemMessage (Wnd, IDC_HLOD_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  540. } else {
  541. //
  542. // Select the HLOD anim UI
  543. //
  544. Show_Settings_Pane (PANE_ANIM_HLOD);
  545. SendDlgItemMessage (Wnd, IDC_ANIM_HLOD_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L);
  546. }
  547. return ;
  548. }
  549. ////////////////////////////////////////////////////////////////////////////////////////
  550. //
  551. // Initialize_Controls
  552. //
  553. ////////////////////////////////////////////////////////////////////////////////////////
  554. void
  555. PresetExportOptionsDialogClass::Initialize_Controls (void)
  556. {
  557. //
  558. // Check the review log file button if necessary
  559. //
  560. CheckDlgButton (Wnd, IDC_REVIEW_LOG, Options->ReviewLog);
  561. //
  562. // Precompute some of the animation data
  563. //
  564. int ticksperframe = ::GetTicksPerFrame();
  565. int startframe = MaxInterface->GetAnimRange ().Start () / ticksperframe;
  566. int endframe = MaxInterface->GetAnimRange ().End () / ticksperframe;
  567. //
  568. // Clamp the real options the same way the displayed values are clamped
  569. //
  570. if (startframe > Options->StartFrame) {
  571. Options->StartFrame = startframe;
  572. }
  573. if (endframe < Options->EndFrame) {
  574. Options->EndFrame = endframe;
  575. }
  576. //
  577. // Loop over all the panes and update any of the controls therein
  578. //
  579. for (int index = 0; index < PANE_MAX; index ++) {
  580. HWND pane_wnd = PaneWnds[index];
  581. //
  582. // Are there any animation controls on this pane to initialize?
  583. //
  584. if (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN) != NULL) {
  585. ISpinnerControl *low_spin = NULL;
  586. ISpinnerControl *high_spin = NULL;
  587. low_spin = ::SetupIntSpinner (pane_wnd, IDC_RANGE_LOW_SPIN, IDC_RANGE_LOW_EDIT,
  588. startframe, endframe, 0);
  589. high_spin = ::SetupIntSpinner (pane_wnd, IDC_RANGE_HIGH_SPIN, IDC_RANGE_HIGH_EDIT,
  590. startframe, endframe, 0);
  591. ::SetProp (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN), "ISpinnerControl", (HANDLE)low_spin);
  592. ::SetProp (::GetDlgItem (pane_wnd, IDC_RANGE_HIGH_SPIN), "ISpinnerControl", (HANDLE)high_spin);
  593. }
  594. }
  595. return ;
  596. }
  597. ////////////////////////////////////////////////////////////////////////////////////////
  598. //
  599. // Update_Controls
  600. //
  601. ////////////////////////////////////////////////////////////////////////////////////////
  602. void
  603. PresetExportOptionsDialogClass::Update_Controls (void)
  604. {
  605. //
  606. // Loop over all the panes and update any of the controls therein
  607. //
  608. for (int index = 0; index < PANE_MAX; index ++) {
  609. HWND pane_wnd = PaneWnds[index];
  610. //
  611. // Handle the check boxes
  612. //
  613. CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_SMOOTH_CHECK, Options->SmoothBetweenMeshes);
  614. CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_AABTREES, !Options->DisableExportAABTrees);
  615. #if ENABLE_MESH_OPTIMIZING
  616. CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_OPTIMIZE, Options->EnableOptimizeMeshData);
  617. #endif
  618. CheckDlgButton (pane_wnd, IDC_USE_SKELETON_CHECK, Options->LoadHierarchy);
  619. CheckDlgButton (pane_wnd, IDC_COMPRESS_ANIMATION_CHECK, Options->CompressAnimation);
  620. //
  621. // Enable/disable the compression settings button
  622. //
  623. HWND compress_settings_btn = ::GetDlgItem (pane_wnd, IDC_COMPRESSION_SETTINGS);
  624. if (compress_settings_btn != NULL) {
  625. ::EnableWindow (compress_settings_btn, Options->CompressAnimation);
  626. }
  627. //
  628. // Setup the skeleton browse button
  629. //
  630. HWND skeleten_browse_btn = ::GetDlgItem (pane_wnd, IDC_WHT_BROWSE_BUTTON);
  631. if (skeleten_browse_btn != NULL) {
  632. //
  633. // Honor the relative path if it is present
  634. //
  635. if (Options->RelativeHierarchyFilename[0] != 0) {
  636. SetWindowText (skeleten_browse_btn, Options->RelativeHierarchyFilename);
  637. ::Create_Full_Path (Options->HierarchyFilename,
  638. W3dExportClass::CurrentExportPath,
  639. Options->RelativeHierarchyFilename);
  640. } else if (Options->HierarchyFilename[0] != 0) {
  641. SetWindowText (skeleten_browse_btn, Options->HierarchyFilename);
  642. ::Create_Relative_Path (Options->RelativeHierarchyFilename,
  643. W3dExportClass::CurrentExportPath,
  644. Options->HierarchyFilename);
  645. }
  646. //
  647. // Set the enable state of the window
  648. //
  649. ::EnableWindow (skeleten_browse_btn, Options->LoadHierarchy);
  650. }
  651. //
  652. // Are there any animation controls on this pane to update?
  653. //
  654. HWND low_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN);
  655. HWND high_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_HIGH_SPIN);
  656. if (low_spin_wnd != NULL && high_spin_wnd != NULL) {
  657. //
  658. // Peek at the spinner control objects
  659. //
  660. ISpinnerControl *low_spin = NULL;
  661. ISpinnerControl *high_spin = NULL;
  662. low_spin = (ISpinnerControl *)::GetProp (low_spin_wnd, "ISpinnerControl");
  663. high_spin = (ISpinnerControl *)::GetProp (high_spin_wnd, "ISpinnerControl");
  664. //
  665. // Update the spin controls
  666. //
  667. low_spin->SetValue (Options->StartFrame, FALSE);
  668. high_spin->SetValue (Options->EndFrame, FALSE);
  669. }
  670. }
  671. return ;
  672. }
  673. ////////////////////////////////////////////////////////////////////////////////////////
  674. //
  675. // Save_Settings
  676. //
  677. ////////////////////////////////////////////////////////////////////////////////////////
  678. void
  679. PresetExportOptionsDialogClass::Save_Settings (void)
  680. {
  681. //
  682. // Force settings that certain preset types need
  683. //
  684. if (::IsDlgButtonChecked (Wnd, IDC_TERRAIN_RADIO)) {
  685. //
  686. // Force some settings for the "Renegade Terrain" preset
  687. //
  688. Options->ExportHierarchy = true;
  689. Options->LoadHierarchy = false;
  690. Options->ExportAnimation = false;
  691. Options->ExportGeometry = true;
  692. Options->CompressAnimation = false;
  693. Options->ReduceAnimation = false;
  694. Options->EnableTerrainMode = true;
  695. Options->DisableExportAABTrees = false;
  696. } else if (::IsDlgButtonChecked (Wnd, IDC_SKELETON_RADIO)) {
  697. //
  698. // Force some settings for the "Skeleton" preset
  699. //
  700. Options->ExportHierarchy = true;
  701. Options->LoadHierarchy = false;
  702. Options->ExportAnimation = false;
  703. Options->ExportGeometry = false;
  704. Options->CompressAnimation = false;
  705. Options->ReduceAnimation = false;
  706. Options->EnableTerrainMode = false;
  707. Options->EnableOptimizeMeshData = false;
  708. Options->DisableExportAABTrees = true;
  709. Options->SmoothBetweenMeshes = false;
  710. Options->EnableTerrainMode = false;
  711. } else if (::IsDlgButtonChecked (Wnd, IDC_MESH_RADIO)) {
  712. //
  713. // Force some settings for the "Simple Mesh" preset
  714. //
  715. Options->ExportHierarchy = false;
  716. Options->LoadHierarchy = false;
  717. Options->ExportAnimation = false;
  718. Options->ExportGeometry = true;
  719. Options->CompressAnimation = false;
  720. Options->ReduceAnimation = false;
  721. Options->EnableTerrainMode = false;
  722. Options->EnableOptimizeMeshData = false;
  723. Options->SmoothBetweenMeshes = false;
  724. Options->EnableTerrainMode = false;
  725. } else if (::IsDlgButtonChecked (Wnd, IDC_HLOD_RADIO)) {
  726. //
  727. // Force some settings for the "Hierarchical Model" preset
  728. //
  729. Options->ExportHierarchy = !Options->LoadHierarchy;
  730. Options->ExportAnimation = false;
  731. Options->ExportGeometry = true;
  732. Options->CompressAnimation = false;
  733. Options->ReduceAnimation = false;
  734. Options->EnableTerrainMode = false;
  735. } else if (::IsDlgButtonChecked (Wnd, IDC_ANIM_HLOD_RADIO)) {
  736. //
  737. // Force some settings for the "Hierarchical Animated Model" preset
  738. //
  739. Options->ExportHierarchy = !Options->LoadHierarchy;
  740. Options->ExportAnimation = true;
  741. Options->ExportGeometry = true;
  742. Options->EnableTerrainMode = false;
  743. } else if (::IsDlgButtonChecked (Wnd, IDC_ANIM_RADIO)) {
  744. //
  745. // Force some settings for the "Pure Animation" preset
  746. //
  747. Options->ExportHierarchy = !Options->LoadHierarchy;
  748. Options->ExportAnimation = true;
  749. Options->ExportGeometry = false;
  750. Options->EnableTerrainMode = false;
  751. Options->EnableOptimizeMeshData = false;
  752. Options->DisableExportAABTrees = true;
  753. Options->SmoothBetweenMeshes = false;
  754. }
  755. //
  756. // Record the "Review Log File" option
  757. //
  758. Options->ReviewLog = (::IsDlgButtonChecked (Wnd, IDC_REVIEW_LOG) == 1);
  759. //
  760. // Check to see if anything has changed
  761. //
  762. if (::memcmp (Options, &OrigOptions, sizeof (OrigOptions)) != 0) {
  763. SetSaveRequiredFlag (true);
  764. }
  765. return ;
  766. }