Various changes for style, changes to Card recommended by Ray.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3136 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2004-10-15 00:14:23 +00:00
parent 9bbd46fa7b
commit 73f44a5ee3
14 changed files with 212 additions and 255 deletions
@@ -1,5 +1,5 @@
//
// $Id: CardGameController.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $
// $Id: CardGameController.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -44,7 +44,7 @@ public abstract class CardGameController extends GameController
CardCodes
{
// Documentation inhertied
public void init(CrowdContext context, PlaceConfig config)
public void init (CrowdContext context, PlaceConfig config)
{
super.init(context, config);
@@ -52,7 +52,7 @@ public abstract class CardGameController extends GameController
}
// Documentation inherited
public void messageReceived(MessageEvent event)
public void messageReceived (MessageEvent event)
{
if(event.getName().equals(TAKE_HAND))
{
@@ -65,6 +65,6 @@ public abstract class CardGameController extends GameController
*
* @param hand the hand dealt to the user
*/
protected void handDealt(Hand hand)
protected void handDealt (Hand hand)
{}
}
@@ -1,5 +1,5 @@
//
// $Id: CardPanel.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $
// $Id: CardPanel.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -52,18 +52,18 @@ public abstract class CardPanel extends VirtualMediaPanel
/** Calls CardSpriteObserver.cardSpriteClicked. */
protected static class CardSpriteClickedOp implements ObserverList.ObserverOp
{
protected CardSprite sprite;
protected MouseEvent me;
protected CardSprite _sprite;
protected MouseEvent _me;
public CardSpriteClickedOp(CardSprite sprite, MouseEvent me)
public CardSpriteClickedOp (CardSprite sprite, MouseEvent me)
{
this.sprite = sprite;
this.me = me;
_sprite = sprite;
_me = me;
}
public boolean apply(Object observer)
public boolean apply (Object observer)
{
((CardSpriteObserver)observer).cardSpriteClicked(sprite, me);
((CardSpriteObserver)observer).cardSpriteClicked(_sprite, _me);
return true;
}
}
@@ -71,18 +71,18 @@ public abstract class CardPanel extends VirtualMediaPanel
/** Calls CardSpriteObserver.cardSpriteDragged. */
protected static class CardSpriteDraggedOp implements ObserverList.ObserverOp
{
protected CardSprite sprite;
protected MouseEvent me;
protected CardSprite _sprite;
protected MouseEvent _me;
public CardSpriteDraggedOp(CardSprite sprite, MouseEvent me)
public CardSpriteDraggedOp (CardSprite sprite, MouseEvent me)
{
this.sprite = sprite;
this.me = me;
_sprite = sprite;
_me = me;
}
public boolean apply(Object observer)
public boolean apply (Object observer)
{
((CardSpriteObserver)observer).cardSpriteDragged(sprite, me);
((CardSpriteObserver)observer).cardSpriteDragged(_sprite, _me);
return true;
}
}
@@ -93,14 +93,14 @@ public abstract class CardPanel extends VirtualMediaPanel
*
* @param frameManager the frame manager
*/
public CardPanel(FrameManager frameManager)
public CardPanel (FrameManager frameManager)
{
super(frameManager);
addMouseListener(
new MouseAdapter()
{
public void mousePressed(MouseEvent me)
public void mousePressed (MouseEvent me)
{
ArrayList al = new ArrayList();
@@ -128,38 +128,38 @@ public abstract class CardPanel extends VirtualMediaPanel
}
}
activeCardSprite = highestSprite;
_activeCardSprite = highestSprite;
if(activeCardSprite != null)
if(_activeCardSprite != null)
{
handleX = activeCardSprite.getX() - me.getX();
handleY = activeCardSprite.getY() - me.getY();
_handleX = _activeCardSprite.getX() - me.getX();
_handleY = _activeCardSprite.getY() - me.getY();
hasBeenDragged = false;
_hasBeenDragged = false;
}
}
else
{
activeCardSprite = null;
_activeCardSprite = null;
}
}
public void mouseReleased(MouseEvent me)
public void mouseReleased (MouseEvent me)
{
if(activeCardSprite != null && hasBeenDragged)
if(_activeCardSprite != null && _hasBeenDragged)
{
activeCardSprite.queueNotification(
new CardSpriteDraggedOp(activeCardSprite, me)
_activeCardSprite.queueNotification(
new CardSpriteDraggedOp(_activeCardSprite, me)
);
}
}
public void mouseClicked(MouseEvent me)
public void mouseClicked (MouseEvent me)
{
if(activeCardSprite != null)
if(_activeCardSprite != null)
{
activeCardSprite.queueNotification(
new CardSpriteClickedOp(activeCardSprite, me)
_activeCardSprite.queueNotification(
new CardSpriteClickedOp(_activeCardSprite, me)
);
}
}
@@ -169,17 +169,17 @@ public abstract class CardPanel extends VirtualMediaPanel
addMouseMotionListener(
new MouseMotionAdapter()
{
public void mouseDragged(MouseEvent me)
public void mouseDragged (MouseEvent me)
{
if(activeCardSprite != null &&
activeCardSprite.isDraggable())
if(_activeCardSprite != null &&
_activeCardSprite.isDraggable())
{
activeCardSprite.setLocation(
me.getX() + handleX,
me.getY() + handleY
_activeCardSprite.setLocation(
me.getX() + _handleX,
me.getY() + _handleY
);
hasBeenDragged = true;
_hasBeenDragged = true;
}
}
}
@@ -191,7 +191,7 @@ public abstract class CardPanel extends VirtualMediaPanel
*
* @return the card back image
*/
public abstract Mirage getCardBackImage();
public abstract Mirage getCardBackImage ();
/**
* Returns the image for the front of the specified card.
@@ -199,15 +199,15 @@ public abstract class CardPanel extends VirtualMediaPanel
* @param card the desired card
* @return the card front image
*/
public abstract Mirage getCardImage(Card card);
public abstract Mirage getCardImage (Card card);
/** The last card sprite pressed. */
private CardSprite activeCardSprite;
protected CardSprite _activeCardSprite;
/** The location of the cursor in the active sprite. */
private int handleX, handleY;
protected int _handleX, _handleY;
/** Whether or not the active sprite has been dragged. */
private boolean hasBeenDragged;
protected boolean _hasBeenDragged;
}
@@ -1,5 +1,5 @@
//
// $Id: CardSprite.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $
// $Id: CardSprite.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -32,26 +32,13 @@ import com.threerings.parlor.card.data.Card;
*/
public class CardSprite extends OrientableImageSprite
{
/** The panel responsible for the sprite. */
protected CardPanel _panel;
/** The depicted card. */
protected Card _card;
/** Whether or not the card is facing up. */
protected boolean _facingUp;
/** Whether or not the user can drag the card around the board. */
protected boolean _draggable;
/**
* Creates a new upward-facing card sprite.
*
* @param panel the panel responsible for the sprite
* @param card the card to depict
*/
public CardSprite(CardPanel panel, Card card)
public CardSprite (CardPanel panel, Card card)
{
_panel = panel;
_card = card;
@@ -67,7 +54,7 @@ public class CardSprite extends OrientableImageSprite
* @param card the card to depict
* @param facingUp whether or not the card should be facing up
*/
public CardSprite(CardPanel panel, Card card, boolean facingUp)
public CardSprite (CardPanel panel, Card card, boolean facingUp)
{
_panel = panel;
_card = card;
@@ -81,7 +68,7 @@ public class CardSprite extends OrientableImageSprite
*
* @param card the new card
*/
public void setCard(Card card)
public void setCard (Card card)
{
_card = card;
@@ -93,7 +80,7 @@ public class CardSprite extends OrientableImageSprite
*
* @return the current card
*/
public Card getCard()
public Card getCard ()
{
return _card;
}
@@ -103,7 +90,7 @@ public class CardSprite extends OrientableImageSprite
*
* @param facingUp whether or not the card should be facing up
*/
public void setFacingUp(boolean facingUp)
public void setFacingUp (boolean facingUp)
{
_facingUp = facingUp;
@@ -115,7 +102,7 @@ public class CardSprite extends OrientableImageSprite
*
* @return true if the card is facing up, false if facing down
*/
public boolean isFacingUp()
public boolean isFacingUp ()
{
return _facingUp;
}
@@ -125,7 +112,7 @@ public class CardSprite extends OrientableImageSprite
*
* @param draggable whether or not the user can drag the card
*/
public void setDraggable(boolean draggable)
public void setDraggable (boolean draggable)
{
_draggable = draggable;
}
@@ -135,7 +122,7 @@ public class CardSprite extends OrientableImageSprite
*
* @return true if the user can drag the card, false if not
*/
public boolean isDraggable()
public boolean isDraggable ()
{
return _draggable;
}
@@ -143,8 +130,21 @@ public class CardSprite extends OrientableImageSprite
/**
* Updates the mirage according to the current state.
*/
private void updateMirage()
private void updateMirage ()
{
setMirage(_facingUp ? _panel.getCardImage(_card) : _panel.getCardBackImage());
}
/** The panel responsible for the sprite. */
protected CardPanel _panel;
/** The depicted card. */
protected Card _card;
/** Whether or not the card is facing up. */
protected boolean _facingUp;
/** Whether or not the user can drag the card around the board. */
protected boolean _draggable;
}
@@ -1,5 +1,5 @@
//
// $Id: CardSpriteObserver.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $
// $Id: CardSpriteObserver.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -21,7 +21,7 @@
package com.threerings.parlor.card.client;
import java.awt.event.*;
import java.awt.event.MouseEvent;
/**
* Observer interface for (draggable) card sprites.
@@ -34,7 +34,7 @@ public interface CardSpriteObserver
* @param sprite the dragged sprite
* @param me the mouse event associated with the drag
*/
public void cardSpriteClicked(CardSprite sprite, MouseEvent me);
public void cardSpriteClicked (CardSprite sprite, MouseEvent me);
/**
* Notifies the observer that the user dragged a card sprite to a new
@@ -43,5 +43,5 @@ public interface CardSpriteObserver
* @param sprite the dragged sprite
* @param me the mouse event associated with the drag
*/
public void cardSpriteDragged(CardSprite sprite, MouseEvent me);
public void cardSpriteDragged (CardSprite sprite, MouseEvent me);
}