| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Max2W3d *
- * *
- * $Archive:: /Commando/Code/Tools/max2w3d/animationcompressionsettings.cpp $*
- * *
- * Original Author:: Patrick Smith *
- * *
- * $Author:: Patrick $*
- * *
- * $Modtime:: 10/30/00 1:57p $*
- * *
- * $Revision:: 2 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "animationcompressionsettings.h"
- #include "dllmain.h"
- #include "resource.h"
- #include "w3dexp.h"
- ////////////////////////////////////////////////////////////////////////////////////////
- //
- // AnimationCompressionSettingsDialogClass
- //
- ////////////////////////////////////////////////////////////////////////////////////////
- AnimationCompressionSettingsDialogClass::AnimationCompressionSettingsDialogClass (Interface *maxinterface, HWND parent_wnd) :
- MaxInterface (maxinterface),
- Options (NULL),
- Wnd (NULL),
- ParentWnd (parent_wnd)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- //
- // ~AnimationCompressionSettingsDialogClass
- //
- ////////////////////////////////////////////////////////////////////////////////////////
- AnimationCompressionSettingsDialogClass::~AnimationCompressionSettingsDialogClass (void)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- //
- // Do_Modal
- //
- ////////////////////////////////////////////////////////////////////////////////////////
- int
- AnimationCompressionSettingsDialogClass::Do_Modal (void)
- {
- int retval = ::DialogBoxParam (AppInstance, MAKEINTRESOURCE (IDD_ANIMATION_COMPRESSION),
- ParentWnd, Real_Message_Proc, (LPARAM)this);
- return retval;
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- //
- // Real_Message_Proc
- //
- ////////////////////////////////////////////////////////////////////////////////////////
- BOOL CALLBACK
- AnimationCompressionSettingsDialogClass::Real_Message_Proc
- (
- HWND wnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam
- )
- {
- AnimationCompressionSettingsDialogClass *dialog_obj = NULL;
- //
- // Setup the framework we need so that the instance
- // can process the messages instead of this static callback.
- //
- if (message == WM_INITDIALOG) {
- dialog_obj = (AnimationCompressionSettingsDialogClass *)lparam;
- dialog_obj->Wnd = wnd;
- ::SetProp (wnd, "DIALOG_OBJ", (HANDLE)dialog_obj);
- } else {
- dialog_obj = (AnimationCompressionSettingsDialogClass *)::GetProp (wnd, "DIALOG_OBJ");
- }
- //
- // Allow the instance to handle the call
- //
- BOOL retval = FALSE;
- if (dialog_obj != NULL) {
- retval = dialog_obj->Message_Proc (message, wparam, lparam);
- }
- //
- // Cleanup the framework
- //
- if (message == WM_DESTROY) {
- ::RemoveProp (wnd, "DIALOG_OBJ");
- }
- return retval;
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- //
- // Message_Proc
- //
- ////////////////////////////////////////////////////////////////////////////////////////
- BOOL
- AnimationCompressionSettingsDialogClass::Message_Proc
- (
- UINT message,
- WPARAM wparam,
- LPARAM lparam
- )
- {
- BOOL retval = FALSE;
- switch (message)
- {
- case WM_INITDIALOG:
- {
- //
- // Center the dialog
- //
- RECT parent_rect = { 0 };
- RECT rect = { 0 };
- ::GetWindowRect (ParentWnd, &parent_rect);
- ::GetWindowRect (Wnd, &rect);
- int width = parent_rect.right - parent_rect.left;
- int height = parent_rect.bottom - parent_rect.top;
- ::SetWindowPos ( Wnd, NULL,
- parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2),
- parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2),
- 0, 0, SWP_NOZORDER | SWP_NOSIZE);
-
- //
- // Initialize the dialog controls
- //
- Initialize_Controls ();
- }
- break;
- case WM_COMMAND:
- {
- switch (LOWORD (wparam))
- {
- case IDCANCEL:
- EndDialog (Wnd, IDCANCEL);
- break;
- case IDOK:
- Save_Settings ();
- EndDialog (Wnd, IDOK);
- break;
- }
- }
- break;
- }
- return retval;
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- //
- // Initialize_Controls
- //
- ////////////////////////////////////////////////////////////////////////////////////////
- void
- AnimationCompressionSettingsDialogClass::Initialize_Controls (void)
- {
- SetCheckBox (Wnd, IDC_REDUCE_ANIMATION_CHECK, Options->ReduceAnimation);
- char string[128] = { 0 };
- //
- // Populate the reduction percent combo box
- //
- HWND percent_combo = ::GetDlgItem (Wnd, IDC_REDUCE_ANIMATION_COMBO);
- for (int index = 1; index < 100; index ++) {
- sprintf (string, "%d", index);
- ComboBox_AddString (percent_combo, string);
- }
- //
- // Populate the animation type combo box
- //
- HWND flavor_combo = ::GetDlgItem (Wnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO);
- ComboBox_AddString (flavor_combo, "TimeCoded");
- ComboBox_AddString (flavor_combo, "Adaptive Delta");
-
- //
- // Bounds check the parameters
- //
- if ((Options->ReduceAnimationPercent < 1) || (Options->ReduceAnimationPercent > 99)) {
- Options->ReduceAnimationPercent = 50;
- }
- if ((Options->CompressAnimationFlavor < 0) || (Options->CompressAnimationFlavor >= ANIM_FLAVOR_VALID)) {
- Options->CompressAnimationFlavor = 0;
- }
- //
- // Select the correct entries in the combo boxes
- //
- ComboBox_SetCurSel (percent_combo, Options->ReduceAnimationPercent - 1);
- ComboBox_SetCurSel (flavor_combo, Options->CompressAnimationFlavor);
- //
- // Fill in the error fields
- //
- ::sprintf (string, "%f", Options->CompressAnimationTranslationError);
- ::SetDlgItemText (Wnd, IDC_MAX_TRANS_ERROR_EDIT, string);
- ::sprintf (string, "%f", Options->CompressAnimationRotationError);
- ::SetDlgItemText (Wnd, IDC_MAX_ROT_ERROR_EDIT, string);
- return ;
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- //
- // Save_Settings
- //
- ////////////////////////////////////////////////////////////////////////////////////////
- void
- AnimationCompressionSettingsDialogClass::Save_Settings (void)
- {
- //
- // Read the compression type setting
- //
- int flavor = ComboBox_GetCurSel (::GetDlgItem (Wnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO));
- Options->CompressAnimationFlavor = flavor;
- //
- // Determine whether or not we want to force reduction
- //
- Options->ReduceAnimation = (IsDlgButtonChecked (Wnd, IDC_REDUCE_ANIMATION_CHECK) == 1);
- //
- // Read the reduction percent setting
- //
- int reduce_percent = ComboBox_GetCurSel (::GetDlgItem (Wnd, IDC_REDUCE_ANIMATION_COMBO)) + 1;
- Options->ReduceAnimationPercent = reduce_percent;
- //
- // Read the amount of compression error we'll allow in the translational component
- //
- char string[128];
- ::GetDlgItemText (Wnd, IDC_MAX_TRANS_ERROR_EDIT, string, sizeof (string));
- float trans_error = ::atof (string);
- Options->CompressAnimationTranslationError = trans_error;
- //
- // Read the amount of compression error we'll allow in the rotational component
- //
- ::GetDlgItemText (Wnd, IDC_MAX_ROT_ERROR_EDIT, string, sizeof (string));
- float rot_error = ::atof (string);
- Options->CompressAnimationRotationError = rot_error;
- return ;
- }
|