gnome-games r8170 - trunk/aisleriot
- From: jclinton svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8170 - trunk/aisleriot
- Date: Tue, 21 Oct 2008 19:48:03 +0000 (UTC)
Author: jclinton
Date: Tue Oct 21 19:48:02 2008
New Revision: 8170
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8170&view=rev
Log:
Added a revealed-card property to AisleriotSlotRenderer to fix
revealing the card with the right mouse button.
Modified:
trunk/aisleriot/board.c
trunk/aisleriot/slot-renderer.c
trunk/aisleriot/slot-renderer.h
Modified: trunk/aisleriot/board.c
==============================================================================
--- trunk/aisleriot/board.c (original)
+++ trunk/aisleriot/board.c Tue Oct 21 19:48:02 2008
@@ -1394,19 +1394,17 @@
int cardid)
{
AisleriotBoardPrivate *priv = board->priv;
- GtkWidget *widget = GTK_WIDGET (board);
Card card;
- GdkRectangle rect;
+ AisleriotSlotRenderer *renderer;
if (priv->show_card_slot == slot)
return;
if (priv->show_card_slot != NULL) {
- get_rect_by_slot_and_card (board,
- priv->show_card_slot,
- priv->show_card_id,
- 1, &rect);
- gdk_window_invalidate_rect (widget->window, &rect, FALSE);
+ if (priv->show_card_slot->slot_renderer) {
+ renderer = AISLERIOT_SLOT_RENDERER (priv->show_card_slot->slot_renderer);
+ aisleriot_slot_renderer_set_revealed_card (renderer, -1);
+ }
priv->show_card_slot = NULL;
priv->show_card_id = -1;
priv->click_status = STATUS_NONE;
@@ -1423,11 +1421,8 @@
priv->show_card_id = cardid;
priv->click_status = STATUS_SHOW;
- get_rect_by_slot_and_card (board,
- priv->show_card_slot,
- priv->show_card_id,
- 1, &rect);
- gdk_window_invalidate_rect (widget->window, &rect, FALSE);
+ renderer = AISLERIOT_SLOT_RENDERER (slot->slot_renderer);
+ aisleriot_slot_renderer_set_revealed_card (renderer, cardid);
}
static void
Modified: trunk/aisleriot/slot-renderer.c
==============================================================================
--- trunk/aisleriot/slot-renderer.c (original)
+++ trunk/aisleriot/slot-renderer.c Tue Oct 21 19:48:02 2008
@@ -68,6 +68,8 @@
gboolean show_highlight;
gint highlight_start;
+ gint revealed_card;
+
ClutterTimeline *timeline;
guint completed_handler;
GArray *animations;
@@ -88,6 +90,7 @@
PROP_CACHE,
PROP_SLOT,
PROP_HIGHLIGHT,
+ PROP_REVEALED_CARD,
PROP_ANIMATION_LAYER
};
@@ -133,6 +136,16 @@
G_PARAM_STATIC_BLURB);
g_object_class_install_property (gobject_class, PROP_HIGHLIGHT, pspec);
+ pspec = g_param_spec_int ("revealed-card", NULL, NULL,
+ 0, G_MAXINT, 0,
+ G_PARAM_WRITABLE |
+ G_PARAM_READABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (gobject_class, PROP_HIGHLIGHT, pspec);
+
pspec = g_param_spec_object ("animation-layer", NULL, NULL,
CLUTTER_TYPE_CONTAINER,
G_PARAM_WRITABLE |
@@ -158,6 +171,7 @@
g_signal_connect_swapped (priv->timeline, "completed",
G_CALLBACK (completed_cb), self);
+ priv->revealed_card = -1;
}
static void
@@ -241,6 +255,11 @@
g_value_get_int (value));
break;
+ case PROP_REVEALED_CARD:
+ aisleriot_slot_renderer_set_revealed_card (srend,
+ g_value_get_int (value));
+ break;
+
case PROP_ANIMATION_LAYER:
aisleriot_slot_renderer_set_animation_layer (srend,
g_value_get_object (value));
@@ -266,6 +285,11 @@
aisleriot_slot_renderer_get_highlight (srend));
break;
+ case PROP_REVEALED_CARD:
+ g_value_set_int (value,
+ aisleriot_slot_renderer_get_revealed_card (srend));
+ break;
+
case PROP_ANIMATION_LAYER:
g_value_set_object (value,
aisleriot_slot_renderer_get_animation_layer (srend));
@@ -278,13 +302,44 @@
}
static void
+aisleriot_slot_renderer_paint_card (AisleriotSlotRenderer *srend,
+ guint card_num)
+{
+ AisleriotSlotRendererPrivate *priv = srend->priv;
+ Card card = CARD (priv->slot->cards->data[card_num]);
+ gboolean is_highlighted;
+ CoglHandle cogl_tex;
+ guint tex_width, tex_height;
+ int cardx, cardy;
+
+ is_highlighted = priv->show_highlight && (card_num >= priv->highlight_start);
+
+ cogl_tex = aisleriot_card_cache_get_card_texture (priv->cache,
+ card,
+ is_highlighted);
+
+ tex_width = cogl_texture_get_width (cogl_tex);
+ tex_height = cogl_texture_get_height (cogl_tex);
+
+ aisleriot_game_get_card_offset (priv->slot, card_num,
+ FALSE,
+ &cardx, &cardy);
+
+ cogl_texture_rectangle (cogl_tex,
+ CLUTTER_INT_TO_FIXED (cardx),
+ CLUTTER_INT_TO_FIXED (cardy),
+ CLUTTER_INT_TO_FIXED (cardx + tex_width),
+ CLUTTER_INT_TO_FIXED (cardy + tex_height),
+ 0, 0, CFX_ONE, CFX_ONE);
+}
+
+static void
aisleriot_slot_renderer_paint (ClutterActor *actor)
{
AisleriotSlotRenderer *srend = (AisleriotSlotRenderer *) actor;
AisleriotSlotRendererPrivate *priv = srend->priv;
guint n_cards;
guint8 *cards;
- int cardx, cardy;
guint i;
g_return_if_fail (priv->cache != NULL);
@@ -319,32 +374,14 @@
n_cards - priv->slot->exposed);
last_card = n_cards - priv->animations->len;
- for (i = first_card; i < last_card; i++) {
- Card card = CARD (cards[i]);
- gboolean is_highlighted;
- CoglHandle cogl_tex;
- guint tex_width, tex_height;
-
- is_highlighted = priv->show_highlight && (i >= priv->highlight_start);
-
- cogl_tex = aisleriot_card_cache_get_card_texture (priv->cache,
- card,
- is_highlighted);
-
- tex_width = cogl_texture_get_width (cogl_tex);
- tex_height = cogl_texture_get_height (cogl_tex);
-
- aisleriot_game_get_card_offset (priv->slot, i,
- FALSE,
- &cardx, &cardy);
-
- cogl_texture_rectangle (cogl_tex,
- CLUTTER_INT_TO_FIXED (cardx),
- CLUTTER_INT_TO_FIXED (cardy),
- CLUTTER_INT_TO_FIXED (cardx + tex_width),
- CLUTTER_INT_TO_FIXED (cardy + tex_height),
- 0, 0, CFX_ONE, CFX_ONE);
- }
+ for (i = first_card; i < last_card; i++)
+ if (i != priv->revealed_card)
+ aisleriot_slot_renderer_paint_card (srend, i);
+
+ /* Paint the revealed card after all of the other cards so that it
+ will appeear on top */
+ if (priv->revealed_card >= first_card && priv->revealed_card < last_card)
+ aisleriot_slot_renderer_paint_card (srend, priv->revealed_card);
}
}
@@ -374,6 +411,31 @@
g_object_notify (G_OBJECT (srend), "highlight");
}
+gint
+aisleriot_slot_renderer_get_revealed_card (AisleriotSlotRenderer *srend)
+{
+ g_return_val_if_fail (AISLERIOT_IS_SLOT_RENDERER (srend), 0);
+
+ return srend->priv->revealed_card;
+}
+
+void
+aisleriot_slot_renderer_set_revealed_card (AisleriotSlotRenderer *srend,
+ gint revealed_card)
+{
+ AisleriotSlotRendererPrivate *priv;
+
+ g_return_if_fail (AISLERIOT_IS_SLOT_RENDERER (srend));
+
+ priv = srend->priv;
+
+ priv->revealed_card = revealed_card;
+
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (srend));
+
+ g_object_notify (G_OBJECT (srend), "revealed-card");
+}
+
ClutterContainer *
aisleriot_slot_renderer_get_animation_layer (AisleriotSlotRenderer *srend)
{
Modified: trunk/aisleriot/slot-renderer.h
==============================================================================
--- trunk/aisleriot/slot-renderer.h (original)
+++ trunk/aisleriot/slot-renderer.h Tue Oct 21 19:48:02 2008
@@ -81,6 +81,10 @@
gint hightlight_start);
guint aisleriot_slot_renderer_get_highlight (AisleriotSlotRenderer *srend);
+void aisleriot_slot_renderer_set_revealed_card (AisleriotSlotRenderer *srend,
+ gint revealed_card);
+gint aisleriot_slot_renderer_get_revealed_card (AisleriotSlotRenderer *srend);
+
ClutterContainer *aisleriot_slot_renderer_get_animation_layer
(AisleriotSlotRenderer *srend);
void aisleriot_slot_renderer_set_animation_layer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]