CBonusTypeHandler.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 : boost::noncopyable
  17. {
  18. public:
  19. CBonusType() = default;
  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 creatureNature = false;
  30. bool hidden = true;
  31. bool blockDescriptionPropagation = false;
  32. };
  33. class DLL_LINKAGE CBonusTypeHandler : public IBonusTypeHandler
  34. {
  35. std::vector<std::string> builtinBonusNames;
  36. public:
  37. CBonusTypeHandler();
  38. virtual ~CBonusTypeHandler();
  39. std::string bonusToString(const std::shared_ptr<Bonus> & bonus, const IBonusBearer * bearer) const override;
  40. ImagePath bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const override;
  41. std::vector<JsonNode> loadLegacyData() override;
  42. void loadObject(std::string scope, std::string name, const JsonNode & data) override;
  43. void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
  44. const std::string & bonusToString(BonusType bonus) const;
  45. bool isCreatureNatureBonus(BonusType bonus) const;
  46. bool shouldPropagateDescription(BonusType bonus) const;
  47. std::vector<BonusType> getAllObjets() const;
  48. private:
  49. void loadItem(const JsonNode & source, CBonusType & dest, const std::string & name) const;
  50. std::vector<std::shared_ptr<CBonusType> > bonusTypes; //index = BonusType
  51. };
  52. VCMI_LIB_NAMESPACE_END
  53. #ifndef INSTANTIATE_CBonusTypeHandler_HERE
  54. extern template class std::vector<VCMI_LIB_WRAP_NAMESPACE(CBonusType)>;
  55. #endif