Sign in to follow this  
  • entries
    37
  • comments
    68
  • views
    46461

The Incredible, Edible Console!

Sign in to follow this  
coldacid

275 views

I'm trying something interesting with the console for the second Asylum prototype. It's being designed so that cvars and commands can be added (or removed) in code. Not only that, but cvars can be observed for changes.

I'm using a Cvar base class which contains the code for managing a bag of observers (CvarHandler objects) and provides an interface to the console for getting and setting the value. A std::map is used by the console to map Cvar objects to their names. Values are provided as strings, and boost::lexical_cast can be used to convert to the actual data type (and at the same time verify that the user input is good).

It's similar for Commands. A Command base class provides the interface that actual command objects must provide, but there's no listeners. Again, strings are used for input (this time, a vector of them) and actual determination of input is done by the Command object itself. Another std::map in the console keeps Commands.

When the user gives input to the console, the console first checks if the first token in the input string matches a command name. If not, it'll check for a cvar name, and if that also fails, tells the user that he's an idiot. But because of the possibility of a cvar and a command having the same name, the console provides two special commands, get and set, for ensuring that cvars can be accessed and mutated. (There are two other special commands, listvars and listcmds, for providing the names and descriptions (and for cvars, values) of registered cvars and commands.)

So far I've not been having problems working with this system, but so far I've only built it. I need to write a driver and unit tests to ensure that it works as planned.
Sign in to follow this  


4 Comments


Recommended Comments

Hey Chris, I just implemented Crazy Eddie's GUI into what I'm working on in C# and SDL [smile].... But I was wondering if you'd mind if I copied your console class and ported it into C#.

Share this comment


Link to comment
Rob, I don't mind if you take my actual code and port it (as long as I'm credited), but there's two things you'll need to know:

1. The console class and its related classes don't even deal with CEGUI. The console state class acts as a driver for the console and a bridge between it and CEGUI.

2. It's still incomplete and untested. I'll try to get it done by Monday, though, and I'll e-mail it to you.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now