RoadHandler.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include "filesystem/ResourcePath.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. class DLL_LINKAGE RoadType : public EntityT<RoadId>
  18. {
  19. friend class RoadTypeHandler;
  20. std::string identifier;
  21. std::string modScope;
  22. RoadId id;
  23. public:
  24. int32_t getIndex() const override { return id.getNum(); }
  25. int32_t getIconIndex() const override { return 0; }
  26. std::string getJsonKey() const override;
  27. void registerIcons(const IconRegistar & cb) const override {}
  28. RoadId getId() const override { return id;}
  29. void updateFrom(const JsonNode & data) {};
  30. std::string getNameTextID() const override;
  31. std::string getNameTranslated() const override;
  32. AnimationPath tilesFilename;
  33. std::string shortIdentifier;
  34. ui8 movementCost;
  35. RoadType();
  36. template <typename Handler> void serialize(Handler& h, const int version)
  37. {
  38. h & tilesFilename;
  39. h & identifier;
  40. h & modScope;
  41. h & id;
  42. h & movementCost;
  43. }
  44. };
  45. class DLL_LINKAGE RoadTypeService : public EntityServiceT<RoadId, RoadType>
  46. {
  47. public:
  48. };
  49. class DLL_LINKAGE RoadTypeHandler : public CHandlerBase<RoadId, RoadType, RoadType, RoadTypeService>
  50. {
  51. public:
  52. virtual RoadType * loadFromJson(
  53. const std::string & scope,
  54. const JsonNode & json,
  55. const std::string & identifier,
  56. size_t index) override;
  57. RoadTypeHandler();
  58. virtual const std::vector<std::string> & getTypeNames() const override;
  59. virtual std::vector<JsonNode> loadLegacyData() override;
  60. virtual std::vector<bool> getDefaultAllowed() const override;
  61. template <typename Handler> void serialize(Handler & h, const int version)
  62. {
  63. h & objects;
  64. }
  65. };
  66. VCMI_LIB_NAMESPACE_END