| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- /*
- ** 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 : leveledit *
- * *
- * $Archive:: /Commando/Code/Tools/LevelEdit/heightfieldpage.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 2/28/02 4:40p $*
- * *
- * $Revision:: 2 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "stdafx.h"
- #include "leveledit.h"
- #include "heightfieldpage.h"
- #include "nodemgr.h"
- #include "node.h"
- #include "utils.h"
- #include "cameramgr.h"
- #include "gotoobjectdialog.h"
- #include "sceneeditor.h"
- #include "icons.h"
- #include "nodecategories.h"
- #include "definition.h"
- #include "definitionfactory.h"
- #include "definitionfactorymgr.h"
- #include "preset.h"
- #include "editableheightfield.h"
- #include "staticphys.h"
- #include "heightfieldeditor.h"
- #include "heightfieldmgr.h"
- #include "terrainmaterial.h"
- #include "heightfieldmaterialsettingsdialog.h"
- #include "newheightfielddialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- ///////////////////////////////////////////////////////////////////////
- // Static member initialization
- ///////////////////////////////////////////////////////////////////////
- HeightfieldPageClass * HeightfieldPageClass::_TheInstance = NULL;
- /////////////////////////////////////////////////////////////////////////////
- //
- // HeightfieldPageClass
- //
- /////////////////////////////////////////////////////////////////////////////
- HeightfieldPageClass::HeightfieldPageClass (CWnd *parent_wnd) :
- IsInitialized (false),
- CDialog (HeightfieldPageClass::IDD)
- {
- //{{AFX_DATA_INIT(HeightfieldPageClass)
- //}}AFX_DATA_INIT
- Create (HeightfieldPageClass::IDD, parent_wnd);
- _TheInstance = this;
- return ;
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- // ~HeightfieldPageClass
- //
- /////////////////////////////////////////////////////////////////////////////
- HeightfieldPageClass::~HeightfieldPageClass (void)
- {
- _TheInstance = NULL;
- return ;
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- // DoDataExchange
- //
- /////////////////////////////////////////////////////////////////////////////
- void
- HeightfieldPageClass::DoDataExchange (CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(HeightfieldPageClass)
- //}}AFX_DATA_MAP
- return ;
- }
- BEGIN_MESSAGE_MAP(HeightfieldPageClass, CDialog)
- //{{AFX_MSG_MAP(HeightfieldPageClass)
- ON_WM_SIZE()
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_CREATE_NEW_BUTTON, OnCreateNewButton)
- ON_BN_CLICKED(IDC_MATERIAL_SETTINGS_BUTTON, OnMaterialSettingsButton)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- #ifdef _DEBUG
- void HeightfieldPageClass::AssertValid() const
- {
- CDialog::AssertValid();
- }
- void HeightfieldPageClass::Dump(CDumpContext& dc) const
- {
- CDialog::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- //
- // OnSize
- //
- /////////////////////////////////////////////////////////////////////////////
- void
- HeightfieldPageClass::OnSize
- (
- UINT nType,
- int cx,
- int cy
- )
- {
- CDialog::OnSize (nType, cx, cy);
- /*if (::IsWindow (m_ListCtrl) && (cx > 0) && (cy > 0)) {
- }*/
- return ;
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- // OnDestroy
- //
- /////////////////////////////////////////////////////////////////////////////
- void
- HeightfieldPageClass::OnDestroy (void)
- {
- ::RemoveProp (m_hWnd, "TRANS_ACCS");
- CDialog::OnDestroy ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////////////
- //
- // OnInitDialog
- //
- ////////////////////////////////////////////////////////////////////////////
- BOOL
- HeightfieldPageClass::OnInitDialog (void)
- {
- CDialog::OnInitDialog ();
- //
- // Set the default parameters
- //
- ::SetDlgItemFloat (m_hWnd, IDC_BRUSH_INNER_RADIUS_EDIT, HeightfieldEditorClass::Get_Brush_Inner_Radius ());
- ::SetDlgItemFloat (m_hWnd, IDC_BRUSH_OUTTER_RADIUS_EDIT, HeightfieldEditorClass::Get_Brush_Outter_Radius ());
- ::SetDlgItemFloat (m_hWnd, IDC_BRUSH_AMOUNT_EDIT, HeightfieldEditorClass::Get_Brush_Amount ());
- //
- // Select the first brush by default
- //
- SendDlgItemMessage (IDC_BRUSH_TYPE_COMBO, CB_SETCURSEL, 0);
- //
- // Select the current default texture...
- //
- int curr_texture = HeightfieldEditorClass::Get_Current_Texture ();
- SendDlgItemMessage (IDC_TEXTURE0_BUTTON + curr_texture, BM_SETCHECK, TRUE);
- SetProp (m_hWnd, "TRANS_ACCS", (HANDLE)1);
- IsInitialized = true;
- return TRUE;
- }
- ////////////////////////////////////////////////////////////////////////////
- //
- // OnCreateNewButton
- //
- ////////////////////////////////////////////////////////////////////////////
- void
- HeightfieldPageClass::OnCreateNewButton (void)
- {
- NewHeightfieldDialogClass dialog (this);
- dialog.DoModal ();
- return ;
- }
- ////////////////////////////////////////////////////////////////////////////
- //
- // OnCommand
- //
- ////////////////////////////////////////////////////////////////////////////
- BOOL
- HeightfieldPageClass::OnCommand (WPARAM wParam, LPARAM lParam)
- {
- if (IsInitialized) {
- int ctrl_id = LOWORD (wParam);
- switch (ctrl_id)
- {
- case IDC_TEXTURE0_BUTTON:
- case IDC_TEXTURE1_BUTTON:
- case IDC_TEXTURE2_BUTTON:
- case IDC_TEXTURE3_BUTTON:
- case IDC_TEXTURE4_BUTTON:
- case IDC_TEXTURE5_BUTTON:
- case IDC_TEXTURE6_BUTTON:
- case IDC_TEXTURE7_BUTTON:
- case IDC_TEXTURE8_BUTTON:
- {
- if (HIWORD (wParam) == BN_CLICKED) {
- int curr_texture = ctrl_id - IDC_TEXTURE0_BUTTON;
- HeightfieldEditorClass::Set_Current_Texture (curr_texture);
- }
- break;
- }
- case IDC_BRUSH_INNER_RADIUS_EDIT:
-
- //
- // Update the heightfield editor with the new values
- //
- if (HIWORD (wParam) == EN_CHANGE) {
- float inner = ::GetDlgItemFloat (m_hWnd, IDC_BRUSH_INNER_RADIUS_EDIT, false);
- float outter = ::GetDlgItemFloat (m_hWnd, IDC_BRUSH_OUTTER_RADIUS_EDIT, false);
- HeightfieldEditorClass::Set_Brush_Radii (inner, outter);
- }
- break;
- case IDC_BRUSH_OUTTER_RADIUS_EDIT:
-
- //
- // Update the heightfield editor with the new values
- //
- if (HIWORD (wParam) == EN_CHANGE) {
- float inner = ::GetDlgItemFloat (m_hWnd, IDC_BRUSH_INNER_RADIUS_EDIT, false);
- float outter = ::GetDlgItemFloat (m_hWnd, IDC_BRUSH_OUTTER_RADIUS_EDIT, false);
- HeightfieldEditorClass::Set_Brush_Radii (inner, outter);
- }
- break;
- case IDC_BRUSH_AMOUNT_EDIT:
- //
- // Update the heightfield editor with the new values
- //
- if (HIWORD (wParam) == EN_CHANGE) {
- float amount = ::GetDlgItemFloat (m_hWnd, IDC_BRUSH_AMOUNT_EDIT, false);
- HeightfieldEditorClass::Set_Brush_Amount (amount);
- }
- break;
- case IDC_BRUSH_TYPE_COMBO:
- {
- int curr_sel = SendDlgItemMessage (IDC_BRUSH_TYPE_COMBO, CB_GETCURSEL);
- HeightfieldEditorClass::Set_Mode ((HeightfieldEditorClass::EDITING_MODE)curr_sel);
- break;
- }
- }
- }
- return CDialog::OnCommand (wParam, lParam);
- }
- ////////////////////////////////////////////////////////////////////////////
- //
- // Update_Material_Button
- //
- ////////////////////////////////////////////////////////////////////////////
- void
- HeightfieldPageClass::Update_Material_Button (int index)
- {
- if (index < 0 || index > 9) {
- return ;
- }
- //
- // Get the button in question
- //
- int ctrl_id = IDC_TEXTURE0_BUTTON + index;
- HWND button_wnd = ::GetDlgItem (m_hWnd, ctrl_id);
- if (button_wnd != NULL) {
-
- HBITMAP thumbnail = NULL;
- //
- // Get the material for this slot
- //
- TerrainMaterialClass *material = HeightfieldEditorClass::Get_Material (index);
- if (material != NULL) {
- //
- // Create a bitmap from this material
- //
- thumbnail = HeightfieldEditorClass::Create_Texture_Thumbnail (material->Get_Texture_Name (), 48, 48);
- }
- //
- // Put the bitmap into the button
- //
- HBITMAP old_bmp = (HBITMAP)::SendMessage (button_wnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)thumbnail);
- if (old_bmp != NULL) {
- //
- // Free the old button bitmap
- //
- ::DeleteObject (old_bmp);
- old_bmp = NULL;
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////////////////
- //
- // OnMaterialSettingsButton
- //
- ////////////////////////////////////////////////////////////////////////////
- void
- HeightfieldPageClass::OnMaterialSettingsButton (void)
- {
- int material_index = HeightfieldEditorClass::Get_Current_Texture ();
- //
- // Display a dialog that allows the user to edit the settings for this
- // material.
- //
- HeightfieldMaterialSettingsDialogClass dialog (this);
- dialog.Set_Material (material_index);
- if (dialog.DoModal () == IDOK) {
-
- //
- // Let the system know that this material has changed
- //
- HeightfieldEditorClass::On_Material_Changed (material_index);
- }
- return ;
- }
|