CFaction.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * CFaction.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 "CFaction.h"
  12. #include "CTown.h"
  13. #include "../../VCMI_Lib.h"
  14. #include "../../texts/CGeneralTextHandler.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. CFaction::~CFaction()
  17. {
  18. if (town)
  19. {
  20. delete town;
  21. town = nullptr;
  22. }
  23. }
  24. int32_t CFaction::getIndex() const
  25. {
  26. return index.getNum();
  27. }
  28. int32_t CFaction::getIconIndex() const
  29. {
  30. return index.getNum(); //???
  31. }
  32. std::string CFaction::getJsonKey() const
  33. {
  34. return modScope + ':' + identifier;
  35. }
  36. void CFaction::registerIcons(const IconRegistar & cb) const
  37. {
  38. if(town)
  39. {
  40. auto & info = town->clientInfo;
  41. cb(info.icons[0][0], 0, "ITPT", info.iconLarge[0][0]);
  42. cb(info.icons[0][1], 0, "ITPT", info.iconLarge[0][1]);
  43. cb(info.icons[1][0], 0, "ITPT", info.iconLarge[1][0]);
  44. cb(info.icons[1][1], 0, "ITPT", info.iconLarge[1][1]);
  45. cb(info.icons[0][0] + 2, 0, "ITPA", info.iconSmall[0][0]);
  46. cb(info.icons[0][1] + 2, 0, "ITPA", info.iconSmall[0][1]);
  47. cb(info.icons[1][0] + 2, 0, "ITPA", info.iconSmall[1][0]);
  48. cb(info.icons[1][1] + 2, 0, "ITPA", info.iconSmall[1][1]);
  49. cb(index.getNum(), 1, "CPRSMALL", info.towerIconSmall);
  50. cb(index.getNum(), 1, "TWCRPORT", info.towerIconLarge);
  51. }
  52. }
  53. std::string CFaction::getNameTranslated() const
  54. {
  55. return VLC->generaltexth->translate(getNameTextID());
  56. }
  57. std::string CFaction::getNameTextID() const
  58. {
  59. return TextIdentifier("faction", modScope, identifier, "name").get();
  60. }
  61. std::string CFaction::getDescriptionTranslated() const
  62. {
  63. return VLC->generaltexth->translate(getDescriptionTextID());
  64. }
  65. std::string CFaction::getDescriptionTextID() const
  66. {
  67. return TextIdentifier("faction", modScope, identifier, "description").get();
  68. }
  69. FactionID CFaction::getId() const
  70. {
  71. return FactionID(index);
  72. }
  73. FactionID CFaction::getFaction() const
  74. {
  75. return FactionID(index);
  76. }
  77. bool CFaction::hasTown() const
  78. {
  79. return town != nullptr;
  80. }
  81. EAlignment CFaction::getAlignment() const
  82. {
  83. return alignment;
  84. }
  85. BoatId CFaction::getBoatType() const
  86. {
  87. return boatType;
  88. }
  89. TerrainId CFaction::getNativeTerrain() const
  90. {
  91. return nativeTerrain;
  92. }
  93. void CFaction::updateFrom(const JsonNode & data)
  94. {
  95. }
  96. void CFaction::serializeJson(JsonSerializeFormat & handler)
  97. {
  98. }
  99. VCMI_LIB_NAMESPACE_END