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.

CommandEngine.cpp 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*!
  2. * \file src/commands/CommandEngine.cpp
  3. * \brief Engine commands
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "Console.h"
  9. #include "Game.h"
  10. #include "Menu.h"
  11. #include "OpenRaider.h"
  12. #include "Render.h"
  13. #include "commands/CommandEngine.h"
  14. std::string CommandLoad::name() {
  15. return "load";
  16. }
  17. std::string CommandLoad::brief() {
  18. return "load a level file";
  19. }
  20. void CommandLoad::printHelp() {
  21. getConsole() << "load-Command Usage:" << Console::endl;
  22. getConsole() << " load /path/to/level" << Console::endl;
  23. }
  24. int CommandLoad::execute(std::istream& args) {
  25. if (!getOpenRaider().mRunning) {
  26. getConsole() << "Use load command interactively!" << Console::endl;
  27. return -1;
  28. }
  29. std::string map;
  30. args >> map;
  31. int error = getGame().loadLevel(map.c_str());
  32. return error;
  33. }
  34. // --------------------------------------
  35. std::string CommandScreenshot::name() {
  36. return "sshot";
  37. }
  38. std::string CommandScreenshot::brief() {
  39. return "make a screenshot";
  40. }
  41. void CommandScreenshot::printHelp() {
  42. getConsole() << "sshot-Command Usage:" << Console::endl;
  43. getConsole() << " sshot [console|menu] [console|menu]" << Console::endl;
  44. getConsole() << "Add console/menu to capture them too" << Console::endl;
  45. }
  46. int CommandScreenshot::execute(std::istream& args) {
  47. if (!getOpenRaider().mRunning) {
  48. getConsole() << "Use sshot command interactively!" << Console::endl;
  49. return -1;
  50. }
  51. std::string filename(getOpenRaider().getBaseDir());
  52. filename += "/sshots/";
  53. filename += VERSION_SHORT;
  54. bool console = false, menu = false;
  55. std::string temp, temp2;
  56. args >> temp >> temp2;
  57. getConsole().makeInvisible();
  58. getMenu().makeInvisible();
  59. if (temp == "console")
  60. getConsole().moveToTop();
  61. else if (temp == "menu")
  62. getMenu().moveToTop();
  63. if (temp2 == "console")
  64. getConsole().moveToTop();
  65. else if (temp2 == "menu")
  66. getMenu().moveToTop();
  67. getOpenRaider().frame();
  68. getOpenRaider().frame(); // Double buffered
  69. getRender().screenShot(filename.c_str());
  70. getMenu().makeInvisible();
  71. getConsole().moveToTop();
  72. getConsole() << "Screenshot stored..." << Console::endl;
  73. return 0;
  74. }
  75. // --------------------------------------
  76. std::string CommandQuit::name() {
  77. return "quit";
  78. }
  79. std::string CommandQuit::brief() {
  80. return "exit OpenRaider";
  81. }
  82. int CommandQuit::execute(std::istream& args) {
  83. exit(0);
  84. return 0;
  85. }