gnome-games r8814 - trunk/aisleriot
- From: nroberts svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8814 - trunk/aisleriot
- Date: Sun, 8 Mar 2009 20:33:40 +0000 (UTC)
Author: nroberts
Date: Sun Mar 8 20:33:40 2009
New Revision: 8814
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8814&view=rev
Log:
[aisleriot-card] Specify the top and bottom card separately
Instead of assuming the bottom card is just the flipped version of the
to card they can now be specified independently with separate
properties. That way we can use AisleriotCard to animate turning over
a deck of cards.
Modified:
trunk/aisleriot/board.c
trunk/aisleriot/card.c
trunk/aisleriot/card.h
trunk/aisleriot/slot-renderer.c
Modified: trunk/aisleriot/board.c
==============================================================================
--- trunk/aisleriot/board.c (original)
+++ trunk/aisleriot/board.c Sun Mar 8 20:33:40 2009
@@ -1230,7 +1230,8 @@
g_array_append_val (priv->removed_cards, removed_card);
- card_tex = aisleriot_card_new (priv->textures, hcard, &priv->selection_colour);
+ card_tex = aisleriot_card_new (priv->textures, hcard, hcard,
+ &priv->selection_colour);
clutter_actor_set_position (card_tex, x, y);
clutter_container_add (CLUTTER_CONTAINER (priv->moving_cards_group),
card_tex, NULL);
Modified: trunk/aisleriot/card.c
==============================================================================
--- trunk/aisleriot/card.c (original)
+++ trunk/aisleriot/card.c Sun Mar 8 20:33:40 2009
@@ -66,7 +66,7 @@
struct _AisleriotCardPrivate
{
- Card card;
+ Card bottom_card, top_card;
ClutterColor highlight_color;
gboolean highlighted;
@@ -78,7 +78,8 @@
PROP_0,
PROP_CACHE,
- PROP_CARD,
+ PROP_BOTTOM_CARD,
+ PROP_TOP_CARD,
PROP_HIGHLIGHTED,
PROP_HIGHLIGHT_COLOR
};
@@ -114,14 +115,23 @@
actor_class->get_preferred_width = aisleriot_card_get_preferred_width;
actor_class->get_preferred_height = aisleriot_card_get_preferred_height;
- pspec = g_param_spec_uchar ("card", NULL, NULL,
+ pspec = g_param_spec_uchar ("bottom-card", NULL, NULL,
0, 255, 0,
G_PARAM_WRITABLE |
G_PARAM_READABLE |
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB);
- g_object_class_install_property (gobject_class, PROP_CARD, pspec);
+ g_object_class_install_property (gobject_class, PROP_BOTTOM_CARD, pspec);
+
+ pspec = g_param_spec_uchar ("top-card", NULL, NULL,
+ 0, 255, 0,
+ G_PARAM_WRITABLE |
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (gobject_class, PROP_TOP_CARD, pspec);
pspec = g_param_spec_object ("cache", NULL, NULL,
GAMES_TYPE_CARD_TEXTURES_CACHE,
@@ -188,12 +198,14 @@
ClutterActor *
aisleriot_card_new (GamesCardTexturesCache *cache,
- Card card,
+ Card bottom_card,
+ Card top_card,
const ClutterColor *highlight_color)
{
return g_object_new (AISLERIOT_TYPE_CARD,
"cache", cache,
- "card", card.value,
+ "bottom-card", bottom_card.value,
+ "top-card", top_card.value,
"highlight-color", highlight_color,
NULL);
}
@@ -209,7 +221,8 @@
CoglHandle tex;
guint width;
- tex = games_card_textures_cache_get_card_texture (priv->cache, priv->card);
+ tex = games_card_textures_cache_get_card_texture (priv->cache,
+ priv->top_card);
if (G_UNLIKELY (tex == COGL_INVALID_HANDLE))
width = 0;
@@ -234,7 +247,8 @@
CoglHandle tex;
guint height;
- tex = games_card_textures_cache_get_card_texture (priv->cache, priv->card);
+ tex = games_card_textures_cache_get_card_texture (priv->cache,
+ priv->top_card);
if (G_UNLIKELY (tex == COGL_INVALID_HANDLE))
height = 0;
@@ -259,8 +273,7 @@
ClutterActorBox alloc_box;
gboolean x_swapped = FALSE;
static const ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
-
- card_num = priv->card;
+ gboolean show_top = TRUE;
x_angle = clutter_actor_get_rotationx (actor, CLUTTER_X_AXIS,
NULL, NULL, NULL);
@@ -270,16 +283,14 @@
/* Show the other side of the card if it is rotated more than 180
degrees in exactly one of the axes */
if (ANGLE_IS_UPSIDE_DOWN (x_angle))
- card_num.attr.face_down = !card_num.attr.face_down;
+ show_top = !show_top;
if (ANGLE_IS_UPSIDE_DOWN (y_angle)) {
- card_num.attr.face_down = !card_num.attr.face_down;
- /* The picture for the back of the card is already drawn as if it
- was rotated so we need to swap the coordinates so it will look
- right when it is rotated again */
- if (card_num.attr.face_down)
- x_swapped = TRUE;
+ show_top = !show_top;
+ x_swapped = TRUE;
}
+ card_num = show_top ? priv->top_card : priv->bottom_card;
+
tex = games_card_textures_cache_get_card_texture (priv->cache, card_num);
if (G_UNLIKELY (tex == COGL_INVALID_HANDLE))
return;
@@ -325,13 +336,23 @@
AisleriotCard *card = AISLERIOT_CARD (self);
switch (property_id) {
- case PROP_CARD:
+ case PROP_BOTTOM_CARD:
{
Card card_num;
card_num.value = g_value_get_uchar (value);
- aisleriot_card_set_card (card, card_num);
+ aisleriot_card_set_card (card, card_num, card->priv->top_card);
+ }
+ break;
+
+ case PROP_TOP_CARD:
+ {
+ Card card_num;
+
+ card_num.value = g_value_get_uchar (value);
+
+ aisleriot_card_set_card (card, card->priv->bottom_card, card_num);
}
break;
@@ -363,8 +384,12 @@
AisleriotCardPrivate *priv = card->priv;
switch (property_id) {
- case PROP_CARD:
- g_value_set_uchar (value, priv->card.value);
+ case PROP_BOTTOM_CARD:
+ g_value_set_uchar (value, priv->bottom_card.value);
+ break;
+
+ case PROP_TOP_CARD:
+ g_value_set_uchar (value, priv->top_card.value);
break;
case PROP_CACHE:
@@ -383,7 +408,9 @@
}
void
-aisleriot_card_set_card (AisleriotCard *card, Card card_num)
+aisleriot_card_set_card (AisleriotCard *card,
+ Card bottom_card,
+ Card top_card)
{
AisleriotCardPrivate *priv;
@@ -391,11 +418,13 @@
priv = card->priv;
- priv->card = card_num;
+ priv->bottom_card = bottom_card;
+ priv->top_card = top_card;
clutter_actor_queue_redraw (CLUTTER_ACTOR (card));
- g_object_notify (G_OBJECT (card), "card");
+ g_object_notify (G_OBJECT (card), "bottom-card");
+ g_object_notify (G_OBJECT (card), "top-card");
}
static void
Modified: trunk/aisleriot/card.h
==============================================================================
--- trunk/aisleriot/card.h (original)
+++ trunk/aisleriot/card.h Sun Mar 8 20:33:40 2009
@@ -64,10 +64,13 @@
GType aisleriot_card_get_type (void) G_GNUC_CONST;
ClutterActor *aisleriot_card_new (GamesCardTexturesCache *cache,
- Card card,
+ Card bottom_card,
+ Card top_card,
const ClutterColor *highlight_color);
-void aisleriot_card_set_card (AisleriotCard *card, Card card_num);
+void aisleriot_card_set_card (AisleriotCard *card,
+ Card bottom_card,
+ Card top_card);
void aisleriot_card_set_highlighted (AisleriotCard *card,
gboolean highlighted);
Modified: trunk/aisleriot/slot-renderer.c
==============================================================================
--- trunk/aisleriot/slot-renderer.c (original)
+++ trunk/aisleriot/slot-renderer.c Sun Mar 8 20:33:40 2009
@@ -578,12 +578,15 @@
AnimationData anim_data;
ClutterAlpha *alpha;
ClutterKnot knots[2];
- Card card = CARD (priv->slot->cards->data[card_num]);
+ Card card = CARD (priv->slot->cards->data[card_num]), flipped_card;
guint card_width, card_height;
memset (&anim_data, 0, sizeof (anim_data));
- anim_data.card_tex = aisleriot_card_new (priv->cache, card, &priv->highlight_color);
+ flipped_card = card;
+ flipped_card.attr.face_down = !flipped_card.attr.face_down;
+ anim_data.card_tex = aisleriot_card_new (priv->cache, flipped_card, card,
+ &priv->highlight_color);
card_width = clutter_actor_get_width (anim_data.card_tex);
card_height = clutter_actor_get_height (anim_data.card_tex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]