Pulled our update code out into functions and then call all of them when
we enter the game room so that everything starts out in the proper configuration even if we show up halfway through a game. git-svn-id: https://samskivert.googlecode.com/svn/trunk@380 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TurnIndicatorView.java,v 1.1 2001/10/16 01:41:55 mdb Exp $
|
// $Id: TurnIndicatorView.java,v 1.2 2001/10/18 20:55:05 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -49,6 +49,12 @@ public class TurnIndicatorView
|
|||||||
// ourselves as an attribute change listener
|
// ourselves as an attribute change listener
|
||||||
_venobj = (VenisonObject)plobj;
|
_venobj = (VenisonObject)plobj;
|
||||||
_venobj.addListener(this);
|
_venobj.addListener(this);
|
||||||
|
|
||||||
|
// update our displays
|
||||||
|
updateCurrentTile();
|
||||||
|
updateGameState();
|
||||||
|
updateTurnHolder();
|
||||||
|
updateRemainingTiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -62,12 +68,27 @@ public class TurnIndicatorView
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void attributeChanged (AttributeChangedEvent event)
|
public void attributeChanged (AttributeChangedEvent event)
|
||||||
{
|
{
|
||||||
// we care about the current tile display
|
|
||||||
if (event.getName().equals(VenisonObject.CURRENT_TILE)) {
|
if (event.getName().equals(VenisonObject.CURRENT_TILE)) {
|
||||||
// display the tile to be placed
|
// update the current tile display
|
||||||
_tileLabel.setTile(_venobj.currentTile);
|
updateCurrentTile();
|
||||||
|
|
||||||
} else if (event.getName().equals(VenisonObject.STATE)) {
|
} else if (event.getName().equals(VenisonObject.STATE)) {
|
||||||
|
// update the game state display
|
||||||
|
updateGameState();
|
||||||
|
// update the tiles remaining
|
||||||
|
updateRemainingTiles();
|
||||||
|
|
||||||
|
} else if (event.getName().equals(VenisonObject.TURN_HOLDER)) {
|
||||||
|
// update the turn holder
|
||||||
|
updateTurnHolder();
|
||||||
|
|
||||||
|
// update the tiles remaining when the turn changes
|
||||||
|
updateRemainingTiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateGameState ()
|
||||||
|
{
|
||||||
switch (_venobj.state) {
|
switch (_venobj.state) {
|
||||||
case VenisonObject.AWAITING_PLAYERS:
|
case VenisonObject.AWAITING_PLAYERS:
|
||||||
_whoLabel.setText("Awaiting players...");
|
_whoLabel.setText("Awaiting players...");
|
||||||
@@ -82,18 +103,19 @@ public class TurnIndicatorView
|
|||||||
_tileLabel.setTile(null);
|
_tileLabel.setTile(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update the tiles remaining
|
protected void updateTurnHolder ()
|
||||||
updateRemainingTiles();
|
{
|
||||||
|
|
||||||
} else if (event.getName().equals(VenisonObject.TURN_HOLDER)) {
|
|
||||||
if (_venobj.state == VenisonObject.IN_PLAY) {
|
if (_venobj.state == VenisonObject.IN_PLAY) {
|
||||||
_whoLabel.setText(_venobj.turnHolder);
|
_whoLabel.setText(_venobj.turnHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the tiles remaining when the turn changes
|
|
||||||
updateRemainingTiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateCurrentTile ()
|
||||||
|
{
|
||||||
|
// display the tile to be placed
|
||||||
|
_tileLabel.setTile(_venobj.currentTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateRemainingTiles ()
|
protected void updateRemainingTiles ()
|
||||||
|
|||||||
Reference in New Issue
Block a user