Fixed bug in raising only selectable card.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3466 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -695,7 +695,7 @@ public abstract class CardPanel extends VirtualMediaPanel
|
|||||||
addSprite(cs);
|
addSprite(cs);
|
||||||
}
|
}
|
||||||
LinePath adjust = new LinePath(new Point(getHandX(size, i),
|
LinePath adjust = new LinePath(new Point(getHandX(size, i),
|
||||||
getHandY(cs, false)), adjustDuration);
|
getHandY(cs, false, false)), adjustDuration);
|
||||||
cs.move(adjust);
|
cs.move(adjust);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -720,7 +720,7 @@ public abstract class CardPanel extends VirtualMediaPanel
|
|||||||
int size = _handSprites.size();
|
int size = _handSprites.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
CardSprite cs = (CardSprite)_handSprites.get(i);
|
CardSprite cs = (CardSprite)_handSprites.get(i);
|
||||||
cs.setLocation(cs.getX(), getHandY(cs, false));
|
cs.setLocation(cs.getX(), getHandY(cs, false, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,14 +746,17 @@ public abstract class CardPanel extends VirtualMediaPanel
|
|||||||
*
|
*
|
||||||
* @param mouseOver whether or not the mouse cursor is currently on the
|
* @param mouseOver whether or not the mouse cursor is currently on the
|
||||||
* card
|
* card
|
||||||
|
* @param raiseOnlySelectable whether or not to raise the only selectable
|
||||||
|
* card automatically
|
||||||
*/
|
*/
|
||||||
protected int getHandY (CardSprite card, boolean mouseOver)
|
protected int getHandY (CardSprite card, boolean mouseOver,
|
||||||
|
boolean raiseOnlySelectable)
|
||||||
{
|
{
|
||||||
if (_selectedHandSprites.contains(card)) {
|
if (_selectedHandSprites.contains(card)) {
|
||||||
return _handLocation.y - _selectedCardOffset;
|
return _handLocation.y - _selectedCardOffset;
|
||||||
|
|
||||||
} else if (isSelectable(card) && (mouseOver ||
|
} else if (isSelectable(card) &&
|
||||||
getSelectableCount() == 1)) {
|
(mouseOver || (raiseOnlySelectable && isOnlySelectable(card)))) {
|
||||||
return _handLocation.y - _selectableCardOffset;
|
return _handLocation.y - _selectableCardOffset;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -761,30 +764,33 @@ public abstract class CardPanel extends VirtualMediaPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of sprites in the hand that are selectable.
|
|
||||||
*/
|
|
||||||
protected int getSelectableCount ()
|
|
||||||
{
|
|
||||||
int size = _handSprites.size(), count = 0;
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (isSelectable((CardSprite)_handSprites.get(i))) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given the current selection mode and predicate, determines if the
|
* Given the current selection mode and predicate, determines if the
|
||||||
* specified sprite is selectable.
|
* specified sprite is selectable.
|
||||||
*/
|
*/
|
||||||
protected boolean isSelectable (CardSprite sprite) {
|
protected boolean isSelectable (CardSprite sprite)
|
||||||
|
{
|
||||||
return _handSelectionMode != NONE &&
|
return _handSelectionMode != NONE &&
|
||||||
(_handSelectionPredicate == null ||
|
(_handSelectionPredicate == null ||
|
||||||
_handSelectionPredicate.evaluate(sprite));
|
_handSelectionPredicate.evaluate(sprite));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the specified sprite is the only selectable sprite
|
||||||
|
* in the hand.
|
||||||
|
*/
|
||||||
|
protected boolean isOnlySelectable (CardSprite sprite)
|
||||||
|
{
|
||||||
|
int size = _handSprites.size();
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
CardSprite cs = (CardSprite)_handSprites.get(i);
|
||||||
|
if (cs != sprite && isSelectable(cs)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lowers all board sprites so that they are rendered at or below the
|
* Lowers all board sprites so that they are rendered at or below the
|
||||||
* specified layer.
|
* specified layer.
|
||||||
@@ -841,10 +847,7 @@ public abstract class CardPanel extends VirtualMediaPanel
|
|||||||
|
|
||||||
/** The sprites for cards within the hand that have been selected. */
|
/** The sprites for cards within the hand that have been selected. */
|
||||||
protected ArrayList _selectedHandSprites = new ArrayList();
|
protected ArrayList _selectedHandSprites = new ArrayList();
|
||||||
|
|
||||||
/** The sprites for cards within the hand that are selectable. */
|
|
||||||
protected ArrayList _selectableHandSprites = new ArrayList();
|
|
||||||
|
|
||||||
/** The current selection mode for the hand. */
|
/** The current selection mode for the hand. */
|
||||||
protected int _handSelectionMode;
|
protected int _handSelectionMode;
|
||||||
|
|
||||||
@@ -899,14 +902,16 @@ public abstract class CardPanel extends VirtualMediaPanel
|
|||||||
public void cardSpriteEntered (CardSprite sprite, MouseEvent me) {
|
public void cardSpriteEntered (CardSprite sprite, MouseEvent me) {
|
||||||
// update the offset
|
// update the offset
|
||||||
if (_handSprites.contains(sprite)) {
|
if (_handSprites.contains(sprite)) {
|
||||||
sprite.setLocation(sprite.getX(), getHandY(sprite, true));
|
sprite.setLocation(sprite.getX(), getHandY(sprite, true,
|
||||||
|
true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cardSpriteExited (CardSprite sprite, MouseEvent me) {
|
public void cardSpriteExited (CardSprite sprite, MouseEvent me) {
|
||||||
// update the offset
|
// update the offset
|
||||||
if (_handSprites.contains(sprite)) {
|
if (_handSprites.contains(sprite)) {
|
||||||
sprite.setLocation(sprite.getX(), getHandY(sprite, false));
|
sprite.setLocation(sprite.getX(), getHandY(sprite, false,
|
||||||
|
true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user