RenderHandler.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * RenderHandler.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 "../render/IRenderHandler.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class EntityService;
  14. VCMI_LIB_NAMESPACE_END
  15. class CDefFile;
  16. class IConstImage;
  17. class RenderHandler : public IRenderHandler
  18. {
  19. using AnimationLayoutMap = std::map<size_t, std::vector<ImageLocator>>;
  20. std::map<AnimationPath, std::shared_ptr<CDefFile>> animationFiles;
  21. std::map<AnimationPath, AnimationLayoutMap> animationLayouts;
  22. std::map<ImageLocator, std::shared_ptr<IConstImage>> imageFiles;
  23. std::shared_ptr<CDefFile> getAnimationFile(const AnimationPath & path);
  24. AnimationLayoutMap & getAnimationLayout(const AnimationPath & path);
  25. void initFromJson(AnimationLayoutMap & layout, const JsonNode & config);
  26. void addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName);
  27. void addImageListEntries(const EntityService * service);
  28. std::shared_ptr<IConstImage> loadImageFromSingleFile(const ImagePath & path);
  29. std::shared_ptr<IConstImage> loadImageFromAnimationFileUncached(const AnimationPath & path, int frame, int group);
  30. std::shared_ptr<IConstImage> loadImageFromAnimationFile(const AnimationPath & path, int frame, int group);
  31. std::shared_ptr<IConstImage> loadImageImpl(const ImageLocator & config);
  32. public:
  33. // IRenderHandler implementation
  34. void onLibraryLoadingFinished(const Services * services) override;
  35. std::shared_ptr<IImage> loadImage(const ImageLocator & locator, EImageBlitMode mode) override;
  36. std::shared_ptr<IImage> loadImage(const ImagePath & path, EImageBlitMode mode) override;
  37. std::shared_ptr<IImage> loadImage(const AnimationPath & path, int frame, int group, EImageBlitMode mode) override;
  38. std::shared_ptr<CAnimation> loadAnimation(const AnimationPath & path, EImageBlitMode mode) override;
  39. std::shared_ptr<IImage> createImage(SDL_Surface * source) override;
  40. };