croupier: Fix Top-Left card no resize bug
There was a small bug where the top-left card wouldn't resize during
a screen rotation. It turns out that I'd forgotten to update the
card data that the ZCard was based off. This CL fixes that.
Change-Id: I9788a184d40b1194002ae0d65cc14964722c9fdd
diff --git a/lib/components/card.dart b/lib/components/card.dart
index 795a198..cc71917 100644
--- a/lib/components/card.dart
+++ b/lib/components/card.dart
@@ -98,6 +98,14 @@
z: z);
}
+ // Check if the data between these Cards matches.
+ // This isn't == since I don't want to override that and hashCode.
+ bool isMatchWith(Card c) {
+ return c.card == card && c.faceUp == faceUp && c.width == width &&
+ c.height == height && c.rotation == rotation && c.useKey == useKey &&
+ c.visible == visible && c.animateEntrance == animateEntrance && c.z == z;
+ }
+
CardState createState() => new CardState();
}
diff --git a/lib/components/game.dart b/lib/components/game.dart
index 6752ab9..9bb71b0 100644
--- a/lib/components/game.dart
+++ b/lib/components/game.dart
@@ -96,6 +96,13 @@
setState(() {
cardLevelMap[logicCard] = new CardAnimationData(c, cad?.newPoint, p, z);
});
+ } else if (!cad.comp_card.isMatchWith(c)) {
+ // Even if the position or z index didn't change, we can still update the
+ // card itself. This can help during screen rotations, since the top-left
+ // card likely not change positions or z-index.
+ setState(() {
+ cad.comp_card = c;
+ });
}
}