SpherePropertySheet.cpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. // SpherePropertySheet.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "w3dview.h"
  22. #include "SpherePropertySheet.h"
  23. #include "utils.h"
  24. #include "W3DViewDoc.h"
  25. #include "assetmgr.h"
  26. #include "datatreeview.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. IMPLEMENT_DYNAMIC(SpherePropertySheetClass, CPropertySheet)
  33. /////////////////////////////////////////////////////////////////////////////
  34. //
  35. // SpherePropertySheetClass
  36. //
  37. /////////////////////////////////////////////////////////////////////////////
  38. SpherePropertySheetClass::SpherePropertySheetClass
  39. (
  40. SphereRenderObjClass * sphere,
  41. UINT nIDCaption,
  42. CWnd * pParentWnd,
  43. UINT iSelectPage
  44. )
  45. : m_RenderObj (NULL),
  46. CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  47. {
  48. MEMBER_ADD (m_RenderObj, sphere);
  49. Initialize ();
  50. return ;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. //
  54. // SpherePropertySheetClass
  55. //
  56. /////////////////////////////////////////////////////////////////////////////
  57. SpherePropertySheetClass::SpherePropertySheetClass
  58. (
  59. SphereRenderObjClass * sphere,
  60. LPCTSTR pszCaption,
  61. CWnd * pParentWnd,
  62. UINT iSelectPage
  63. )
  64. : m_RenderObj (NULL),
  65. CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  66. {
  67. MEMBER_ADD (m_RenderObj, sphere);
  68. Initialize ();
  69. return ;
  70. }
  71. /////////////////////////////////////////////////////////////////////////////
  72. //
  73. // ~SpherePropertySheetClass
  74. //
  75. /////////////////////////////////////////////////////////////////////////////
  76. SpherePropertySheetClass::~SpherePropertySheetClass (void)
  77. {
  78. MEMBER_RELEASE (m_RenderObj);
  79. return ;
  80. }
  81. BEGIN_MESSAGE_MAP(SpherePropertySheetClass, CPropertySheet)
  82. //{{AFX_MSG_MAP(SpherePropertySheetClass)
  83. ON_WM_CREATE()
  84. //}}AFX_MSG_MAP
  85. END_MESSAGE_MAP()
  86. /////////////////////////////////////////////////////////////////////////////
  87. // SpherePropertySheetClass
  88. /////////////////////////////////////////////////////////////////////////////
  89. /////////////////////////////////////////////////////////////
  90. //
  91. // WindowProc
  92. //
  93. /////////////////////////////////////////////////////////////
  94. LRESULT
  95. SpherePropertySheetClass::WindowProc
  96. (
  97. UINT message,
  98. WPARAM wParam,
  99. LPARAM lParam
  100. )
  101. {
  102. switch (message)
  103. {
  104. // Is a control sending us an oldstyle notification?
  105. case WM_COMMAND:
  106. {
  107. // What control sent the notification?
  108. switch (LOWORD (wParam))
  109. {
  110. case IDCANCEL:
  111. {
  112. ::GetCurrentDocument ()->Reload_Displayed_Object ();
  113. }
  114. break;
  115. /*case IDOK:
  116. {
  117. // If the apply button isn't enabled, then don't do the apply operation.
  118. if (::IsWindowEnabled (::GetDlgItem (m_hWnd, ID_APPLY_NOW)) == FALSE) {
  119. break;
  120. }
  121. }*/
  122. case IDOK:
  123. case ID_APPLY_NOW:
  124. {
  125. // Did the user click the button?
  126. if (HIWORD (wParam) == BN_CLICKED) {
  127. LRESULT lresult = CPropertySheet::WindowProc (message, wParam, lParam);
  128. // If all the pages contain valid data, then update the emitter
  129. if ( m_GeneralPage.Is_Data_Valid () &&
  130. m_ColorPage.Is_Data_Valid () &&
  131. m_ScalePage.Is_Data_Valid ())
  132. {
  133. // Update the current emitter to match the data
  134. Update_Object ();
  135. }
  136. return lresult;
  137. }
  138. }
  139. break;
  140. }
  141. break;
  142. }
  143. break;
  144. }
  145. // Allow the base class to process this message
  146. return CPropertySheet::WindowProc (message, wParam, lParam);
  147. }
  148. /////////////////////////////////////////////////////////////
  149. //
  150. // Add_Object_To_Viewer
  151. //
  152. /////////////////////////////////////////////////////////////
  153. void
  154. SpherePropertySheetClass::Add_Object_To_Viewer (void)
  155. {
  156. CW3DViewDoc *doc = ::GetCurrentDocument ();
  157. if ((doc != NULL) && (m_RenderObj != NULL)) {
  158. //
  159. // Create a new prototype for this object
  160. //
  161. SpherePrototypeClass *prototype = new SpherePrototypeClass (m_RenderObj);
  162. //
  163. // Update the asset manager with the new prototype
  164. //
  165. if (m_LastSavedName.GetLength () > 0) {
  166. WW3DAssetManager::Get_Instance()->Remove_Prototype (m_LastSavedName);
  167. }
  168. WW3DAssetManager::Get_Instance()->Add_Prototype (prototype);
  169. //
  170. // Add this object to the data tree
  171. //
  172. CDataTreeView *data_tree = doc->GetDataTreeView ();
  173. data_tree->Refresh_Asset (m_RenderObj->Get_Name (), m_LastSavedName, TypePrimitives);
  174. //
  175. // Display the object
  176. //
  177. doc->Reload_Displayed_Object ();
  178. m_LastSavedName = m_RenderObj->Get_Name ();
  179. MEMBER_ADD (m_RenderObj, (SphereRenderObjClass *)doc->GetDisplayedObject ());
  180. //
  181. // Pass the object along to the pages
  182. //
  183. m_GeneralPage.Set_Sphere (m_RenderObj);
  184. m_ColorPage.Set_Sphere (m_RenderObj);
  185. m_ScalePage.Set_Sphere (m_RenderObj);
  186. }
  187. return ;
  188. }
  189. /////////////////////////////////////////////////////////////
  190. //
  191. // Update_Object
  192. //
  193. /////////////////////////////////////////////////////////////
  194. void
  195. SpherePropertySheetClass::Update_Object (void)
  196. {
  197. Add_Object_To_Viewer ();
  198. return ;
  199. }
  200. /////////////////////////////////////////////////////////////
  201. //
  202. // Initialize
  203. //
  204. /////////////////////////////////////////////////////////////
  205. void
  206. SpherePropertySheetClass::Initialize (void)
  207. {
  208. if (m_RenderObj == NULL) {
  209. Create_New_Object ();
  210. } else {
  211. m_LastSavedName = m_RenderObj->Get_Name ();
  212. }
  213. //
  214. // Pass the object along to the pages
  215. //
  216. m_GeneralPage.Set_Sphere (m_RenderObj);
  217. m_ColorPage.Set_Sphere (m_RenderObj);
  218. m_ScalePage.Set_Sphere (m_RenderObj);
  219. //
  220. // Add the pages to the sheet
  221. //
  222. AddPage (&m_GeneralPage);
  223. AddPage (&m_ColorPage);
  224. AddPage (&m_ScalePage);
  225. //
  226. // Force the pages to be created up front
  227. //
  228. m_GeneralPage.m_psp.dwFlags |= PSP_PREMATURE;
  229. m_ColorPage.m_psp.dwFlags |= PSP_PREMATURE;
  230. m_ScalePage.m_psp.dwFlags |= PSP_PREMATURE;
  231. return ;
  232. }
  233. /////////////////////////////////////////////////////////////
  234. //
  235. // Create_New_Object
  236. //
  237. /////////////////////////////////////////////////////////////
  238. void
  239. SpherePropertySheetClass::Create_New_Object (void)
  240. {
  241. m_RenderObj = new SphereRenderObjClass;
  242. m_RenderObj->Set_Name ("Sphere");
  243. //
  244. // Display the new object
  245. //
  246. ::GetCurrentDocument ()->DisplayObject (m_RenderObj);
  247. return ;
  248. }