CGeneralTextHandler.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 capColors; //names of player colors with first letter capitalized ("Red",...)
  46. LegacyTextContainer turnDurations; //turn durations for pregame (1 Minute ... Unlimited)
  47. //towns
  48. LegacyTextContainer tcommands; //texts for town screen,
  49. LegacyTextContainer hcommands; // town hall screen
  50. LegacyTextContainer fcommands; // fort screen
  51. LegacyTextContainer tavernInfo;
  52. LegacyHelpContainer zelp;
  53. //objects
  54. LegacyTextContainer advobtxt;
  55. LegacyTextContainer restypes; //names of resources
  56. LegacyTextContainer seerEmpty;
  57. LegacyTextContainer seerNames;
  58. LegacyTextContainer tentColors;
  59. //sec skills
  60. LegacyTextContainer levels;
  61. //commanders
  62. LegacyTextContainer znpc00; //more or less useful content of that file
  63. std::vector<std::string> findStringsWithPrefix(const std::string & prefix);
  64. int32_t pluralText(int32_t textIndex, int32_t count) const;
  65. size_t getCampaignLength(size_t campaignID) const;
  66. CGeneralTextHandler();
  67. CGeneralTextHandler(const CGeneralTextHandler&) = delete;
  68. CGeneralTextHandler operator=(const CGeneralTextHandler&) = delete;
  69. /// Attempts to detect encoding & language of H3 files
  70. static void detectInstallParameters();
  71. /// Returns name of language preferred by user
  72. static std::string getPreferredLanguage();
  73. /// Returns name of language of Heroes III text files
  74. static std::string getInstalledLanguage();
  75. /// Returns name of encoding of Heroes III text files
  76. static std::string getInstalledEncoding();
  77. };
  78. VCMI_LIB_NAMESPACE_END