CampaignHandler.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * CampaignHandler.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 "CampaignState.h" // Convenience include - not required for build, but required for any user of CampaignHandler
  12. #include "../filesystem/ResourcePath.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class DLL_LINKAGE CampaignHandler
  15. {
  16. static std::string readLocalizedString(CampaignHeader & target, CBinaryReader & reader, std::string filename, std::string modName, std::string encoding, std::string identifier);
  17. static std::string readLocalizedString(CampaignHeader & target, std::string text, std::string filename, std::string modName, std::string identifier);
  18. static void readCampaign(Campaign * target, const std::vector<ui8> & stream, std::string filename, std::string modName, std::string encoding);
  19. //parsers for VCMI campaigns (*.vcmp)
  20. static void readHeaderFromJson(CampaignHeader & target, JsonNode & reader, std::string filename, std::string modName, std::string encoding);
  21. static CampaignScenario readScenarioFromJson(JsonNode & reader);
  22. static CampaignTravel readScenarioTravelFromJson(JsonNode & reader);
  23. //parsers for original H3C campaigns
  24. static void readHeaderFromMemory(CampaignHeader & target, CBinaryReader & reader, std::string filename, std::string modName, std::string encoding);
  25. static CampaignScenario readScenarioFromMemory(CBinaryReader & reader, CampaignHeader & header);
  26. static CampaignTravel readScenarioTravelFromMemory(CBinaryReader & reader, CampaignVersion version);
  27. /// returns h3c split in parts. 0 = h3c header, 1-end - maps (binary h3m)
  28. /// headerOnly - only header will be decompressed, returned vector wont have any maps
  29. static std::vector<std::vector<ui8>> getFile(std::unique_ptr<CInputStream> file, const std::string & filename, bool headerOnly);
  30. static VideoPath prologVideoName(ui8 index);
  31. static AudioPath prologMusicName(ui8 index);
  32. static AudioPath prologVoiceName(ui8 index);
  33. static constexpr auto VCMP_HEADER_FILE_NAME = "header.json";
  34. public:
  35. static std::unique_ptr<Campaign> getHeader( const std::string & name); //name - name of appropriate file
  36. static std::shared_ptr<CampaignState> getCampaign(const std::string & name); //name - name of appropriate file
  37. };
  38. VCMI_LIB_NAMESPACE_END