AssetGenerator.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * AssetGenerator.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 "ImageLocator.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class PlayerColor;
  14. VCMI_LIB_NAMESPACE_END
  15. class ISharedImage;
  16. class CanvasImage;
  17. class AssetGenerator
  18. {
  19. public:
  20. using AnimationLayoutMap = std::map<size_t, std::vector<ImageLocator>>;
  21. using CanvasPtr = std::shared_ptr<CanvasImage>;
  22. void initialize();
  23. std::shared_ptr<ISharedImage> generateImage(const ImagePath & image);
  24. std::map<ImagePath, std::shared_ptr<ISharedImage>> generateAllImages();
  25. std::map<AnimationPath, AnimationLayoutMap> generateAllAnimations();
  26. private:
  27. using ImageGenerationFunctor = std::function<CanvasPtr()>;
  28. struct PaletteAnimation
  29. {
  30. /// index of first color to cycle
  31. int32_t start;
  32. /// total numbers of colors to cycle
  33. int32_t length;
  34. };
  35. std::map<ImagePath, ImageGenerationFunctor> imageFiles;
  36. std::map<AnimationPath, AnimationLayoutMap> animationFiles;
  37. CanvasPtr createAdventureOptionsCleanBackground() const;
  38. CanvasPtr createBigSpellBook() const;
  39. CanvasPtr createPlayerColoredBackground(const PlayerColor & player) const;
  40. CanvasPtr createCombatUnitNumberWindow(float multR, float multG, float multB) const;
  41. CanvasPtr createCampaignBackground() const;
  42. CanvasPtr createChroniclesCampaignImages(int chronicle) const;
  43. CanvasPtr createPaletteShiftedImage(const AnimationPath & source, const std::vector<PaletteAnimation> & animation, int frameIndex, int paletteShiftCounter) const;
  44. void createPaletteShiftedSprites();
  45. void generatePaletteShiftedAnimation(const AnimationPath & source, const std::vector<PaletteAnimation> & animation);
  46. };