ResourceConverter.h 2.3 KB

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