evasettings.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/evasettings.cpp $*
  25. * *
  26. * $Author:: Patrick $*
  27. * *
  28. * $Modtime:: 1/07/02 10:46a $*
  29. * *
  30. * $Revision:: 10 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "evasettings.h"
  36. #include "combatchunkid.h"
  37. #include "wwhack.h"
  38. #include "persistfactory.h"
  39. #include "definitionfactory.h"
  40. #include "simpledefinitionfactory.h"
  41. #include "debug.h"
  42. #include "objectives.h"
  43. #include "combat.h"
  44. #include "messagewindow.h"
  45. DECLARE_FORCE_LINK (EvaSettings)
  46. ///////////////////////////////////////////////////////////////////////////////////////////
  47. // Static member initialization
  48. ///////////////////////////////////////////////////////////////////////////////////////////
  49. EvaSettingsDefClass * EvaSettingsDefClass::EvaSettings = NULL;
  50. ///////////////////////////////////////////////////////////////////////////////////////////
  51. // Factories
  52. ///////////////////////////////////////////////////////////////////////////////////////////
  53. SimplePersistFactoryClass<EvaSettingsDefClass, CHUNKID_GLOBAL_SETTINGS_DEF_EVA> _EvaSettingsDefPersistFactory;
  54. DECLARE_DEFINITION_FACTORY(EvaSettingsDefClass, CLASSID_GLOBAL_SETTINGS_DEF_EVA, "Eva Settings") _EvaSettingsDefDefFactory;
  55. ///////////////////////////////////////////////////////////////////////////////////////////
  56. // Save/load constants
  57. ///////////////////////////////////////////////////////////////////////////////////////////
  58. enum
  59. {
  60. CHUNKID_PARENT = 803001812,
  61. CHUNKID_VARIABLES,
  62. VARID_OBJECTIVESSCREENRECT = 1,
  63. VARID_OBJECTIVESTEXTRECT,
  64. VARID_OBJECTIVESENDCAPUVRECT,
  65. VARID_OBJECTIVESFADEOUTUVRECT,
  66. VARID_OBJECTIVESBACKGROUNDUVRECT,
  67. VARID_OBJECTIVESTEXTURESIZE,
  68. VARID_MESSAGESSCREENRECT,
  69. VARID_MESSAGESTEXTRECT,
  70. VARID_MESSAGESENDCAPUVRECT,
  71. VARID_MESSAGESFADEOUTUVRECT,
  72. VARID_MESSAGESBACKGROUNDUVRECT,
  73. VARID_MESSAGESTEXTURESIZE,
  74. VARID_MESSAGESICONPOS
  75. };
  76. ///////////////////////////////////////////////////////////////////////////////////////////
  77. // Default values
  78. ///////////////////////////////////////////////////////////////////////////////////////////
  79. const RectClass DEF_OBJECTIVESSCREENRECT (0.063F, 0.25F, 0.938F, 0.75);
  80. const RectClass DEF_OBJECTIVESTEXTRECT (0.1F, 0.260F, 0.906F, 0.555F);
  81. const RectClass DEF_OBJECTIVESENDCAPUVRECT (0, 67, 8, 127);
  82. const RectClass DEF_OBJECTIVESFADEOUTUVRECT (41, 34, 127, 65);
  83. const RectClass DEF_OBJECTIVESBACKGROUNDUVRECT (2, 1, 126, 32);
  84. const Vector2 DEF_OBJECTIVESTEXTURESIZE (128, 128);
  85. const RectClass DEF_MESSAGESSCREENRECT (0.116F, 0.021F, 0.938F, 0.208F);
  86. const RectClass DEF_MESSAGESTEXTRECT (0.147F, 0.031F, 0.906F, 0.198F);
  87. const RectClass DEF_MESSAGESENDCAPUVRECT (0, 67, 8, 127);
  88. const RectClass DEF_MESSAGESFADEOUTUVRECT (41, 34, 127, 65);
  89. const RectClass DEF_MESSAGESBACKGROUNDUVRECT (2, 1, 126, 32);
  90. const Vector2 DEF_MESSAGESTEXTURESIZE (128, 128);
  91. const Vector2 DEF_MESSAGESICONPOS (0.016F, 0.021F);
  92. EvaSettingsDefClass _DefaultSettings;
  93. ///////////////////////////////////////////////////////////////////////////////////////////
  94. //
  95. // EvaSettingsDefClass
  96. //
  97. ///////////////////////////////////////////////////////////////////////////////////////////
  98. EvaSettingsDefClass::EvaSettingsDefClass (void) :
  99. ObjectivesScreenRect (DEF_OBJECTIVESSCREENRECT),
  100. ObjectivesTextRect (DEF_OBJECTIVESTEXTRECT),
  101. ObjectivesEndcapUVRect (DEF_OBJECTIVESENDCAPUVRECT),
  102. ObjectivesFadeoutUVRect (DEF_OBJECTIVESFADEOUTUVRECT),
  103. ObjectivesBackgroundUVRect (DEF_OBJECTIVESBACKGROUNDUVRECT),
  104. ObjectivesTextureSize (DEF_OBJECTIVESTEXTURESIZE),
  105. MessagesScreenRect (DEF_MESSAGESSCREENRECT),
  106. MessagesTextRect (DEF_MESSAGESTEXTRECT),
  107. MessagesEndcapUVRect (DEF_MESSAGESENDCAPUVRECT),
  108. MessagesFadeoutUVRect (DEF_MESSAGESFADEOUTUVRECT),
  109. MessagesBackgroundUVRect (DEF_MESSAGESBACKGROUNDUVRECT),
  110. MessagesTextureSize (DEF_MESSAGESTEXTURESIZE),
  111. MessagesIconPos (DEF_MESSAGESICONPOS)
  112. {
  113. PARAM_SEPARATOR (EvaSettingsDefClass, "Objectives Viewer");
  114. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, ObjectivesScreenRect, "Screen Rect (normalized pixels)");
  115. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, ObjectivesTextRect, "Text Rect (normalized pixels)");
  116. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_VECTOR2, ObjectivesTextureSize, "Texture Size (pixels)");
  117. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, ObjectivesEndcapUVRect, "Endcap UV Rect (pixels)");
  118. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, ObjectivesFadeoutUVRect, "Fadeout UV Rect (pixels)");
  119. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, ObjectivesBackgroundUVRect, "Background UV Rect (pixels)");
  120. PARAM_SEPARATOR (EvaSettingsDefClass, "Messages Window");
  121. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, MessagesScreenRect, "Screen Rect (normalized pixels)");
  122. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, MessagesTextRect, "Text Rect (normalized pixels)");
  123. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_VECTOR2, MessagesIconPos, "Icon Position (normalized pixels)");
  124. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_VECTOR2, MessagesTextureSize, "Texture Size (pixels)");
  125. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, MessagesEndcapUVRect, "Endcap UV Rect (pixels)");
  126. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, MessagesFadeoutUVRect, "Fadeout UV Rect (pixels)");
  127. NAMED_EDITABLE_PARAM (EvaSettingsDefClass, ParameterClass::TYPE_RECT, MessagesBackgroundUVRect, "Background UV Rect (pixels)");
  128. EvaSettings = this;
  129. return ;
  130. }
  131. ///////////////////////////////////////////////////////////////////////////////////////////
  132. //
  133. // ~EvaSettingsDefClass
  134. //
  135. ///////////////////////////////////////////////////////////////////////////////////////////
  136. EvaSettingsDefClass::~EvaSettingsDefClass (void)
  137. {
  138. EvaSettings = &_DefaultSettings;
  139. return ;
  140. }
  141. ///////////////////////////////////////////////////////////////////////////////////////////
  142. //
  143. // Get_Class_ID
  144. //
  145. ///////////////////////////////////////////////////////////////////////////////////////////
  146. uint32
  147. EvaSettingsDefClass::Get_Class_ID (void) const
  148. {
  149. return CLASSID_GLOBAL_SETTINGS_DEF_EVA;
  150. }
  151. ///////////////////////////////////////////////////////////////////////////////////////////
  152. //
  153. // Get_Factory
  154. //
  155. ///////////////////////////////////////////////////////////////////////////////////////////
  156. const PersistFactoryClass &
  157. EvaSettingsDefClass::Get_Factory (void) const
  158. {
  159. return _EvaSettingsDefPersistFactory;
  160. }
  161. ///////////////////////////////////////////////////////////////////////////////////////////
  162. //
  163. // Create
  164. //
  165. ///////////////////////////////////////////////////////////////////////////////////////////
  166. PersistClass *
  167. EvaSettingsDefClass::Create (void) const
  168. {
  169. WWASSERT (0);
  170. return NULL;
  171. }
  172. ///////////////////////////////////////////////////////////////////////////////////////////
  173. //
  174. // Save
  175. //
  176. ///////////////////////////////////////////////////////////////////////////////////////////
  177. bool
  178. EvaSettingsDefClass::Save (ChunkSaveClass &csave)
  179. {
  180. csave.Begin_Chunk (CHUNKID_PARENT);
  181. DefinitionClass::Save (csave);
  182. csave.End_Chunk ();
  183. csave.Begin_Chunk (CHUNKID_VARIABLES);
  184. WRITE_MICRO_CHUNK (csave, VARID_OBJECTIVESSCREENRECT, ObjectivesScreenRect);
  185. WRITE_MICRO_CHUNK (csave, VARID_OBJECTIVESTEXTRECT, ObjectivesTextRect);
  186. WRITE_MICRO_CHUNK (csave, VARID_OBJECTIVESENDCAPUVRECT, ObjectivesEndcapUVRect);
  187. WRITE_MICRO_CHUNK (csave, VARID_OBJECTIVESFADEOUTUVRECT, ObjectivesFadeoutUVRect);
  188. WRITE_MICRO_CHUNK (csave, VARID_OBJECTIVESBACKGROUNDUVRECT, ObjectivesBackgroundUVRect);
  189. WRITE_MICRO_CHUNK (csave, VARID_OBJECTIVESTEXTURESIZE, ObjectivesTextureSize);
  190. WRITE_MICRO_CHUNK (csave, VARID_MESSAGESSCREENRECT, MessagesScreenRect);
  191. WRITE_MICRO_CHUNK (csave, VARID_MESSAGESTEXTRECT, MessagesTextRect);
  192. WRITE_MICRO_CHUNK (csave, VARID_MESSAGESENDCAPUVRECT, MessagesEndcapUVRect);
  193. WRITE_MICRO_CHUNK (csave, VARID_MESSAGESFADEOUTUVRECT, MessagesFadeoutUVRect);
  194. WRITE_MICRO_CHUNK (csave, VARID_MESSAGESBACKGROUNDUVRECT, MessagesBackgroundUVRect);
  195. WRITE_MICRO_CHUNK (csave, VARID_MESSAGESTEXTURESIZE, MessagesTextureSize);
  196. WRITE_MICRO_CHUNK (csave, VARID_MESSAGESICONPOS, MessagesIconPos);
  197. csave.End_Chunk();
  198. return true;
  199. }
  200. ///////////////////////////////////////////////////////////////////////////////////////////
  201. //
  202. // Load
  203. //
  204. ///////////////////////////////////////////////////////////////////////////////////////////
  205. bool
  206. EvaSettingsDefClass::Load (ChunkLoadClass &cload)
  207. {
  208. while (cload.Open_Chunk ()) {
  209. switch(cload.Cur_Chunk_ID ()) {
  210. case CHUNKID_PARENT:
  211. DefinitionClass::Load (cload);
  212. break;
  213. case CHUNKID_VARIABLES:
  214. while (cload.Open_Micro_Chunk ()) {
  215. switch(cload.Cur_Micro_Chunk_ID ()) {
  216. READ_MICRO_CHUNK (cload, VARID_OBJECTIVESSCREENRECT, ObjectivesScreenRect);
  217. READ_MICRO_CHUNK (cload, VARID_OBJECTIVESTEXTRECT, ObjectivesTextRect);
  218. READ_MICRO_CHUNK (cload, VARID_OBJECTIVESENDCAPUVRECT, ObjectivesEndcapUVRect);
  219. READ_MICRO_CHUNK (cload, VARID_OBJECTIVESFADEOUTUVRECT, ObjectivesFadeoutUVRect);
  220. READ_MICRO_CHUNK (cload, VARID_OBJECTIVESBACKGROUNDUVRECT, ObjectivesBackgroundUVRect);
  221. READ_MICRO_CHUNK (cload, VARID_OBJECTIVESTEXTURESIZE, ObjectivesTextureSize);
  222. READ_MICRO_CHUNK (cload, VARID_MESSAGESSCREENRECT, MessagesScreenRect);
  223. READ_MICRO_CHUNK (cload, VARID_MESSAGESTEXTRECT, MessagesTextRect);
  224. READ_MICRO_CHUNK (cload, VARID_MESSAGESENDCAPUVRECT, MessagesEndcapUVRect);
  225. READ_MICRO_CHUNK (cload, VARID_MESSAGESFADEOUTUVRECT, MessagesFadeoutUVRect);
  226. READ_MICRO_CHUNK (cload, VARID_MESSAGESBACKGROUNDUVRECT, MessagesBackgroundUVRect);
  227. READ_MICRO_CHUNK (cload, VARID_MESSAGESTEXTURESIZE, MessagesTextureSize);
  228. READ_MICRO_CHUNK (cload, VARID_MESSAGESICONPOS, MessagesIconPos);
  229. default:
  230. Debug_Say(("Unhandled Micro Chunk:%d File:%s Line:%d\r\n",cload.Cur_Micro_Chunk_ID (),__FILE__,__LINE__));
  231. break;
  232. }
  233. cload.Close_Micro_Chunk();
  234. }
  235. break;
  236. default:
  237. Debug_Say(("Unhandled Chunk:%d File:%s Line:%d\r\n",cload.Cur_Chunk_ID(),__FILE__,__LINE__));
  238. break;
  239. }
  240. cload.Close_Chunk();
  241. }
  242. ObjectiveManager::Reload_Viewer ();
  243. //
  244. // Ask the message window to recalculate its size...
  245. //
  246. MessageWindowClass *message_window = CombatManager::Get_Message_Window ();
  247. if (message_window != NULL) {
  248. message_window->Clear_Log ();
  249. message_window->Reset_Current_Rect ();
  250. message_window->Set_Window_Dirty (true);
  251. }
  252. return true;
  253. }