RoadHandler.h 1.8 KB

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