CGeneralTextHandler.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * CGeneralTextHandler.h, 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. #pragma once
  11. #include "TextLocalizationContainer.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class CGeneralTextHandler;
  14. /// Small wrapper that provides text access API compatible with old code
  15. class DLL_LINKAGE LegacyTextContainer
  16. {
  17. CGeneralTextHandler & owner;
  18. std::string basePath;
  19. public:
  20. LegacyTextContainer(CGeneralTextHandler & owner, std::string basePath);
  21. std::string operator [](size_t index) const;
  22. };
  23. /// Small wrapper that provides help text access API compatible with old code
  24. class DLL_LINKAGE LegacyHelpContainer
  25. {
  26. CGeneralTextHandler & owner;
  27. std::string basePath;
  28. public:
  29. LegacyHelpContainer(CGeneralTextHandler & owner, std::string basePath);
  30. std::pair<std::string, std::string> operator[](size_t index) const;
  31. };
  32. /// Handles all text-related data in game
  33. class DLL_LINKAGE CGeneralTextHandler: public TextLocalizationContainer
  34. {
  35. void readToVector(const std::string & sourceID, const std::string & sourceName);
  36. /// number of scenarios in specific campaign. TODO: move to a better location
  37. std::vector<size_t> scenariosCountPerCampaign;
  38. public:
  39. LegacyTextContainer allTexts;
  40. LegacyTextContainer arraytxt;
  41. LegacyTextContainer primarySkillNames;
  42. LegacyTextContainer jktexts;
  43. LegacyTextContainer heroscrn;
  44. LegacyTextContainer overview;//text for Kingdom Overview window
  45. LegacyTextContainer colors; //names of player colors ("red",...)
  46. LegacyTextContainer capColors; //names of player colors with first letter capitalized ("Red",...)
  47. LegacyTextContainer turnDurations; //turn durations for pregame (1 Minute ... Unlimited)
  48. //towns
  49. LegacyTextContainer tcommands, hcommands, fcommands; //texts for town screen, town hall screen and fort screen
  50. LegacyTextContainer tavernInfo;
  51. LegacyTextContainer tavernRumors;
  52. LegacyTextContainer qeModCommands;
  53. LegacyHelpContainer zelp;
  54. LegacyTextContainer lossConditions;
  55. LegacyTextContainer victoryConditions;
  56. //objects
  57. LegacyTextContainer advobtxt;
  58. LegacyTextContainer restypes; //names of resources
  59. LegacyTextContainer randsign;
  60. LegacyTextContainer seerEmpty;
  61. LegacyTextContainer seerNames;
  62. LegacyTextContainer tentColors;
  63. //sec skills
  64. LegacyTextContainer levels;
  65. //commanders
  66. LegacyTextContainer znpc00; //more or less useful content of that file
  67. std::vector<std::string> findStringsWithPrefix(const std::string & prefix);
  68. int32_t pluralText(int32_t textIndex, int32_t count) const;
  69. size_t getCampaignLength(size_t campaignID) const;
  70. CGeneralTextHandler();
  71. CGeneralTextHandler(const CGeneralTextHandler&) = delete;
  72. CGeneralTextHandler operator=(const CGeneralTextHandler&) = delete;
  73. /// Attempts to detect encoding & language of H3 files
  74. static void detectInstallParameters();
  75. /// Returns name of language preferred by user
  76. static std::string getPreferredLanguage();
  77. /// Returns name of language of Heroes III text files
  78. static std::string getInstalledLanguage();
  79. /// Returns name of encoding of Heroes III text files
  80. static std::string getInstalledEncoding();
  81. };
  82. VCMI_LIB_NAMESPACE_END