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 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*!
  2. * \file src/commands/CommandEngine.cpp
  3. * \brief Engine commands
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "Game.h"
  9. #include "Log.h"
  10. #include "Menu.h"
  11. #include "RunTime.h"
  12. #include "Render.h"
  13. #include "UI.h"
  14. #include "commands/CommandEngine.h"
  15. std::string CommandLoad::name() {
  16. return "load";
  17. }
  18. std::string CommandLoad::brief() {
  19. return "load a level file";
  20. }
  21. void CommandLoad::printHelp() {
  22. getLog() << "load-Command Usage:" << Log::endl;
  23. getLog() << " load /path/to/level" << Log::endl;
  24. }
  25. int CommandLoad::execute(std::istream& args) {
  26. if (!RunTime::isRunning()) {
  27. getLog() << "Use load command interactively!" << Log::endl;
  28. return -1;
  29. }
  30. std::string map;
  31. args >> map;
  32. int error = getGame().loadLevel(map.c_str());
  33. return error;
  34. }
  35. // --------------------------------------
  36. std::string CommandScreenshot::name() {
  37. return "sshot";
  38. }
  39. std::string CommandScreenshot::brief() {
  40. return "make a screenshot";
  41. }
  42. void CommandScreenshot::printHelp() {
  43. getLog() << "sshot-Command Usage:" << Log::endl;
  44. getLog() << " sshot" << Log::endl;
  45. getLog() << "You wont be able to capture imgui..." << Log::endl;
  46. }
  47. int CommandScreenshot::execute(std::istream& args) {
  48. if (!RunTime::isRunning()) {
  49. getLog() << "Use sshot command interactively!" << Log::endl;
  50. return -1;
  51. }
  52. std::string filename(RunTime::getBaseDir());
  53. filename += "/sshots/";
  54. filename += VERSION_SHORT;
  55. Render::screenShot(filename.c_str());
  56. return 0;
  57. }
  58. // --------------------------------------
  59. std::string CommandQuit::name() {
  60. return "quit";
  61. }
  62. std::string CommandQuit::brief() {
  63. return "exit OpenRaider";
  64. }
  65. int CommandQuit::execute(std::istream& args) {
  66. RunTime::setRunning(false);
  67. return 0;
  68. }