CBonusTypeHandler.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * CBonusTypeHandler.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 "IBonusTypeHandler.h"
  12. #include "IHandlerBase.h"
  13. #include "bonuses/Bonus.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class JsonNode;
  16. class DLL_LINKAGE CBonusType
  17. {
  18. public:
  19. CBonusType();
  20. std::string getDescriptionTextID() const;
  21. private:
  22. friend class CBonusTypeHandler;
  23. ImagePath icon;
  24. std::map<int, ImagePath> subtypeIcons;
  25. std::map<int, ImagePath> valueIcons;
  26. std::string identifier;
  27. bool hidden;
  28. };
  29. class DLL_LINKAGE CBonusTypeHandler : public IBonusTypeHandler
  30. {
  31. public:
  32. CBonusTypeHandler();
  33. virtual ~CBonusTypeHandler();
  34. std::string bonusToString(const std::shared_ptr<Bonus> & bonus, const IBonusBearer * bearer) const override;
  35. ImagePath bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const override;
  36. std::vector<JsonNode> loadLegacyData() override;
  37. void loadObject(std::string scope, std::string name, const JsonNode & data) override;
  38. void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
  39. private:
  40. void loadItem(const JsonNode & source, CBonusType & dest, const std::string & name) const;
  41. std::vector<CBonusType> bonusTypes; //index = BonusType
  42. };
  43. VCMI_LIB_NAMESPACE_END
  44. #ifndef INSTANTIATE_CBonusTypeHandler_HERE
  45. extern template class std::vector<VCMI_LIB_WRAP_NAMESPACE(CBonusType)>;
  46. #endif