SpellSchoolHandler.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * SpellSchoolHandler.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 "../constants/EntityIdentifiers.h"
  14. #include "../IHandlerBase.h"
  15. #include "../filesystem/ResourcePath.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. class SpellSchoolHandler;
  18. namespace spells
  19. {
  20. class DLL_LINKAGE SpellSchoolType : public EntityT<SpellSchool>
  21. {
  22. friend class VCMI_LIB_WRAP_NAMESPACE(SpellSchoolHandler);
  23. SpellSchool id; //backlink
  24. AnimationPath spellBordersPath;
  25. AnimationPath schoolBookmarkPath;
  26. ImagePath schoolHeaderPath;
  27. std::string identifier;
  28. std::string modScope;
  29. public:
  30. AnimationPath getSpellBordersPath() const
  31. {
  32. return spellBordersPath;
  33. }
  34. AnimationPath getSchoolBookmarkPath() const
  35. {
  36. return schoolBookmarkPath;
  37. }
  38. ImagePath getSchoolHeaderPath() const
  39. {
  40. return schoolHeaderPath;
  41. }
  42. std::string getJsonKey() const override { return identifier; }
  43. int32_t getIndex() const override { return id.getNum(); }
  44. SpellSchool getId() const override { return id;}
  45. int32_t getIconIndex() const override { return 0; }
  46. std::string getModScope() const override { return modScope; };
  47. void registerIcons(const IconRegistar & cb) const override {};
  48. std::string getNameTextID() const override;
  49. std::string getNameTranslated() const override;
  50. };
  51. }
  52. class DLL_LINKAGE SpellSchoolHandler : public IHandlerBase
  53. {
  54. std::shared_ptr<spells::SpellSchoolType> loadObjectImpl(std::string scope, std::string name, const JsonNode & data, size_t index);
  55. public:
  56. std::vector<JsonNode> loadLegacyData() override;
  57. /// loads single object into game. Scope is namespace of this object, same as name of source mod
  58. void loadObject(std::string scope, std::string name, const JsonNode & data) override;
  59. void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
  60. std::vector<SpellSchool> getAllObjects() const;
  61. const spells::SpellSchoolType * getById(SpellSchool index) const
  62. {
  63. return objects.at(index).get();
  64. }
  65. private:
  66. std::vector<std::shared_ptr<spells::SpellSchoolType>> objects;
  67. };
  68. VCMI_LIB_NAMESPACE_END