CMapInfo.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. 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. void mapInit(const std::string & fname);
  43. void saveInit(const ResourcePath & file);
  44. void campaignInit();
  45. void countPlayers();
  46. std::string getNameTranslated() const;
  47. std::string getNameForList() const;
  48. std::string getDescriptionTranslated() const;
  49. int getMapSizeIconId() const;
  50. int getMapSizeFormatIconId() const;
  51. std::string getMapSizeName() const;
  52. template <typename Handler> void serialize(Handler &h)
  53. {
  54. h & mapHeader;
  55. h & campaign;
  56. h & scenarioOptionsOfSave;
  57. h & fileURI;
  58. h & date;
  59. h & amountOfPlayersOnMap;
  60. h & amountOfHumanControllablePlayers;
  61. h & amountOfHumanPlayersInSave;
  62. h & isRandomMap;
  63. }
  64. };
  65. VCMI_LIB_NAMESPACE_END