Allow "draw" text to be provided as well. Also nixed the green because it was

really ugly...


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@75 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2006-09-25 04:06:35 +00:00
parent 6611e60c1c
commit b0d148f107
@@ -96,6 +96,15 @@ public class TurnDisplay extends JPanel
_winnerText = winnerText; _winnerText = winnerText;
} }
/**
* Sets the text to be displayed next to everyone's name in the event of a
* draw.
*/
public void setDrawText (String drawText)
{
_drawText = drawText;
}
/** /**
* Set optional icons to use for identifying each player in the game. * Set optional icons to use for identifying each player in the game.
*/ */
@@ -126,7 +135,8 @@ public class TurnDisplay extends JPanel
labelC.gridwidth = GridBagConstraints.REMAINDER; labelC.gridwidth = GridBagConstraints.REMAINDER;
Name[] names = _turnObj.getPlayers(); Name[] names = _turnObj.getPlayers();
boolean[] winners = ((GameObject) _turnObj).winners; GameObject gameobj = (GameObject)_turnObj;
boolean[] winners = gameobj.winners;
Name holder = _turnObj.getTurnHolder(); Name holder = _turnObj.getTurnHolder();
for (int ii=0, jj=0; ii < names.length; ii++, jj++) { for (int ii=0, jj=0; ii < names.length; ii++, jj++) {
if (names[ii] == null) continue; if (names[ii] == null) continue;
@@ -136,10 +146,12 @@ public class TurnDisplay extends JPanel
if (names[ii].equals(holder)) { if (names[ii].equals(holder)) {
iconLabel.setIcon(_turnIcon); iconLabel.setIcon(_turnIcon);
} }
} else if (gameobj.isDraw()) {
iconLabel.setText(_drawText);
} else if (winners[ii]) { } else if (winners[ii]) {
iconLabel.setText(_winnerText); iconLabel.setText(_winnerText);
iconLabel.setForeground(Color.GREEN);
} }
iconLabel.setForeground(Color.BLACK);
_labels.put(names[ii], iconLabel); _labels.put(names[ii], iconLabel);
add(iconLabel, iconC); add(iconLabel, iconC);
@@ -210,7 +222,10 @@ public class TurnDisplay extends JPanel
protected Icon[] _playerIcons; protected Icon[] _playerIcons;
/** The text to display next to a winner's name. */ /** The text to display next to a winner's name. */
protected String _winnerText; protected String _winnerText = "";
/** The text to display next to a drawing player's name. */
protected String _drawText = "";
/** The Icon we use for indicating the turn. */ /** The Icon we use for indicating the turn. */
protected Icon _turnIcon; protected Icon _turnIcon;