Show panel when a player disappears during a game
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@575 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
9ced7cf953
commit
079de08aea
5 changed files with 161 additions and 124 deletions
|
@ -1,7 +1,6 @@
|
||||||
package jrummikub.control.network;
|
package jrummikub.control.network;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import jrummikub.model.GameSettings;
|
import jrummikub.model.GameSettings;
|
||||||
|
@ -107,8 +106,7 @@ public class GameOfferControl extends AbstractGameBeginControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleLeave(String nickname) {
|
private void handleLeave(String nickname) {
|
||||||
List<PlayerSettings> players = gameData.getGameSettings().getPlayerList();
|
for (PlayerSettings s : gameData.getGameSettings().getPlayerList()) {
|
||||||
for (PlayerSettings s : players) {
|
|
||||||
if (s.getName().equals(nickname) && s.getType() == Type.NETWORK) {
|
if (s.getName().equals(nickname) && s.getType() == Type.NETWORK) {
|
||||||
s.setType(Type.VACANT);
|
s.setType(Type.VACANT);
|
||||||
s.setName("Offen");
|
s.setName("Offen");
|
||||||
|
|
|
@ -5,7 +5,10 @@ import jrummikub.control.RoundControl;
|
||||||
import jrummikub.control.SaveControl;
|
import jrummikub.control.SaveControl;
|
||||||
import jrummikub.model.GameSettings;
|
import jrummikub.model.GameSettings;
|
||||||
import jrummikub.model.IRoundState;
|
import jrummikub.model.IRoundState;
|
||||||
|
import jrummikub.model.PlayerSettings;
|
||||||
|
import jrummikub.model.PlayerSettings.Type;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
|
import jrummikub.util.IListener1;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
import jrummikub.view.IView.BottomPanelType;
|
import jrummikub.view.IView.BottomPanelType;
|
||||||
|
|
||||||
|
@ -30,19 +33,36 @@ public class NetworkGameControl extends GameControl {
|
||||||
* @param host
|
* @param host
|
||||||
* of the current game
|
* of the current game
|
||||||
*/
|
*/
|
||||||
public NetworkGameControl(GameSettings gameSettings,
|
public NetworkGameControl(GameSettings gameSettings, SaveControl saveControl,
|
||||||
SaveControl saveControl, IView view,
|
final IView view, IConnectionControl connectionControl, boolean host) {
|
||||||
IConnectionControl connectionControl, boolean host) {
|
|
||||||
super(gameSettings, saveControl, view);
|
super(gameSettings, saveControl, view);
|
||||||
|
|
||||||
this.connectionControl = connectionControl;
|
this.connectionControl = connectionControl;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
|
||||||
|
connections.add(connectionControl.getParticipantLeftEvent().add(
|
||||||
|
new IListener1<String>() {
|
||||||
|
@Override
|
||||||
|
public void handle(String nickname) {
|
||||||
|
if (NetworkGameControl.this.gameSettings == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PlayerSettings s : NetworkGameControl.this.gameSettings
|
||||||
|
.getPlayerList()) {
|
||||||
|
if (s.getName().equals(nickname) && s.getType() == Type.NETWORK) {
|
||||||
|
abortGame();
|
||||||
|
view.setBottomPanel(BottomPanelType.NETWORK_CONNECTION_LOST_PANEL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startRound() {
|
protected void startRound() {
|
||||||
connections.add(connectionControl.getRoundStartEvent().add(
|
connections.add(connectionControl.getRoundStartEvent().add(new IListener() {
|
||||||
new IListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
NetworkGameControl.super.startRound();
|
NetworkGameControl.super.startRound();
|
||||||
|
@ -61,8 +81,7 @@ public class NetworkGameControl extends GameControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RoundControl createRoundControl(IRoundState roundState) {
|
protected RoundControl createRoundControl(IRoundState roundState) {
|
||||||
return new NetworkRoundControl(roundState, view, connectionControl,
|
return new NetworkRoundControl(roundState, view, connectionControl, host);
|
||||||
host);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -128,8 +128,8 @@ public interface IView {
|
||||||
public void setCurrentPlayerColor(Color color);
|
public void setCurrentPlayerColor(Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is used for the PlayerPanel to display if a player has laid out along
|
* Is used for the PlayerPanel to display if a player has laid out along with
|
||||||
* with the name
|
* the name
|
||||||
*
|
*
|
||||||
* @param hasLaidOut
|
* @param hasLaidOut
|
||||||
* specifies if the current player has laid out or not
|
* specifies if the current player has laid out or not
|
||||||
|
@ -152,8 +152,8 @@ public interface IView {
|
||||||
public void setBottomPanel(BottomPanelType type);
|
public void setBottomPanel(BottomPanelType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The menu new game event is emitted when the user selects the new game
|
* The menu new game event is emitted when the user selects the new game menu
|
||||||
* menu entry
|
* entry
|
||||||
*
|
*
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
|
@ -367,23 +367,6 @@ public interface IView {
|
||||||
* Different types of bottom panels
|
* Different types of bottom panels
|
||||||
*/
|
*/
|
||||||
public enum BottomPanelType {
|
public enum BottomPanelType {
|
||||||
/** */
|
START_GAME_PANEL, START_TURN_PANEL, START_REDEAL_TURN_PANEL, START_LAST_TURN_PANEL, INVALID_TURN_PANEL, HUMAN_HAND_PANEL, NONHUMAN_HAND_PANEL, WIN_PANEL, NETWORK_WIN_PANEL, NETWORK_CONNECTION_LOST_PANEL
|
||||||
START_GAME_PANEL,
|
|
||||||
/** */
|
|
||||||
START_TURN_PANEL,
|
|
||||||
/** */
|
|
||||||
START_REDEAL_TURN_PANEL,
|
|
||||||
/** */
|
|
||||||
START_LAST_TURN_PANEL,
|
|
||||||
/** */
|
|
||||||
INVALID_TURN_PANEL,
|
|
||||||
/** */
|
|
||||||
HUMAN_HAND_PANEL,
|
|
||||||
/** */
|
|
||||||
NONHUMAN_HAND_PANEL,
|
|
||||||
/** */
|
|
||||||
WIN_PANEL,
|
|
||||||
/** */
|
|
||||||
NETWORK_WIN_PANEL
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,8 +187,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());
|
||||||
|
@ -206,8 +205,8 @@ public class View extends JFrame implements IView {
|
||||||
.showMessageDialog(
|
.showMessageDialog(
|
||||||
this,
|
this,
|
||||||
alreadyRunning ? "Ein XMPP-Server l\u00e4ft bereits auf diesem Computer"
|
alreadyRunning ? "Ein XMPP-Server l\u00e4ft bereits auf diesem Computer"
|
||||||
: "Der Server konnte nicht gestartet werden",
|
: "Der Server konnte nicht gestartet werden", "Fehler",
|
||||||
"Fehler", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,8 +395,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);
|
||||||
|
@ -417,9 +415,9 @@ public class View extends JFrame implements IView {
|
||||||
sidePanel = new SidePanel();
|
sidePanel = new SidePanel();
|
||||||
sidePanel.setVisible(false);
|
sidePanel.setVisible(false);
|
||||||
mainLayer.add(sidePanel);
|
mainLayer.add(sidePanel);
|
||||||
sidePanel.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1,
|
sidePanel
|
||||||
Color.BLACK), new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
|
.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1, Color.BLACK),
|
||||||
Color.GRAY)));
|
new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, Color.GRAY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -623,24 +621,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));
|
||||||
|
@ -655,9 +653,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
|
||||||
|
@ -673,7 +671,8 @@ public class View extends JFrame implements IView {
|
||||||
startTurnPanel.setType(type);
|
startTurnPanel.setType(type);
|
||||||
startTurnPanel.setVisible(showStartTurnPanel);
|
startTurnPanel.setVisible(showStartTurnPanel);
|
||||||
|
|
||||||
boolean showWinPanel = (type == BottomPanelType.WIN_PANEL || type == BottomPanelType.NETWORK_WIN_PANEL);
|
boolean showWinPanel = (type == BottomPanelType.WIN_PANEL
|
||||||
|
|| type == BottomPanelType.NETWORK_WIN_PANEL || type == BottomPanelType.NETWORK_CONNECTION_LOST_PANEL);
|
||||||
winPanel.setType(type);
|
winPanel.setType(type);
|
||||||
winPanel.setVisible(showWinPanel);
|
winPanel.setVisible(showWinPanel);
|
||||||
|
|
||||||
|
@ -681,8 +680,7 @@ public class View extends JFrame implements IView {
|
||||||
&& type != null);
|
&& 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ class WinPanel extends JPanel {
|
||||||
private final static float MAX_BUTTON_FONT_SIZE = 12;
|
private final static float MAX_BUTTON_FONT_SIZE = 12;
|
||||||
|
|
||||||
private JLabel waitingLabel;
|
private JLabel waitingLabel;
|
||||||
|
private JLabel connectionLostLabel;
|
||||||
|
|
||||||
private JButton newRoundButton;
|
private JButton newRoundButton;
|
||||||
private JButton newGameButton;
|
private JButton newGameButton;
|
||||||
private JButton endProgramButton;
|
private JButton endProgramButton;
|
||||||
|
@ -50,6 +52,12 @@ class WinPanel extends JPanel {
|
||||||
waitingLabel.setVerticalAlignment(JLabel.CENTER);
|
waitingLabel.setVerticalAlignment(JLabel.CENTER);
|
||||||
add(waitingLabel);
|
add(waitingLabel);
|
||||||
|
|
||||||
|
connectionLostLabel = new JLabel(
|
||||||
|
"Die Verbindung zu einem Spieler ist abgebrochen.");
|
||||||
|
connectionLostLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
connectionLostLabel.setVerticalAlignment(JLabel.CENTER);
|
||||||
|
add(connectionLostLabel);
|
||||||
|
|
||||||
newRoundButton = new JButton("Neue Runde");
|
newRoundButton = new JButton("Neue Runde");
|
||||||
newRoundButton.addActionListener(new ActionListener() {
|
newRoundButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,44 +125,26 @@ class WinPanel extends JPanel {
|
||||||
width = width / 2 + PANEL_MAX_WIDTH / 2;
|
width = width / 2 + PANEL_MAX_WIDTH / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int buttonWidth;
|
|
||||||
int buttonHeight;
|
|
||||||
int buttonY;
|
|
||||||
if (type == BottomPanelType.WIN_PANEL) {
|
if (type == BottomPanelType.WIN_PANEL) {
|
||||||
buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
|
rescaleWinPanel(x, y, width, height);
|
||||||
buttonHeight = height;
|
} else if (type == BottomPanelType.NETWORK_WIN_PANEL) {
|
||||||
buttonY = y;
|
rescaleNetworkWinPanel(x, y, width, height);
|
||||||
} else {
|
} else if (type == BottomPanelType.NETWORK_CONNECTION_LOST_PANEL) {
|
||||||
buttonWidth = (width - PANEL_SEPARATOR) / 2;
|
rescaleNetworkConnectionLostPanel(x, y, width, height);
|
||||||
buttonHeight = height * 2 / 3 - PANEL_SEPARATOR;
|
|
||||||
buttonY = y + height - buttonHeight;
|
|
||||||
}
|
}
|
||||||
int labelHeight = height - buttonHeight - PANEL_SEPARATOR;
|
}
|
||||||
|
|
||||||
|
private void rescaleWinPanel(int x, int y, int width, int height) {
|
||||||
|
int buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
|
||||||
|
int buttonHeight = height;
|
||||||
|
int buttonY = y;
|
||||||
|
|
||||||
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
|
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
|
||||||
if (fontSize > MAX_BUTTON_FONT_SIZE)
|
if (fontSize > MAX_BUTTON_FONT_SIZE)
|
||||||
fontSize = MAX_BUTTON_FONT_SIZE;
|
fontSize = MAX_BUTTON_FONT_SIZE;
|
||||||
|
|
||||||
if (type == BottomPanelType.WIN_PANEL) {
|
|
||||||
rescaleWinPanel(x, buttonWidth, buttonHeight, buttonY, fontSize);
|
|
||||||
} else if (type == BottomPanelType.NETWORK_WIN_PANEL) {
|
|
||||||
waitingLabel.setBounds(x, y, width, labelHeight);
|
|
||||||
waitingLabel.setVisible(true);
|
|
||||||
|
|
||||||
newRoundButton.setVisible(false);
|
|
||||||
|
|
||||||
newGameButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
|
|
||||||
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
|
||||||
|
|
||||||
endProgramButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
|
|
||||||
buttonWidth, buttonHeight);
|
|
||||||
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rescaleWinPanel(int x, int buttonWidth, int buttonHeight,
|
|
||||||
int buttonY, float fontSize) {
|
|
||||||
waitingLabel.setVisible(false);
|
waitingLabel.setVisible(false);
|
||||||
|
connectionLostLabel.setVisible(false);
|
||||||
newRoundButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
|
newRoundButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
|
||||||
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
|
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
|
||||||
newRoundButton.setVisible(true);
|
newRoundButton.setVisible(true);
|
||||||
|
@ -168,6 +158,55 @@ class WinPanel extends JPanel {
|
||||||
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
|
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rescaleNetworkWinPanel(int x, int y, int width, int height) {
|
||||||
|
int buttonWidth = (width - PANEL_SEPARATOR) / 2;
|
||||||
|
int buttonHeight = height * 2 / 3 - PANEL_SEPARATOR;
|
||||||
|
int buttonY = y + height - buttonHeight;
|
||||||
|
int labelHeight = height - buttonHeight - PANEL_SEPARATOR;
|
||||||
|
|
||||||
|
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
|
||||||
|
if (fontSize > MAX_BUTTON_FONT_SIZE)
|
||||||
|
fontSize = MAX_BUTTON_FONT_SIZE;
|
||||||
|
|
||||||
|
waitingLabel.setBounds(x, y, width, labelHeight);
|
||||||
|
waitingLabel.setVisible(true);
|
||||||
|
connectionLostLabel.setVisible(false);
|
||||||
|
|
||||||
|
newRoundButton.setVisible(false);
|
||||||
|
|
||||||
|
newGameButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
|
||||||
|
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
||||||
|
|
||||||
|
endProgramButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
|
||||||
|
buttonWidth, buttonHeight);
|
||||||
|
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rescaleNetworkConnectionLostPanel(int x, int y, int width,
|
||||||
|
int height) {
|
||||||
|
int buttonWidth = (width - PANEL_SEPARATOR) / 2;
|
||||||
|
int buttonHeight = height * 2 / 3 - PANEL_SEPARATOR;
|
||||||
|
int buttonY = y + height - buttonHeight;
|
||||||
|
int labelHeight = height - buttonHeight - PANEL_SEPARATOR;
|
||||||
|
|
||||||
|
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
|
||||||
|
if (fontSize > MAX_BUTTON_FONT_SIZE)
|
||||||
|
fontSize = MAX_BUTTON_FONT_SIZE;
|
||||||
|
|
||||||
|
waitingLabel.setVisible(false);
|
||||||
|
connectionLostLabel.setBounds(x, y, width, labelHeight);
|
||||||
|
connectionLostLabel.setVisible(true);
|
||||||
|
|
||||||
|
newRoundButton.setVisible(false);
|
||||||
|
|
||||||
|
newGameButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
|
||||||
|
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
||||||
|
|
||||||
|
endProgramButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
|
||||||
|
buttonWidth, buttonHeight);
|
||||||
|
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
|
||||||
|
}
|
||||||
|
|
||||||
void setType(BottomPanelType type) {
|
void setType(BottomPanelType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
rescale();
|
rescale();
|
||||||
|
|
Reference in a new issue