CampaignManager.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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: CampaignManager.h /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Jul 2002
  34. //
  35. // Filename: CampaignManager.h
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose:
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __CAMPAIGN_MANAGER_H_
  45. #define __CAMPAIGN_MANAGER_H_
  46. //-----------------------------------------------------------------------------
  47. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. //-----------------------------------------------------------------------------
  50. // USER INCLUDES //////////////////////////////////////////////////////////////
  51. //-----------------------------------------------------------------------------
  52. #include "Common/Snapshot.h"
  53. #include "Common/AudioEventRTS.h"
  54. //-----------------------------------------------------------------------------
  55. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  56. //-----------------------------------------------------------------------------
  57. class AsciiString;
  58. class Image;
  59. enum{ MAX_OBJECTIVE_LINES = 5 };
  60. enum{ MAX_DISPLAYED_UNITS = 3 };
  61. //-----------------------------------------------------------------------------
  62. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  63. //-----------------------------------------------------------------------------
  64. class Mission : public MemoryPoolObject
  65. {
  66. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( Mission, "Mission" )
  67. public:
  68. Mission( void );
  69. //~Mission( void );
  70. public:
  71. AsciiString m_name;
  72. AsciiString m_mapName;
  73. AsciiString m_nextMission;
  74. AsciiString m_movieLabel;
  75. AsciiString m_missionObjectivesLabel[MAX_OBJECTIVE_LINES];
  76. AudioEventRTS m_briefingVoice;
  77. AsciiString m_locationNameLabel;
  78. AsciiString m_unitNames[MAX_DISPLAYED_UNITS];
  79. Int m_voiceLength;
  80. AsciiString m_generalName;
  81. };
  82. class Campaign : public MemoryPoolObject
  83. {
  84. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( Campaign, "Campaign" )
  85. public:
  86. Campaign( void );
  87. //~Campaign( void );
  88. Mission *newMission( AsciiString name );
  89. Mission *getNextMission( Mission *current);
  90. Mission *getMission( AsciiString missionName);
  91. AsciiString getFinalVictoryMovie( void );
  92. Bool isChallengeCampaign( void ) { return m_isChallengeCampaign; }
  93. public:
  94. typedef std::list< Mission* > MissionList; ///< list of Shell Menu schemes
  95. typedef MissionList::iterator MissionListIt;
  96. AsciiString m_name;
  97. AsciiString m_firstMission;
  98. AsciiString m_campaignNameLabel; ///< campaign name label from string manager
  99. MissionList m_missions;
  100. AsciiString m_finalMovieName;
  101. Bool m_isChallengeCampaign;
  102. AsciiString m_playerFactionName;
  103. };
  104. class CampaignManager : public Snapshot
  105. {
  106. public:
  107. CampaignManager( void );
  108. ~CampaignManager( void );
  109. // snapshot methods
  110. virtual void crc( Xfer *xfer ) { }
  111. virtual void xfer( Xfer *xfer );
  112. virtual void loadPostProcess( void );
  113. void init( void );
  114. Campaign *getCurrentCampaign( void ); ///< Returns a point to the current Campaign
  115. Mission *getCurrentMission( void ); ///< Returns a point to the current mission
  116. Mission *gotoNextMission( void ); ///< Set the next mission as the current Mission, and returns a point to it
  117. void setCampaignAndMission( AsciiString campaign, AsciiString mission ); ///< Sets the campaing and Mission we're on
  118. void setCampaign( AsciiString campaign ); ///< sets the campaign and set's it's first mission
  119. AsciiString getCurrentMap( void ); ///< Get the map located in m_currentMission;
  120. enum { INVALID_MISSION_NUMBER = -1 };
  121. Int getCurrentMissionNumber( void ); ///< get mission number for the currently loaded level if we are in a campaign
  122. const FieldParse *getFieldParse( void ) const { return m_campaignFieldParseTable; } ///< returns the parsing fields
  123. static const FieldParse m_campaignFieldParseTable[]; ///< the parse table
  124. static void parseMissionPart( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the Mission Part
  125. Campaign *newCampaign(AsciiString name);
  126. Bool isVictorious( void ) { return m_victorious; }
  127. void SetVictorious( Bool victory ) { m_victorious = victory; }
  128. void setRankPoints( Int rankPoints ) { m_currentRankPoints = rankPoints; }
  129. Int getRankPoints() const {
  130. // All campaign missions, regular and generals' challenge now start each map at rank 0.
  131. // This is because they weren't designed with rank persistence in mind, and were primarily
  132. // tested in a debug context, with no notion of previous rank.
  133. // NOTE: the assumption is being made that this method will never be used for any purpose
  134. // other than setting initial starting rank on map load, as it is currently. 08/09/03
  135. return 0;
  136. }
  137. GameDifficulty getGameDifficulty() const { return m_difficulty; }
  138. void setGameDifficulty(GameDifficulty d) { m_difficulty = d; }
  139. private:
  140. typedef std::list< Campaign* > CampaignList; ///< list of Shell Menu schemes
  141. typedef CampaignList::iterator CampaignListIt;
  142. CampaignList m_campaignList; ///< Our List of Campaigns
  143. Campaign *m_currentCampaign; ///< Our current Campaign
  144. Mission *m_currentMission; ///< our Current Mission
  145. Bool m_victorious;
  146. Int m_currentRankPoints;
  147. GameDifficulty m_difficulty;
  148. Int m_xferChallengeGeneralsPlayerTemplateNum; ///< Need a place to stick this naughty singleton's important bit.
  149. };
  150. //-----------------------------------------------------------------------------
  151. // INLINING ///////////////////////////////////////////////////////////////////
  152. //-----------------------------------------------------------------------------
  153. //-----------------------------------------------------------------------------
  154. // EXTERNALS //////////////////////////////////////////////////////////////////
  155. //-----------------------------------------------------------------------------
  156. extern CampaignManager *TheCampaignManager;
  157. #endif // __CAMPAIGN_MANAGER_H_