gnomine
- From: Timo Sirainen <aaaaaa sicom fi>
- To: gnome-list gnome org
- Subject: gnomine
- Date: Sun, 17 May 1998 22:54:35 +0300 (EEST)
Forgot to include the patch :)
diff -u old-gnomine/ChangeLog gnomine/ChangeLog
--- old-gnomine/ChangeLog Mon May 11 01:34:32 1998
+++ gnomine/ChangeLog Sun May 17 22:45:06 1998
@@ -1,3 +1,25 @@
+1998-05-17 Timo Sirainen <a@sicom.fi>
+
+ * minefield.c: Marking two mines fast resulted as doubleclick and
+ didn't work right
+ * minefield.c: Changed multi press behaviour so that it always
+ displays what squares are about to be pressed
+ * minefield.c: Mine is now marked directly when button is pressed down
+ * minefield.c: You can't win anymore by marking mines to all squares.
+ Also, you can win now when there's only left same
+ amount of unopened and unmarked mines like you don't
+ really have to mark any mines to win :)
+ * minefield.c: The previous fix "multi show didn't work if pressed
+ over marked mine" wasn't actually good idea, removed..
+ * minefield.c: Colors of mines 4-8 changed
+ * minefield.c: Opened mines have now thin borders, I think this is
+ somewhat clearer :) and bigger fonts can be used.
+ * minefield.c: Square presses follow now mouse.
+ * gnomine.c: Because of above, I removed the "off release" option
+ since it didn't have anything to do anymore..
+ * gnomine.c: Minefield sizes changed to same as other minesweepers
+ have
+
1998-05-10 Timo Sirainen <a@sicom.fi>
* minefield.c: multi show didn't work if pressed over marked mine
diff -u old-gnomine/gnomine.c gnomine/gnomine.c
--- old-gnomine/gnomine.c Mon May 11 01:34:32 1998
+++ gnomine/gnomine.c Sun May 17 17:18:22 1998
@@ -64,7 +64,6 @@
guint nmines;
guint fsize, fsc;
guint minesize;
-guint outrelease, outsetup;
char *fsize2names[] = {
N_("Tiny"),
@@ -185,7 +184,7 @@
void setup_mode(GtkWidget *widget, gint mode)
{
- gint size_table[3][3] = {{ 10, 10, 10 }, {20, 20, 50}, {35, 35, 170}};
+ gint size_table[3][3] = {{ 8, 8, 10 }, {16, 16, 40}, {30, 16, 99}};
gint x,y,m,s;
if (mode == 3) {
@@ -232,7 +231,6 @@
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 ();
@@ -253,7 +251,6 @@
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();
}
@@ -283,11 +280,6 @@
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;
@@ -313,13 +305,6 @@
all_boxes = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(setupdialog), all_boxes);
- button = gtk_check_button_new_with_label(_("off square button releases"));
- 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"));
@@ -443,7 +428,6 @@
gtk_widget_show(all_boxes);
fsc = fsize;
- outsetup = outrelease;
gtk_widget_show(setupdialog);
}
@@ -523,8 +507,6 @@
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' */
@@ -553,9 +535,6 @@
/* 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;
@@ -593,20 +572,16 @@
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);
if (! x_set)
- xsize = gnome_config_get_int("/gnomine/geometry/xsize=20");
+ xsize = gnome_config_get_int("/gnomine/geometry/xsize=16");
if (! y_set)
- ysize = gnome_config_get_int("/gnomine/geometry/ysize=20");
+ ysize = gnome_config_get_int("/gnomine/geometry/ysize=16");
if (! nmines_set)
- nmines = gnome_config_get_int("/gnomine/geometry/nmines=50");
+ nmines = gnome_config_get_int("/gnomine/geometry/nmines=40");
if (! minesize_set){
minesize = gnome_config_get_int("/gnomine/geometry/minesize=17");
if (minesize < 0)
@@ -614,8 +589,6 @@
}
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 -u old-gnomine/minefield.c gnomine/minefield.c
--- old-gnomine/minefield.c Mon May 11 01:34:32 1998
+++ gnomine/minefield.c Sun May 17 22:40:01 1998
@@ -28,11 +28,11 @@
{ 0 , 0 , 255 }, /* Blue */
{ 0 , 160, 0 }, /* Green */
{ 255, 0 , 0 }, /* Red */
- { 255, 0 , 255 }, /* Violet */
{ 0 , 0 , 127 }, /* DarkBlue */
- { 0 , 127, 0 }, /* DarkGreen */
{ 160, 0 , 0 }, /* DarkRed */
- { 160, 0 , 160 } /* DarkViolet */
+ { 0 , 255, 255 }, /* Cyan */
+ { 160, 0 , 160 }, /* DarkViolet */
+ { 0 , 0 , 0 } /* Black */
};
@@ -64,8 +64,8 @@
image = gdk_imlib_create_image_from_xpm_data(data);
gdk_imlib_render (image,
- 5 * (minesize - 4) / 8,
- 5 * (minesize - 4) / 8);
+ 5 * (minesize - 2) / 8,
+ 5 * (minesize - 2) / 8);
signp->pixmap = gdk_imlib_move_image (image);
signp->mask = gdk_imlib_move_mask (image);
gdk_imlib_destroy_image (image);
@@ -104,7 +104,8 @@
attributes.colormap = gtk_widget_get_colormap(widget);
attributes.event_mask = gtk_widget_get_events(widget);
attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK;
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
@@ -163,15 +164,14 @@
static void gtk_mine_draw(GtkMineField *mfield, guint x, guint y)
{
int c = cell_idx(mfield, x, y);
- int shadow_type;
+ int noshadow;
int n;
GtkWidget *widget = GTK_WIDGET(mfield);
if (mfield->lose || mfield->win) {
- shadow_type = mfield->mines[c].shown ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
+ noshadow = mfield->mines[c].shown;
} else {
- shadow_type = mfield->mines[c].down || mfield->mines[c].shown ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
+ noshadow = mfield->mines[c].down || mfield->mines[c].shown;
}
gdk_window_clear_area(widget->window,
@@ -179,11 +179,27 @@
minesize,
minesize);
- gtk_draw_shadow(widget->style, widget->window,
- GTK_WIDGET_STATE (widget), shadow_type,
- x*minesize, y*minesize,
- minesize,
- minesize);
+ if (!noshadow)
+ {
+ gtk_draw_shadow(widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT,
+ x*minesize, y*minesize,
+ minesize,
+ minesize);
+ } else {
+ gdk_draw_line(widget->window,
+ widget->style->black_gc,
+ x*minesize+minesize-1,
+ y*minesize,
+ x*minesize+minesize-1,
+ y*minesize+minesize-1);
+ gdk_draw_line(widget->window,
+ widget->style->black_gc,
+ x*minesize,
+ y*minesize+minesize-1,
+ x*minesize+minesize-1,
+ y*minesize+minesize-1);
+ }
if (mfield->mines[c].shown && !mfield->mines[c].mined) {
if ((n = mfield->mines[c].neighbours) != 0) {
@@ -297,7 +313,7 @@
gtk_minefield_setup_signs(widget);
- pxlsz = minesize - 4;
+ pxlsz = minesize - 2;
if (pxlsz > 999) pxlsz = 999;
if (pxlsz < 2) pxlsz = 2;
@@ -417,6 +433,19 @@
static void gtk_minefield_win(GtkMineField *mfield)
{
+ guint x, y, c;
+
+ for (x = 0; x < mfield->xsize; x++)
+ for (y = 0; y < mfield->ysize; y++)
+ {
+ c = x+y*mfield->xsize;
+ if (mfield->mines[c].shown == 0 && mfield->mines[c].marked == 0)
+ {
+ mfield->mines[c].marked = 1;
+ gtk_mine_draw(mfield, x, y);
+ }
+ }
+
gtk_signal_emit(GTK_OBJECT(mfield),
minefield_signals[WIN_SIGNAL]);
mfield->win = 1;
@@ -434,7 +463,7 @@
gtk_minefield_loose(mfield);
} else {
gtk_minefield_check_field(mfield, x, y);
- if (mfield->flags+mfield->shown == mfield->xsize*mfield->ysize) {
+ if (mfield->shown == mfield->xsize*mfield->ysize-mfield->mcount) {
gtk_minefield_win(mfield);
}
}
@@ -452,7 +481,7 @@
}
gtk_signal_emit(GTK_OBJECT(mfield),
minefield_signals[MARKS_CHANGED_SIGNAL]);
- if (mfield->flags+mfield->shown == mfield->xsize*mfield->ysize) {
+ if (mfield->shown == mfield->xsize*mfield->ysize-mfield->mcount) {
gtk_minefield_win(mfield);
}
}
@@ -460,40 +489,41 @@
static inline void gtk_minefield_multi_press(GtkMineField *mfield, guint x, guint y, gint c)
{
- guint n, i;
+ guint i;
gint nx, ny, c2;
- n = 0;
for (i=0; i<8; i++) {
nx = x+neighbour_map[i].x;
ny = y+neighbour_map[i].y;
if ((c2 = cell_idx(mfield, nx, ny)) == -1)
continue;
- if (mfield->mines[c2].marked) n++;
- }
- if (mfield->mines[c].neighbours == n) {
- for (i=0; i<8; i++) {
- nx = x+neighbour_map[i].x;
- ny = y+neighbour_map[i].y;
- if ((c2 = cell_idx(mfield, nx, ny)) == -1)
- continue;
- if (!mfield->mines[c2].marked &&
- !mfield->mines[c2].shown) {
- mfield->mines[c2].down = 1;
- gtk_mine_draw(mfield, nx, ny);
- }
+ if (!mfield->mines[c2].marked && !mfield->mines[c2].shown) {
+ mfield->mines[c2].down = 1;
+ gtk_mine_draw(mfield, nx, ny);
}
- mfield->multi_mode = 1;
}
+ mfield->multi_mode = 1;
}
-static void gtk_minefield_multi_release (GtkMineField *mfield, guint x, guint y, guint really)
+static void gtk_minefield_multi_release (GtkMineField *mfield, guint x, guint y, guint c, guint really)
{
- gint nx, ny, i, c2;
+ gint n, nx, ny, i, c2;
guint loose = 0;
mfield->multi_mode = 0;
-
+
+ n = 0;
+ for (i=0; i<8; i++) {
+ nx = x+neighbour_map[i].x;
+ ny = y+neighbour_map[i].y;
+ if ((c2 = cell_idx(mfield, nx, ny)) == -1)
+ continue;
+ if (mfield->mines[c2].marked) n++;
+ }
+ if (mfield->mines[c].neighbours != n ||
+ mfield->mines[c].marked ||
+ !mfield->mines[c].shown) really = 0;
+
for (i=0; i<8; i++) {
nx = x+neighbour_map[i].x;
ny = y+neighbour_map[i].y;
@@ -515,12 +545,50 @@
gtk_minefield_loose(mfield);
} else if (really) {
gtk_minefield_check_field(mfield, x, y);
- if (mfield->flags+mfield->shown == mfield->xsize*mfield->ysize) {
+ if (mfield->shown == mfield->xsize*mfield->ysize-mfield->mcount) {
gtk_minefield_win(mfield);
}
}
}
+static gint gtk_minefield_motion_notify(GtkWidget *widget, GdkEventMotion *event)
+{
+ GtkMineField *mfield;
+ guint x, y;
+ guint c;
+ guint multi;
+
+ g_return_val_if_fail(widget != NULL, 0);
+ g_return_val_if_fail(GTK_IS_MINEFIELD(widget), 0);
+ g_return_val_if_fail(event != NULL, 0);
+
+ mfield = GTK_MINEFIELD(widget);
+
+ if (mfield->lose || mfield->win) return FALSE;
+
+ if (mfield->bdown[0] || mfield->bdown[1]) {
+ x = event->x/minesize;
+ y = event->y/minesize;
+ c = x+y*(mfield->xsize);
+
+ if (c != mfield->cdown) {
+ mfield->mines[mfield->cdown].down = 0;
+ gtk_mine_draw(mfield, mfield->cdownx, mfield->cdowny);
+
+ multi = mfield->multi_mode;
+ if (multi) gtk_minefield_multi_release(mfield, mfield->cdownx, mfield->cdowny, mfield->cdown, 0);
+ mfield->cdownx = x;
+ mfield->cdowny = y;
+ mfield->cdown = c;
+ mfield->mines[c].down = 1;
+ gtk_mine_draw(mfield, x, y);
+
+ if (multi) gtk_minefield_multi_press(mfield, x, y, c);
+ }
+ }
+ return FALSE;
+}
+
static gint gtk_minefield_button_press(GtkWidget *widget, GdkEventButton *event)
{
GtkMineField *mfield;
@@ -540,17 +608,21 @@
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-1] = 1;
- gtk_mine_draw(mfield, x, y);
- if ((event->button == 2 || (mfield->bdown[0] && mfield->bdown[2]))
- && (mfield->mines[c].shown == 1 || mfield->mines[c].marked == 1)) { /* multi show */
+ mfield->cdownx = x;
+ mfield->cdowny = y;
+ mfield->cdown = c;
+ mfield->mines[c].down = 1;
+ }
+ mfield->bdown[event->button-1]++;
+ gtk_mine_draw(mfield, x, y);
+ if (event->button == 2 || (mfield->bdown[0] && mfield->bdown[2])) { /* multi show */
gtk_minefield_multi_press(mfield, x, y, c);
- }
+ }
+ else if (event->button == 3 && mfield->bdown[2] == 1)
+ {
+ gtk_minefield_toggle_mark(mfield, x, y);
+ gtk_mine_draw(mfield, x, y);
+ }
if (event->button == 1 || event->button == 2) {
gtk_signal_emit(GTK_OBJECT(mfield),
minefield_signals[LOOK_SIGNAL]);
@@ -562,7 +634,6 @@
static gint gtk_minefield_button_release(GtkWidget *widget, GdkEventButton *event)
{
GtkMineField *mfield;
- guint x, y;
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(GTK_IS_MINEFIELD(widget), FALSE);
@@ -573,8 +644,6 @@
if (mfield->lose || mfield->win) return FALSE;
if (event->button <= 3 && mfield->bdown[event->button-1]) {
- x = event->x/minesize;
- y = event->y/minesize;
if (mfield->bdown[0] && mfield->bdown[2] && event->button != 2) {
/* left+right click = multi show */
mfield->bdown[0] = 0;
@@ -582,18 +651,12 @@
mfield->bdown[2] = 0;
event->button = 2;
}
- if (x+y*(mfield->xsize) == mfield->cdown || outrelease) {
- switch (event->button) {
- case 1: gtk_minefield_show(mfield, mfield->cdownx, mfield->cdowny);
- break;
- case 2: if (mfield->multi_mode) gtk_minefield_multi_release(mfield, mfield->cdownx, mfield->cdowny, 1);
- break;
- case 3: gtk_minefield_toggle_mark(mfield, mfield->cdownx, mfield->cdowny);
- break;
- }
- } else if (mfield->multi_mode) {
- gtk_minefield_multi_release(mfield, mfield->cdownx, mfield->cdowny, 0);
- }
+ switch (event->button) {
+ case 1: gtk_minefield_show(mfield, mfield->cdownx, mfield->cdowny);
+ break;
+ case 2: if (mfield->multi_mode) gtk_minefield_multi_release(mfield, mfield->cdownx, mfield->cdowny, mfield->cdown, 1);
+ break;
+ }
if (!mfield->lose && !mfield->win) {
gtk_signal_emit(GTK_OBJECT(mfield),
minefield_signals[UNLOOK_SIGNAL]);
@@ -624,7 +687,8 @@
widget_class->expose_event = gtk_minefield_expose;
widget_class->button_press_event = gtk_minefield_button_press;
widget_class->button_release_event = gtk_minefield_button_release;
-
+ widget_class->motion_notify_event = gtk_minefield_motion_notify;
+
class->marks_changed = NULL;
class->explode = NULL;
class->look = NULL;
diff -u old-gnomine/minefield.h gnomine/minefield.h
--- old-gnomine/minefield.h Mon May 11 01:34:32 1998
+++ gnomine/minefield.h Sun May 17 17:17:45 1998
@@ -83,7 +83,6 @@
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]