OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
CommandEngine.cpp
Go to the documentation of this file.
1 
8 #include "global.h"
9 #include "Game.h"
10 #include "Log.h"
11 #include "Menu.h"
12 #include "RunTime.h"
13 #include "Render.h"
14 #include "UI.h"
15 #include "commands/CommandEngine.h"
16 
17 std::string CommandLoad::name() {
18  return "load";
19 }
20 
21 std::string CommandLoad::brief() {
22  return "load a level file";
23 }
24 
26  Log::get(LOG_USER) << "load-Command Usage:" << Log::endl;
27  Log::get(LOG_USER) << " load /path/to/level" << Log::endl;
28 }
29 
30 int CommandLoad::execute(std::istream& args) {
31  if (!RunTime::isRunning()) {
32  Log::get(LOG_USER) << "Use load command interactively!" << Log::endl;
33  return -1;
34  }
35 
36  std::string map;
37  args >> map;
38  int error = Game::loadLevel(map.c_str());
39  return error;
40 }
41 
42 // --------------------------------------
43 
44 std::string CommandScreenshot::name() {
45  return "sshot";
46 }
47 
48 std::string CommandScreenshot::brief() {
49  return "make a screenshot";
50 }
51 
53  Log::get(LOG_USER) << "sshot-Command Usage:" << Log::endl;
54  Log::get(LOG_USER) << " sshot" << Log::endl;
55  Log::get(LOG_USER) << "You wont be able to capture imgui..." << Log::endl;
56 }
57 
58 int CommandScreenshot::execute(std::istream& args) {
59  if (!RunTime::isRunning()) {
60  Log::get(LOG_USER) << "Use sshot command interactively!" << Log::endl;
61  return -1;
62  }
63 
64  std::string filename(RunTime::getBaseDir());
65  filename += "/sshots/";
66  filename += VERSION_SHORT;
67 
68  Render::screenShot(filename.c_str());
69  return 0;
70 }
71 
72 // --------------------------------------
73 
74 std::string CommandQuit::name() {
75  return "quit";
76 }
77 
78 std::string CommandQuit::brief() {
79  return "exit OpenRaider";
80 }
81 
82 int CommandQuit::execute(std::istream& args) {
83  RunTime::setRunning(false);
84  return 0;
85 }
86 
virtual int execute(std::istream &args)
Engine Commands.
#define LOG_USER
Definition: Log.h:18
virtual std::string name()
Main Menu.
virtual void printHelp()
virtual int execute(std::istream &args)
Included everywhere.
static std::string getBaseDir()
Definition: RunTime.h:23
static LogLevel & get(int level)
Definition: Log.cpp:14
static bool isRunning()
Definition: RunTime.h:35
virtual std::string name()
Global Logging Utility.
virtual std::string name()
static void error(char *msg)
Definition: commander.c:19
World Renderer.
virtual std::string brief()
static void setRunning(bool run)
Definition: RunTime.h:36
virtual void printHelp()
virtual std::string brief()
static const char endl
Definition: Log.h:35
Runtime Configuration Storage.
virtual std::string brief()
static void screenShot(const char *filenameBase)
Definition: Render.cpp:121
virtual int execute(std::istream &args)
UI/Event Manager.
static int loadLevel(std::string level)
Definition: Game.cpp:41
Gameplay Handler.