diff options
author | Bruno Coudoin <bcoudoin@src.gnome.org> | 2006-10-05 21:38:52 (GMT) |
---|---|---|
committer | Bruno Coudoin <bcoudoin@src.gnome.org> | 2006-10-05 21:38:52 (GMT) |
commit | 951e6a4f1ef6acb24977a5596ef7ce625e0ed19f (patch) | |
tree | 7e2528116897a45efe23bc019e641b12accfa5e3 | |
parent | 95e2ab81f5fdc99f6538e483d21f59e235cad371 (diff) |
- fixed to work with shape game that provides a pixmap instead of the red dot.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/boards/shapegame.c | 37 |
2 files changed, 35 insertions, 9 deletions
@@ -1,5 +1,12 @@ 2006-10-05 Bruno coudoin <bruno.coudoin@free.fr> + - fixed to work with shape game that provides a pixmap instead of the red dot. + + * src/boards/shapegame.c: (find_closest_shape), (item_event), + (add_shape_to_canvas): + +2006-10-05 Bruno coudoin <bruno.coudoin@free.fr> + - On a great suggestion of Joshua N Pritikin, now in shapegames like puzzles and geography, the hot point is set in green. This let the kid know in advance where she will drop her piece. diff --git a/src/boards/shapegame.c b/src/boards/shapegame.c index 5c5aed0..3c38eec 100644 --- a/src/boards/shapegame.c +++ b/src/boards/shapegame.c @@ -89,6 +89,7 @@ struct _Shape { gboolean found; /* The user found this item */ gboolean placed; /* The user placed this item */ GnomeCanvasItem *target_point; /* Target point item for this shape */ + GnomeCanvasItem *targetitem; /* Target item for this shape (if targetfile is defined) */ }; gchar *colorlist [] = @@ -904,8 +905,6 @@ static Shape *find_closest_shape(double x, double y, double limit) { /* Calc the distance between this shape and the given coord */ dist = sqrt(pow((shape->x-x),2) + pow((shape->y-y),2)); - g_warning("DIST=%f shapename=%s\n", dist, shape->name); - g_warning(" x=%f y=%f shape->x=%f shape->y=%f\n", x, y, shape->x, shape->y); if(dist<goodDist) { goodDist=dist; @@ -1135,15 +1134,29 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, Shape *shape) if(targetshape!=NULL) { if(target_point_previous) - gnome_canvas_item_set(GNOME_CANVAS_ITEM(target_point_previous), - "fill_color_rgba", POINT_COLOR_OFF, - NULL); + { + if(strcmp(shape->targetfile, UNDEFINED)==0) + { + gnome_canvas_item_set(GNOME_CANVAS_ITEM(target_point_previous), + "fill_color_rgba", POINT_COLOR_OFF, + NULL); - gnome_canvas_item_set(GNOME_CANVAS_ITEM(targetshape->target_point), - "fill_color_rgba", POINT_COLOR_ON, - NULL); + gnome_canvas_item_set(GNOME_CANVAS_ITEM(targetshape->target_point), + "fill_color_rgba", POINT_COLOR_ON, + NULL); + } + else + { + gc_item_focus_set(target_point_previous, FALSE); + gc_item_focus_set(targetshape->targetitem, TRUE); + target_point_previous = targetshape->targetitem; + } + } - target_point_previous = targetshape->target_point; + if(strcmp(shape->targetfile, UNDEFINED)==0) + target_point_previous = targetshape->target_point; + else + target_point_previous = targetshape->targetitem; } } break; @@ -1157,9 +1170,14 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, Shape *shape) dragging = FALSE; if(target_point_previous) + { + if(strcmp(shape->targetfile, UNDEFINED)==0) gnome_canvas_item_set(GNOME_CANVAS_ITEM(target_point_previous), "fill_color_rgba", POINT_COLOR_OFF, NULL); + else + gc_item_focus_set(target_point_previous, FALSE); + } target_point_previous = NULL; targetshape = find_closest_shape(item_x - offset_x, @@ -1479,6 +1497,7 @@ add_shape_to_canvas(Shape *shape) "width_set", TRUE, "height_set", TRUE, NULL); + shape->targetitem = item; gdk_pixbuf_unref(targetpixmap); } else |