PlayerTemplate.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: PlayerTemplate.h ////////////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: PlayerTemplate.h
  36. //
  37. // Created: Steven Johnson, October 2001
  38. //
  39. // Desc: @todo
  40. //
  41. //-----------------------------------------------------------------------------
  42. #pragma once
  43. #ifndef _PLAYERTEMPLATE_H_
  44. #define _PLAYERTEMPLATE_H_
  45. #include "Common/SubsystemInterface.h"
  46. #include "Common/GameMemory.h"
  47. #include "Common/Debug.h"
  48. #include "Common/Handicap.h"
  49. #include "Common/Money.h"
  50. #include "Common/Science.h"
  51. #include "Common/AsciiString.h"
  52. #include "Common/UnicodeString.h"
  53. #include "Common/NameKeyGenerator.h"
  54. #include "Common/STLTypedefs.h"
  55. // ----------------------------------------------------------------------------------------------
  56. class INI;
  57. struct FieldParse;
  58. class Image;
  59. // ----------------------------------------------------------------------------------------------
  60. #define MAX_MP_STARTING_UNITS 10
  61. // ----------------------------------------------------------------------------------------------
  62. class PlayerTemplate
  63. {
  64. public:
  65. PlayerTemplate();
  66. inline void setNameKey(NameKeyType namekey) { m_nameKey = namekey; }
  67. inline NameKeyType getNameKey() const { DEBUG_ASSERTCRASH(m_nameKey != NAMEKEY_INVALID, ("bad namekey")); return m_nameKey; }
  68. inline AsciiString getName() const { return KEYNAME(m_nameKey); }
  69. inline UnicodeString getDisplayName() const { return m_displayName; }
  70. inline AsciiString getSide() const { return m_side; }
  71. inline AsciiString getBaseSide() const { return m_baseSide; }
  72. /// return the tech tree for the player.
  73. inline const Handicap *getHandicap() const { return &m_handicap; }
  74. /// return the money for the player.
  75. inline const Money *getMoney() const { return &m_money; }
  76. inline const RGBColor* getPreferredColor() const { return &m_preferredColor; }
  77. inline AsciiString getStartingBuilding( void ) const { return m_startingBuilding; }
  78. AsciiString getStartingUnit( Int i ) const;
  79. inline const ProductionChangeMap& getProductionCostChanges() const { return m_productionCostChanges; }
  80. inline const ProductionChangeMap& getProductionTimeChanges() const { return m_productionTimeChanges; }
  81. inline const ProductionVeterancyMap& getProductionVeterancyLevels() const { return m_productionVeterancyLevels; }
  82. inline Bool isObserver() const { return m_observer; }
  83. inline Bool isPlayableSide() const { return m_playableSide; }
  84. inline AsciiString getScoreScreen (void ) const { return m_scoreScreenImage; }
  85. inline AsciiString getLoadScreen (void ) const { return m_loadScreenImage; }
  86. inline AsciiString getBeaconTemplate( void ) const { return m_beaconTemplate; }
  87. const Image *getHeadWaterMarkImage( void ) const;
  88. const Image *getFlagWaterMarkImage( void ) const;
  89. const Image *getEnabledImage( void ) const;
  90. //const Image *getDisabledImage( void ) const;
  91. //const Image *getHiliteImage( void ) const;
  92. //const Image *getPushedImage( void ) const;
  93. const Image *getSideIconImage( void ) const;
  94. const Image *getGeneralImage( void ) const;
  95. inline const AsciiString getTooltip() const { return m_tooltip; }
  96. inline const AsciiString getGeneralFeatures( void ) const { return m_strGeneralFeatures; }
  97. AsciiString getMedallionNormal() const { return m_strMedallionNormal; }
  98. AsciiString getMedallionHilite() const { return m_strMedallionHilite; }
  99. AsciiString getMedallionSelected() const { return m_strMedallionSelected; }
  100. const ScienceVec& getIntrinsicSciences() const { return m_intrinsicSciences; }
  101. Int getIntrinsicSciencePurchasePoints() const { return m_intrinsicSPP; }
  102. AsciiString getPurchaseScienceCommandSetRank1( void ) const {return m_purchaseScienceCommandSetRank1; }
  103. AsciiString getPurchaseScienceCommandSetRank3( void ) const {return m_purchaseScienceCommandSetRank3; }
  104. AsciiString getPurchaseScienceCommandSetRank8( void ) const {return m_purchaseScienceCommandSetRank8; }
  105. AsciiString getSpecialPowerShortcutCommandSet( void ) const {return m_specialPowerShortcutCommandSet; }
  106. AsciiString getSpecialPowerShortcutWinName( void ) const {return m_specialPowerShortcutWinName; }
  107. Int getSpecialPowerShortcutButtonCount( void ) const {return m_specialPowerShortcutButtonCount; }
  108. AsciiString getLoadScreenMusic( void ) const {return m_loadScreenMusic; }
  109. AsciiString getScoreScreenMusic() const { return m_scoreScreenMusic; }
  110. inline Bool isOldFaction( void ) const { return m_oldFaction; }
  111. static const FieldParse* getFieldParse();
  112. protected:
  113. // for parsing from INI
  114. static void parseStartMoney( INI* ini, void *instance, void *store, const void* /*userData*/ );
  115. static void parseProductionCostChange( INI* ini, void *instance, void *store, const void* /*userData*/ );
  116. static void parseProductionTimeChange( INI* ini, void *instance, void *store, const void* /*userData*/ );
  117. static void parseProductionVeterancyLevel( INI* ini, void *instance, void *store, const void* /*userData*/ );
  118. private:
  119. NameKeyType m_nameKey;
  120. UnicodeString m_displayName;
  121. AsciiString m_side, m_baseSide;
  122. Handicap m_handicap; ///< initial baseline for Player capabilities
  123. Money m_money; ///< starting credits, if any
  124. RGBColor m_preferredColor; ///< our preferred starting color
  125. AsciiString m_startingBuilding; ///< template name of our multiplayer start building (con yard, i'd expect)
  126. AsciiString m_startingUnits[MAX_MP_STARTING_UNITS]; ///< template names of our multiplayer start units
  127. ProductionChangeMap m_productionCostChanges;
  128. ProductionChangeMap m_productionTimeChanges;
  129. ProductionVeterancyMap m_productionVeterancyLevels;
  130. ScienceVec m_intrinsicSciences; ///< sciences that this Player will always know
  131. AsciiString m_purchaseScienceCommandSetRank1; ///< the command set we'll use when we want to purchase sciences
  132. AsciiString m_purchaseScienceCommandSetRank3; ///< the command set we'll use when we want to purchase sciences
  133. AsciiString m_purchaseScienceCommandSetRank8; ///< the command set we'll use when we want to purchase sciences
  134. AsciiString m_specialPowerShortcutCommandSet; ///< the command set we'll use when we want to show the shortcut to the special powers
  135. AsciiString m_specialPowerShortcutWinName; ///< The name of the window we'll be using for the shortcut bar
  136. Int m_specialPowerShortcutButtonCount; ///< The number of buttons located on the shortcut bar
  137. AsciiString m_loadScreenMusic; ///< the load screen music we want to play
  138. AsciiString m_scoreScreenMusic; ///< the score screen music we want to play
  139. AsciiString m_tooltip; ///< The tooltip describing this player template
  140. Bool m_observer;
  141. Bool m_playableSide;
  142. Bool m_oldFaction; ///< Faction existed in the original Generals
  143. Int m_intrinsicSPP;
  144. AsciiString m_scoreScreenImage; ///< Image that will be shown on the score screen
  145. AsciiString m_loadScreenImage;
  146. AsciiString m_headWaterMark; ///< Image that will be the background on the observer control bar
  147. AsciiString m_flagWaterMark; ///< Imabe that will be the background on the observer control bar
  148. AsciiString m_enabledImage; ///< enable button image
  149. //AsciiString m_disabledImage; ///< disabled button image
  150. //AsciiString m_hiliteImage; ///< hilite button image
  151. //AsciiString m_pushedImage; ///< pushed button image
  152. AsciiString m_sideIconImage; ///< The little icon we show on game info screens for the sides
  153. AsciiString m_generalImage; ///< The icon overlayed on the rank image in My Persona
  154. AsciiString m_beaconTemplate; ///< ThingTemplate name for beacons
  155. AsciiString m_strGeneralFeatures; ///< used in loadscreens
  156. AsciiString m_strMedallionNormal;
  157. AsciiString m_strMedallionHilite;
  158. AsciiString m_strMedallionSelected;
  159. };
  160. // ----------------------------------------------------------------------------------------------
  161. /**
  162. This is a singleton class that maintains the list of PlayerTemplates.
  163. */
  164. class PlayerTemplateStore : public SubsystemInterface
  165. {
  166. public:
  167. PlayerTemplateStore();
  168. ~PlayerTemplateStore();
  169. virtual void init();
  170. virtual void reset();
  171. virtual void update();
  172. static void parsePlayerTemplateDefinition( INI* ini );
  173. const PlayerTemplate* getNthPlayerTemplate(Int i) const;
  174. const PlayerTemplate* findPlayerTemplate(NameKeyType namekey) const;
  175. inline Int getPlayerTemplateCount() const { return m_playerTemplates.size(); }
  176. Int getTemplateNumByName(AsciiString name) const;
  177. // This function will fill outStringList with all the sides found in all the templates
  178. void getAllSideStrings(AsciiStringList *outStringList);
  179. private:
  180. typedef std::vector<PlayerTemplate> PlayerTemplateVector;
  181. PlayerTemplateVector m_playerTemplates;
  182. };
  183. // ----------------------------------------------------------------------------------------------
  184. extern PlayerTemplateStore *ThePlayerTemplateStore; ///< singleton instance of PlayerTemplateStore
  185. #endif // _PLAYERTEMPLATE_H_