Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have been working on a game for quite a while, and I am using Ogre3D for the rendering engine. It is getting to the point I need to move adjustable settings to a configuration file such as video settings/options, player keybindings, etc.

I am using RapidXML for parsing and loading my scenes, but I am not sure this is the best way to go about doing configurations. As a long time fan of Valve games, I know there's are just a long list of settings, basically no grouping, just a list. Where as UT games do something like

[VideoOptions] ... ...

[GameSettings] ... ...

Anyways, I am just wondering what the best way to go about this is.

share|improve this question
4  
XML is not the answer to everything. Actually, it's rarely the correct answer whatever the question is. –  Lohoris Sep 27 '10 at 13:39
2  
XML is like violence: if it doesn't work, use more. :) –  dash-tom-bang Sep 27 '10 at 19:27

3 Answers 3

up vote 5 down vote accepted

This probably isn't the optimal solution, but I'm currently using Ogre's ConfigFile class (here is the API ref for it) for simple gfx/control/whatever config settings. Not a terribly robust solution, but it's worked fine for simple stuff.

Its format is similar to the UT example you gave, for instance:

[GraphicsSettings]
Resolution=1024 x 768
Antialiasing=2

[ControlSettings]
InvertLook=No
Sensitivity=2.0
...
share|improve this answer
    
Thank you, this looks like it will be perfect. –  Brett Powell Sep 27 '10 at 9:43
    
The thing with this is that it's super easy to parse, so it's easy to write code to read it. It's also easy to change settings, you don't need to match tags or anything like that. –  dash-tom-bang Sep 27 '10 at 19:29

You may also be interested in Boost.PropertyTree. It let's you access properties in a hierarchical manner, e.g. settings.get<int>("Graphics.Resolution.Width"). The are parsers/loaders available for XML, JSON, and more.

share|improve this answer

Another option is to embed a simple language like Lua and expose the configuration values you want to Lua. Then your configuration file becomes a series of assignments, and can be as complex or as simple as you like. I probably wouldn't do this just for loading configuration files, but scripting languages do come in very handy for many aspects of game development so it's worth considering.

share|improve this answer
    
This is how the excellent SciTE editor does its configuration, and while documentation on the settings could be better it's pretty convenient to be able to edit in such a "computer friendly" format. –  dash-tom-bang Sep 29 '10 at 0:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.