Apologies & better mahjongg patch...
- From: Michael Meeks <michael imaginator com>
- To: Marc Ewing <marc redhat com>
- cc: gnome-list gnome org
- Subject: Apologies & better mahjongg patch...
- Date: Mon, 8 Jun 1998 19:50:13 +0100 (BST)
Sorry, silly bug such that you could select a tile then undo making that
tile inaccessible, yet still have it selected.
This fixes that, and makes the re-draw far more aesthetic.
The patch is against clean gnome-games-0.20.tar.gz
Thanks,
Michael Meeks.
--
michael@imaginator.com <><, Pseudo Engineer, itinerant idiot
*** mahjongg/mahjongg.c Wed Jun 3 02:07:33 1998
--- oldmahjongg/mahjongg.c Mon Jun 8 19:51:02 1998
***************
*** 252,271 ****
--- 252,273 ----
int layer;
int x;
int y;
int visible;
int selected;
+ int sequence;
};
GtkWidget *window, *pref_dialog;
GtkWidget *mbox;
GtkWidget *draw_area;
GtkWidget *tiles_label;
GdkPixmap *tiles_pix, *mask;
GdkGC *my_gc;
tile tiles[MAX_TILES];
int selected_tile, visible_tiles;
+ int sequence_number;
static GdkImlibImage *tiles_image;
static gchar *tileset;
static struct {
***************
*** 275,284 ****
--- 277,287 ----
void load_tiles (char *fname);
void quit_game_callback (GtkWidget *widget, gpointer data);
void new_game_callback (GtkWidget *widget, gpointer data);
void restart_game_callback (GtkWidget *widget, gpointer data);
+ void undo_tile_callback (GtkWidget *widget, gpointer data);
void select_game_callback (GtkWidget *widget, gpointer date);
void new_game (void);
void properties_callback (GtkWidget *widget, gpointer data);
void redraw_area (int x1, int y1, int x2, int y2, int mlayer);
void about_callback (GtkWidget *widget, gpointer data);
***************
*** 299,309 ****
{GNOME_APP_UI_SEPARATOR},
{GNOME_APP_UI_ITEM, N_("Hint"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL},
! {GNOME_APP_UI_ITEM, N_("Undo"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_UNDO, 0, 0, NULL},
{GNOME_APP_UI_SEPARATOR},
{GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_game_callback, NULL, NULL,
--- 302,312 ----
{GNOME_APP_UI_SEPARATOR},
{GNOME_APP_UI_ITEM, N_("Hint"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL},
! {GNOME_APP_UI_ITEM, N_("Undo"), NULL, undo_tile_callback, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_UNDO, 0, 0, NULL},
{GNOME_APP_UI_SEPARATOR},
{GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_game_callback, NULL, NULL,
***************
*** 365,375 ****
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_REFRESH, 0, 0, NULL},
{GNOME_APP_UI_ITEM, N_("Hint"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HELP, 0, 0, NULL},
! {GNOME_APP_UI_ITEM, N_("Undo"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_UNDO, 0, 0, NULL},
{GNOME_APP_UI_TOGGLEITEM, N_("Sound"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_DATA, mini_sound_xpm, 0, 0, NULL},
--- 368,378 ----
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_REFRESH, 0, 0, NULL},
{GNOME_APP_UI_ITEM, N_("Hint"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HELP, 0, 0, NULL},
! {GNOME_APP_UI_ITEM, N_("Undo"), NULL, undo_tile_callback, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_UNDO, 0, 0, NULL},
{GNOME_APP_UI_TOGGLEITEM, N_("Sound"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_DATA, mini_sound_xpm, 0, 0, NULL},
***************
*** 616,625 ****
--- 619,639 ----
gnome_dialog_set_modal (GNOME_DIALOG (mb));
gtk_widget_show (mb);
}
}
+ void redraw_tile (int i)
+ {
+ gdk_window_clear_area (draw_area->window, tiles[i].x, tiles[i].y,
+ TILE_WIDTH, TILE_HEIGHT);
+
+ redraw_area (tiles[i].x, tiles[i].y,
+ tiles[i].x + TILE_WIDTH - 1,
+ tiles[i].y + TILE_HEIGHT - 1,
+ 0);
+ }
+
void you_won (void)
{
GtkWidget *mb;
mb = gnome_message_box_new (_("You won!"),
***************
*** 740,749 ****
--- 754,791 ----
tiles[i].selected = 0;
}
gtk_widget_draw (draw_area, NULL);
}
+ void undo_tile_callback (GtkWidget *widget, gpointer data)
+ {
+ int i;
+ gchar tmpchar[4] ;
+
+ // printf ("Undo\n") ;
+ if (selected_tile<MAX_TILES)
+ {
+ tiles[selected_tile].selected = 0 ;
+ redraw_tile (selected_tile) ;
+ selected_tile = MAX_TILES + 1;
+ }
+ if (sequence_number>1)
+ sequence_number-- ;
+ for (i=0; i<144; i++)
+ if (tiles[i].sequence == sequence_number)
+ {
+ tiles[i].sequence = 0 ;
+ tiles[i].selected = 0 ;
+ tiles[i].visible = 1 ;
+ visible_tiles++ ;
+ redraw_tile(i) ;
+ }
+
+ sprintf(tmpchar,"%d",visible_tiles) ;
+ gtk_label_set(GTK_LABEL(tiles_label), tmpchar);
+ }
+
static void
input_callback (GtkWidget *widget, gpointer data)
{
srand (atoi (GTK_ENTRY (data)->text));
new_game ();
***************
*** 821,830 ****
--- 863,873 ----
void new_game (void)
{
int i, f, n;
+ sequence_number = 1 ;
visible_tiles = 144;
for (f = 0; f < 144; f++) {
tiles[f].visible = 0;
}
selected_tile = MAX_TILES + 1;
***************
*** 840,849 ****
--- 883,893 ----
tiles[f].x = default_pos[f].x * (HALF_WIDTH-0) + 30 + (5 * default_pos[f].layer);
tiles[f].y = default_pos[f].y * (HALF_HEIGHT-0) + 25 - (4 * default_pos[f].layer);
tiles[f].layer = default_pos[f].layer;
tiles[f].type = default_types[i].type;
tiles[f].image = default_types[i].image;
+ tiles[f].sequence = 0 ;
}
}
gtk_widget_draw (draw_area, NULL);
}
***************
*** 926,936 ****
}
void button_pressed (int x, int y)
{
int i;
! gchar *tmpchar;
i = find_tile (x, y);
if (i < MAX_TILES) {
if (tile_free (i)) {
if (selected_tile < MAX_TILES) {
--- 970,980 ----
}
void button_pressed (int x, int y)
{
int i;
! gchar tmpchar[4];
i = find_tile (x, y);
if (i < MAX_TILES) {
if (tile_free (i)) {
if (selected_tile < MAX_TILES) {
***************
*** 940,949 ****
--- 984,995 ----
tiles[selected_tile].visible = 0;
tile_gone (i, x, y);
tile_gone (selected_tile,
tiles[selected_tile].x + 1,
tiles[selected_tile].y + 1);
+ tiles[i].sequence = sequence_number ;
+ tiles[selected_tile].sequence = sequence_number++ ;
selected_tile = MAX_TILES + 1;
visible_tiles -= 2;
sprintf(tmpchar,"%d",visible_tiles);
gtk_label_set(GTK_LABEL(tiles_label), tmpchar);
check_free();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]