diff --git a/src/java/com/threerings/parlor/card/client/ButtonSprite.java b/src/java/com/threerings/parlor/card/client/ButtonSprite.java index 8776589f4..071730b8c 100644 --- a/src/java/com/threerings/parlor/card/client/ButtonSprite.java +++ b/src/java/com/threerings/parlor/card/client/ButtonSprite.java @@ -1,5 +1,5 @@ // -// $Id: ButtonSprite.java,v 1.4 2004/11/09 03:24:50 andrzej Exp $ +// $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -276,52 +276,72 @@ public class ButtonSprite extends Sprite switch (_style) { case NORMAL: - gfx.setColor(_enabled ? _backgroundColor : _backgroundColor.darker()); + gfx.setColor(_enabled ? _backgroundColor : + _backgroundColor.darker()); gfx.fill3DRect(_bounds.x, _bounds.y, _bounds.width, _bounds.height, !_pressed); - _label.render(gfx, _bounds.x + (_pressed ? PADDING : PADDING - 1), - _bounds.y + (_pressed ? PADDING : PADDING - 1)); + _label.render(gfx, _bounds.x + (_pressed ? PADDING : + PADDING - 1), _bounds.y + (_pressed ? PADDING : + PADDING - 1)); break; case ROUNDED: Object aaState = SwingUtil.activateAntiAliasing(gfx); // draw outline gfx.setColor(_alternateColor); - gfx.fillRoundRect(_bounds.x, _bounds.y, _bounds.width, _bounds.height, - _arcWidth, _arcHeight); + gfx.fillRoundRect(_bounds.x, _bounds.y, _bounds.width, + _bounds.height, _arcWidth, _arcHeight); // draw foreground - gfx.setColor(_enabled ? _backgroundColor : _backgroundColor.darker()); + gfx.setColor(_enabled ? _backgroundColor : + _backgroundColor.darker()); int innerBoundsX = _bounds.x+1, innerBoundsY = _bounds.y+1, - innerBoundsWidth = _bounds.width-2, innerBoundsHeight = _bounds.height-2, - innerBoundsArcWidth = _arcWidth-2, innerBoundsArcHeight = _arcHeight-2; - gfx.fillRoundRect(innerBoundsX, innerBoundsY, innerBoundsWidth, innerBoundsHeight, + innerBoundsWidth = _bounds.width-2, + innerBoundsHeight = _bounds.height-2, + innerBoundsArcWidth = _arcWidth-2, + innerBoundsArcHeight = _arcHeight-2; + gfx.fillRoundRect(innerBoundsX, innerBoundsY, + innerBoundsWidth, innerBoundsHeight, innerBoundsArcWidth, innerBoundsArcHeight); - Color brighter = _enabled ? _backgroundColor.brighter() : _backgroundColor, - darker = _enabled ? _backgroundColor.darker() : _backgroundColor.darker().darker(); + Color brighter = _enabled ? _backgroundColor.brighter() : + _backgroundColor, darker = _enabled ? + _backgroundColor.darker() : + _backgroundColor.darker().darker(); // draw the upper left/lower right corners (always dark) gfx.setColor(darker); - gfx.drawArc(innerBoundsX, innerBoundsY, innerBoundsArcWidth, innerBoundsArcHeight, 90, 90); - gfx.drawArc(innerBoundsX + innerBoundsWidth - innerBoundsArcWidth - 1, - innerBoundsY + innerBoundsHeight - innerBoundsArcHeight - 1, + gfx.drawArc(innerBoundsX, innerBoundsY, innerBoundsArcWidth, + innerBoundsArcHeight, 90, 90); + gfx.drawArc(innerBoundsX + innerBoundsWidth - + innerBoundsArcWidth - 1, + innerBoundsY + innerBoundsHeight - + innerBoundsArcHeight - 1, innerBoundsArcWidth, innerBoundsArcHeight, 270, 90); // draw the upper right (dark when pressed) gfx.setColor(_pressed ? darker : brighter); - gfx.drawLine(innerBoundsX + innerBoundsArcWidth/2, innerBoundsY, - innerBoundsX + innerBoundsWidth - innerBoundsArcWidth/2, innerBoundsY); - gfx.drawArc(innerBoundsX + innerBoundsWidth - innerBoundsArcWidth - 1, innerBoundsY, + gfx.drawLine(innerBoundsX + innerBoundsArcWidth/2, + innerBoundsY, innerBoundsX + innerBoundsWidth - + innerBoundsArcWidth/2, innerBoundsY); + gfx.drawArc(innerBoundsX + innerBoundsWidth - + innerBoundsArcWidth - 1, innerBoundsY, innerBoundsArcWidth, innerBoundsArcHeight, 0, 90); - gfx.drawLine(innerBoundsX + innerBoundsWidth - 1, innerBoundsY + innerBoundsArcHeight/2, - innerBoundsX + innerBoundsWidth - 1, innerBoundsY + innerBoundsHeight - innerBoundsArcHeight/2); + gfx.drawLine(innerBoundsX + innerBoundsWidth - 1, + innerBoundsY + innerBoundsArcHeight/2, + innerBoundsX + innerBoundsWidth - 1, innerBoundsY + + innerBoundsHeight - innerBoundsArcHeight/2); // draw the lower left (light when pressed) gfx.setColor(_pressed ? brighter : darker); - gfx.drawLine(innerBoundsX, innerBoundsY + innerBoundsArcHeight/2, innerBoundsX, - innerBoundsY + innerBoundsHeight - innerBoundsArcHeight/2); - gfx.drawArc(innerBoundsX, innerBoundsY + innerBoundsHeight - innerBoundsArcHeight - 1, + gfx.drawLine(innerBoundsX, innerBoundsY + + innerBoundsArcHeight/2, innerBoundsX, + innerBoundsY + innerBoundsHeight - + innerBoundsArcHeight/2); + gfx.drawArc(innerBoundsX, innerBoundsY + innerBoundsHeight - + innerBoundsArcHeight - 1, innerBoundsArcWidth, innerBoundsArcHeight, 180, 90); - gfx.drawLine(innerBoundsX + innerBoundsArcWidth/2, innerBoundsY + innerBoundsHeight - 1, + gfx.drawLine(innerBoundsX + innerBoundsArcWidth/2, + innerBoundsY + innerBoundsHeight - 1, innerBoundsX + innerBoundsWidth - innerBoundsArcWidth/2, innerBoundsY + innerBoundsHeight - 1); SwingUtil.restoreAntiAliasing(gfx, aaState); - _label.render(gfx, _bounds.x + PADDING + _arcWidth/2 - (_pressed ? 2 : 1), + _label.render(gfx, _bounds.x + PADDING + _arcWidth/2 - + (_pressed ? 2 : 1), _bounds.y + PADDING + (_pressed ? 1 : 0)); break; } diff --git a/src/java/com/threerings/parlor/card/client/ButtonSpriteObserver.java b/src/java/com/threerings/parlor/card/client/ButtonSpriteObserver.java deleted file mode 100644 index 56cd44b10..000000000 --- a/src/java/com/threerings/parlor/card/client/ButtonSpriteObserver.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// $Id: ButtonSpriteObserver.java,v 1.1 2004/10/29 00:41:50 andrzej Exp $ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/narya/ -// -// This library is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.parlor.card.client; - -import com.samskivert.swing.event.CommandEvent; - -/** - * Observer interface for button sprites. - */ -public interface ButtonSpriteObserver -{ - /** - * Notifies the observer that the user clicked a button sprite. - * - * @param sprite the clicked sprite - * @param ce the command event associated with the click - */ - public void buttonSpriteClicked (ButtonSprite sprite, CommandEvent ce); -} diff --git a/src/java/com/threerings/parlor/card/client/CardPanel.java b/src/java/com/threerings/parlor/card/client/CardPanel.java index 6ba1c80bc..4cbdc7dce 100644 --- a/src/java/com/threerings/parlor/card/client/CardPanel.java +++ b/src/java/com/threerings/parlor/card/client/CardPanel.java @@ -1,5 +1,5 @@ // -// $Id: CardPanel.java,v 1.8 2004/11/04 02:03:47 andrzej Exp $ +// $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -55,7 +55,8 @@ public abstract class CardPanel extends VirtualMediaPanel implements CardCodes { /** Calls CardSpriteObserver.cardSpriteClicked. */ - protected static class CardSpriteClickedOp implements ObserverList.ObserverOp + protected static class CardSpriteClickedOp implements + ObserverList.ObserverOp { public CardSpriteClickedOp (CardSprite sprite, MouseEvent me) { @@ -65,7 +66,8 @@ public abstract class CardPanel extends VirtualMediaPanel public boolean apply (Object observer) { - ((CardSpriteObserver)observer).cardSpriteClicked(_sprite, _me); + ((CardSpriteObserver)observer).cardSpriteClicked(_sprite, + _me); return true; } @@ -74,7 +76,8 @@ public abstract class CardPanel extends VirtualMediaPanel } /** Calls CardSpriteObserver.cardSpriteEntered. */ - protected static class CardSpriteEnteredOp implements ObserverList.ObserverOp + protected static class CardSpriteEnteredOp implements + ObserverList.ObserverOp { public CardSpriteEnteredOp (CardSprite sprite, MouseEvent me) { @@ -93,7 +96,8 @@ public abstract class CardPanel extends VirtualMediaPanel } /** Calls CardSpriteObserver.cardSpriteExited. */ - protected static class CardSpriteExitedOp implements ObserverList.ObserverOp + protected static class CardSpriteExitedOp implements + ObserverList.ObserverOp { public CardSpriteExitedOp (CardSprite sprite, MouseEvent me) { @@ -112,7 +116,8 @@ public abstract class CardPanel extends VirtualMediaPanel } /** Calls CardSpriteObserver.cardSpriteDragged. */ - protected static class CardSpriteDraggedOp implements ObserverList.ObserverOp + protected static class CardSpriteDraggedOp implements + ObserverList.ObserverOp { public CardSpriteDraggedOp (CardSprite sprite, MouseEvent me) { @@ -130,25 +135,6 @@ public abstract class CardPanel extends VirtualMediaPanel protected MouseEvent _me; } - /** Calls ButtonSpriteObserver.buttonSpriteClicked. */ - protected static class ButtonSpriteClickedOp implements ObserverList.ObserverOp - { - public ButtonSpriteClickedOp (ButtonSprite sprite, CommandEvent ce) - { - _sprite = sprite; - _ce = ce; - } - - public boolean apply (Object observer) - { - ((ButtonSpriteObserver)observer).buttonSpriteClicked(_sprite, _ce); - return true; - } - - protected ButtonSprite _sprite; - protected CommandEvent _ce; - } - /** * Constructor. * @@ -177,17 +163,17 @@ public abstract class CardPanel extends VirtualMediaPanel public void mouseReleased (MouseEvent me) { if (_activeSprite != null && !isManaged(_activeSprite)) { _activeSprite = null; - } else if (_activeSprite instanceof CardSprite && _hasBeenDragged) { + } else if (_activeSprite instanceof CardSprite && + _hasBeenDragged) { _activeSprite.queueNotification( new CardSpriteDraggedOp((CardSprite)_activeSprite, me) ); } else if (_activeSprite instanceof ButtonSprite) { ButtonSprite bs = (ButtonSprite)_activeSprite; if (bs.isPressed()) { - CommandEvent ce = new CommandEvent(CardPanel.this, bs.getActionCommand(), - bs.getCommandArgument(), me.getWhen(), me.getModifiers()); - bs.queueNotification( - new ButtonSpriteClickedOp(bs, ce)); + CommandEvent ce = new CommandEvent(CardPanel.this, + bs.getActionCommand(), bs.getCommandArgument(), + me.getWhen(), me.getModifiers()); Controller.postAction(ce); bs.setPressed(false); } @@ -236,7 +222,8 @@ public abstract class CardPanel extends VirtualMediaPanel if (_activeSprite instanceof CardSprite && isManaged(_activeSprite)) { _activeSprite.queueNotification( - new CardSpriteExitedOp((CardSprite)_activeSprite, me) + new CardSpriteExitedOp((CardSprite)_activeSprite, + me) ); } else if (_activeSprite instanceof ButtonSprite && isManaged(_activeSprite)) { @@ -244,7 +231,8 @@ public abstract class CardPanel extends VirtualMediaPanel } if (newActiveSprite instanceof CardSprite) { newActiveSprite.queueNotification( - new CardSpriteEnteredOp((CardSprite)newActiveSprite, me) + new CardSpriteEnteredOp( + (CardSprite)newActiveSprite, me) ); } _activeSprite = newActiveSprite; diff --git a/src/java/com/threerings/parlor/card/client/CardSprite.java b/src/java/com/threerings/parlor/card/client/CardSprite.java index a7d1b0ce0..301e80d79 100644 --- a/src/java/com/threerings/parlor/card/client/CardSprite.java +++ b/src/java/com/threerings/parlor/card/client/CardSprite.java @@ -1,5 +1,5 @@ // -// $Id: CardSprite.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ +// $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -132,10 +132,10 @@ public class CardSprite extends OrientableImageSprite */ private void updateMirage () { - setMirage(_facingUp ? _panel.getCardImage(_card) : _panel.getCardBackImage()); + setMirage(_facingUp ? _panel.getCardImage(_card) : + _panel.getCardBackImage()); } - /** The panel responsible for the sprite. */ protected CardPanel _panel; diff --git a/src/java/com/threerings/parlor/card/data/Card.java b/src/java/com/threerings/parlor/card/data/Card.java index aa8c8f789..f831e110f 100644 --- a/src/java/com/threerings/parlor/card/data/Card.java +++ b/src/java/com/threerings/parlor/card/data/Card.java @@ -1,5 +1,5 @@ // -// $Id: Card.java,v 1.7 2004/11/01 22:10:21 andrzej Exp $ +// $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -108,8 +108,8 @@ public class Card implements DSet.Entry, Comparable, CardCodes } /** - * Checks whether or not this card is valid. The no-arg public constructor - * for deserialization creates an invalid card. + * Checks whether or not this card is valid. The no-arg public + * constructor for deserialization creates an invalid card. * * @return true if this card is valid, false if not */ diff --git a/src/java/com/threerings/parlor/card/data/Deck.java b/src/java/com/threerings/parlor/card/data/Deck.java index a93b503fd..351533b66 100644 --- a/src/java/com/threerings/parlor/card/data/Deck.java +++ b/src/java/com/threerings/parlor/card/data/Deck.java @@ -1,5 +1,5 @@ // -// $Id: Deck.java,v 1.6 2004/11/01 22:10:21 andrzej Exp $ +// $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -107,9 +107,9 @@ public class Deck implements CardCodes, else { Hand hand = new Hand(); + int cardsLeft = cards.size(); for (int i=0;i