ResourceConverter.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * ResourceConverter.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. namespace bfs = boost::filesystem;
  12. // Struct for holding all Convertor Options
  13. struct ConversionOptions
  14. {
  15. bool splitDefs = false; // splits TwCrPort, CPRSMALL, FlagPort, ITPA, ITPt, Un32 and Un44 into individual PNG's
  16. bool convertPcxToPng = false; // converts single Images (found in Images folder) from .pcx to png.
  17. bool deleteOriginals = false; // delete original files, for the ones splitted / converted.
  18. };
  19. // Struct for holding all Resource Extractor / Converter options
  20. struct ExtractionOptions
  21. {
  22. bool extractArchives = false; // if set, original H3 archives will be extracted into a separate folder
  23. ConversionOptions conversionOptions;
  24. bool moveExtractedArchivesToSoDMod = false;
  25. };
  26. /**
  27. * Class functionality to be used after extracting original H3 resources and before moving those resources to SoD Mod
  28. * Splits def files containing individual images, so that faction resources are independent. (TwCrPort, CPRSMALL, FlagPort, ITPA, ITPt, Un32 and Un44)
  29. * (town creature portraits, hero army creature portraits, adventure map dwellings, small town icons, big town icons,
  30. * hero speciality small icons, hero speciality large icons)
  31. * Converts all PCX images to PNG
  32. */
  33. class ResourceConverter
  34. {
  35. public:
  36. // Splits def files that are shared between factions and converts pcx to PNG depending on Extraction Options
  37. static void convertExtractedResourceFiles(ConversionOptions conversionOptions);
  38. private:
  39. /** Converts all .pcx from extractedFolder/Images into .png */
  40. static void doConvertPcxToPng(const bfs::path & sourceFolder, bool deleteOriginals);
  41. /** splits a .def file into individual images and converts the output to PNG format */
  42. static void splitDefFile(const std::string & fileName, const bfs::path & sourceFolder, bool deleteOriginals);
  43. /** Splits the given .def files into individual images.
  44. * For each .def file, the resulting images will be output in the same folder, in a subfolder (named just like the .def file)
  45. */
  46. static void splitDefFiles(const bfs::path & sourceFolder, std::vector<std::string> defFileNames, bool deleteOriginals);
  47. };