The Incredible, Edible Console!

Published July 09, 2005
Advertisement
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.
Previous Entry Mark II
0 likes 4 comments

Comments

Rob Loach
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#.
July 09, 2005 10:13 AM
Rob Loach
God damn it, Crazy Eddie's GUI rendering in SDL.NET is very slow. It might be my code, I'm not entirely sure yet.
July 09, 2005 02:33 PM
coldacid
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.
July 13, 2005 04:07 PM
Rob Loach
August 02, 2005 02:52 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement