pause panel and start turn panel now show player color

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@489 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Bennet Gerlach 2011-06-19 19:31:55 +02:00
parent 4231fad826
commit b875e44530
3 changed files with 56 additions and 52 deletions

View file

@ -1,5 +1,6 @@
package jrummikub.view.impl; package jrummikub.view.impl;
import java.awt.Color;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -40,9 +41,7 @@ class PausePanel extends JPanel {
pauseLabel = new JLabel(); pauseLabel = new JLabel();
pauseLabel.setHorizontalAlignment(JLabel.CENTER); pauseLabel.setHorizontalAlignment(JLabel.CENTER);
pauseLabel.setHorizontalTextPosition(JLabel.CENTER);
pauseLabel.setVerticalAlignment(JLabel.CENTER); pauseLabel.setVerticalAlignment(JLabel.CENTER);
pauseLabel.setVerticalTextPosition(JLabel.CENTER);
pauseLabel.putClientProperty("html.disable", Boolean.TRUE); pauseLabel.putClientProperty("html.disable", Boolean.TRUE);
add(pauseLabel); add(pauseLabel);
@ -64,7 +63,11 @@ class PausePanel extends JPanel {
} }
void setCurrentPlayerName(String playerName) { void setCurrentPlayerName(String playerName) {
pauseLabel.setText("Der Zug von " + playerName + " ist pausiert."); pauseLabel.setText(playerName + "'s Zug ist pausiert.");
}
void setCurrentPlayerColor(Color color) {
pauseLabel.setIcon(ImageUtil.createColorIcon(color, 12, 1));
} }
IEvent getEndPauseEvent() { IEvent getEndPauseEvent() {

View file

@ -1,5 +1,6 @@
package jrummikub.view.impl; package jrummikub.view.impl;
import java.awt.Color;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -44,9 +45,7 @@ class StartTurnPanel extends JPanel {
startTurnLabel = new JLabel(); startTurnLabel = new JLabel();
startTurnLabel.setHorizontalAlignment(JLabel.CENTER); startTurnLabel.setHorizontalAlignment(JLabel.CENTER);
startTurnLabel.setHorizontalTextPosition(JLabel.CENTER);
startTurnLabel.setVerticalAlignment(JLabel.CENTER); startTurnLabel.setVerticalAlignment(JLabel.CENTER);
startTurnLabel.setVerticalTextPosition(JLabel.CENTER);
startTurnLabel.putClientProperty("html.disable", Boolean.TRUE); startTurnLabel.putClientProperty("html.disable", Boolean.TRUE);
add(startTurnLabel); add(startTurnLabel);
@ -71,6 +70,10 @@ class StartTurnPanel extends JPanel {
startTurnLabel.setText(playerName + " ist jetzt an der Reihe."); startTurnLabel.setText(playerName + " ist jetzt an der Reihe.");
} }
void setCurrentPlayerColor(Color color) {
startTurnLabel.setIcon(ImageUtil.createColorIcon(color, 12, 1));
}
void setInitialMeldError(int points) { void setInitialMeldError(int points) {
startTurnLabel.setText("Es wurden weniger als " + points startTurnLabel.setText("Es wurden weniger als " + points
+ " Punkte ausgelegt."); + " Punkte ausgelegt.");
@ -117,16 +120,15 @@ class StartTurnPanel extends JPanel {
} }
switch (type) { switch (type) {
case START_TURN_PANEL: case START_TURN_PANEL:
startTurnButton.setText("Zug beginnen"); startTurnButton.setText("Zug beginnen");
buttonEvent = startTurnEvent; buttonEvent = startTurnEvent;
break; break;
case INVALID_TURN_PANEL: case INVALID_TURN_PANEL:
startTurnLabel startTurnLabel.setText("Es liegen ung\u00FCltige Serien auf dem Tisch.");
.setText("Es liegen ung\u00FCltige Serien auf dem Tisch."); startTurnButton.setText("N\u00E4chster Spieler");
startTurnButton.setText("N\u00E4chster Spieler"); buttonEvent = acknowledgeInvalidEvent;
buttonEvent = acknowledgeInvalidEvent; break;
break;
} }
} }

View file

@ -102,12 +102,12 @@ public class View extends JFrame implements IView {
public ITablePanel getTablePanel() { public ITablePanel getTablePanel() {
return table; return table;
} }
@Override @Override
public ISidePanel getSidePanel() { public ISidePanel getSidePanel() {
return sidePanel; return sidePanel;
} }
@Override @Override
public IHandPanel getHandPanel() { public IHandPanel getHandPanel() {
return playerPanel.getHandPanel(); return playerPanel.getHandPanel();
@ -164,8 +164,7 @@ public class View extends JFrame implements IView {
showSettingsPanel(false); showSettingsPanel(false);
showLoginPanel(false); showLoginPanel(false);
showGameListPanel(false); showGameListPanel(false);
getHandPanel().setStones( getHandPanel().setStones(Collections.<Pair<Stone, Position>> emptyList());
Collections.<Pair<Stone, Position>> emptyList());
getTablePanel().setStoneSets( getTablePanel().setStoneSets(
Collections.<Pair<StoneSet, Position>> emptyList()); Collections.<Pair<StoneSet, Position>> emptyList());
setSelectedStones(Collections.<Stone> emptyList()); setSelectedStones(Collections.<Stone> emptyList());
@ -330,8 +329,7 @@ public class View extends JFrame implements IView {
table = new TablePanel(); table = new TablePanel();
mainLayer.add(table); mainLayer.add(table);
table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, Color.BLACK));
Color.BLACK));
playerPanel = new PlayerPanel(); playerPanel = new PlayerPanel();
mainLayer.add(playerPanel); mainLayer.add(playerPanel);
@ -380,7 +378,8 @@ public class View extends JFrame implements IView {
playerPanel.setBounds(0, tableHeight, width, playerPanelHeight); playerPanel.setBounds(0, tableHeight, width, playerPanelHeight);
playerPanel.rescale(); playerPanel.rescale();
int sideWidth = sidePanel.isVisible() ? playerPanel.getLeftPanelWidth() + 1 : 0; int sideWidth = sidePanel.isVisible() ? playerPanel.getLeftPanelWidth() + 1
: 0;
table.setBounds(sideWidth, 0, width - sideWidth, tableHeight); table.setBounds(sideWidth, 0, width - sideWidth, tableHeight);
table.validate(); table.validate();
@ -390,12 +389,11 @@ public class View extends JFrame implements IView {
startTurnPanel.setBounds(0, tableHeight, width, playerPanelHeight); startTurnPanel.setBounds(0, tableHeight, width, playerPanelHeight);
pausePanel.setBounds(0, tableHeight, width, playerPanelHeight); pausePanel.setBounds(0, tableHeight, width, playerPanelHeight);
winPanel.setBounds(0, tableHeight, width, playerPanelHeight); winPanel.setBounds(0, tableHeight, width, playerPanelHeight);
rescaleSubpanel(settingsPanel, 1 / 2.0, 1 / 2.0, 475, 300);
rescaleSubpanel(settingsPanel, 1 / 2.0, 1/ 2.0, 475, 300); rescaleSubpanel(scorePanel, 3 / 4.0, 1 / 2.0, 450, 300);
rescaleSubpanel(scorePanel, 3 / 4.0, 1/ 2.0, 450, 300); rescaleSubpanel(loginPanel, 1 / 3.0, 1 / 3.0, 200, 200);
rescaleSubpanel(loginPanel, 1 / 3.0, 1/ 3.0, 200, 200); rescaleSubpanel(gameListPanel, 1 / 2.0, 1 / 2.0, 475, 300);
rescaleSubpanel(gameListPanel, 1 / 2.0, 1/ 2.0, 475, 300);
} }
private void rescaleSubpanel(JPanel sub, double widthFactor, private void rescaleSubpanel(JPanel sub, double widthFactor,
@ -449,7 +447,7 @@ public class View extends JFrame implements IView {
public void showScorePanel(boolean show) { public void showScorePanel(boolean show) {
scorePanel.setVisible(show); scorePanel.setVisible(show);
} }
@Override @Override
public void showSidePanel(boolean show) { public void showSidePanel(boolean show) {
sidePanel.setVisible(show); sidePanel.setVisible(show);
@ -476,6 +474,8 @@ public class View extends JFrame implements IView {
@Override @Override
public void setCurrentPlayerColor(Color color) { public void setCurrentPlayerColor(Color color) {
playerPanel.setCurrentPlayerColor(color); playerPanel.setCurrentPlayerColor(color);
startTurnPanel.setCurrentPlayerColor(color);
pausePanel.setCurrentPlayerColor(color);
} }
@Override @Override
@ -510,24 +510,24 @@ public class View extends JFrame implements IView {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<Pair<Stone, Position>> createDecorationStones() { private List<Pair<Stone, Position>> createDecorationStones() {
Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(-'J',
-'J', StoneColor.BLACK), new Position(2.5f, 0)); StoneColor.BLACK), new Position(2.5f, 0));
Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(-'R',
-'R', StoneColor.ORANGE), new Position(3.5f, 0)); StoneColor.ORANGE), new Position(3.5f, 0));
Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(-'u',
-'u', StoneColor.BLUE), new Position(4.5f, 0)); StoneColor.BLUE), new Position(4.5f, 0));
Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(-'m',
-'m', StoneColor.RED), new Position(5.5f, 0)); StoneColor.RED), new Position(5.5f, 0));
Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(-'m',
-'m', StoneColor.GREEN), new Position(6.5f, 0)); StoneColor.GREEN), new Position(6.5f, 0));
Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(-'i',
-'i', StoneColor.VIOLET), new Position(7.5f, 0)); StoneColor.VIOLET), new Position(7.5f, 0));
Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(-'k',
-'k', StoneColor.AQUA), new Position(8.5f, 0)); StoneColor.AQUA), new Position(8.5f, 0));
Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(-'u',
-'u', StoneColor.GRAY), new Position(9.5f, 0)); StoneColor.GRAY), new Position(9.5f, 0));
Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(-'b',
-'b', StoneColor.BLACK), new Position(10.5f, 0)); StoneColor.BLACK), new Position(10.5f, 0));
Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone(
StoneColor.RED), new Position(2, 1)); StoneColor.RED), new Position(2, 1));
@ -542,9 +542,9 @@ public class View extends JFrame implements IView {
Pair<Stone, Position> stone6 = new Pair<Stone, Position>(new Stone( Pair<Stone, Position> stone6 = new Pair<Stone, Position>(new Stone(
StoneColor.BLACK), new Position(11, 1)); StoneColor.BLACK), new Position(11, 1));
return Arrays.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, return Arrays
stonek, stoneu2, stoneb, stone1, stone2, stone3, stone4, .asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, stonek,
stone5, stone6); stoneu2, stoneb, stone1, stone2, stone3, stone4, stone5, stone6);
} }
@Override @Override
@ -564,8 +564,7 @@ public class View extends JFrame implements IView {
&& type != BottomPanelType.WIN_PANEL && type != null); && type != BottomPanelType.WIN_PANEL && type != null);
if (type == BottomPanelType.START_GAME_PANEL) { if (type == BottomPanelType.START_GAME_PANEL) {
table.setStoneSets(Collections table.setStoneSets(Collections.<Pair<StoneSet, Position>> emptyList());
.<Pair<StoneSet, Position>> emptyList());
playerPanel.getHandPanel().setStones(createDecorationStones()); playerPanel.getHandPanel().setStones(createDecorationStones());
} }