ImageLocator.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * ImageLocator.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 "IImage.h"
  12. #include "../../lib/filesystem/ResourcePath.h"
  13. #include "../../lib/constants/EntityIdentifiers.h"
  14. struct ImageLocator
  15. {
  16. std::optional<ImagePath> image;
  17. std::optional<AnimationPath> defFile;
  18. int defFrame = -1;
  19. int defGroup = -1;
  20. PlayerColor playerColored = PlayerColor::CANNOT_DETERMINE; // FIXME: treat as identical to blue to avoid double-loading?
  21. bool verticalFlip = false;
  22. bool horizontalFlip = false;
  23. int8_t scalingFactor = 0; // 0 = auto / use default scaling
  24. int8_t preScaledFactor = 1;
  25. EImageBlitMode layer = EImageBlitMode::OPAQUE;
  26. ImageLocator() = default;
  27. ImageLocator(const AnimationPath & path, int frame, int group);
  28. explicit ImageLocator(const JsonNode & config);
  29. explicit ImageLocator(const ImagePath & path);
  30. bool operator < (const ImageLocator & other) const;
  31. bool empty() const;
  32. ImageLocator copyFile() const;
  33. ImageLocator copyFileTransform() const;
  34. ImageLocator copyFileTransformScale() const;
  35. // generates string representation of this image locator
  36. // guaranteed to be a valid file path with no extension
  37. // but may contain '/' if source file is in directory
  38. std::string toString() const;
  39. };