Got a bit distracted from the zones thing then because I decided I wanted to have text-based configuration files for storing game options. Since I will probably always want this in games, I decided to build a static library to deal with nice and simple option files. It presents this interface:
It can then cope with .cfg files like:
; this is a comment
another_key = "a string value" ; this is another comment
number = 10
and so on. The groovy little template and stringstream stuff means you can query the configuration for a value of any type that std::stringstream can deal with converting and it will tell you if:
a) the key doesn't exist
b) the value is invalid for the type
So you can do something like:
std::cerr << con.error_text() << "\n"; return false;
if(con("key",s)==configuration::ok) std::cout << s << std::endl;
if(r==configuration::no_key) std::cout << "real_number not in the file\n";
if(r==configuration::invalid_value) std::cout << "value not a float\n";
if(r==configuration::ok) std::cout << f << "\n";
Nice and simple but pretty robust. In case anyone cares, the dummy >> into a std::string at the end of the template conversion method is to prevent something like "123x" from returning a valid int (123) and leaving "x" in the stringstream.
Udo has now been updated to use the above so I can manually edit the resolution and turn the sound on and off with notepad. Woohoo.
Should probably stop spending evenings on details like this and get on with the game really.