CampaignHandler.h 2.1 KB

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