From 96133e45e9a441f967991c6600fe096ef2c92592 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 14 Apr 2005 22:54:28 +0000 Subject: [PATCH] Keep track of active card sprite, making sure it keeps being shown as selectable between selection mode switches. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3487 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../parlor/card/client/CardPanel.java | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/java/com/threerings/parlor/card/client/CardPanel.java b/src/java/com/threerings/parlor/card/client/CardPanel.java index 4b3bf38d0..80d745395 100644 --- a/src/java/com/threerings/parlor/card/client/CardPanel.java +++ b/src/java/com/threerings/parlor/card/client/CardPanel.java @@ -723,7 +723,7 @@ public abstract class CardPanel extends VirtualMediaPanel int size = _handSprites.size(); for (int i = 0; i < size; i++) { CardSprite cs = (CardSprite)_handSprites.get(i); - cs.setLocation(cs.getX(), getHandY(cs, false, true)); + cs.setLocation(cs.getX(), getHandY(cs)); } } @@ -744,22 +744,16 @@ public abstract class CardPanel extends VirtualMediaPanel } /** - * Determines the y location of the specified card, given its selection - * state. - * - * @param mouseOver whether or not the mouse cursor is currently on the - * card - * @param raiseOnlySelectable whether or not to raise the only selectable - * card automatically + * Determines the y location of the specified card sprite, given its + * selection state. */ - protected int getHandY (CardSprite card, boolean mouseOver, - boolean raiseOnlySelectable) + protected int getHandY (CardSprite sprite) { - if (_selectedHandSprites.contains(card)) { + if (_selectedHandSprites.contains(sprite)) { return _handLocation.y - _selectedCardOffset; - } else if (isSelectable(card) && - (mouseOver || (raiseOnlySelectable && isOnlySelectable(card)))) { + } else if (isSelectable(sprite) && + (sprite == _activeCardSprite || isOnlySelectable(sprite))) { return _handLocation.y - _selectableCardOffset; } else { @@ -845,6 +839,9 @@ public abstract class CardPanel extends VirtualMediaPanel /** The width of the playing cards. */ protected int _cardWidth; + /** The currently active card sprite (the one that the mouse is over). */ + protected CardSprite _activeCardSprite; + /** The sprites for cards within the hand. */ protected ArrayList _handSprites = new ArrayList(); @@ -906,16 +903,14 @@ public abstract class CardPanel extends VirtualMediaPanel public void cardSpriteEntered (CardSprite sprite, MouseEvent me) { // update the offset if (_handSprites.contains(sprite)) { - sprite.setLocation(sprite.getX(), getHandY(sprite, true, - true)); + sprite.setLocation(sprite.getX(), getHandY(sprite)); } } public void cardSpriteExited (CardSprite sprite, MouseEvent me) { // update the offset if (_handSprites.contains(sprite)) { - sprite.setLocation(sprite.getX(), getHandY(sprite, false, - true)); + sprite.setLocation(sprite.getX(), getHandY(sprite)); } } @@ -998,7 +993,6 @@ public abstract class CardPanel extends VirtualMediaPanel } } - protected CardSprite _activeCardSprite; protected int _handleX, _handleY; protected boolean _hasBeenDragged; }