Preset.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. /***********************************************************************************************
  19. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/Preset.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 8/26/01 9:53a $*
  29. * *
  30. * $Revision:: 25 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __PRESET_H
  39. #define __PRESET_H
  40. #include "refcount.h"
  41. #include "persist.h"
  42. #include "vector.h"
  43. #include "listtypes.h"
  44. #include "definition.h"
  45. #include "utils.h"
  46. #include "transition.h"
  47. ///////////////////////////////////////////////////////////////////////
  48. // Forward declarations
  49. ///////////////////////////////////////////////////////////////////////
  50. class DefinitionClass;
  51. class NodeClass;
  52. class ModelDefParameterClass;
  53. ///////////////////////////////////////////////////////////////////////
  54. //
  55. // PresetClass
  56. //
  57. ///////////////////////////////////////////////////////////////////////
  58. class PresetClass : public PersistClass
  59. {
  60. public:
  61. ////////////////////////////////////////////////////////////////////
  62. // Public constructors/destructors
  63. ////////////////////////////////////////////////////////////////////
  64. PresetClass (void);
  65. virtual ~PresetClass (void);
  66. ////////////////////////////////////////////////////////////////////
  67. // Public methods
  68. ////////////////////////////////////////////////////////////////////
  69. //
  70. // From PersistClass
  71. //
  72. const PersistFactoryClass & Get_Factory (void) const;
  73. virtual bool Save (ChunkSaveClass &csave);
  74. virtual bool Load (ChunkLoadClass &cload);
  75. virtual void On_Post_Load (void);
  76. virtual bool Show_Properties (bool read_only = false);
  77. virtual bool Delete (void) { return true; }
  78. virtual void Copy_Properties (const PresetClass &preset);
  79. virtual NodeClass * Create (void);
  80. //
  81. // Asset management
  82. //
  83. void Load_All_Assets (void);
  84. void Add_Files_To_VSS (void);
  85. //
  86. // Dependency management
  87. //
  88. void Get_All_Dependencies (STRING_LIST &list) const;
  89. void Get_Implicit_Dependencies (STRING_LIST &list) const;
  90. void Get_Manual_Dependencies (STRING_LIST &list) const;
  91. void Set_Manual_Dependencies (STRING_LIST &list);
  92. //
  93. // Inline accessors
  94. //
  95. DefinitionClass * Get_Definition (void) const { return m_Definition; }
  96. void Set_Definition (DefinitionClass *definition);
  97. LPCTSTR Get_Comments (void) const;
  98. void Set_Comments (LPCTSTR comments);
  99. bool Get_IsTemporary (void) const;
  100. void Set_IsTemporary (bool is_temp);
  101. PresetClass * Get_Parent (void) const { return m_Parent; }
  102. void Set_Parent (PresetClass *parent);
  103. bool Is_A_Parent (PresetClass *preset);
  104. bool Is_A_Parent (LPCTSTR parent_name);
  105. //
  106. // Child access
  107. //
  108. int Get_Child_Preset_Count (void) { return m_ChildIDList.Count (); }
  109. int Get_Child_Preset_ID (int index) { return m_ChildIDList[index]; }
  110. PresetClass * Get_Child_Preset (int index);
  111. void Add_Child_Preset (int child_id);
  112. void Remove_Child_Preset (int child_id);
  113. //
  114. // Definition access
  115. //
  116. void Collect_Definitions (DEFINITION_LIST &list);
  117. static void Add_Definition_Dependencies (DefinitionClass *definition, STRING_LIST &list);
  118. //
  119. // Display methods
  120. //
  121. int Get_Icon_Index (void) const;
  122. //
  123. // Pass-thrus to the definition object
  124. //
  125. uint32 Get_ID (void) const;
  126. void Set_ID (uint32 id);
  127. LPCTSTR Get_Name (void) const;
  128. void Set_Name (LPCTSTR name);
  129. uint32 Get_Class_ID (void) const;
  130. //
  131. // Misc helper methods
  132. //
  133. bool Is_Valid_Sound_Preset (void);
  134. bool Is_Soldier_Preset (void);
  135. //
  136. // Validity checks
  137. //
  138. bool Is_Valid (void) const;
  139. //
  140. // Node list access
  141. //
  142. void Build_Node_List (NodeClass *parent_node);
  143. void Create_Linked_Nodes (NodeClass *parent_node);
  144. NODE_LIST & Get_Node_List (void) { return m_NodeList; }
  145. void Free_Node_List (void);
  146. protected:
  147. ////////////////////////////////////////////////////////////////////
  148. // Protected methods
  149. ////////////////////////////////////////////////////////////////////
  150. virtual bool Save_Variables (ChunkSaveClass &csave);
  151. virtual bool Load_Variables (ChunkLoadClass &cload);
  152. TRANSITION_DATA_LIST * Get_Transition_List (void) const;
  153. void Build_Zone_List (DefinitionClass *definition, ZONE_PARAM_LIST &zone_list) const;
  154. ModelDefParameterClass * Get_Phys_Def_Param (void);
  155. ScriptListParameterClass * Get_Script_List_Param (void);
  156. ////////////////////////////////////////////////////////////////////
  157. // Protected member data
  158. ////////////////////////////////////////////////////////////////////
  159. PresetClass * m_NextPreset;
  160. PresetClass * m_PrevPreset;
  161. private:
  162. ////////////////////////////////////////////////////////////////////
  163. // Private member data
  164. ////////////////////////////////////////////////////////////////////
  165. PresetClass * m_Parent;
  166. DefinitionClass * m_Definition;
  167. STRING_LIST m_ManualDependencies;
  168. StringClass m_Comments;
  169. bool m_IsTemporary;
  170. bool m_IsValid;
  171. uint32 m_ParentID;
  172. mutable uint32 m_DefinitionID;
  173. NODE_LIST m_NodeList;
  174. DynamicVectorClass<int> m_ChildIDList;
  175. ////////////////////////////////////////////////////////////////////
  176. // Friends
  177. ////////////////////////////////////////////////////////////////////
  178. friend class PresetMgrClass;
  179. };
  180. //INLINE_ACCESSOR_CONST (DefinitionClass *, PresetClass, Definition);
  181. INLINE_ACCESSOR_CONST (LPCTSTR, PresetClass, Comments);
  182. INLINE_ACCESSOR_CONST (bool, PresetClass, IsTemporary);
  183. //INLINE_ACCESSOR_CONST (PresetClass *, PresetClass, Parent);
  184. ////////////////////////////////////////////////////////////////////
  185. // Get_ID
  186. ////////////////////////////////////////////////////////////////////
  187. inline uint32
  188. PresetClass::Get_ID (void) const
  189. {
  190. if (m_Definition != NULL) {
  191. m_DefinitionID = m_Definition->Get_ID ();
  192. }
  193. return m_DefinitionID;
  194. }
  195. ////////////////////////////////////////////////////////////////////
  196. // Set_ID
  197. ////////////////////////////////////////////////////////////////////
  198. inline void
  199. PresetClass::Set_ID (uint32 id)
  200. {
  201. if (m_Definition != NULL) {
  202. m_Definition->Set_ID (id);
  203. }
  204. m_DefinitionID = id;
  205. return ;
  206. }
  207. ////////////////////////////////////////////////////////////////////
  208. // Get_Name
  209. ////////////////////////////////////////////////////////////////////
  210. inline LPCTSTR
  211. PresetClass::Get_Name (void) const
  212. {
  213. LPCTSTR name = NULL;
  214. if (m_Definition != NULL) {
  215. name = m_Definition->Get_Name ();
  216. }
  217. return name;
  218. }
  219. ////////////////////////////////////////////////////////////////////
  220. // Set_Name
  221. ////////////////////////////////////////////////////////////////////
  222. inline void
  223. PresetClass::Set_Name (LPCTSTR name)
  224. {
  225. if (m_Definition != NULL) {
  226. m_Definition->Set_Name (name);
  227. }
  228. return ;
  229. }
  230. ////////////////////////////////////////////////////////////////////
  231. // Is_Valid
  232. ////////////////////////////////////////////////////////////////////
  233. inline bool
  234. PresetClass::Is_Valid (void) const
  235. {
  236. return m_IsValid;
  237. }
  238. ////////////////////////////////////////////////////////////////////
  239. // Get_Manual_Dependencies
  240. ////////////////////////////////////////////////////////////////////
  241. inline void
  242. PresetClass::Get_Manual_Dependencies (STRING_LIST &list) const
  243. {
  244. list = m_ManualDependencies;
  245. return ;
  246. }
  247. ////////////////////////////////////////////////////////////////////
  248. // Set_Manual_Dependencies
  249. ////////////////////////////////////////////////////////////////////
  250. inline void
  251. PresetClass::Set_Manual_Dependencies (STRING_LIST &list)
  252. {
  253. m_ManualDependencies = list;
  254. return ;
  255. }
  256. ////////////////////////////////////////////////////////////////////
  257. // Get_Class_ID
  258. ////////////////////////////////////////////////////////////////////
  259. inline uint32
  260. PresetClass::Get_Class_ID (void) const
  261. {
  262. uint32 class_id = 0;
  263. if (m_Definition != NULL) {
  264. class_id = m_Definition->Get_Class_ID ();
  265. }
  266. return class_id;
  267. }
  268. #endif //__PRESET_H