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