chiark / gitweb /
Split out the text color portion of draw_tile
authorKevin Lyles <kevinlyles@gmail.com>
Sat, 16 May 2015 18:51:34 +0000 (13:51 -0500)
committerSimon Tatham <anakin@pobox.com>
Fri, 22 May 2015 07:18:45 +0000 (08:18 +0100)
towers.c

index 2b9e4e7ba4690ee8086ed2e39123f4bcc0c861a9..3da691cab1f1c150fe13a652752ea537e9fa85c7 100644 (file)
--- a/towers.c
+++ b/towers.c
@@ -1598,14 +1598,23 @@ static void draw_tile(drawing *dr, game_drawstate *ds, struct clues *clues,
 
     /* new number needs drawing? */
     if (tile & DF_DIGIT_MASK) {
+        int color;
+
        str[1] = '\0';
        str[0] = (tile & DF_DIGIT_MASK) + '0';
+
+        if (tile & DF_ERROR)
+            color = COL_ERROR;
+        else if (x < 0 || y < 0 || x >= w || y >= w)
+            color = COL_GRID;
+        else if (tile & DF_IMMUTABLE)
+            color = COL_GRID;
+        else
+            color = COL_USER;
+
        draw_text(dr, tx + TILESIZE/2, ty + TILESIZE/2, FONT_VARIABLE,
                  (tile & DF_PLAYAREA ? TILESIZE/2 : TILESIZE*2/5),
-                 ALIGN_VCENTRE | ALIGN_HCENTRE,
-                 (tile & DF_ERROR) ? COL_ERROR :
-                 (x < 0 || y < 0 || x >= w || y >= w) ? COL_GRID :
-                 (tile & DF_IMMUTABLE) ? COL_GRID : COL_USER, str);
+                  ALIGN_VCENTRE | ALIGN_HCENTRE, color, str);
     } else {
         int i, j, npencil;
        int pl, pr, pt, pb;