Update GameView.java
added jokers
This commit is contained in:
parent
34e634a05d
commit
20c679c262
1 changed files with 20 additions and 3 deletions
|
|
@ -22,6 +22,9 @@ import gui.components.MapPanel;
|
||||||
|
|
||||||
public class GameView extends View implements GameInterface {
|
public class GameView extends View implements GameInterface {
|
||||||
|
|
||||||
|
private final int JOKER_PANEL_HEIGHT = 50;
|
||||||
|
|
||||||
|
|
||||||
private MapPanel map;
|
private MapPanel map;
|
||||||
private JScrollPane scrollLog;
|
private JScrollPane scrollLog;
|
||||||
private JTextPane txtStats;
|
private JTextPane txtStats;
|
||||||
|
|
@ -29,12 +32,17 @@ public class GameView extends View implements GameInterface {
|
||||||
private JTextPane gameLog;
|
private JTextPane gameLog;
|
||||||
private JButton button;
|
private JButton button;
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
|
private JokerPanel jokers;
|
||||||
|
|
||||||
GameView(GameWindow gameWindow, Game game) {
|
GameView(GameWindow gameWindow, Game game) {
|
||||||
super(gameWindow);
|
super(gameWindow);
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
jokers.setGame(game);
|
||||||
|
jokers.setGameView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int sidebarWidth() {
|
private int sidebarWidth() {
|
||||||
return (int) Math.max(getWidth() * 0.15, 300);
|
return (int) Math.max(getWidth() * 0.15, 300);
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +50,7 @@ public class GameView extends View implements GameInterface {
|
||||||
private Dimension mapPanelSize() {
|
private Dimension mapPanelSize() {
|
||||||
int w = getWidth();
|
int w = getWidth();
|
||||||
int h = getHeight();
|
int h = getHeight();
|
||||||
return new Dimension(w - sidebarWidth() - 40, h - 20);
|
return new Dimension(w - sidebarWidth() - 40, h - 20 - JOKER_PANEL_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -53,13 +61,19 @@ public class GameView extends View implements GameInterface {
|
||||||
|
|
||||||
int sidebarWidth = sidebarWidth();
|
int sidebarWidth = sidebarWidth();
|
||||||
Dimension mapPanelSize = mapPanelSize();
|
Dimension mapPanelSize = mapPanelSize();
|
||||||
this.map.setBounds(10, 10, mapPanelSize.width, mapPanelSize.height);
|
this.map.setBounds(10, JOKER_PANEL_HEIGHT + 10, mapPanelSize.width, mapPanelSize.height);
|
||||||
this.map.revalidate();
|
this.map.revalidate();
|
||||||
this.map.repaint();
|
this.map.repaint();
|
||||||
|
|
||||||
int x = w - sidebarWidth - 20;
|
int x = w - sidebarWidth - 20;
|
||||||
int y = 10;
|
int y = 10;
|
||||||
|
|
||||||
|
jokers.setSize(mapPanelSize.width, JOKER_PANEL_HEIGHT);
|
||||||
|
jokers.setBounds(10, y, mapPanelSize.width, JOKER_PANEL_HEIGHT - 10);
|
||||||
|
|
||||||
|
jokers.revalidate();
|
||||||
|
jokers.repaint();
|
||||||
|
|
||||||
txtStats.setSize(sidebarWidth, 50 + 20 * game.getPlayers().size());
|
txtStats.setSize(sidebarWidth, 50 + 20 * game.getPlayers().size());
|
||||||
dices.setSize(sidebarWidth, 50);
|
dices.setSize(sidebarWidth, 50);
|
||||||
scrollLog.setSize(sidebarWidth, h - txtStats.getHeight() - dices.getHeight() - 50 - BUTTON_SIZE.height);
|
scrollLog.setSize(sidebarWidth, h - txtStats.getHeight() - dices.getHeight() - 50 - BUTTON_SIZE.height);
|
||||||
|
|
@ -87,6 +101,9 @@ public class GameView extends View implements GameInterface {
|
||||||
this.dices = new DicePanel(getWindow().getResources());
|
this.dices = new DicePanel(getWindow().getResources());
|
||||||
this.dices.setBorder(new LineBorder(Color.BLACK));
|
this.dices.setBorder(new LineBorder(Color.BLACK));
|
||||||
this.add(dices);
|
this.add(dices);
|
||||||
|
this.jokers = new JokerPanel(getWindow().getResources(), game);
|
||||||
|
this.jokers.setBorder(new LineBorder(Color.BLACK));
|
||||||
|
this.add(jokers);
|
||||||
this.gameLog = createTextPane();
|
this.gameLog = createTextPane();
|
||||||
this.gameLog.addStyle("PlayerColor", null);
|
this.gameLog.addStyle("PlayerColor", null);
|
||||||
this.scrollLog = new JScrollPane(gameLog);
|
this.scrollLog = new JScrollPane(gameLog);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue