animationcompressionsettings.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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/animationcompressionsettings.cpp $*
  25. * *
  26. * Original Author:: Patrick Smith *
  27. * *
  28. * $Author:: Patrick $*
  29. * *
  30. * $Modtime:: 10/30/00 1:57p $*
  31. * *
  32. * $Revision:: 2 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #include "animationcompressionsettings.h"
  38. #include "dllmain.h"
  39. #include "resource.h"
  40. #include "w3dexp.h"
  41. ////////////////////////////////////////////////////////////////////////////////////////
  42. //
  43. // AnimationCompressionSettingsDialogClass
  44. //
  45. ////////////////////////////////////////////////////////////////////////////////////////
  46. AnimationCompressionSettingsDialogClass::AnimationCompressionSettingsDialogClass (Interface *maxinterface, HWND parent_wnd) :
  47. MaxInterface (maxinterface),
  48. Options (NULL),
  49. Wnd (NULL),
  50. ParentWnd (parent_wnd)
  51. {
  52. return ;
  53. }
  54. ////////////////////////////////////////////////////////////////////////////////////////
  55. //
  56. // ~AnimationCompressionSettingsDialogClass
  57. //
  58. ////////////////////////////////////////////////////////////////////////////////////////
  59. AnimationCompressionSettingsDialogClass::~AnimationCompressionSettingsDialogClass (void)
  60. {
  61. return ;
  62. }
  63. ////////////////////////////////////////////////////////////////////////////////////////
  64. //
  65. // Do_Modal
  66. //
  67. ////////////////////////////////////////////////////////////////////////////////////////
  68. int
  69. AnimationCompressionSettingsDialogClass::Do_Modal (void)
  70. {
  71. int retval = ::DialogBoxParam (AppInstance, MAKEINTRESOURCE (IDD_ANIMATION_COMPRESSION),
  72. ParentWnd, Real_Message_Proc, (LPARAM)this);
  73. return retval;
  74. }
  75. ////////////////////////////////////////////////////////////////////////////////////////
  76. //
  77. // Real_Message_Proc
  78. //
  79. ////////////////////////////////////////////////////////////////////////////////////////
  80. BOOL CALLBACK
  81. AnimationCompressionSettingsDialogClass::Real_Message_Proc
  82. (
  83. HWND wnd,
  84. UINT message,
  85. WPARAM wparam,
  86. LPARAM lparam
  87. )
  88. {
  89. AnimationCompressionSettingsDialogClass *dialog_obj = NULL;
  90. //
  91. // Setup the framework we need so that the instance
  92. // can process the messages instead of this static callback.
  93. //
  94. if (message == WM_INITDIALOG) {
  95. dialog_obj = (AnimationCompressionSettingsDialogClass *)lparam;
  96. dialog_obj->Wnd = wnd;
  97. ::SetProp (wnd, "DIALOG_OBJ", (HANDLE)dialog_obj);
  98. } else {
  99. dialog_obj = (AnimationCompressionSettingsDialogClass *)::GetProp (wnd, "DIALOG_OBJ");
  100. }
  101. //
  102. // Allow the instance to handle the call
  103. //
  104. BOOL retval = FALSE;
  105. if (dialog_obj != NULL) {
  106. retval = dialog_obj->Message_Proc (message, wparam, lparam);
  107. }
  108. //
  109. // Cleanup the framework
  110. //
  111. if (message == WM_DESTROY) {
  112. ::RemoveProp (wnd, "DIALOG_OBJ");
  113. }
  114. return retval;
  115. }
  116. ////////////////////////////////////////////////////////////////////////////////////////
  117. //
  118. // Message_Proc
  119. //
  120. ////////////////////////////////////////////////////////////////////////////////////////
  121. BOOL
  122. AnimationCompressionSettingsDialogClass::Message_Proc
  123. (
  124. UINT message,
  125. WPARAM wparam,
  126. LPARAM lparam
  127. )
  128. {
  129. BOOL retval = FALSE;
  130. switch (message)
  131. {
  132. case WM_INITDIALOG:
  133. {
  134. //
  135. // Center the dialog
  136. //
  137. RECT parent_rect = { 0 };
  138. RECT rect = { 0 };
  139. ::GetWindowRect (ParentWnd, &parent_rect);
  140. ::GetWindowRect (Wnd, &rect);
  141. int width = parent_rect.right - parent_rect.left;
  142. int height = parent_rect.bottom - parent_rect.top;
  143. ::SetWindowPos ( Wnd, NULL,
  144. parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2),
  145. parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2),
  146. 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  147. //
  148. // Initialize the dialog controls
  149. //
  150. Initialize_Controls ();
  151. }
  152. break;
  153. case WM_COMMAND:
  154. {
  155. switch (LOWORD (wparam))
  156. {
  157. case IDCANCEL:
  158. EndDialog (Wnd, IDCANCEL);
  159. break;
  160. case IDOK:
  161. Save_Settings ();
  162. EndDialog (Wnd, IDOK);
  163. break;
  164. }
  165. }
  166. break;
  167. }
  168. return retval;
  169. }
  170. ////////////////////////////////////////////////////////////////////////////////////////
  171. //
  172. // Initialize_Controls
  173. //
  174. ////////////////////////////////////////////////////////////////////////////////////////
  175. void
  176. AnimationCompressionSettingsDialogClass::Initialize_Controls (void)
  177. {
  178. SetCheckBox (Wnd, IDC_REDUCE_ANIMATION_CHECK, Options->ReduceAnimation);
  179. char string[128] = { 0 };
  180. //
  181. // Populate the reduction percent combo box
  182. //
  183. HWND percent_combo = ::GetDlgItem (Wnd, IDC_REDUCE_ANIMATION_COMBO);
  184. for (int index = 1; index < 100; index ++) {
  185. sprintf (string, "%d", index);
  186. ComboBox_AddString (percent_combo, string);
  187. }
  188. //
  189. // Populate the animation type combo box
  190. //
  191. HWND flavor_combo = ::GetDlgItem (Wnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO);
  192. ComboBox_AddString (flavor_combo, "TimeCoded");
  193. ComboBox_AddString (flavor_combo, "Adaptive Delta");
  194. //
  195. // Bounds check the parameters
  196. //
  197. if ((Options->ReduceAnimationPercent < 1) || (Options->ReduceAnimationPercent > 99)) {
  198. Options->ReduceAnimationPercent = 50;
  199. }
  200. if ((Options->CompressAnimationFlavor < 0) || (Options->CompressAnimationFlavor >= ANIM_FLAVOR_VALID)) {
  201. Options->CompressAnimationFlavor = 0;
  202. }
  203. //
  204. // Select the correct entries in the combo boxes
  205. //
  206. ComboBox_SetCurSel (percent_combo, Options->ReduceAnimationPercent - 1);
  207. ComboBox_SetCurSel (flavor_combo, Options->CompressAnimationFlavor);
  208. //
  209. // Fill in the error fields
  210. //
  211. ::sprintf (string, "%f", Options->CompressAnimationTranslationError);
  212. ::SetDlgItemText (Wnd, IDC_MAX_TRANS_ERROR_EDIT, string);
  213. ::sprintf (string, "%f", Options->CompressAnimationRotationError);
  214. ::SetDlgItemText (Wnd, IDC_MAX_ROT_ERROR_EDIT, string);
  215. return ;
  216. }
  217. ////////////////////////////////////////////////////////////////////////////////////////
  218. //
  219. // Save_Settings
  220. //
  221. ////////////////////////////////////////////////////////////////////////////////////////
  222. void
  223. AnimationCompressionSettingsDialogClass::Save_Settings (void)
  224. {
  225. //
  226. // Read the compression type setting
  227. //
  228. int flavor = ComboBox_GetCurSel (::GetDlgItem (Wnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO));
  229. Options->CompressAnimationFlavor = flavor;
  230. //
  231. // Determine whether or not we want to force reduction
  232. //
  233. Options->ReduceAnimation = (IsDlgButtonChecked (Wnd, IDC_REDUCE_ANIMATION_CHECK) == 1);
  234. //
  235. // Read the reduction percent setting
  236. //
  237. int reduce_percent = ComboBox_GetCurSel (::GetDlgItem (Wnd, IDC_REDUCE_ANIMATION_COMBO)) + 1;
  238. Options->ReduceAnimationPercent = reduce_percent;
  239. //
  240. // Read the amount of compression error we'll allow in the translational component
  241. //
  242. char string[128];
  243. ::GetDlgItemText (Wnd, IDC_MAX_TRANS_ERROR_EDIT, string, sizeof (string));
  244. float trans_error = ::atof (string);
  245. Options->CompressAnimationTranslationError = trans_error;
  246. //
  247. // Read the amount of compression error we'll allow in the rotational component
  248. //
  249. ::GetDlgItemText (Wnd, IDC_MAX_ROT_ERROR_EDIT, string, sizeof (string));
  250. float rot_error = ::atof (string);
  251. Options->CompressAnimationRotationError = rot_error;
  252. return ;
  253. }