xyginext  0.2.0
Second generation of xygine game creation framework
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
xy::Console Class Referencefinal

Console class. The console class provides a feedback window and interface with xygine. Any class can register a command with the console as long as it inherits the ConsoleClient interface. More...

#include <Console.hpp>

Public Types

using Command = std::function< void(const std::string &)>
 

Public Member Functions

const ConfigObjectgetConvars ()
 Returns a reference to the ConfigObject containing any existing convars. The returned reference is const, use addConvar() to write to the ConfigObject.
 
template<>
std::string getConvarValue (const std::string &name)
 
template<>
sf::Int32 getConvarValue (const std::string &name)
 
template<>
float getConvarValue (const std::string &name)
 
template<>
bool getConvarValue (const std::string &name)
 

Static Public Member Functions

static void print (const std::string &)
 Prints the given string to the console window.
 
static void show ()
 Toggles the console window visibility.
 
static bool isVisible ()
 Returns true if the console is currently shown.
 
static void doCommand (const std::string &)
 Executes the given command line. Allows for programatically executing arbitrary commands.
 
static void addConvar (const std::string &name, const std::string &value, const std::string &helpText=std::string())
 Adds a convar it if it doesn't exist. More...
 
template<typename T >
static T getConvarValue (const std::string &convar)
 Attempts to retrieve the current value of the given console variable.
 
static void printStat (const std::string &, const std::string &)
 Prints the name/value pair to the stats window.
 

Friends

class App
 
class ConsoleClient
 

Detailed Description

Console class. The console class provides a feedback window and interface with xygine. Any class can register a command with the console as long as it inherits the ConsoleClient interface.

The Console functions are not threadsafe - appropriate care should be taken when using the Console from multiple threads.

Member Typedef Documentation

◆ Command

using xy::Console::Command = std::function<void(const std::string&)>

Command functions are registered with an associated string, and executed when that string is entered into the consle window. Any further characters entered after the command are passed into the command function as a parameter. If this is a list of parameters it is up to the command function implementation to properly parse the given string. Registering a command with the console may be done by any class which inherits ConsoleClient.

See also
ConsoleClient

Member Function Documentation

◆ addConvar()

static void xy::Console::addConvar ( const std::string &  name,
const std::string &  value,
const std::string &  helpText = std::string() 
)
static

Adds a convar it if it doesn't exist.

Parameters
nameName of the variable as it appears in the console.
valuethe default value of the variable
helpTextOptional string describing the variable which appears the console when searching for variable names.