xoreos  0.0.5
console.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include <algorithm>
26 
27 #include <boost/bind.hpp>
28 
29 #include "src/common/ustring.h"
30 #include "src/common/util.h"
31 #include "src/common/filepath.h"
32 #include "src/common/filelist.h"
33 #include "src/common/configman.h"
34 
35 #include "src/aurora/resman.h"
36 
38 
40 #include "src/engines/jade/jade.h"
41 #include "src/engines/jade/game.h"
43 
44 namespace Engines {
45 
46 namespace Jade {
47 
49  ::Engines::Console(engine, Graphics::Aurora::kSystemFontMono, 13),
50  _engine(&engine) {
51 
52  registerCommand("exitmodule" , boost::bind(&Console::cmdExitModule , this, _1),
53  "Usage: exitmodule\nExit the module, returning to the main menu");
54  registerCommand("listmodules", boost::bind(&Console::cmdListModules, this, _1),
55  "Usage: listmodules\nList all modules");
56  registerCommand("loadmodule" , boost::bind(&Console::cmdLoadModule , this, _1),
57  "Usage: loadmodule <module>\nLoad and enter the specified module");
58 }
59 
61 }
62 
65 
66  updateModules();
67 }
68 
70  _modules.clear();
72 
73  setArguments("loadmodule", _modules);
74 }
75 
77  hide();
79 }
80 
82  updateModules();
84 }
85 
87  if (cl.args.empty()) {
89  return;
90  }
91 
92  for (std::vector<Common::UString>::iterator m = _modules.begin(); m != _modules.end(); ++m) {
93  if (m->equalsIgnoreCase(cl.args)) {
94  hide();
96  return;
97  }
98  }
99 
100  printf("No such module \"%s\"", cl.args.c_str());
101 }
102 
103 } // End of namespace Jade
104 
105 } // End of namespace Engines
void exit()
Exit the currently running module.
Definition: module.cpp:119
Common::UString args
Definition: console.h:218
Module & getModule()
Return the module context.
Definition: game.cpp:61
Engine class handling Jade Empire.
The global config manager.
Console(JadeEngine &engine)
Definition: console.cpp:48
Game & getGame()
Return the context running the actual game.
Definition: jade.cpp:149
The context handling the gameplay in Jade Empire.
void cmdListModules(const CommandLine &cl)
Definition: console.cpp:81
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
#define UNUSED(x)
Definition: system.h:170
JadeEngine * _engine
Definition: console.h:45
Basic Aurora graphics types.
Utility templates and functions.
static void getModules(std::vector< Common::UString > &modules)
Return a list of all modules.
Definition: game.cpp:160
const char * kSystemFontMono
Identifier used for the monospaced system font.
Definition: fontman.cpp:41
void printList(const std::vector< Common::UString > &list, size_t maxSize=0)
Definition: console.cpp:1479
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
std::vector< Common::UString > _modules
All known modules.
Definition: console.h:48
Jade (debug) console.
void cmdLoadModule(const CommandLine &cl)
Definition: console.cpp:86
Unicode string handling.
void load(const Common::UString &module)
Load a module.
Definition: module.cpp:66
A module.
void printf(const char *s,...) GCC_PRINTF(2
Definition: console.cpp:1093
A list of files.
void cmdExitModule(const CommandLine &cl)
Definition: console.cpp:76
virtual void updateCaches()
Definition: console.cpp:1122
void printCommandHelp(const Common::UString &cmd)
Definition: console.cpp:1391
void setArguments(const Common::UString &cmd, const std::vector< Common::UString > &args)
Definition: console.cpp:1565
bool registerCommand(const Common::UString &cmd, const CommandCallback &callback, const Common::UString &help)
Definition: console.cpp:1576
The global resource manager for Aurora resources.
Utility class for manipulating file paths.