CMapInfo.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #include "../serializer/Serializeable.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. struct StartInfo;
  14. class CMapHeader;
  15. class Campaign;
  16. class ResourcePath;
  17. /**
  18. * A class which stores the count of human players and all players, the filename,
  19. * scenario options, the map header information,...
  20. */
  21. class DLL_LINKAGE CMapInfo : public Serializeable
  22. {
  23. public:
  24. std::unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
  25. std::unique_ptr<Campaign> campaign; //may be nullptr if scenario
  26. std::unique_ptr<StartInfo> scenarioOptionsOfSave; // Options with which scenario has been started (used only with saved games)
  27. std::string fileURI;
  28. std::string originalFileURI; // no need to serialize
  29. std::string fullFileURI; // no need to serialize
  30. std::time_t lastWrite; // no need to serialize
  31. std::string date;
  32. int amountOfPlayersOnMap;
  33. int amountOfHumanControllablePlayers;
  34. int amountOfHumanPlayersInSave;
  35. bool isRandomMap;
  36. CMapInfo();
  37. virtual ~CMapInfo();
  38. CMapInfo(CMapInfo &&other) = delete;
  39. CMapInfo(const CMapInfo &other) = delete;
  40. CMapInfo &operator=(CMapInfo &&other) = delete;
  41. CMapInfo &operator=(const CMapInfo &other) = delete;
  42. std::string getFullFileURI(const ResourcePath& file) const;
  43. void mapInit(const std::string & fname);
  44. void saveInit(const ResourcePath & file);
  45. void campaignInit();
  46. void countPlayers();
  47. std::string getNameTranslated() const;
  48. std::string getNameForList() const;
  49. std::string getDescriptionTranslated() const;
  50. int getMapSizeIconId() const;
  51. int getMapSizeFormatIconId() const;
  52. std::string getMapSizeName() const;
  53. template <typename Handler> void serialize(Handler &h)
  54. {
  55. h & mapHeader;
  56. h & campaign;
  57. h & scenarioOptionsOfSave;
  58. h & fileURI;
  59. h & date;
  60. h & amountOfPlayersOnMap;
  61. h & amountOfHumanControllablePlayers;
  62. h & amountOfHumanPlayersInSave;
  63. h & isRandomMap;
  64. }
  65. };
  66. VCMI_LIB_NAMESPACE_END