gnomine



Here's a patch to gnomine to do following: 

 - multi show didn't work if pressed over marked mine

 - left+right button does same as middle - couldn't find out any really
simple way to do this so this might be a bit hackish :) 

 - I _really_ hated that I had to release mouse before it could be moved
away from the field it was pressed.. If you want to cancel the button
press just click the other mouse button which results then as multi show..
Anyway put this as option, if you can think of better name than
"outrelease" then change it :) also the check button name should be
changed, "blah" doesn't describe much.. 

(hope this file attachment works.. first time I try it..)
diff -bu mine-old/gnomine.c gnomine/gnomine.c
--- mine-old/gnomine.c	Thu Apr 16 08:21:26 1998
+++ gnomine/gnomine.c	Thu May  7 17:47:14 1998
@@ -64,6 +64,7 @@
 guint nmines;
 guint fsize, fsc;
 guint minesize;
+guint outrelease, outsetup;
 
 char *fsize2names[] = {
 	N_("Tiny"),
@@ -231,6 +232,7 @@
 	ysize  = atoi(gtk_entry_get_text(GTK_ENTRY(yentry)));
         nmines = atoi(gtk_entry_get_text(GTK_ENTRY(mentry)));
         minesize = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sentry));
+        outrelease = outsetup;
 	fsize  = fsc;
 
 	verify_ranges ();
@@ -251,6 +253,7 @@
 	gnome_config_set_int("/gnomine/geometry/nmines", nmines);
 	gnome_config_set_int("/gnomine/geometry/minesize", minesize);
 	gnome_config_set_int("/gnomine/geometry/mode",   fsize);
+	gnome_config_set_int("/gnomine/general/outrelease", outrelease);
 	gnome_config_sync();
 }
 
@@ -280,6 +283,11 @@
 	gtk_widget_set_sensitive(cframe, fsc == 3);
 }
 
+void outrelease_callback(GtkWidget *widget, gpointer data)
+{
+    outsetup = !outsetup;
+}
+
 void setup_game(GtkWidget *widget, gpointer data)
 {
         GtkWidget *all_boxes;
@@ -305,6 +313,13 @@
 	all_boxes = gtk_vbox_new(FALSE, 5);
 	gtk_container_add(GTK_CONTAINER(setupdialog), all_boxes);
 
+	button = gtk_check_button_new_with_label(_("blah"));
+	if (outrelease) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (button), TRUE);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(outrelease_callback),
+			   (gpointer) 0);
+	gtk_box_pack_start(GTK_BOX(all_boxes), button, TRUE, TRUE, 0);
+        gtk_widget_show(button);
+        
         cframe = gtk_frame_new(_("Custom size"));
 
 	frame = gtk_frame_new(_("Field size"));
@@ -428,6 +443,7 @@
 	gtk_widget_show(all_boxes);
 
         fsc = fsize;
+        outsetup = outrelease;
 
 	gtk_widget_show(setupdialog);
 }
@@ -507,6 +523,8 @@
 	argv[i++] = nstr (xpos);
 	argv[i++] = "-b";
 	argv[i++] = nstr (ypos);
+	argv[i++] = "-o";
+	argv[i++] = nstr (outrelease);
 
 	gnome_client_set_restart_command (client, i, argv);
 	/* i.e. clone_command = restart_command - '--sm-client-id' */
@@ -535,6 +553,9 @@
 /* Whether fsize has been set.  */
 static int fsize_set;
 
+/* Whether outrelease has been set.  */
+static int outrelease_set;
+
 /* Some positioning info.  */
 static int set_pos;
 static int xpos, ypos;
@@ -572,6 +593,10 @@
 		set_pos |= 2;
 		ypos = atoi (arg);
 		break;
+	case 'o':
+                outrelease_set = 1;
+                outrelease = atoi (arg);;
+		break;
 	case ARGP_KEY_SUCCESS:
 		if (set_pos == 3)
 			gtk_widget_set_uposition (window, xpos, ypos);
@@ -589,6 +614,8 @@
 		}
 		if (! fsize_set)
 			fsize  = gnome_config_get_int("/gnomine/geometry/mode=0");
+		if (! outrelease_set)
+			outrelease  = gnome_config_get_int("/gnomine/general/outrelease=1");
 		break;
 		
 	default:
diff -bu mine-old/minefield.c gnomine/minefield.c
--- mine-old/minefield.c	Sat Apr 25 03:14:02 1998
+++ gnomine/minefield.c	Thu May  7 17:52:26 1998
@@ -535,17 +535,20 @@
 
 	if (mfield->lose || mfield->win) return FALSE;
 	
-        if (!mfield->bdown) {
+        if (event->button <= 3 && !mfield->bdown[1]) {
                 x = event->x/minesize;
                 y = event->y/minesize;
                 c = x+y*(mfield->xsize);
+                if (!mfield->bdown[0] && !mfield->bdown[1] && !mfield->bdown[2]) {
                 mfield->cdownx = x;
                 mfield->cdowny = y;
                 mfield->cdown = c;
                 mfield->mines[c].down = 1;
-		mfield->bdown = event->button;
+                }
+		mfield->bdown[event->button-1] = 1;
 		gtk_mine_draw(mfield, x, y);
-		if (event->button == 2 && mfield->mines[c].shown == 1) { /* multi show */
+                if ((event->button == 2 || (mfield->bdown[0] && mfield->bdown[2]))
+                    && mfield->mines[c].shown == 1 || mfield->mines[c].marked == 1) { /* multi show */
                         gtk_minefield_multi_press(mfield, x, y, c);
 		}
 		if (event->button == 1 || event->button == 2) {
@@ -569,17 +572,23 @@
 
 	if (mfield->lose || mfield->win) return FALSE;
 
-        if (event->button == mfield->bdown) {
+        if (event->button <= 3 && mfield->bdown[event->button-1]) {
                 x = event->x/minesize;
                 y = event->y/minesize;
-		if (x+y*(mfield->xsize) == mfield->cdown) {
+                if (mfield->bdown[0] && mfield->bdown[2] && event->button != 2) {
+                    /* left+right click = multi show */
+                    mfield->bdown[0] = 0;
+                    mfield->bdown[1] = 1;
+                    mfield->bdown[2] = 0;
+                    event->button = 2;
+                }
+		if (x+y*(mfield->xsize) == mfield->cdown || outrelease) {
                         switch (event->button) {
-			case 1: gtk_minefield_show(mfield, x, y);
+                        case 1: gtk_minefield_show(mfield, mfield->cdownx, mfield->cdowny);
                                 break;
-			case 2: if (mfield->multi_mode) gtk_minefield_multi_release(mfield, x, y, 1);
-
+                        case 2: if (mfield->multi_mode) gtk_minefield_multi_release(mfield, mfield->cdownx, mfield->cdowny, 1);
                                 break;
-                        case 3: gtk_minefield_toggle_mark(mfield, x, y);
+                        case 3: gtk_minefield_toggle_mark(mfield, mfield->cdownx, mfield->cdowny);
                                 break;
 			}
                 } else if (mfield->multi_mode) {
@@ -591,7 +600,7 @@
 		}
 		mfield->mines[mfield->cdown].down = 0;
                 mfield->cdown = -1;
-		mfield->bdown = 0;
+		mfield->bdown[event->button-1] = 0;
 		gtk_mine_draw(mfield, mfield->cdownx, mfield->cdowny);
         }
         return FALSE;
@@ -757,7 +766,9 @@
 	mfield->shown = 0;
 	mfield->lose  = 0;
 	mfield->win   = 0;
-	mfield->bdown = 0;
+	mfield->bdown[0] = 0;
+	mfield->bdown[1] = 0;
+	mfield->bdown[2] = 0;
         mfield->cdown = -1;
         mfield->multi_mode = 0;
 
diff -bu mine-old/minefield.h gnomine/minefield.h
--- mine-old/minefield.h	Tue Mar  3 00:46:24 1998
+++ gnomine/minefield.h	Thu May  7 17:17:04 1998
@@ -49,7 +49,7 @@
 	gint cdown;
         guint cdownx;
         guint cdowny;
-	gint bdown;
+	gint bdown[3];
         gint lose;
         gint win;
 	gint multi_mode;
@@ -83,6 +83,7 @@
 void gtk_minefield_set_mines(GtkMineField *mfield, guint mcount, guint minesize);
 void gtk_minefield_restart(GtkMineField *mfield);
 extern guint minesize;
+extern guint outrelease;
 
 #ifdef __cplusplus
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]