RiverHandler.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. VCMI_LIB_NAMESPACE_BEGIN
  15. RiverTypeHandler::RiverTypeHandler()
  16. {
  17. objects.push_back(new RiverType);
  18. }
  19. RiverType * RiverTypeHandler::loadFromJson(
  20. const std::string & scope,
  21. const JsonNode & json,
  22. const std::string & identifier,
  23. size_t index)
  24. {
  25. assert(identifier.find(':') == std::string::npos);
  26. RiverType * info = new RiverType;
  27. info->id = RiverId(index);
  28. if (identifier.find(':') == std::string::npos)
  29. info->identifier = scope + ":" + identifier;
  30. else
  31. info->identifier = identifier;
  32. info->tilesFilename = json["tilesFilename"].String();
  33. info->shortIdentifier = json["shortIdentifier"].String();
  34. info->deltaName = json["delta"].String();
  35. VLC->generaltexth->registerString(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(size_t dataSize)
  44. {
  45. objects.resize(dataSize);
  46. return {};
  47. }
  48. std::vector<bool> RiverTypeHandler::getDefaultAllowed() const
  49. {
  50. return {};
  51. }
  52. std::string RiverType::getNameTextID() const
  53. {
  54. return TextIdentifier( "river", identifier, "name" ).get();
  55. }
  56. std::string RiverType::getNameTranslated() const
  57. {
  58. return VLC->generaltexth->translate(getNameTextID());
  59. }
  60. RiverType::RiverType():
  61. id(River::NO_RIVER),
  62. identifier("core:empty")
  63. {}
  64. VCMI_LIB_NAMESPACE_END