PlayerTemplate.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. ** Command & Conquer Generals(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. /// return the tech tree for the player.
  72. inline const Handicap *getHandicap() const { return &m_handicap; }
  73. /// return the money for the player.
  74. inline const Money *getMoney() const { return &m_money; }
  75. inline const RGBColor* getPreferredColor() const { return &m_preferredColor; }
  76. inline AsciiString getStartingBuilding( void ) const { return m_startingBuilding; }
  77. AsciiString getStartingUnit( Int i ) const;
  78. inline const ProductionChangeMap& getProductionCostChanges() const { return m_productionCostChanges; }
  79. inline const ProductionChangeMap& getProductionTimeChanges() const { return m_productionTimeChanges; }
  80. inline const ProductionVeterancyMap& getProductionVeterancyLevels() const { return m_productionVeterancyLevels; }
  81. inline Bool isObserver() const { return m_observer; }
  82. inline Bool isPlayableSide() const { return m_playableSide; }
  83. inline AsciiString getScoreScreen (void ) const { return m_scoreScreenImage; }
  84. inline AsciiString getLoadScreen (void ) const { return m_loadScreenImage; }
  85. inline AsciiString getBeaconTemplate( void ) const { return m_beaconTemplate; }
  86. const Image *getHeadWaterMarkImage( void ) const;
  87. const Image *getFlagWaterMarkImage( void ) const;
  88. const Image *getEnabledImage( void ) const;
  89. //const Image *getDisabledImage( void ) const;
  90. //const Image *getHiliteImage( void ) const;
  91. //const Image *getPushedImage( void ) const;
  92. const Image *getSideIconImage( void ) const;
  93. const ScienceVec& getIntrinsicSciences() const { return m_intrinsicSciences; }
  94. Int getIntrinsicSciencePurchasePoints() const { return m_intrinsicSPP; }
  95. AsciiString getPurchaseScienceCommandSetRank1( void ) const {return m_purchaseScienceCommandSetRank1; }
  96. AsciiString getPurchaseScienceCommandSetRank3( void ) const {return m_purchaseScienceCommandSetRank3; }
  97. AsciiString getPurchaseScienceCommandSetRank8( void ) const {return m_purchaseScienceCommandSetRank8; }
  98. AsciiString getSpecialPowerShortcutCommandSet( void ) const {return m_specialPowerShortcutCommandSet; }
  99. AsciiString getSpecialPowerShortcutWinName( void ) const {return m_specialPowerShortcutWinName; }
  100. Int getSpecialPowerShortcutButtonCount( void ) const {return m_specialPowerShortcutButtonCount; }
  101. AsciiString getLoadScreenMusic( void ) const {return m_loadScreenMusic; }
  102. static const FieldParse* getFieldParse();
  103. protected:
  104. // for parsing from INI
  105. static void parseStartMoney( INI* ini, void *instance, void *store, const void* /*userData*/ );
  106. static void parseProductionCostChange( INI* ini, void *instance, void *store, const void* /*userData*/ );
  107. static void parseProductionTimeChange( INI* ini, void *instance, void *store, const void* /*userData*/ );
  108. static void parseProductionVeterancyLevel( INI* ini, void *instance, void *store, const void* /*userData*/ );
  109. private:
  110. NameKeyType m_nameKey;
  111. UnicodeString m_displayName;
  112. AsciiString m_side;
  113. Handicap m_handicap; ///< initial baseline for Player capabilities
  114. Money m_money; ///< starting credits, if any
  115. RGBColor m_preferredColor; ///< our preferred starting color
  116. AsciiString m_startingBuilding; ///< template name of our multiplayer start building (con yard, i'd expect)
  117. AsciiString m_startingUnits[MAX_MP_STARTING_UNITS]; ///< template names of our multiplayer start units
  118. ProductionChangeMap m_productionCostChanges;
  119. ProductionChangeMap m_productionTimeChanges;
  120. ProductionVeterancyMap m_productionVeterancyLevels;
  121. ScienceVec m_intrinsicSciences; ///< sciences that this Player will always know
  122. AsciiString m_purchaseScienceCommandSetRank1; ///< the command set we'll use when we want to purchase sciences
  123. AsciiString m_purchaseScienceCommandSetRank3; ///< the command set we'll use when we want to purchase sciences
  124. AsciiString m_purchaseScienceCommandSetRank8; ///< the command set we'll use when we want to purchase sciences
  125. AsciiString m_specialPowerShortcutCommandSet; ///< the command set we'll use when we want to show the shortcut to the special powers
  126. AsciiString m_specialPowerShortcutWinName; ///< The name of the window we'll be using for the shortcut bar
  127. Int m_specialPowerShortcutButtonCount; ///< The number of buttons located on the shortcut bar
  128. AsciiString m_loadScreenMusic; ///< the load screen music we want to play
  129. Bool m_observer;
  130. Bool m_playableSide;
  131. Int m_intrinsicSPP;
  132. AsciiString m_scoreScreenImage; ///< Image that will be shown on the score screen
  133. AsciiString m_loadScreenImage;
  134. AsciiString m_headWaterMark; ///< Image that will be the background on the observer control bar
  135. AsciiString m_flagWaterMark; ///< Imabe that will be the background on the observer control bar
  136. AsciiString m_enabledImage; ///< enable button image
  137. //AsciiString m_disabledImage; ///< disabled button image
  138. //AsciiString m_hiliteImage; ///< hilite button image
  139. //AsciiString m_pushedImage; ///< pushed button image
  140. AsciiString m_sideIconImage; ///< The little icon we show on game info screens for the sides
  141. AsciiString m_beaconTemplate; ///< ThingTemplate name for beacons
  142. };
  143. // ----------------------------------------------------------------------------------------------
  144. /**
  145. This is a singleton class that maintains the list of PlayerTemplates.
  146. */
  147. class PlayerTemplateStore : public SubsystemInterface
  148. {
  149. public:
  150. PlayerTemplateStore();
  151. ~PlayerTemplateStore();
  152. virtual void init();
  153. virtual void reset();
  154. virtual void update();
  155. static void parsePlayerTemplateDefinition( INI* ini );
  156. const PlayerTemplate* getNthPlayerTemplate(Int i) const;
  157. const PlayerTemplate* findPlayerTemplate(NameKeyType namekey) const;
  158. inline Int getPlayerTemplateCount() const { return m_playerTemplates.size(); }
  159. // This function will fill outStringList with all the sides found in all the templates
  160. void getAllSideStrings(AsciiStringList *outStringList);
  161. private:
  162. typedef std::vector<PlayerTemplate> PlayerTemplateVector;
  163. PlayerTemplateVector m_playerTemplates;
  164. };
  165. // ----------------------------------------------------------------------------------------------
  166. extern PlayerTemplateStore *ThePlayerTemplateStore; ///< singleton instance of PlayerTemplateStore
  167. #endif // _PLAYERTEMPLATE_H_