Slight changes to cope with lag and unresponsiveness.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3535 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2005-05-03 01:49:10 +00:00
parent ae0547a0ff
commit 0793baaf22
@@ -172,32 +172,17 @@ public abstract class CardPanel extends VirtualMediaPanel
_selectedCardOffset = offset; _selectedCardOffset = offset;
} }
/**
* Sets the selection mode for the hand (NONE, PLAY_SINGLE, SELECT_SINGLE,
* or SELECT_MULTIPLE) and updates the hand sprite offsets. Changing the
* selection mode does not change the current selection.
*/
public void setHandSelectionMode (int mode)
{
setHandSelectionMode(mode, true);
}
/** /**
* Sets the selection mode for the hand (NONE, PLAY_SINGLE, SELECT_SINGLE, * Sets the selection mode for the hand (NONE, PLAY_SINGLE, SELECT_SINGLE,
* or SELECT_MULTIPLE). Changing the selection mode does not change the * or SELECT_MULTIPLE). Changing the selection mode does not change the
* current selection. * current selection.
*
* @param updateOffsets if true, immediately update the offsets of the
* cards in the hand
*/ */
public void setHandSelectionMode (int mode, boolean updateOffsets) public void setHandSelectionMode (int mode)
{ {
_handSelectionMode = mode; _handSelectionMode = mode;
// update the offsets of all cards in the hand // update the offsets of all cards in the hand
if (updateOffsets) { updateHandOffsets();
updateHandOffsets();
}
} }
/** /**
@@ -733,13 +718,11 @@ public abstract class CardPanel extends VirtualMediaPanel
} }
/** /**
* Removes a card from the hand, deselecting it if selected. * Removes a card from the hand.
*/ */
protected void removeFromHand (CardSprite card) protected void removeFromHand (CardSprite card)
{ {
if (_selectedHandSprites.contains(card)) { _selectedHandSprites.remove(card);
deselectHandSprite(card);
}
_handSprites.remove(card); _handSprites.remove(card);
} }
@@ -884,12 +867,12 @@ public abstract class CardPanel extends VirtualMediaPanel
protected void updateActiveCardSprite () protected void updateActiveCardSprite ()
{ {
// can't do anything if we don't know where the mouse pointer is // can't do anything if we don't know where the mouse pointer is
if (_mouseMotionEvent == null) { if (_mouseEvent == null) {
return; return;
} }
Sprite newHighestHit = _spritemgr.getHighestHitSprite( Sprite newHighestHit = _spritemgr.getHighestHitSprite(
_mouseMotionEvent.getX(), _mouseMotionEvent.getY()); _mouseEvent.getX(), _mouseEvent.getY());
CardSprite newActiveCardSprite = CardSprite newActiveCardSprite =
(newHighestHit instanceof CardSprite ? (newHighestHit instanceof CardSprite ?
@@ -900,24 +883,24 @@ public abstract class CardPanel extends VirtualMediaPanel
isManaged(_activeCardSprite)) { isManaged(_activeCardSprite)) {
_activeCardSprite.queueNotification( _activeCardSprite.queueNotification(
new CardSpriteExitedOp(_activeCardSprite, new CardSpriteExitedOp(_activeCardSprite,
_mouseMotionEvent) _mouseEvent)
); );
} }
_activeCardSprite = newActiveCardSprite; _activeCardSprite = newActiveCardSprite;
if (_activeCardSprite != null) { if (_activeCardSprite != null) {
_activeCardSprite.queueNotification( _activeCardSprite.queueNotification(
new CardSpriteEnteredOp(_activeCardSprite, new CardSpriteEnteredOp(_activeCardSprite,
_mouseMotionEvent) _mouseEvent)
); );
} }
} }
} }
/** The width of the playing cards. */ /** The width of the playing cards. */
protected int _cardWidth; protected int _cardWidth;
/** The last motion event received from the mouse. */ /** The last motion/entrance/exit event received from the mouse. */
protected MouseEvent _mouseMotionEvent; protected MouseEvent _mouseEvent;
/** The currently active card sprite (the one that the mouse is over). */ /** The currently active card sprite (the one that the mouse is over). */
protected CardSprite _activeCardSprite; protected CardSprite _activeCardSprite;
@@ -1050,14 +1033,14 @@ public abstract class CardPanel extends VirtualMediaPanel
public void mouseMoved (MouseEvent me) public void mouseMoved (MouseEvent me)
{ {
_mouseMotionEvent = me; _mouseEvent = me;
updateActiveCardSprite(); updateActiveCardSprite();
} }
public void mouseDragged (MouseEvent me) public void mouseDragged (MouseEvent me)
{ {
_mouseMotionEvent = me; _mouseEvent = me;
if (_activeCardSprite != null && if (_activeCardSprite != null &&
isManaged(_activeCardSprite) && isManaged(_activeCardSprite) &&
@@ -1073,6 +1056,16 @@ public abstract class CardPanel extends VirtualMediaPanel
} }
} }
public void mouseEntered (MouseEvent me)
{
_mouseEvent = me;
}
public void mouseExited (MouseEvent me)
{
_mouseEvent = me;
}
protected int _handleX, _handleY; protected int _handleX, _handleY;
protected boolean _hasBeenDragged; protected boolean _hasBeenDragged;
} }