CHero.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * CHero.cpp, 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. #include "StdInc.h"
  11. #include "CHero.h"
  12. #include "../../GameLibrary.h"
  13. #include "../../texts/CGeneralTextHandler.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. CHero::CHero() = default;
  16. CHero::~CHero() = default;
  17. int32_t CHero::getIndex() const
  18. {
  19. return ID.getNum();
  20. }
  21. int32_t CHero::getIconIndex() const
  22. {
  23. return imageIndex;
  24. }
  25. std::string CHero::getJsonKey() const
  26. {
  27. return modScope + ':' + identifier;
  28. }
  29. std::string CHero::getModScope() const
  30. {
  31. return modScope;
  32. }
  33. HeroTypeID CHero::getId() const
  34. {
  35. return ID;
  36. }
  37. std::string CHero::getNameTranslated() const
  38. {
  39. return LIBRARY->generaltexth->translate(getNameTextID());
  40. }
  41. std::string CHero::getBiographyTranslated() const
  42. {
  43. return LIBRARY->generaltexth->translate(getBiographyTextID());
  44. }
  45. std::string CHero::getSpecialtyNameTranslated() const
  46. {
  47. return LIBRARY->generaltexth->translate(getSpecialtyNameTextID());
  48. }
  49. std::string CHero::getSpecialtyDescriptionTranslated() const
  50. {
  51. return LIBRARY->generaltexth->translate(getSpecialtyDescriptionTextID());
  52. }
  53. std::string CHero::getSpecialtyTooltipTranslated() const
  54. {
  55. return LIBRARY->generaltexth->translate(getSpecialtyTooltipTextID());
  56. }
  57. std::string CHero::getNameTextID() const
  58. {
  59. return TextIdentifier("hero", modScope, identifier, "name").get();
  60. }
  61. std::string CHero::getBiographyTextID() const
  62. {
  63. return TextIdentifier("hero", modScope, identifier, "biography").get();
  64. }
  65. std::string CHero::getSpecialtyNameTextID() const
  66. {
  67. return TextIdentifier("hero", modScope, identifier, "specialty", "name").get();
  68. }
  69. std::string CHero::getSpecialtyDescriptionTextID() const
  70. {
  71. return TextIdentifier("hero", modScope, identifier, "specialty", "description").get();
  72. }
  73. std::string CHero::getSpecialtyTooltipTextID() const
  74. {
  75. return TextIdentifier("hero", modScope, identifier, "specialty", "tooltip").get();
  76. }
  77. void CHero::registerIcons(const IconRegistar & cb) const
  78. {
  79. cb(getIconIndex(), 0, "UN32", iconSpecSmall);
  80. cb(getIconIndex(), 0, "UN44", iconSpecLarge);
  81. cb(getIconIndex(), 0, "PORTRAITSLARGE", portraitLarge);
  82. cb(getIconIndex(), 0, "PORTRAITSSMALL", portraitSmall);
  83. }
  84. void CHero::updateFrom(const JsonNode & data)
  85. {
  86. //todo: CHero::updateFrom
  87. }
  88. void CHero::serializeJson(JsonSerializeFormat & handler)
  89. {
  90. }
  91. VCMI_LIB_NAMESPACE_END