| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- /*
- ** Command & Conquer Renegade(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 : W3DView *
- * *
- * $Archive:: /Commando/Code/Tools/W3DView/VolumeRandomDialog.cpp $Modtime:: $*
- * *
- * $Revision:: 2 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "Stdafx.H"
- #include "W3DView.H"
- #include "VolumeRandomDialog.H"
- #include "V3_Rnd.H"
- #include "Utils.H"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- ////////////////////////////////////////////////////////////////////
- //
- // VolumeRandomDialogClass
- //
- ////////////////////////////////////////////////////////////////////
- VolumeRandomDialogClass::VolumeRandomDialogClass (Vector3Randomizer *randomizer, CWnd *pParent)
- : m_Randomizer (randomizer),
- CDialog (VolumeRandomDialogClass::IDD, pParent)
- {
- //{{AFX_DATA_INIT(VolumeRandomDialogClass)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- //
- // DoDataExchange
- //
- ////////////////////////////////////////////////////////////////////
- void
- VolumeRandomDialogClass::DoDataExchange (CDataExchange *pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(VolumeRandomDialogClass)
- DDX_Control(pDX, IDC_SPHERE_RADIUS_SPIN, m_SphereRadiusSpin);
- DDX_Control(pDX, IDC_CYLINDER_RADIUS_SPIN, m_CylinderRadiusSpin);
- DDX_Control(pDX, IDC_CYLINDER_HEIGHT_SPIN, m_CylinderHeightSpin);
- DDX_Control(pDX, IDC_BOX_Z_SPIN, m_BoxZSpin);
- DDX_Control(pDX, IDC_BOX_Y_SPIN, m_BoxYSpin);
- DDX_Control(pDX, IDC_BOX_X_SPIN, m_BoxXSpin);
- //}}AFX_DATA_MAP
- return ;
- }
- BEGIN_MESSAGE_MAP(VolumeRandomDialogClass, CDialog)
- //{{AFX_MSG_MAP(VolumeRandomDialogClass)
- ON_BN_CLICKED(IDC_BOX_RADIO, OnBoxRadio)
- ON_BN_CLICKED(IDC_CYLINDER_RADIO, OnCylinderRadio)
- ON_BN_CLICKED(IDC_SPHERE_RADIO, OnSphereRadio)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- ////////////////////////////////////////////////////////////////////
- //
- // OnOK
- //
- ////////////////////////////////////////////////////////////////////
- void
- VolumeRandomDialogClass::OnOK (void)
- {
- if (SendDlgItemMessage (IDC_BOX_RADIO, BM_GETCHECK) == 1) {
-
- //
- // Create a box randomizer
- //
- Vector3 extents (0, 0, 0);
- extents.X = ::GetDlgItemFloat (m_hWnd, IDC_BOX_X_EDIT);
- extents.Y = ::GetDlgItemFloat (m_hWnd, IDC_BOX_Y_EDIT);
- extents.Z = ::GetDlgItemFloat (m_hWnd, IDC_BOX_Z_EDIT);
- m_Randomizer = new Vector3SolidBoxRandomizer (extents);
- } else if (SendDlgItemMessage (IDC_SPHERE_RADIO, BM_GETCHECK) == 1) {
-
- //
- // What type of sphere is this, hollow or solid?
- //
- float radius = ::GetDlgItemFloat (m_hWnd, IDC_SPHERE_RADIUS_EDIT);
- if (SendDlgItemMessage (IDC_SPHERE_HOLLOW_CHECK, BM_GETCHECK) == 1) {
- m_Randomizer = new Vector3HollowSphereRandomizer (radius);
- } else {
- m_Randomizer = new Vector3SolidSphereRandomizer (radius);
- }
- } else if (SendDlgItemMessage (IDC_CYLINDER_RADIO, BM_GETCHECK) == 1) {
-
- //
- // Create a cylinder randomizer
- //
- float radius = ::GetDlgItemFloat (m_hWnd, IDC_CYLINDER_RADIUS_EDIT);
- float height = ::GetDlgItemFloat (m_hWnd, IDC_CYLINDER_HEIGHT_EDIT);
- m_Randomizer = new Vector3SolidCylinderRandomizer (height, radius);
- }
-
- CDialog::OnOK ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- //
- // OnInitDialog
- //
- ////////////////////////////////////////////////////////////////////
- BOOL
- VolumeRandomDialogClass::OnInitDialog (void)
- {
- CDialog::OnInitDialog ();
- //
- // Start with some default values
- //
- Vector3 initial_box (1, 1, 1);
- float initial_sphere_radius = 1.0F;
- bool initial_sphere_hollow = false;
- float initial_cylinder_radius = 1.0F;
- float initial_cylinder_height = 1.0F;
- UINT initial_type = IDC_BOX_RADIO;
- //
- // Initialize from the provided randomizer
- //
- if (m_Randomizer != NULL) {
-
- // What type of randomizer is this?
- switch (m_Randomizer->Class_ID ())
- {
- case Vector3Randomizer::CLASSID_SOLIDBOX:
- initial_type = IDC_BOX_RADIO;
- initial_box = ((Vector3SolidBoxRandomizer *)m_Randomizer)->Get_Extents ();
- break;
- case Vector3Randomizer::CLASSID_SOLIDSPHERE:
- initial_type = IDC_SPHERE_RADIO;
- initial_sphere_radius = ((Vector3SolidSphereRandomizer *)m_Randomizer)->Get_Radius();
- initial_sphere_hollow = false;
- break;
- case Vector3Randomizer::CLASSID_HOLLOWSPHERE:
- initial_type = IDC_SPHERE_RADIO;
- initial_sphere_radius = ((Vector3HollowSphereRandomizer *)m_Randomizer)->Get_Radius ();
- initial_sphere_hollow = true;
- break;
-
- case Vector3Randomizer::CLASSID_SOLIDCYLINDER:
- initial_type = IDC_CYLINDER_RADIO;
- initial_cylinder_radius = ((Vector3SolidCylinderRandomizer *)m_Randomizer)->Get_Radius ();
- initial_cylinder_height = ((Vector3SolidCylinderRandomizer *)m_Randomizer)->Get_Height ();
- break;
-
- default:
- ASSERT (0);
- break;
- }
- }
- //
- // Initialize the box controls
- //
- ::Initialize_Spinner (m_BoxXSpin, initial_box.X, -10000, 10000);
- ::Initialize_Spinner (m_BoxYSpin, initial_box.Y, -10000, 10000);
- ::Initialize_Spinner (m_BoxZSpin, initial_box.Z, -10000, 10000);
- //
- // Initialize the sphere controls
- //
- ::Initialize_Spinner (m_SphereRadiusSpin, initial_sphere_radius, 0, 10000);
- SendDlgItemMessage (IDC_SPHERE_HOLLOW_CHECK, BM_SETCHECK, (WPARAM)initial_sphere_hollow);
- //
- // Initialize the cylinder controls
- //
- ::Initialize_Spinner (m_CylinderRadiusSpin, initial_cylinder_radius, 0, 10000);
- ::Initialize_Spinner (m_CylinderHeightSpin, initial_cylinder_height, 0, 10000);
- //
- // Check the appropriate radio
- //
- SendDlgItemMessage (initial_type, BM_SETCHECK, (WPARAM)TRUE);
- Update_Enable_State ();
- return TRUE;
- }
- ////////////////////////////////////////////////////////////////////
- //
- // OnBoxRadio
- //
- ////////////////////////////////////////////////////////////////////
- void
- VolumeRandomDialogClass::OnBoxRadio (void)
- {
- Update_Enable_State ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- //
- // OnCylinderRadio
- //
- ////////////////////////////////////////////////////////////////////
- void
- VolumeRandomDialogClass::OnCylinderRadio (void)
- {
- Update_Enable_State ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- //
- // OnSphereRadio
- //
- ////////////////////////////////////////////////////////////////////
- void
- VolumeRandomDialogClass::OnSphereRadio (void)
- {
- Update_Enable_State ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- //
- // Update_Enable_State
- //
- ////////////////////////////////////////////////////////////////////
- void
- VolumeRandomDialogClass::Update_Enable_State (void)
- {
- bool enable_box_ctrls = (SendDlgItemMessage (IDC_BOX_RADIO, BM_GETCHECK) == 1);
- bool enable_sphere_ctrls = (SendDlgItemMessage (IDC_SPHERE_RADIO, BM_GETCHECK) == 1);
- bool enable_cylinder_ctrls = (SendDlgItemMessage (IDC_CYLINDER_RADIO, BM_GETCHECK) == 1);
- //
- // Update the box controls
- //
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_BOX_X_EDIT), enable_box_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_BOX_Y_EDIT), enable_box_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_BOX_Z_EDIT), enable_box_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_BOX_X_SPIN), enable_box_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_BOX_Y_SPIN), enable_box_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_BOX_Z_SPIN), enable_box_ctrls);
- //
- // Update the sphere controls
- //
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_SPHERE_RADIUS_EDIT), enable_sphere_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_SPHERE_RADIUS_SPIN), enable_sphere_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_SPHERE_HOLLOW_CHECK), enable_sphere_ctrls);
- //
- // Update the cylinder controls
- //
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_CYLINDER_RADIUS_EDIT), enable_cylinder_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_CYLINDER_RADIUS_SPIN), enable_cylinder_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_CYLINDER_HEIGHT_EDIT), enable_cylinder_ctrls);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_CYLINDER_HEIGHT_SPIN), enable_cylinder_ctrls);
- return ;
- }
- ////////////////////////////////////////////////////////////////////
- //
- // OnNotify
- //
- ////////////////////////////////////////////////////////////////////
- BOOL
- VolumeRandomDialogClass::OnNotify
- (
- WPARAM wParam,
- LPARAM lParam,
- LRESULT *pResult
- )
- {
- //
- // Update the spinner control if necessary
- //
- NMHDR *pheader = (NMHDR *)lParam;
- if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) {
- LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam;
- ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta);
- }
-
- // Allow the base class to process this message
- return CDialog::OnNotify (wParam, lParam, pResult);
- }
|