CGeneralTextHandler.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #pragma once
  2. /*
  3. * CGeneralTextHandler.h, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. class CInputStream;
  12. /// Parser for any text files from H3
  13. class CLegacyConfigParser
  14. {
  15. std::unique_ptr<char[]> data;
  16. char * curr;
  17. char * end;
  18. void init(const std::unique_ptr<CInputStream> & input);
  19. /// extracts part of quoted string.
  20. std::string extractQuotedPart();
  21. /// extracts quoted string. Any end of lines are ignored, double-quote is considered as "escaping"
  22. std::string extractQuotedString();
  23. /// extracts non-quoted string
  24. std::string extractNormalString();
  25. public:
  26. /// read one entry from current line. Return ""/0 if end of line reached
  27. std::string readString();
  28. float readNumber();
  29. template <typename numeric>
  30. std::vector<numeric> readNumArray(size_t size)
  31. {
  32. std::vector<numeric> ret;
  33. ret.reserve(size);
  34. while (size--)
  35. ret.push_back(readNumber());
  36. return ret;
  37. }
  38. /// returns true if next entry is empty
  39. bool isNextEntryEmpty();
  40. /// end current line
  41. bool endLine();
  42. CLegacyConfigParser(std::string URI);
  43. CLegacyConfigParser(const std::unique_ptr<CInputStream> & input);
  44. };
  45. class DLL_LINKAGE CGeneralTextHandler //Handles general texts
  46. {
  47. public:
  48. std::vector<std::string> allTexts;
  49. std::vector<std::string> arraytxt;
  50. std::vector<std::string> primarySkillNames;
  51. std::vector<std::string> jktexts;
  52. std::vector<std::string> heroscrn;
  53. std::vector<std::string> overview;//text for Kingdom Overview window
  54. std::vector<std::string> colors; //names of player colors ("red",...)
  55. std::vector<std::string> capColors; //names of player colors with first letter capitalized ("Red",...)
  56. std::vector<std::string> turnDurations; //turn durations for pregame (1 Minute ... Unlimited)
  57. //towns
  58. std::vector<std::string> tcommands, hcommands, fcommands; //texts for town screen, town hall screen and fort screen
  59. std::vector<std::string> tavernInfo;
  60. std::vector<std::pair<std::string,std::string> > zelp;
  61. std::vector<std::string> lossCondtions;
  62. std::vector<std::string> victoryConditions;
  63. //objects
  64. std::vector<std::string> names; //vector of objects; i-th object in vector has subnumber i
  65. std::vector<std::string> creGens; //names of creatures' generators
  66. std::vector<std::string> creGens4; //names of multiple creatures' generators
  67. std::vector<std::string> advobtxt;
  68. std::vector<std::string> xtrainfo;
  69. std::vector<std::string> restypes; //names of resources
  70. std::vector<std::string> terrainNames;
  71. std::vector<std::string> randsign;
  72. std::vector<std::pair<std::string,std::string> > mines; //first - name; second - event description
  73. std::vector<std::string> seerEmpty;
  74. std::vector <std::vector <std::vector <std::string> > > quests; //[quest][type][index]
  75. //type: quest, progress, complete, rollover, log OR time limit //index: 0-2 seer hut, 3-5 border guard
  76. std::vector<std::string> seerNames;
  77. std::vector<std::string> tentColors;
  78. std::vector<std::string> threat; //power rating for neutral stacks
  79. //sec skills
  80. std::vector <std::string> skillName;
  81. std::vector <std::vector <std::string> > skillInfoTexts; //[id][level] : level 0 - basic; 2 - advanced
  82. std::vector<std::string> levels;
  83. std::vector<std::string> zcrexp; //more or less useful content of that file
  84. //campaigns
  85. std::vector <std::string> campaignMapNames;
  86. std::vector < std::vector <std::string> > campaignRegionNames;
  87. void readToVector(std::string sourceName, std::vector<std::string> & dest);
  88. CGeneralTextHandler();
  89. };