SpellSchoolHandler.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 "../constants/EntityIdentifiers.h"
  12. #include "../IHandlerBase.h"
  13. #include "../filesystem/ResourcePath.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class SpellSchoolHandler;
  16. namespace spells
  17. {
  18. class DLL_LINKAGE SpellSchoolType
  19. {
  20. friend class VCMI_LIB_WRAP_NAMESPACE(SpellSchoolHandler);
  21. SpellSchool id; //backlink
  22. std::string jsonName;
  23. AnimationPath spellBordersPath;
  24. public:
  25. std::string getJsonKey() const
  26. {
  27. return jsonName;
  28. }
  29. AnimationPath getSpellBordersPath() const
  30. {
  31. return spellBordersPath;
  32. }
  33. int getIndex() const
  34. {
  35. return id.getNum();
  36. }
  37. };
  38. }
  39. class DLL_LINKAGE SpellSchoolHandler : public IHandlerBase
  40. {
  41. std::shared_ptr<spells::SpellSchoolType> loadObjectImpl(std::string scope, std::string name, const JsonNode & data, size_t index);
  42. public:
  43. std::vector<JsonNode> loadLegacyData() override;
  44. /// loads single object into game. Scope is namespace of this object, same as name of source mod
  45. void loadObject(std::string scope, std::string name, const JsonNode & data) override;
  46. void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
  47. std::vector<SpellSchool> getAllObjects() const;
  48. const spells::SpellSchoolType * getById(SpellSchool index) const
  49. {
  50. return objects.at(index).get();
  51. }
  52. private:
  53. std::vector<std::shared_ptr<spells::SpellSchoolType>> objects;
  54. };
  55. VCMI_LIB_NAMESPACE_END