Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Script.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*!
  2. * \file include/Script.h
  3. * \brief Game script loader
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _SCRIPT_H_
  8. #define _SCRIPT_H_
  9. #include "utils/binary.h"
  10. #include <cstdint>
  11. #include <string>
  12. #include <vector>
  13. /*!
  14. * \brief Game script loader
  15. */
  16. class Script {
  17. public:
  18. typedef enum {
  19. S_English = 0,
  20. S_French = 1,
  21. S_German = 2,
  22. S_American = 3,
  23. S_Japanese = 4
  24. } ScriptLanguage;
  25. Script();
  26. ~Script();
  27. int load(const char *file);
  28. unsigned int levelCount();
  29. std::string getLevelName(unsigned int i);
  30. std::string getLevelFilename(unsigned int i);
  31. unsigned int cutsceneCount();
  32. std::string getCutsceneFilename(unsigned int i);
  33. unsigned int titleCount();
  34. std::string getTitleFilename(unsigned int i);
  35. unsigned int videoCount();
  36. std::string getVideoFilename(unsigned int i);
  37. unsigned int gameStringCount();
  38. std::string getGameString(unsigned int i);
  39. unsigned int pcStringCount();
  40. std::string getPCString(unsigned int i);
  41. std::string getPuzzleString(unsigned int i, unsigned int j);
  42. std::string getPickupString(unsigned int i, unsigned int j);
  43. std::string getKeyString(unsigned int i, unsigned int j);
  44. private:
  45. void readStringPackage(BinaryFile &f, std::vector<std::string> &v, unsigned int n, bool tag, uint16_t off);
  46. enum ScriptFlags {
  47. S_DemoVersion = (1 << 0), //!< Don't load a MAIN.SFX
  48. S_TitleDisabled = (1 << 1), //!< If set, game has no title screen
  49. S_CheatModeCheckDisabled = (1 << 2), //!< Disable flare/step/rotate/jump sequence
  50. S_NoInputTimeout = (1 << 3), //!< If set don't timeout input to start demo
  51. S_LoadSaveDisabled = (1 << 4), //!< Don't allow load/save
  52. S_ScreenSizingDisabled = (1 << 5), //!< Don't change screen resolution
  53. S_LockOutOptionRing = (1 << 6), //!< No option ring while in level
  54. S_DOZYCheatEnabled = (1 << 7), //!< DOZY flying cheat
  55. S_UseSecurityTag = (1 << 8), //!< Strings XORed with cypherCode
  56. S_Unknown = (1 << 9), //!< Usually set, no known effect
  57. S_SelectAnyLevel = (1 << 10), //!< Level selectable in Title
  58. S_EnableCheatCode = (1 << 11) //!< No known effect
  59. };
  60. // Header
  61. uint32_t version;
  62. std::string description;
  63. // Gameflow data
  64. uint32_t firstOption;
  65. int32_t titleReplace;
  66. uint32_t onDeathDemoMode;
  67. uint32_t onDeathInGame;
  68. uint32_t noInputTime;
  69. uint32_t onDemoInterrupt;
  70. uint32_t onDemoEnd;
  71. uint16_t numLevels;
  72. uint16_t numPictures;
  73. uint16_t numTitles;
  74. uint16_t numFMVs;
  75. uint16_t numCutscenes;
  76. uint16_t numDemos;
  77. uint16_t titleTrack;
  78. int16_t singleLevel;
  79. uint16_t flags;
  80. uint8_t cypherCode;
  81. uint8_t language;
  82. uint16_t secretTrack;
  83. uint16_t numGameStrings;
  84. // Strings
  85. std::vector<std::string> levelNames; // numLevels
  86. std::vector<std::string> pictureFilenames; // numPictures
  87. std::vector<std::string> titleFilenames; // numTitles
  88. std::vector<std::string> fmvFilenames; // numFMVs
  89. std::vector<std::string> levelFilenames; // numLevels
  90. std::vector<std::string> cutsceneFilenames; // numCutscenes
  91. std::vector<std::string> script; // numLevels + 1
  92. std::vector<std::string> gameStrings; // numGameStrings, 89
  93. std::vector<std::string> pcStrings; // 41
  94. std::vector<std::vector<std::string>> puzzles; // 4 * numLevels
  95. std::vector<std::vector<std::string>> pickups; // 2 * numLevels
  96. std::vector<std::vector<std::string>> keys; // 4 * numLevels
  97. };
  98. #endif