Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Script.cpp 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*!
  2. * \file test/Script.cpp
  3. * \brief Game script loader unit test
  4. *
  5. * \author xythobuz
  6. */
  7. #include <iostream>
  8. #include "global.h"
  9. #include "test.h"
  10. #include "utils/strings.h"
  11. #include "Script.h"
  12. #define printStrings(cnt, acc, name) { \
  13. std::cout << name << " (" << cnt << ")" << std::endl; \
  14. for (unsigned int i = 0; i < cnt; i++) { \
  15. std::cout << " " << acc(i) << std::endl; \
  16. } \
  17. std::cout << std::endl; \
  18. }
  19. #define printStrings2D(c, cnt, acc, name) { \
  20. std::cout << name << " (" << c << "*" << cnt << ")" << std::endl; \
  21. for (unsigned int a = 0; a < cnt; a++) { \
  22. std::cout << " "; \
  23. for (unsigned int i = 0; i < c; i++) { \
  24. std::cout << acc(i, a); \
  25. if (i < (c - 1)) \
  26. std::cout << " | "; \
  27. } \
  28. std::cout << std::endl; \
  29. } \
  30. std::cout << std::endl; \
  31. }
  32. namespace {
  33. int test(const char *f) {
  34. Script s;
  35. assertEqual(s.load(f), 0);
  36. printStrings(s.levelCount(), s.getLevelName, "Level Names");
  37. printStrings(s.levelCount(), s.getLevelFilename, "Level Filenames");
  38. printStrings(s.cutsceneCount(), s.getCutsceneFilename, "Cutscenes");
  39. printStrings(s.titleCount(), s.getTitleFilename, "Titles");
  40. printStrings(s.videoCount(), s.getVideoFilename, "Videos");
  41. printStrings(s.gameStringCount(), s.getGameString, "Game Strings");
  42. printStrings(s.pcStringCount(), s.getPCString, "PC Strings");
  43. printStrings2D(4, s.levelCount(), s.getPuzzleString, "Puzzles");
  44. printStrings2D(2, s.levelCount(), s.getPickupString, "Pickups");
  45. printStrings2D(4, s.levelCount(), s.getKeyString, "Keys");
  46. return 0;
  47. }
  48. }
  49. int main() {
  50. char *f = fullPath("~/.OpenRaider/paks/tr2/TOMBPC.DAT", 0);
  51. int error = test(f);
  52. delete [] f;
  53. return error;
  54. }