CMapInfo.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * CMapInfo.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. VCMI_LIB_NAMESPACE_BEGIN
  12. struct StartInfo;
  13. class CMapHeader;
  14. class Campaign;
  15. class ResourcePath;
  16. /**
  17. * A class which stores the count of human players and all players, the filename,
  18. * scenario options, the map header information,...
  19. */
  20. class DLL_LINKAGE CMapInfo
  21. {
  22. public:
  23. std::unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
  24. std::unique_ptr<Campaign> campaign; //may be nullptr if scenario
  25. StartInfo * scenarioOptionsOfSave; // Options with which scenario has been started (used only with saved games)
  26. std::string fileURI;
  27. std::string originalFileURI; // no need to serialize
  28. std::string fullFileURI; // no need to serialize
  29. std::time_t lastWrite; // no need to serialize
  30. std::string date;
  31. int amountOfPlayersOnMap;
  32. int amountOfHumanControllablePlayers;
  33. int amountOfHumanPlayersInSave;
  34. bool isRandomMap;
  35. CMapInfo();
  36. virtual ~CMapInfo();
  37. CMapInfo(CMapInfo &&other) = delete;
  38. CMapInfo(const CMapInfo &other) = delete;
  39. CMapInfo &operator=(CMapInfo &&other) = delete;
  40. CMapInfo &operator=(const CMapInfo &other) = delete;
  41. void mapInit(const std::string & fname);
  42. void saveInit(const ResourcePath & file);
  43. void campaignInit();
  44. void countPlayers();
  45. std::string getNameTranslated() const;
  46. std::string getNameForList() const;
  47. std::string getDescriptionTranslated() const;
  48. int getMapSizeIconId() const;
  49. int getMapSizeFormatIconId() const;
  50. std::string getMapSizeName() const;
  51. template <typename Handler> void serialize(Handler &h)
  52. {
  53. h & mapHeader;
  54. h & campaign;
  55. h & scenarioOptionsOfSave;
  56. h & fileURI;
  57. h & date;
  58. h & amountOfPlayersOnMap;
  59. h & amountOfHumanControllablePlayers;
  60. h & amountOfHumanPlayersInSave;
  61. h & isRandomMap;
  62. }
  63. };
  64. VCMI_LIB_NAMESPACE_END