ImageLocator.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * ImageLocator.cpp, 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. #include "StdInc.h"
  11. #include "ImageLocator.h"
  12. #include "../../lib/json/JsonNode.h"
  13. ImageLocator::ImageLocator(const JsonNode & config)
  14. : image(ImagePath::fromJson(config["file"]))
  15. , defFile(AnimationPath::fromJson(config["defFile"]))
  16. , defFrame(config["defFrame"].Integer())
  17. , defGroup(config["defGroup"].Integer())
  18. , verticalFlip(config["verticalFlip"].Bool())
  19. , horizontalFlip(config["horizontalFlip"].Bool())
  20. {
  21. }
  22. ImageLocator::ImageLocator(const ImagePath & path)
  23. : image(path)
  24. {
  25. }
  26. ImageLocator::ImageLocator(const AnimationPath & path, int frame, int group)
  27. : defFile(path)
  28. , defFrame(frame)
  29. , defGroup(group)
  30. {
  31. }
  32. bool ImageLocator::operator<(const ImageLocator & other) const
  33. {
  34. if(image != other.image)
  35. return image < other.image;
  36. if(defFile != other.defFile)
  37. return defFile < other.defFile;
  38. if(defGroup != other.defGroup)
  39. return defGroup < other.defGroup;
  40. if(defFrame != other.defFrame)
  41. return defFrame < other.defFrame;
  42. if(verticalFlip != other.verticalFlip)
  43. return verticalFlip < other.verticalFlip;
  44. return horizontalFlip < other.horizontalFlip;
  45. }