CFaction.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. std::string CFaction::getModScope() const
  37. {
  38. return modScope;
  39. }
  40. void CFaction::registerIcons(const IconRegistar & cb) const
  41. {
  42. if(town)
  43. {
  44. auto & info = town->clientInfo;
  45. cb(info.icons[0][0], 0, "ITPT", info.iconLarge[0][0]);
  46. cb(info.icons[0][1], 0, "ITPT", info.iconLarge[0][1]);
  47. cb(info.icons[1][0], 0, "ITPT", info.iconLarge[1][0]);
  48. cb(info.icons[1][1], 0, "ITPT", info.iconLarge[1][1]);
  49. cb(info.icons[0][0] + 2, 0, "ITPA", info.iconSmall[0][0]);
  50. cb(info.icons[0][1] + 2, 0, "ITPA", info.iconSmall[0][1]);
  51. cb(info.icons[1][0] + 2, 0, "ITPA", info.iconSmall[1][0]);
  52. cb(info.icons[1][1] + 2, 0, "ITPA", info.iconSmall[1][1]);
  53. cb(index.getNum(), 1, "CPRSMALL", info.towerIconSmall);
  54. cb(index.getNum(), 1, "TWCRPORT", info.towerIconLarge);
  55. }
  56. }
  57. std::string CFaction::getNameTranslated() const
  58. {
  59. return VLC->generaltexth->translate(getNameTextID());
  60. }
  61. std::string CFaction::getNameTextID() const
  62. {
  63. return TextIdentifier("faction", modScope, identifier, "name").get();
  64. }
  65. std::string CFaction::getDescriptionTranslated() const
  66. {
  67. return VLC->generaltexth->translate(getDescriptionTextID());
  68. }
  69. std::string CFaction::getDescriptionTextID() const
  70. {
  71. return TextIdentifier("faction", modScope, identifier, "description").get();
  72. }
  73. FactionID CFaction::getId() const
  74. {
  75. return FactionID(index);
  76. }
  77. FactionID CFaction::getFactionID() const
  78. {
  79. return FactionID(index);
  80. }
  81. bool CFaction::hasTown() const
  82. {
  83. return town != nullptr;
  84. }
  85. EAlignment CFaction::getAlignment() const
  86. {
  87. return alignment;
  88. }
  89. BoatId CFaction::getBoatType() const
  90. {
  91. return boatType;
  92. }
  93. TerrainId CFaction::getNativeTerrain() const
  94. {
  95. return nativeTerrain;
  96. }
  97. void CFaction::updateFrom(const JsonNode & data)
  98. {
  99. }
  100. void CFaction::serializeJson(JsonSerializeFormat & handler)
  101. {
  102. }
  103. VCMI_LIB_NAMESPACE_END