Package: xbomb
Version: 2.1a-6.1
Severity: wishlist
Hi,
here's a patch that colors the numbers displayed in the minefield like
the "original" windows minesweeper does. It would be nice if it got
included in the Debian package. (I actually wrote the patch back in
2002 and didn't get around to submitting it until now...)
Index: xbomb-2.1a/xwindow.c
===================================================================
--- xbomb-2.1a.orig/xwindow.c 1999-04-10 20:28:36.000000000 +0200
+++ xbomb-2.1a/xwindow.c 2007-03-12 17:10:58.187115536 +0100
@@ -74,21 +74,33 @@ static int msecs(void);
/*+ A structure to hold the colour and font resource data in. +*/
struct temp
{
- Pixel colours[6]; /*+ The colours. +*/
+ Pixel colours[17]; /*+ The colours. +*/
XFontStruct* fontstruct; /*+ The font. +*/
}
resources;
/*+ An array to hold the GCs in. +*/
-static GC gc[7];
+#define NUM_GC 18
+static GC gc[NUM_GC];
#define GC_BOMB 0 /*+ For drawing the bomb and flag foreground.
+*/
#define GC_ACTUAL_BACK 1 /*+ For drawing the bomb background. +*/
#define GC_THINK_BACK 2 /*+ For drawing the flag background. +*/
-#define GC_NUMBERS 3 /*+ For drawing the numbers on the grid. +*/
-#define GC_UNSEEN 4 /*+ For unseen (hidden) tiles. +*/
-#define GC_CORRECT 5 /*+ For correctly guessed tiles at the end.+*/
-#define GC_BLANK 6 /*+ For blank squares. +*/
+#define GC_NUMBER1 3 /*+ For drawing the number 1 on the grid. +*/
+#define GC_NUMBER2 4 /*+ 2 +*/
+#define GC_NUMBER3 5 /*+ 3 +*/
+#define GC_NUMBER4 6 /*+ 4 +*/
+#define GC_NUMBER5 7 /*+ 5 +*/
+#define GC_NUMBER6 8 /*+ 6 +*/
+#define GC_NUMBER7 9 /*+ 7 +*/
+#define GC_NUMBER8 10 /*+ 8 +*/
+#define GC_NUMBER9 11 /*+ 9 +*/
+#define GC_NUMBER10 12 /*+ 10 (A) +*/
+#define GC_NUMBER11 13 /*+ 11 (B) +*/
+#define GC_NUMBER12 14 /*+ 12 (C) +*/
+#define GC_UNSEEN 15 /*+ For unseen (hidden) tiles. +*/
+#define GC_CORRECT 16 /*+ For correctly guessed tiles at the end.+*/
+#define GC_BLANK 17 /*+ For blank squares. +*/
/*+ The colour resources for the map. +*/
static XtResource xresources[]=
@@ -96,10 +108,21 @@ static XtResource xresources[]=
{"bomb" , "XBomb", XtRPixel , sizeof(String) , 0 ,
XtRString, "black" },
{"bombreal", "XBomb", XtRPixel , sizeof(String) , sizeof(String),
XtRString, "red" },
{"bombmark", "XBomb", XtRPixel , sizeof(String) , 2*sizeof(String),
XtRString, "orange" },
- {"number" , "XBomb", XtRPixel , sizeof(String) , 3*sizeof(String),
XtRString, "blue" },
- {"hidden" , "XBomb", XtRPixel , sizeof(String) , 4*sizeof(String),
XtRString, "grey50" },
- {"correct" , "XBomb", XtRPixel , sizeof(String) , 5*sizeof(String),
XtRString, "green" },
- {"font" , "XBomb", XtRFontStruct, sizeof(XFontStruct*), 6*sizeof(String),
XtRString, "lucidasans-24"}
+ {"number1" , "XBomb", XtRPixel , sizeof(String) , 3*sizeof(String),
XtRString, "navyblue" },
+ {"number2" , "XBomb", XtRPixel , sizeof(String) , 4*sizeof(String),
XtRString, "darkgreen" },
+ {"number3" , "XBomb", XtRPixel , sizeof(String) , 5*sizeof(String),
XtRString, "darkred" },
+ {"number4" , "XBomb", XtRPixel , sizeof(String) , 6*sizeof(String),
XtRString, "black" },
+ {"number5" , "XBomb", XtRPixel , sizeof(String) , 7*sizeof(String),
XtRString, "turquoise" },
+ {"number6" , "XBomb", XtRPixel , sizeof(String) , 8*sizeof(String),
XtRString, "orange" },
+ {"number7" , "XBomb", XtRPixel , sizeof(String) , 9*sizeof(String),
XtRString, "violet" },
+ {"number8" , "XBomb", XtRPixel , sizeof(String) ,10*sizeof(String),
XtRString, "white" },
+ {"number9" , "XBomb", XtRPixel , sizeof(String) ,11*sizeof(String),
XtRString, "blue" },
+ {"number10", "XBomb", XtRPixel , sizeof(String) ,12*sizeof(String),
XtRString, "blue" },
+ {"number11", "XBomb", XtRPixel , sizeof(String) ,13*sizeof(String),
XtRString, "blue" },
+ {"number12", "XBomb", XtRPixel , sizeof(String) ,14*sizeof(String),
XtRString, "blue" },
+ {"hidden" , "XBomb", XtRPixel , sizeof(String) ,15*sizeof(String),
XtRString, "grey50" },
+ {"correct" , "XBomb", XtRPixel , sizeof(String) ,16*sizeof(String),
XtRString, "green" },
+ {"font" , "XBomb", XtRFontStruct, sizeof(XFontStruct*),17*sizeof(String),
XtRString, "lucidasans-24"}
};
@@ -219,10 +242,10 @@ void InitialiseX(int *argc,char **argv)
XtVaGetSubresources(play_area,(XtPointer)&resources,"grid","XBomb",xresources,XtNumber(xresources),NULL);
values.font=resources.fontstruct->fid;
- for(i=0;i<6;i++)
+ for(i=0;i<NUM_GC;i++)
{
values.foreground=resources.colours[i];
- if(i==4)
+ if(i==GC_UNSEEN)
{
GC tempgc;
XGCValues gcxval;
@@ -316,7 +339,7 @@ void InitialiseX(int *argc,char **argv)
/* Centre the text */
- fontstruct=XQueryFont(display,XGContextFromGC(gc[GC_NUMBERS]));
+ fontstruct=XQueryFont(display,XGContextFromGC(gc[GC_NUMBER1]));
xoffset=XTextWidth(fontstruct,"0",1)/2;
yoffset=fontstruct->ascent/2;
@@ -343,7 +366,7 @@ void FinishUpX(void)
/* Free the graphics contexts. */
- for(i=0;i<7;i++)
+ for(i=0;i<NUM_GC;i++)
XFreeGC(display,gc[i]);
/* Free the pixmaps. */
@@ -465,7 +488,8 @@ void DrawSquare(int x,int y,unsigned cha
{
int text_xpos=xpos+pixw/2-xoffset;
int text_ypos=ypos+pixh/2+yoffset;
-
XDrawString(display,play_window,gc[GC_NUMBERS],text_xpos,text_ypos,grid_numbers[(value&~CORRECT)],1);
+ int gc_number=(value&~CORRECT)+GC_NUMBER1-1; /* Calculate GC_NUMBERx
offset. */
+
XDrawString(display,play_window,gc[gc_number],text_xpos,text_ypos,grid_numbers[(value&~CORRECT)],1);
}
/* Draw the correct squares at the end. */
Index: xbomb-2.1a/xbomb.6
===================================================================
--- xbomb-2.1a.orig/xbomb.6 2007-03-12 17:08:09.642738176 +0100
+++ xbomb-2.1a/xbomb.6 2007-03-12 17:12:41.411423056 +0100
@@ -118,8 +118,8 @@ The colour of the real bombs \- default
.BR grid.bombmark
The colour of the bombs that are marked by the user \- default orange.
.TP
-.BR grid.number
-The colour of the numbers that are drawn in the grid \- default blue.
+.BR grid.number\fIn\fP
+The colours of the numbers that are drawn in the grid, 1 <= \fIn\fP <= 12.
.TP
.BR grid.hidden
The colour of the hidden squares \- default grey50.
Christoph
--
[EMAIL PROTECTED] | http://www.df7cb.de/cs/
Universität des Saarlandes, Compiler Design Lab