Re: [AD] patch for config.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, 2004-11-11 at 14:00 +1100, Peter Wang wrote: 
> 
> 
> Sounds good to me.  Didn't test it though.

On Wed, 2004-11-10 at 16:13 -0800, Chris wrote:

> This seems to be my biggest beef with the current config system.
> There's no way I can use the original allegro.cfg loaded by
> allegro_init (or wherever), but also have another mygame.cfg that can
> override some of those values with game-specific ones, and to have
> new/modified values written to mygame.cfg (they would go into
> allegro.cfg). If this is what that patch allows, I'm all for it.
> 

Ok, I applied it. I also wrote the attached docs patch, to now specify
the behavior.


-- 
Elias Pschernig
Index: docs/src/allegro._tx
===================================================================
RCS file: /cvsroot/alleg/allegro/docs/src/allegro._tx,v
retrieving revision 1.273
diff -u -r1.273 allegro._tx
--- docs/src/allegro._tx	30 Oct 2004 11:45:44 -0000	1.273
+++ docs/src/allegro._tx	12 Nov 2004 16:22:57 -0000
@@ -1582,6 +1582,36 @@
    still use an `allegro.cfg' file to specify the port settings and irq
    numbers.
 
+   The override config file will not only take precedence when reading, but will
+   also be used for storing values. When you are done with using the override
+   config file, you can call override_config_file with a NULL parameter, so
+   config data will be directly read from the current config file again.
+
+   Note: The override file is completely independent from the current
+   configuration. You can e.g. call set_config_file, and the override file will
+   still be active. Also the flush_config_file function will only affect the
+   current config file (which can be changed with set_config_file), never the
+   overriding one specified with this function. The modified override config is
+   written back to disk whenever you call override_config_file.
+
+   Example:
+<codeblock>
+   override_config_file("my.cfg");
+   /* This will read from my.cfg, and if it doesn't find a setting,
+    * will read from the current config file instead.
+    */
+   language = get_config_string("system", "language", NULL);
+   /* This will always write to my.cfg, no matter if the settings is already
+    * present or not.
+    */
+   set_config_string("system", "language", "RU");
+   /* This forces the changed setting to be written back to disk. Else it is
+    * written back at the next call to override_config_file, or when Allegro
+    * shuts down.
+    */
+   override_config_file(NULL);
+   <endblock>
+
 @@void @override_config_data(const char *data, int length);
 @xref override_config_file, set_config_data
    Version of override_config_file() which uses a block of data that has 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/