PresetZoneTab.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. // PresetGeneralTab.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "presetzonetab.h"
  23. #include "definition.h"
  24. #include "preset.h"
  25. #include "utils.h"
  26. #include "zoneeditdialog.h"
  27. #include "objectnode.h"
  28. #include "rendobj.h"
  29. #include "SceneEditor.h"
  30. #include "decophys.h"
  31. #include "CollisionGroups.h"
  32. #include "staticphys.h"
  33. #include "zone.h"
  34. #include "wheelvehicle.h"
  35. #include "cameramgr.h"
  36. #include "hlod.h"
  37. #include "parameter.h"
  38. #ifdef _DEBUG
  39. #define new DEBUG_NEW
  40. #undef THIS_FILE
  41. static char THIS_FILE[] = __FILE__;
  42. #endif
  43. /////////////////////////////////////////////////////////////////////////////
  44. // Constants
  45. /////////////////////////////////////////////////////////////////////////////
  46. const float DROP_POS = 5.0F;
  47. const float DROP_HEIGHT = 5.0F;
  48. const int COL_NAME = 0;
  49. /////////////////////////////////////////////////////////////////////////////
  50. //
  51. // PresetZoneTabClass
  52. //
  53. /////////////////////////////////////////////////////////////////////////////
  54. PresetZoneTabClass::PresetZoneTabClass (PresetClass *preset)
  55. : m_Preset (preset),
  56. m_PhysObj (NULL),
  57. m_ZoneList (NULL),
  58. DockableFormClass(PresetZoneTabClass::IDD)
  59. {
  60. //{{AFX_DATA_INIT(PresetZoneTabClass)
  61. // NOTE: the ClassWizard will add member initialization here
  62. //}}AFX_DATA_INIT
  63. return ;
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. //
  67. // ~PresetZoneTabClass
  68. //
  69. /////////////////////////////////////////////////////////////////////////////
  70. PresetZoneTabClass::~PresetZoneTabClass (void)
  71. {
  72. MEMBER_RELEASE (m_PhysObj);
  73. return ;
  74. }
  75. /////////////////////////////////////////////////////////////////////////////
  76. //
  77. // DoDataExchange
  78. //
  79. /////////////////////////////////////////////////////////////////////////////
  80. void
  81. PresetZoneTabClass::DoDataExchange (CDataExchange *pDX)
  82. {
  83. DockableFormClass::DoDataExchange(pDX);
  84. //{{AFX_DATA_MAP(PresetZoneTabClass)
  85. DDX_Control(pDX, IDC_ZONE_LIST, m_ListCtrl);
  86. //}}AFX_DATA_MAP
  87. return ;
  88. }
  89. BEGIN_MESSAGE_MAP(PresetZoneTabClass, DockableFormClass)
  90. //{{AFX_MSG_MAP(PresetZoneTabClass)
  91. ON_NOTIFY(NM_DBLCLK, IDC_ZONE_LIST, OnDblclkZoneList)
  92. //}}AFX_MSG_MAP
  93. END_MESSAGE_MAP()
  94. #ifdef _DEBUG
  95. void PresetZoneTabClass::AssertValid() const
  96. {
  97. DockableFormClass::AssertValid();
  98. }
  99. void PresetZoneTabClass::Dump(CDumpContext& dc) const
  100. {
  101. DockableFormClass::Dump(dc);
  102. }
  103. #endif //_DEBUG
  104. /////////////////////////////////////////////////////////////////////////////
  105. //
  106. // HandleInitDialog
  107. //
  108. /////////////////////////////////////////////////////////////////////////////
  109. void
  110. PresetZoneTabClass::HandleInitDialog (void)
  111. {
  112. ASSERT (m_Preset != NULL);
  113. ListView_SetExtendedListViewStyle (m_ListCtrl, LVS_EX_FULLROWSELECT);
  114. m_ListCtrl.InsertColumn (COL_NAME, "Name");
  115. //
  116. // Add the zones to the list ctrl
  117. //
  118. int count = m_ZoneList->Count ();
  119. for (int index = 0; index < count; index ++) {
  120. //
  121. // Insert this zone into the control
  122. //
  123. ZoneParameterClass *parameter = (*m_ZoneList)[index];
  124. if (parameter != NULL) {
  125. m_ListCtrl.InsertItem (index, parameter->Get_Name (), 0);
  126. }
  127. }
  128. //
  129. // Size the columns
  130. //
  131. CRect rect;
  132. m_ListCtrl.GetWindowRect (&rect);
  133. m_ListCtrl.SetColumnWidth (COL_NAME, (rect.Width ()) - (::GetSystemMetrics (SM_CXVSCROLL) + 1));
  134. m_ListCtrl.SetFocus ();
  135. return ;
  136. }
  137. /////////////////////////////////////////////////////////////////////////////
  138. //
  139. // Apply_Changes
  140. //
  141. /////////////////////////////////////////////////////////////////////////////
  142. bool
  143. PresetZoneTabClass::Apply_Changes (void)
  144. {
  145. return true;
  146. }
  147. /////////////////////////////////////////////////////////////////////////////
  148. //
  149. // Modify_Selected_Zone
  150. //
  151. /////////////////////////////////////////////////////////////////////////////
  152. void
  153. PresetZoneTabClass::Modify_Selected_Zone (void)
  154. {
  155. Create_Phys_Obj ();
  156. if (m_PhysObj != NULL) {
  157. //
  158. // Get the currently selected item
  159. //
  160. int index = m_ListCtrl.GetNextItem (-1, LVNI_ALL | LVNI_SELECTED);
  161. if (index >= 0) {
  162. ZoneParameterClass *parameter = (*m_ZoneList)[index];
  163. if (parameter != NULL) {
  164. //
  165. // Show the zone edit dialog
  166. //
  167. ZoneEditDialogClass dialog (this);
  168. dialog.Set_Phys_Obj (m_PhysObj);
  169. dialog.Set_Zone (parameter->Get_Zone ());
  170. if (dialog.DoModal () == IDOK) {
  171. parameter->Set_Zone (dialog.Get_Zone ());
  172. }
  173. }
  174. }
  175. }
  176. return ;
  177. }
  178. /////////////////////////////////////////////////////////////////////////////
  179. //
  180. // Create_Phys_Obj
  181. //
  182. /////////////////////////////////////////////////////////////////////////////
  183. void
  184. PresetZoneTabClass::Create_Phys_Obj (void)
  185. {
  186. CWaitCursor wait_cursor;
  187. if (m_PhysObj == NULL && m_Preset != NULL) {
  188. //
  189. // Instantiate the node
  190. //
  191. NodeClass *node = (NodeClass *)m_Preset->Create ();
  192. ASSERT (node != NULL);
  193. if (node != NULL) {
  194. //
  195. // Initialize the node and get its phys object pointer
  196. //
  197. node->Initialize ();
  198. PhysClass *phys_obj = node->Peek_Physics_Obj ();
  199. ASSERT (phys_obj != NULL);
  200. if (phys_obj != NULL) {
  201. //
  202. // Keep a copy of the physics object for our own uses.
  203. //
  204. m_PhysObj = phys_obj;
  205. m_PhysObj->Add_Ref ();
  206. //
  207. // Force the object to use its highest LOD
  208. //
  209. /*if (m_RenderObj->Class_ID () == RenderObjClass::CLASSID_HLOD) {
  210. HLodClass *lod_obj = (HLodClass *)m_RenderObj;
  211. lod_obj->Set_LOD_Level (lod_obj->Get_LOD_Count () - 1);
  212. }*/
  213. }
  214. MEMBER_RELEASE (node);
  215. }
  216. }
  217. return ;
  218. }
  219. /////////////////////////////////////////////////////////////////////////////
  220. //
  221. // OnDblclkZoneList
  222. //
  223. /////////////////////////////////////////////////////////////////////////////
  224. void
  225. PresetZoneTabClass::OnDblclkZoneList
  226. (
  227. NMHDR * pNMHDR,
  228. LRESULT *pResult
  229. )
  230. {
  231. (*pResult) = 0;
  232. Modify_Selected_Zone ();
  233. return ;
  234. }