Just for Gareth: a means of overriding individual game colour
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 17 May 2005 11:47:33 +0000 (11:47 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 17 May 2005 11:47:33 +0000 (11:47 +0000)
settings using environment variables. GTK frontend only, because
this is an unsupported (and unprincipled) hack.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5792 cda61777-01e9-0310-a592-d414129be87e

gtk.c

diff --git a/gtk.c b/gtk.c
index 5d78f4e..24b2cca 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -1131,9 +1131,24 @@ static frontend *new_window(char *game_id, char **error)
         fe->ncolours = ncolours;
         fe->colours = snewn(ncolours, GdkColor);
         for (i = 0; i < ncolours; i++) {
-            fe->colours[i].red = colours[i*3] * 0xFFFF;
-            fe->colours[i].green = colours[i*3+1] * 0xFFFF;
-            fe->colours[i].blue = colours[i*3+2] * 0xFFFF;
+            /*
+             * Just for Gareth: if you dislike any of the standard
+             * colours, here's your chance to configure them in a
+             * really hacky way. 
+             */
+            char buf[80], *e;
+            unsigned int r, g, b;
+            sprintf(buf, "PUZZLE_COLOUR_%d", i);
+            if ((e = getenv(buf)) != NULL &&
+                sscanf(e, "%2x%2x%2x", &r, &g, &b) == 3) {
+                fe->colours[i].red = r * 0x101;
+                fe->colours[i].green = g * 0x101;
+                fe->colours[i].blue = b * 0x101;
+            } else {
+                fe->colours[i].red = colours[i*3] * 0xFFFF;
+                fe->colours[i].green = colours[i*3+1] * 0xFFFF;
+                fe->colours[i].blue = colours[i*3+2] * 0xFFFF;
+            }
         }
         success = snewn(ncolours, gboolean);
         gdk_colormap_alloc_colors(fe->colmap, fe->colours, ncolours,