HierarchyPropPage.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. // HierarchyPropPage.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "W3DView.h"
  22. #include "HierarchyPropPage.h"
  23. #include "AssetMgr.H"
  24. #include "RendObj.H"
  25. #include "AssetPropertySheet.H"
  26. #include "MeshPropPage.H"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CHierarchyPropPage property page
  34. IMPLEMENT_DYNCREATE(CHierarchyPropPage, CPropertyPage)
  35. ////////////////////////////////////////////////////////////////
  36. //
  37. // CHierarchyPropPage
  38. //
  39. CHierarchyPropPage::CHierarchyPropPage (const CString &stringHierarchyName)
  40. : CPropertyPage(CHierarchyPropPage::IDD)
  41. {
  42. //{{AFX_DATA_INIT(CHierarchyPropPage)
  43. // NOTE: the ClassWizard will add member initialization here
  44. //}}AFX_DATA_INIT
  45. m_stringHierarchyName = stringHierarchyName;
  46. return ;
  47. }
  48. ////////////////////////////////////////////////////////////////
  49. //
  50. // CHierarchyPropPage
  51. //
  52. CHierarchyPropPage::~CHierarchyPropPage (void)
  53. {
  54. return ;
  55. }
  56. ////////////////////////////////////////////////////////////////
  57. //
  58. // DoDataExchange
  59. //
  60. void
  61. CHierarchyPropPage::DoDataExchange (CDataExchange* pDX)
  62. {
  63. CPropertyPage::DoDataExchange(pDX);
  64. //{{AFX_DATA_MAP(CHierarchyPropPage)
  65. DDX_Control(pDX, IDC_SUBOBJECT_LIST, m_subObjectListCtrl);
  66. //}}AFX_DATA_MAP
  67. return ;
  68. }
  69. BEGIN_MESSAGE_MAP(CHierarchyPropPage, CPropertyPage)
  70. //{{AFX_MSG_MAP(CHierarchyPropPage)
  71. ON_NOTIFY(NM_DBLCLK, IDC_SUBOBJECT_LIST, OnDblclkSubObjectList)
  72. //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CHierarchyPropPage message handlers
  76. ////////////////////////////////////////////////////////////////
  77. //
  78. // OnInitDialog
  79. //
  80. BOOL
  81. CHierarchyPropPage::OnInitDialog (void)
  82. {
  83. // Allow the base class to process this message
  84. CPropertyPage::OnInitDialog();
  85. if (m_stringHierarchyName.GetLength () > 0)
  86. {
  87. // Get a pointer to the hierarchy object from the asset manager
  88. RenderObjClass *pCHierarchy = WW3DAssetManager::Get_Instance()->Create_Render_Obj (m_stringHierarchyName);
  89. ASSERT (pCHierarchy);
  90. if (pCHierarchy)
  91. {
  92. CString stringDesc;
  93. stringDesc.Format (IDS_HIERARCHY_PROP_DESC, m_stringHierarchyName);
  94. // Put the description onto the dialog
  95. SetDlgItemText (IDC_DESCRIPTION, stringDesc);
  96. // Put the polygon count onto the dialog
  97. SetDlgItemInt (IDC_TOTAL_POLYGONS, pCHierarchy->Get_Num_Polys ());
  98. // Put the subobject count onto the dialog
  99. int iSubObjects = pCHierarchy->Get_Num_Sub_Objects ();
  100. SetDlgItemInt (IDC_SUBOBJECTS, iSubObjects);
  101. // Add the name column to the list control
  102. m_subObjectListCtrl.InsertColumn (0, "Name");
  103. // Loop through all the subobjects and add them to the list control
  104. for (int iObject = 0;
  105. iObject < iSubObjects;
  106. iObject ++)
  107. {
  108. // Get this subobject
  109. RenderObjClass *pCSubObject = pCHierarchy->Get_Sub_Object (iObject);
  110. if (pCSubObject)
  111. {
  112. // Add this object to the list
  113. m_subObjectListCtrl.InsertItem (0, pCSubObject->Get_Name ());
  114. // Free this object
  115. pCSubObject->Release_Ref ();
  116. pCSubObject = NULL;
  117. }
  118. }
  119. // Resize the column so it is wide enough to display the largest string
  120. m_subObjectListCtrl.SetColumnWidth (0, LVSCW_AUTOSIZE);
  121. // Free the object
  122. pCHierarchy->Release_Ref ();
  123. pCHierarchy = NULL;
  124. }
  125. }
  126. GetParent ()->GetDlgItem (IDOK)->ShowWindow (SW_HIDE);
  127. GetParent ()->GetDlgItem (IDCANCEL)->SetWindowText ("Close");
  128. return TRUE;
  129. }
  130. ////////////////////////////////////////////////////////////////
  131. //
  132. // OnDblclkSubObjectList
  133. //
  134. void
  135. CHierarchyPropPage::OnDblclkSubObjectList
  136. (
  137. NMHDR* pNMHDR,
  138. LRESULT* pResult
  139. )
  140. {
  141. // Get the currently selected item
  142. int iIndex = m_subObjectListCtrl.GetNextItem (-1, LVNI_ALL | LVNI_SELECTED);
  143. if (iIndex != -1)
  144. {
  145. // Create a one-page property sheet that will display property information
  146. // for the mesh
  147. CMeshPropPage meshPropPage (m_subObjectListCtrl.GetItemText (iIndex, 0));
  148. CAssetPropertySheet propertySheet (IDS_MESH_PROP_TITLE, &meshPropPage, this);
  149. // Show the property sheet
  150. propertySheet.DoModal ();
  151. }
  152. (*pResult) = 0;
  153. return ;
  154. }