RiverHandler.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * TerrainHandler.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 <vcmi/EntityService.h>
  12. #include <vcmi/Entity.h>
  13. #include "GameConstants.h"
  14. #include "IHandlerBase.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. struct DLL_LINKAGE RiverPaletteAnimation
  17. {
  18. /// index of first color to cycle
  19. int32_t start;
  20. /// total numbers of colors to cycle
  21. int32_t length;
  22. template <typename Handler> void serialize(Handler& h, const int version)
  23. {
  24. h & start;
  25. h & length;
  26. }
  27. };
  28. class DLL_LINKAGE RiverType : public EntityT<RiverId>
  29. {
  30. friend class RiverTypeHandler;
  31. std::string identifier;
  32. std::string modScope;
  33. RiverId id;
  34. public:
  35. int32_t getIndex() const override { return id.getNum(); }
  36. int32_t getIconIndex() const override { return 0; }
  37. std::string getJsonKey() const override;
  38. void registerIcons(const IconRegistar & cb) const override {}
  39. RiverId getId() const override { return id;}
  40. void updateFrom(const JsonNode & data) {};
  41. std::string getNameTextID() const override;
  42. std::string getNameTranslated() const override;
  43. std::string tilesFilename;
  44. std::string shortIdentifier;
  45. std::string deltaName;
  46. std::vector<RiverPaletteAnimation> paletteAnimation;
  47. RiverType();
  48. template <typename Handler> void serialize(Handler& h, const int version)
  49. {
  50. h & tilesFilename;
  51. h & identifier;
  52. h & modScope;
  53. h & deltaName;
  54. h & id;
  55. h & paletteAnimation;
  56. }
  57. };
  58. class DLL_LINKAGE RiverTypeService : public EntityServiceT<RiverId, RiverType>
  59. {
  60. public:
  61. };
  62. class DLL_LINKAGE RiverTypeHandler : public CHandlerBase<RiverId, RiverType, RiverType, RiverTypeService>
  63. {
  64. public:
  65. virtual RiverType * loadFromJson(
  66. const std::string & scope,
  67. const JsonNode & json,
  68. const std::string & identifier,
  69. size_t index) override;
  70. RiverTypeHandler();
  71. virtual const std::vector<std::string> & getTypeNames() const override;
  72. virtual std::vector<JsonNode> loadLegacyData() override;
  73. virtual std::vector<bool> getDefaultAllowed() const override;
  74. template <typename Handler> void serialize(Handler & h, const int version)
  75. {
  76. h & objects;
  77. }
  78. };
  79. VCMI_LIB_NAMESPACE_END