CBonusTypeHandler.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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::map<int, std::string> subtypeDescriptions;
  27. std::map<int, std::string> valueDescriptions;
  28. std::string identifier;
  29. bool hidden;
  30. };
  31. class DLL_LINKAGE CBonusTypeHandler : public IBonusTypeHandler
  32. {
  33. std::vector<std::string> bonusNames;
  34. public:
  35. CBonusTypeHandler();
  36. virtual ~CBonusTypeHandler();
  37. std::string bonusToString(const std::shared_ptr<Bonus> & bonus, const IBonusBearer * bearer) const override;
  38. ImagePath bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const override;
  39. std::vector<JsonNode> loadLegacyData() override;
  40. void loadObject(std::string scope, std::string name, const JsonNode & data) override;
  41. void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
  42. BonusType stringToBonus(const std::string & name) const;
  43. const std::string bonusToString(BonusType bonus) const;
  44. std::vector<BonusType> getAllObjets() const;
  45. private:
  46. void loadItem(const JsonNode & source, CBonusType & dest, const std::string & name) const;
  47. std::vector<CBonusType> bonusTypes; //index = BonusType
  48. };
  49. VCMI_LIB_NAMESPACE_END
  50. #ifndef INSTANTIATE_CBonusTypeHandler_HERE
  51. extern template class std::vector<VCMI_LIB_WRAP_NAMESPACE(CBonusType)>;
  52. #endif