18#include <OgreRenderWindow.h>
20#include <OgreStringConverter.h>
36void CmdQuit(
const Ogre::StringVector& params){
46void CmdEcho(
const Ogre::StringVector& params){
47 if (params.size() < 1){
48 Console::getSingleton().AddTextToOutput(
49 "Usage: /echo <string to output>"
54 for (
size_t i = 1; i < params.size(); ++ i){
55 if (i != 1)text +=
" ";
58 Console::getSingleton().AddTextToOutput(text +
"\n");
70 if (params.size() > 2){
71 Console::getSingleton().AddTextToOutput(
"Usage: /config_var_list [search string]");
76 int num_vars = ConfigVarHandler::getSingleton().GetConfigVarNumber();
77 for (
int i = 0; i < num_vars; ++ i){
78 ConfigVar* var = ConfigVarHandler::getSingleton().GetConfigVar(i);
81 if (params.size() > 1){
82 int found = name.find(params[1]);
84 Console::getSingleton().AddTextToOutput(
91 Console::getSingleton().AddTextToOutput(var->
GetName() +
" = \"" + var->
GetS() +
"\"");
95 Console::getSingleton().AddTextToOutput(
96 Ogre::StringConverter::toString(number) +
" config variables.\n"
109 if (params.size() > 2){
110 Console::getSingleton().AddTextToOutput(
"Usage: /config_cmd_list [search string]");
114 int num_cmds = ConfigCmdHandler::getSingleton().GetConfigCmdNumber();
115 for (
int i = 0; i < num_cmds; ++ i){
116 ConfigCmd* cmd = ConfigCmdHandler::getSingleton().GetConfigCmd(i);
118 if (params.size() > 1){
119 int found = name.find(params[1]);
121 Console::getSingleton().AddTextToOutput(cmd->
GetName());
126 Console::getSingleton().AddTextToOutput(cmd->
GetName());
130 Console::getSingleton().AddTextToOutput(
131 Ogre::StringConverter::toString(number) +
" config commands.\n"
146 if (params.size() < 2 || params.size() > 3){
147 Console::getSingleton().AddTextToOutput(
"Usage: /set <config variable> [value]");
151 ConfigVar* cvar = ConfigVarHandler::getSingleton().Find(name);
153 LOG_ERROR(
"Config variable \"" + name +
"\" not found.");
156 if (params.size() == 3){
157 cvar->
SetS(params[2]);
158 Console* console = Console::getSingletonPtr();
159 if (console != NULL)
LOG_TRIVIAL(params[1] +
" changed to \"" + params[2] +
"\".");
178 if (params.size() < 4){
179 Console::getSingleton().AddTextToOutput(
180 "Usage: /toggle <config variable> [value1] [value2] ...");
184 ConfigVar* cvar = ConfigVarHandler::getSingleton().Find(name);
186 LOG_ERROR(
"Config variable \"" + name +
"\" not found.");
191 int number_of_values = params.size() - 2;
194 for (; i < number_of_values; ++ i){
195 if (value == params[i + 2]){
200 if (i == number_of_values) i = 0;
201 cvar->
SetS(params[i + 2]);
216 if (params.size() != 5){
217 Console::getSingleton().AddTextToOutput(
218 "Usage: /increment <cvar name> [value min] [value max] [step]"
223 ConfigVar* cvar = ConfigVarHandler::getSingleton().Find(name);
225 LOG_ERROR(
"Config variable \"" + name +
"\" not found.");
228 float start_value = Ogre::StringConverter::parseReal(params[2]);
229 float end_value = Ogre::StringConverter::parseReal(params[3]);
230 float step = Ogre::StringConverter::parseReal(params[4]);
232 float new_value = cvar->
GetF() + step;
233 if (new_value > end_value) new_value = end_value;
234 else if (new_value < start_value) new_value = start_value;
235 cvar->
SetF(new_value);
247 if (params.size() != 2){
248 Console::getSingleton().AddTextToOutput(
249 "Usage: /log_level <level: 1 - only errors, 2 - errors and warnings, 3 - all>"
254 int value = Ogre::StringConverter::parseInt(params[1]);
255 if (value > 0 && value < 4){
256 Ogre::LogManager::getSingletonPtr()->getDefaultLog()->setLogDetail(
257 (Ogre::LoggingLevel) value
261 Console::getSingleton().AddTextToOutput(
262 "Logger level changed to \"only errors\".\n"
266 Console::getSingleton().AddTextToOutput(
267 "Logger level changed to \"errors and warnings\".\n"
271 Console::getSingleton().AddTextToOutput(
"Logger level changed to \"all\".\n");
276 Console::getSingleton().AddTextToOutput(
277 "Logger level can't be changed. Value \""
278 + params[1] +
"\" isn't supported.\n"
290void CmdMap(
const Ogre::StringVector& params){
291 if (params.size() != 2){
292 Console::getSingleton().AddTextToOutput(
"Usage: /map [map_id]");
295 EntityManager::getSingleton().Clear();
321 if (params.size() < 3){
322 Console::getSingleton().AddTextToOutput(
323 "Usage: /resolution <width> <height> [full screen]"
327 Ogre::RenderWindow*
window = VGears::Application::getSingleton().getRenderWindow();
328 if (params.size() >= 4){
330 Ogre::StringConverter::parseBool(params[3]), Ogre::StringConverter::parseInt(params[1]),
331 Ogre::StringConverter::parseInt(params[2])
336 Ogre::StringConverter::parseInt(params[1]), Ogre::StringConverter::parseInt(params[2])
338 window->getViewport(0)->setDimensions(0.0f, 0.0f, 1.0f, 1.0f);
352 complete_params.push_back(
"640 480 0");
353 complete_params.push_back(
"640 480 1");
354 complete_params.push_back(
"800 600 0");
355 complete_params.push_back(
"800 600 1");
356 complete_params.push_back(
"1024 768 0");
357 complete_params.push_back(
"1024 768 1");
358 complete_params.push_back(
"1280 720 0");
359 complete_params.push_back(
"1280 720 1");
360 complete_params.push_back(
"1280 1024 0");
361 complete_params.push_back(
"1280 1024 1");
370 Ogre::RenderWindow*
window = VGears::Application::getSingleton().getRenderWindow();
372 Console::getSingleton().AddTextToOutput(
"Screenshot " + ret +
" saved.");
432 "config_var_list",
"List of registered config variables",
"[<filter substring>]",
436 "config_cmd_list",
"List of registered config commands",
441 "toggle",
"Toggle cvar value",
"<cvar name> [value1] [value2] ...",
CmdToggleConfigVar, NULL
444 "increment",
"Increment cvar value",
"<cvar name> [value min] [value max] [step]",
void CmdScreenshot(const Ogre::StringVector ¶ms)
Saves a screenshot of the current game window.
Definition: ConfigCmdHandlerCommands.h:369
void CmdMap(const Ogre::StringVector ¶ms)
Changes the game map.
Definition: ConfigCmdHandlerCommands.h:290
void CmdMapCompletion(Ogre::StringVector &complete_params)
Loads a list of map names.
Definition: ConfigCmdHandlerCommands.h:307
void CmdResolution(const Ogre::StringVector ¶ms)
Sets the resolution and full screen mode.
Definition: ConfigCmdHandlerCommands.h:320
void CmdSetConfigVar(const Ogre::StringVector ¶ms)
Sets the value of a configuration value.
Definition: ConfigCmdHandlerCommands.h:145
void CmdQuit(const Ogre::StringVector ¶ms)
Command to quit the application.
Definition: ConfigCmdHandlerCommands.h:36
void CmdResolutionCompletition(Ogre::StringVector &complete_params)
Loads a list of resolution modes.
Definition: ConfigCmdHandlerCommands.h:351
void CmdEcho(const Ogre::StringVector ¶ms)
Command to print to console.
Definition: ConfigCmdHandlerCommands.h:46
void CmdConfigVarList(const Ogre::StringVector ¶ms)
Searches variables in the variable list and prints them.
Definition: ConfigCmdHandlerCommands.h:69
void CmdConfigCmdList(const Ogre::StringVector ¶ms)
Searches the command list and prints the comands.
Definition: ConfigCmdHandlerCommands.h:108
void CmdToggleConfigVar(const Ogre::StringVector ¶ms)
Changes the value of a configuration value conditionally.
Definition: ConfigCmdHandlerCommands.h:177
void CmdSetLogLevel(const Ogre::StringVector ¶ms)
Configures the log level.
Definition: ConfigCmdHandlerCommands.h:246
void CmdIncrementConfigVar(const Ogre::StringVector ¶ms)
Increments the value of a configuration variable.
Definition: ConfigCmdHandlerCommands.h:215
Ogre::RenderWindow * window
The Ogre render window.
Definition: OgreBase.cpp:24
void InitCmd()
Initializes the command.
Definition: ConfigCmdHandlerCommands.h:428
void AddCommand(const Ogre::String &name, const Ogre::String &description, const Ogre::String ¶ms_description, ConfigCmdParams params, ConfigCmdCompletion completion)
Adds a command to the manager.
Definition: ConfigCmdHandler.cpp:30
A configuration command.
Definition: ConfigCmd.h:31
const Ogre::String & GetName() const
Retrieves the command name.
Definition: ConfigCmd.cpp:29
A configuration variable.
Definition: ConfigVar.h:25
void SetS(const Ogre::String &value)
Sets the string value of the variable.
Definition: ConfigVar.cpp:63
const Ogre::String & GetDefaultValue() const
Retrieves the variable default value.
Definition: ConfigVar.cpp:72
const Ogre::String & GetName() const
Retrieves the variable name.
Definition: ConfigVar.cpp:68
void SetF(float value)
Sets the float value of the variable.
Definition: ConfigVar.cpp:53
Ogre::String GetS() const
Retrieves the value of the variable in string form.
Definition: ConfigVar.cpp:46
float GetF() const
Retrieves the value of the variable in float form.
Definition: ConfigVar.cpp:42
The game console.
Definition: Console.h:30
Handles XML map files.
Definition: XmlMapFile.h:23
void LoadMap()
Parses the file and loads the map data.
Definition: XmlMapFile.cpp:30
Handles the main maps file.
Definition: XmlMapsFile.h:24
void GetMapNames(Ogre::StringVector &complete_params)
Retrieves a list of map names.
Definition: XmlMapsFile.cpp:41
const Ogre::String GetMapFileNameByName(const Ogre::String &name)
Retrieves a map file by map name.
Definition: XmlMapsFile.cpp:23
#define LOG_ERROR(message)
Prints an error log message.
Definition: Logger.h:28
#define LOG_TRIVIAL(message)
Prints a trivial log message.
Definition: Logger.h:50
GAME_STATE g_ApplicationState
Global application status indicator.
Definition: VGearsGameState.cpp:19
@ G_EXIT
The game is ready to be quit and can exit in the next loop pass.
Definition: VGearsGameState.h:28
Ogre::String String
Definition: TypeDefine.h:37