RiverHandler.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Terrain.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 "RiverHandler.h"
  12. #include "CModHandler.h"
  13. #include "CGeneralTextHandler.h"
  14. #include "GameSettings.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. RiverTypeHandler::RiverTypeHandler()
  17. {
  18. objects.push_back(new RiverType);
  19. VLC->generaltexth->registerString("core", objects[0]->getNameTextID(), "");
  20. }
  21. RiverType * RiverTypeHandler::loadFromJson(
  22. const std::string & scope,
  23. const JsonNode & json,
  24. const std::string & identifier,
  25. size_t index)
  26. {
  27. assert(identifier.find(':') == std::string::npos);
  28. auto * info = new RiverType;
  29. info->id = RiverId(index);
  30. info->identifier = identifier;
  31. info->modScope = scope;
  32. info->tilesFilename = json["tilesFilename"].String();
  33. info->shortIdentifier = json["shortIdentifier"].String();
  34. info->deltaName = json["delta"].String();
  35. VLC->generaltexth->registerString(scope, info->getNameTextID(), json["text"].String());
  36. return info;
  37. }
  38. const std::vector<std::string> & RiverTypeHandler::getTypeNames() const
  39. {
  40. static const std::vector<std::string> typeNames = { "river" };
  41. return typeNames;
  42. }
  43. std::vector<JsonNode> RiverTypeHandler::loadLegacyData()
  44. {
  45. size_t dataSize = VLC->settings()->getInteger(EGameSettings::TEXTS_RIVER);
  46. objects.resize(dataSize);
  47. return {};
  48. }
  49. std::vector<bool> RiverTypeHandler::getDefaultAllowed() const
  50. {
  51. return {};
  52. }
  53. std::string RiverType::getJsonKey() const
  54. {
  55. return modScope + ":" + identifier;
  56. }
  57. std::string RiverType::getNameTextID() const
  58. {
  59. return TextIdentifier( "river", modScope, identifier, "name" ).get();
  60. }
  61. std::string RiverType::getNameTranslated() const
  62. {
  63. return VLC->generaltexth->translate(getNameTextID());
  64. }
  65. RiverType::RiverType():
  66. id(River::NO_RIVER),
  67. identifier("empty"),
  68. modScope("core")
  69. {}
  70. VCMI_LIB_NAMESPACE_END