EditorData.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. #ifndef EDITORDATA_H
  2. #define EDITORDATA_H
  3. //===========================================================================//
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. //===========================================================================//
  6. #include "mclib.h"
  7. #ifndef OBJECTIVE_H
  8. #include "Objective.h"
  9. #endif
  10. #ifndef ELIST_H
  11. #include "elist.h"
  12. #endif
  13. #ifndef ESTRING_H
  14. #include "EString.h"
  15. #endif
  16. static const int GAME_MAX_PLAYERS = 8;
  17. #define EDITOR_VISIBLE_VERTICES 60
  18. // ARM
  19. namespace Microsoft
  20. {
  21. namespace Xna
  22. {
  23. namespace Arm
  24. {
  25. struct IProviderAsset;
  26. }
  27. }
  28. }
  29. extern Microsoft::Xna::Arm::IProviderAsset * mapAsset;
  30. extern Microsoft::Xna::Arm::IProviderAsset * mechAsset;
  31. class CTeam
  32. {
  33. public:
  34. CTeam(int alignment = 0) { Alignment(alignment); }
  35. bool operator==(const CTeam &rhs) const;
  36. void Clear() { m_objectives.Clear(); }
  37. int Alignment() { return m_alignment; }
  38. void Alignment(int alignment) { m_alignment = alignment; m_objectives.Alignment(m_alignment); }
  39. bool Read( FitIniFile* missionFile ) { return m_objectives.Read(missionFile); }
  40. bool Save( FitIniFile* missionFile ) { return m_objectives.Save(missionFile); }
  41. CObjectives &ObjectivesRef() { return m_objectives; }
  42. void handleObjectInvalidation(const EditorObject *pObj) { m_objectives.handleObjectInvalidation(pObj); }
  43. bool NoteThePositionsOfObjectsReferenced() { return m_objectives.NoteThePositionsOfObjectsReferenced(); }
  44. bool RestoreObjectPointerReferencesFromNotedPositions() { return m_objectives.RestoreObjectPointerReferencesFromNotedPositions(); }
  45. bool ThereAreObjectivesWithNoConditions() { return m_objectives.ThereAreObjectivesWithNoConditions(); }
  46. private:
  47. int m_alignment;
  48. CObjectives m_objectives;
  49. };
  50. class CTeams
  51. {
  52. public:
  53. CTeams();
  54. CTeams &operator=(const CTeams &master);
  55. bool operator==(const CTeams &rhs) const;
  56. void Clear();
  57. bool Read( FitIniFile* missionFile );
  58. bool Save( FitIniFile* missionFile );
  59. CTeam &TeamRef(int i);
  60. void handleObjectInvalidation(const EditorObject *pObj);
  61. bool NoteThePositionsOfObjectsReferenced();
  62. bool RestoreObjectPointerReferencesFromNotedPositions();
  63. bool ThereAreObjectivesWithNoConditions();
  64. private:
  65. CTeam m_teamArray[GAME_MAX_PLAYERS];
  66. };
  67. class CPlayer
  68. {
  69. public:
  70. CPlayer() { Clear(); }
  71. void Clear() { m_defaultTeam = 0; }
  72. int DefaultTeam() { return m_defaultTeam; }
  73. void DefaultTeam(int team);
  74. bool Read( FitIniFile* missionFile, int playerNum );
  75. bool Save( FitIniFile* missionFile, int playerNum );
  76. private:
  77. int m_defaultTeam;
  78. };
  79. class CPlayers
  80. {
  81. public:
  82. void Clear();
  83. CPlayer &PlayerRef(int i) { return m_playerArray[i]; }
  84. bool Read( FitIniFile* missionFile );
  85. bool Save( FitIniFile* missionFile );
  86. private:
  87. CPlayers &operator=(const CPlayers &master) { /*not valid, do not use*/ }
  88. CPlayer m_playerArray[GAME_MAX_PLAYERS];
  89. };
  90. class MissionSettings
  91. {
  92. public:
  93. int largeArtillery;
  94. int smallArtillery;
  95. int cameraDrones;
  96. int sensors;
  97. int time;
  98. void clear(){ largeArtillery = smallArtillery = cameraDrones = sensors = time = 0; }
  99. MissionSettings(){ clear(); }
  100. bool save( FitIniFile* file );
  101. };
  102. class EditorData
  103. {
  104. public:
  105. static EditorData* instance;
  106. EditorData();
  107. ~EditorData();
  108. // wipes all the data, the terrain, object etc.
  109. static bool clear();
  110. // makes a terrain from a height map.
  111. static bool initTerrainFromTGA( int mapSize, int min = 0, int max = 512, int terrain = 0 );
  112. static bool initTerrainFromPCV( const char* fileName );
  113. static bool reassignHeightsFromTGA( const char* fileName, int min, int max );
  114. bool save( const char* fileName, bool quickSave = false );
  115. bool quickSave( const char* fileName );
  116. static bool saveHeightMap( File* file );
  117. bool saveMissionFitFileStuff( FitIniFile &fitFile );
  118. static void setMapName( const char* name );
  119. static const char* getMapName(){ return strlen( mapName ) ? mapName : 0; }
  120. static void updateTitleBar();
  121. EString MissionName() { return m_missionName; }
  122. void MissionName(EString missionName) { m_missionName = missionName; }
  123. bool MissionNameUseResourceString() { return m_missionNameUseResourceString; }
  124. void MissionNameUseResourceString(bool missionNameUseResourceString) { m_missionNameUseResourceString = missionNameUseResourceString; }
  125. int MissionNameResourceStringID() { return m_missionNameResourceStringID; }
  126. void MissionNameResourceStringID(int missionNameResourceStringID) { m_missionNameResourceStringID = missionNameResourceStringID; }
  127. EString Author() { return m_author; }
  128. void Author(EString author) { m_author = author; }
  129. EString Blurb() { return m_blurb; }
  130. void Blurb(EString blurb) { m_blurb = blurb; }
  131. bool BlurbUseResourceString() { return m_blurbUseResourceString; }
  132. void BlurbUseResourceString(bool blurbUseResourceString) { m_blurbUseResourceString = blurbUseResourceString; }
  133. int BlurbResourceStringID() { return m_blurbResourceStringID; }
  134. void BlurbResourceStringID(int blurbResourceStringID) { m_blurbResourceStringID = blurbResourceStringID; }
  135. EString Blurb2() { return m_blurb2; }
  136. void Blurb2(EString blurb2) { m_blurb2 = blurb2; }
  137. bool Blurb2UseResourceString() { return m_blurb2UseResourceString; }
  138. void Blurb2UseResourceString(bool blurb2UseResourceString) { m_blurb2UseResourceString = blurb2UseResourceString; }
  139. int Blurb2ResourceStringID() { return m_blurb2ResourceStringID; }
  140. void Blurb2ResourceStringID(int blurb2ResourceStringID) { m_blurb2ResourceStringID = blurb2ResourceStringID; }
  141. float TimeLimit() { return m_timeLimit; }
  142. void TimeLimit(float timeLimit) { m_timeLimit = timeLimit; }
  143. float DropWeightLimit() { return m_dropWeightLimit; }
  144. void DropWeightLimit(float dropWeightLimit) { m_dropWeightLimit = dropWeightLimit; }
  145. int InitialResourcePoints() { return m_initialResourcePoints; }
  146. void InitialResourcePoints(int initialResourcePoints) { m_initialResourcePoints = initialResourcePoints; }
  147. int CBills() { return m_CBills; }
  148. void CBills( int newCBills ) { m_CBills = newCBills; }
  149. bool IsSinglePlayer() { return m_isSinglePlayer; }
  150. void IsSinglePlayer(bool isSinglePlayer) { m_isSinglePlayer = isSinglePlayer; }
  151. int MaxTeams() { return m_maxTeams; }
  152. void MaxTeams(int maxTeams) { m_maxTeams = maxTeams; /* Not finished. Need to check 2 <= param <= 8, disable menu items, etc.,. */}
  153. int MaxPlayers() { return m_maxPlayers; }
  154. void MaxPlayers(int maxPlayers);
  155. //{ m_maxPlayers = maxPlayers; /* Not finished. Need to check 2 <= param <= 8, disable menu items, etc.,. */}
  156. CTeams &TeamsRef() { return m_teams; }
  157. CPlayers &PlayersRef() { return m_players; }
  158. int ScenarioTune() { return m_scenarioTune; }
  159. void ScenarioTune(int scenarioTune) { m_scenarioTune = scenarioTune; }
  160. EString VideoFilename() { return m_videoFilename; }
  161. void VideoFilename(EString videoFilename) { m_videoFilename = videoFilename; }
  162. int NumRandomRPbuildings() { return m_numRandomRPbuildings; }
  163. void NumRandomRPbuildings(int numRandomRPbuildings) { m_numRandomRPbuildings = numRandomRPbuildings; }
  164. EString DownloadURL() { return m_downloadURL; }
  165. void DownloadURL(EString downloadURL) { m_downloadURL = downloadURL; }
  166. int MissionType() { return m_missionType; }
  167. void MissionType(int missionType) { m_missionType = missionType; }
  168. bool AirStrikesEnabledDefault() { return m_airStrikesEnabledDefault; }
  169. void AirStrikesEnabledDefault(bool airStrikesEnabledDefault) { m_airStrikesEnabledDefault = airStrikesEnabledDefault; }
  170. bool MineLayersEnabledDefault() { return m_mineLayersEnabledDefault; }
  171. void MineLayersEnabledDefault(bool mineLayersEnabledDefault) { m_mineLayersEnabledDefault = mineLayersEnabledDefault; }
  172. bool ScoutCoptersEnabledDefault() { return m_scoutCoptersEnabledDefault; }
  173. void ScoutCoptersEnabledDefault(bool scoutCoptersEnabledDefault) { m_scoutCoptersEnabledDefault = scoutCoptersEnabledDefault; }
  174. bool SensorProbesEnabledDefault() { return m_sensorProbesEnabledDefault; }
  175. void SensorProbesEnabledDefault(bool sensorProbesEnabledDefault) { m_sensorProbesEnabledDefault = sensorProbesEnabledDefault; }
  176. bool UnlimitedAmmoEnabledDefault() { return m_unlimitedAmmoEnabledDefault; }
  177. void UnlimitedAmmoEnabledDefault(bool unlimitedAmmoEnabledDefault) { m_unlimitedAmmoEnabledDefault = unlimitedAmmoEnabledDefault; }
  178. bool AllTechEnabledDefault() { return m_allTechEnabledDefault; }
  179. void AllTechEnabledDefault(bool allTechEnabledDefault) { m_allTechEnabledDefault = allTechEnabledDefault; }
  180. bool RepairVehicleEnabledDefault() { return m_repairVehicleEnabledDefault; }
  181. void RepairVehicleEnabledDefault(bool repairVehicleEnabledDefault) { m_repairVehicleEnabledDefault = repairVehicleEnabledDefault; }
  182. bool SalvageCraftEnabledDefault() { return m_salvageCraftEnabledDefault; }
  183. void SalvageCraftEnabledDefault(bool salvageCraftEnabledDefault) { m_salvageCraftEnabledDefault = salvageCraftEnabledDefault; }
  184. bool ResourceBuildingsEnabledDefault() { return m_resourceBuildingsEnabledDefault; }
  185. void ResourceBuildingsEnabledDefault(bool resourceBuildingsEnabledDefault) { m_resourceBuildingsEnabledDefault = resourceBuildingsEnabledDefault; }
  186. bool NoVariantsEnabledDefault() { return m_noVariantsEnabledDefault; }
  187. void NoVariantsEnabledDefault(bool noVariantsEnabledDefault) { m_noVariantsEnabledDefault = noVariantsEnabledDefault; }
  188. bool ArtilleryPieceEnabledDefault() { return m_artilleryPieceEnabledDefault; }
  189. void ArtilleryPieceEnabledDefault(bool artilleryPieceEnabledDefault) { m_artilleryPieceEnabledDefault = artilleryPieceEnabledDefault; }
  190. bool RPsForMechsEnabledDefault() { return m_rPsForMechsEnabledDefault; }
  191. void RPsForMechsEnabledDefault(bool rPsForMechsEnabledDefault) { m_rPsForMechsEnabledDefault = rPsForMechsEnabledDefault; }
  192. //weather
  193. int MaxRaindrops() { return m_maxRaindrops; }
  194. void MaxRaindrops(int maxRaindrops) { m_maxRaindrops = maxRaindrops; }
  195. float StartingRainLevel() { return m_startingRainLevel; }
  196. void StartingRainLevel(float startingRainLevel) { m_startingRainLevel = startingRainLevel; }
  197. float ChanceOfRain() { return m_chanceOfRain; }
  198. void ChanceOfRain(float chanceOfRain) { m_chanceOfRain = chanceOfRain; }
  199. float BaseLightningChance() { return m_baseLightningChance; }
  200. void BaseLightningChance(float baseLightningChance) { m_baseLightningChance = baseLightningChance; }
  201. long TheSkyNumber()
  202. {
  203. return m_theSkyNumber;
  204. }
  205. void TheSkyNumber (long theSkyNumber)
  206. {
  207. m_theSkyNumber = theSkyNumber;
  208. }
  209. bool MissionNeedsSaving() { return m_missionNeedsSaving; }
  210. void MissionNeedsSaving(bool missionNeedsSaving) { m_missionNeedsSaving = missionNeedsSaving; }
  211. bool DetailTextureNeedsSaving() { return m_detailTextureNeedsSaving; }
  212. void DetailTextureNeedsSaving(bool detailTextureNeedsSaving) { m_detailTextureNeedsSaving = detailTextureNeedsSaving; }
  213. bool WaterTextureNeedsSaving() { return m_waterTextureNeedsSaving; }
  214. void WaterTextureNeedsSaving(bool waterTextureNeedsSaving) { m_waterTextureNeedsSaving = waterTextureNeedsSaving; }
  215. bool WaterDetailTextureNeedsSaving() { return m_waterDetailTextureNeedsSaving; }
  216. void WaterDetailTextureNeedsSaving(bool waterDetailTextureNeedsSaving) { m_waterDetailTextureNeedsSaving = waterDetailTextureNeedsSaving; }
  217. bool saveObjectives( FitIniFile* file );
  218. bool DoTeamDialog(int team) { return TeamsRef().TeamRef(team).ObjectivesRef().EditDialog(); }
  219. void handleObjectInvalidation(const EditorObject *pObj) { TeamsRef().handleObjectInvalidation(pObj); }
  220. void makeTacMap(BYTE*& pOutput, long& dataSize, int tacMapSize ); // this allocates memory, below just draws
  221. void drawTacMap( BYTE* pDest, long dataSize, int tacMapSize );
  222. void loadTacMap(PacketFile *file, BYTE*& pDest, long dataSize, int tacMapSize ); // this allocates memory. Saves millions of CPU cycles on load
  223. private:
  224. EditorData& operator=( const EditorData& editorData );
  225. EditorData( const EditorData& editorData );
  226. bool saveTacMap (PacketFile* file, long whichPacket );
  227. EString m_missionName;
  228. bool m_missionNameUseResourceString;
  229. int m_missionNameResourceStringID;
  230. EString m_author;
  231. EString m_blurb;
  232. bool m_blurbUseResourceString;
  233. int m_blurbResourceStringID;
  234. EString m_blurb2;
  235. bool m_blurb2UseResourceString;
  236. int m_blurb2ResourceStringID;
  237. float m_timeLimit;
  238. float m_dropWeightLimit;
  239. int m_initialResourcePoints;
  240. int m_CBills;
  241. bool m_isSinglePlayer;
  242. int m_maxTeams;
  243. int m_maxPlayers;
  244. CTeams m_teams;
  245. CPlayers m_players;
  246. int m_scenarioTune;
  247. EString m_videoFilename;
  248. int m_numRandomRPbuildings;
  249. EString m_downloadURL;
  250. int m_missionType;
  251. /*defaults for multiplayer options*/
  252. bool m_airStrikesEnabledDefault;
  253. bool m_mineLayersEnabledDefault;
  254. bool m_scoutCoptersEnabledDefault;
  255. bool m_sensorProbesEnabledDefault;
  256. bool m_unlimitedAmmoEnabledDefault;
  257. bool m_allTechEnabledDefault;
  258. bool m_repairVehicleEnabledDefault;
  259. bool m_salvageCraftEnabledDefault;
  260. bool m_resourceBuildingsEnabledDefault;
  261. bool m_noVariantsEnabledDefault;
  262. bool m_artilleryPieceEnabledDefault;
  263. bool m_rPsForMechsEnabledDefault;
  264. static char mapName[256];
  265. static unsigned long* tacMapBmp; // tac map data, keep around so we can update
  266. MissionSettings missionSettings;
  267. //weather info
  268. int m_maxRaindrops;
  269. float m_startingRainLevel;
  270. float m_chanceOfRain;
  271. float m_baseLightningChance;
  272. long m_theSkyNumber;
  273. bool m_missionNeedsSaving;
  274. bool m_detailTextureNeedsSaving;
  275. bool m_waterTextureNeedsSaving;
  276. bool m_waterDetailTextureNeedsSaving;
  277. };
  278. //*************************************************************************************************
  279. #endif // end of file ( EditorData.h )