CampaignHandler.h 2.1 KB

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