CFaction.cpp 2.4 KB

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