CGeneralTextHandler.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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; //texts for town screen,
  50. LegacyTextContainer hcommands; // town hall screen
  51. LegacyTextContainer fcommands; // fort screen
  52. LegacyTextContainer tavernInfo;
  53. LegacyTextContainer tavernRumors;
  54. LegacyTextContainer qeModCommands;
  55. LegacyHelpContainer zelp;
  56. LegacyTextContainer lossConditions;
  57. LegacyTextContainer victoryConditions;
  58. //objects
  59. LegacyTextContainer advobtxt;
  60. LegacyTextContainer restypes; //names of resources
  61. LegacyTextContainer randsign;
  62. LegacyTextContainer seerEmpty;
  63. LegacyTextContainer seerNames;
  64. LegacyTextContainer tentColors;
  65. //sec skills
  66. LegacyTextContainer levels;
  67. //commanders
  68. LegacyTextContainer znpc00; //more or less useful content of that file
  69. std::vector<std::string> findStringsWithPrefix(const std::string & prefix);
  70. int32_t pluralText(int32_t textIndex, int32_t count) const;
  71. size_t getCampaignLength(size_t campaignID) const;
  72. CGeneralTextHandler();
  73. CGeneralTextHandler(const CGeneralTextHandler&) = delete;
  74. CGeneralTextHandler operator=(const CGeneralTextHandler&) = delete;
  75. /// Attempts to detect encoding & language of H3 files
  76. static void detectInstallParameters();
  77. /// Returns name of language preferred by user
  78. static std::string getPreferredLanguage();
  79. /// Returns name of language of Heroes III text files
  80. static std::string getInstalledLanguage();
  81. /// Returns name of encoding of Heroes III text files
  82. static std::string getInstalledEncoding();
  83. };
  84. VCMI_LIB_NAMESPACE_END