123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /*!
- * \file src/commands/CommandEngine.cpp
- * \brief Engine commands
- *
- * \author xythobuz
- */
-
- #include "global.h"
- #include "Console.h"
- #include "Game.h"
- #include "Menu.h"
- #include "OpenRaider.h"
- #include "Render.h"
- #include "commands/CommandEngine.h"
-
- std::string CommandLoad::name() {
- return "load";
- }
-
- std::string CommandLoad::brief() {
- return "load a level file";
- }
-
- void CommandLoad::printHelp() {
- getConsole() << "load-Command Usage:" << Console::endl;
- getConsole() << " load /path/to/level" << Console::endl;
- }
-
- int CommandLoad::execute(std::istream& args) {
- if (!getOpenRaider().mRunning) {
- getConsole() << "Use load command interactively!" << Console::endl;
- return -1;
- }
-
- std::string map;
- args >> map;
- int error = getGame().loadLevel(map.c_str());
- return error;
- }
-
- // --------------------------------------
-
- std::string CommandScreenshot::name() {
- return "sshot";
- }
-
- std::string CommandScreenshot::brief() {
- return "make a screenshot";
- }
-
- void CommandScreenshot::printHelp() {
- getConsole() << "sshot-Command Usage:" << Console::endl;
- getConsole() << " sshot [console|menu] [console|menu]" << Console::endl;
- getConsole() << "Add console/menu to capture them too" << Console::endl;
- }
-
- int CommandScreenshot::execute(std::istream& args) {
- if (!getOpenRaider().mRunning) {
- getConsole() << "Use sshot command interactively!" << Console::endl;
- return -1;
- }
-
- std::string filename(getOpenRaider().getBaseDir());
- filename += "/sshots/";
- filename += VERSION_SHORT;
-
- bool console = false, menu = false;
- std::string temp, temp2;
- args >> temp >> temp2;
-
- getConsole().makeInvisible();
- getMenu().makeInvisible();
-
- if (temp == "console")
- getConsole().moveToTop();
- else if (temp == "menu")
- getMenu().moveToTop();
-
- if (temp2 == "console")
- getConsole().moveToTop();
- else if (temp2 == "menu")
- getMenu().moveToTop();
-
- getOpenRaider().frame();
- getOpenRaider().frame(); // Double buffered
- getRender().screenShot(filename.c_str());
-
- getMenu().makeInvisible();
- getConsole().moveToTop();
-
- getConsole() << "Screenshot stored..." << Console::endl;
- return 0;
- }
-
- // --------------------------------------
-
- std::string CommandQuit::name() {
- return "quit";
- }
-
- std::string CommandQuit::brief() {
- return "exit OpenRaider";
- }
-
- int CommandQuit::execute(std::istream& args) {
- exit(0);
- return 0;
- }
|