mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
spjspj - Modifications to shrink size of players who have left.
This commit is contained in:
parent
48ae863459
commit
157d94360c
2 changed files with 81 additions and 6 deletions
|
@ -30,6 +30,7 @@ package mage.client.game;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
|
@ -156,6 +157,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
private static final String CMD_AUTO_ORDER_RESET_ALL = "cmdAutoOrderResetAll";
|
private static final String CMD_AUTO_ORDER_RESET_ALL = "cmdAutoOrderResetAll";
|
||||||
|
|
||||||
private final Map<UUID, PlayAreaPanel> players = new HashMap<>();
|
private final Map<UUID, PlayAreaPanel> players = new HashMap<>();
|
||||||
|
private final Map<UUID, Boolean> playersWhoLeft = new HashMap<>();
|
||||||
|
|
||||||
// non modal frames
|
// non modal frames
|
||||||
private final Map<UUID, CardInfoWindowDialog> exiles = new HashMap<>();
|
private final Map<UUID, CardInfoWindowDialog> exiles = new HashMap<>();
|
||||||
|
@ -309,6 +311,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
playAreaPanelEntry.getValue().CleanUp();
|
playAreaPanelEntry.getValue().CleanUp();
|
||||||
}
|
}
|
||||||
this.players.clear();
|
this.players.clear();
|
||||||
|
this.playersWhoLeft.clear();
|
||||||
|
|
||||||
jLayeredPane.remove(abilityPicker);
|
jLayeredPane.remove(abilityPicker);
|
||||||
this.abilityPicker.cleanUp();
|
this.abilityPicker.cleanUp();
|
||||||
|
@ -594,6 +597,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private void addPlayers(GameView game) {
|
private void addPlayers(GameView game) {
|
||||||
this.players.clear();
|
this.players.clear();
|
||||||
|
this.playersWhoLeft.clear();
|
||||||
this.pnlBattlefield.removeAll();
|
this.pnlBattlefield.removeAll();
|
||||||
//arrange players in a circle with the session player at the bottom left
|
//arrange players in a circle with the session player at the bottom left
|
||||||
int numSeats = game.getPlayers().size();
|
int numSeats = game.getPlayers().size();
|
||||||
|
@ -614,6 +618,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
PlayAreaPanel playAreaPanel = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
|
PlayAreaPanel playAreaPanel = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
|
||||||
new PlayAreaPanelOptions(game.isPlayer(), game.isPlayer(), game.isRollbackTurnsAllowed()));
|
new PlayAreaPanelOptions(game.isPlayer(), game.isPlayer(), game.isRollbackTurnsAllowed()));
|
||||||
players.put(player.getPlayerId(), playAreaPanel);
|
players.put(player.getPlayerId(), playAreaPanel);
|
||||||
|
playersWhoLeft.put(player.getPlayerId(), false);
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
c.weightx = 0.5;
|
c.weightx = 0.5;
|
||||||
|
@ -622,8 +627,19 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
c.gridwidth = 2;
|
c.gridwidth = 2;
|
||||||
}
|
}
|
||||||
c.gridx = col;
|
c.gridx = col;
|
||||||
c.gridy = row;
|
c.gridy = 0;
|
||||||
this.pnlBattlefield.add(playAreaPanel, c);
|
|
||||||
|
// Top panel (row=0)
|
||||||
|
JPanel topPanel = new JPanel();
|
||||||
|
topPanel.setOpaque(false);
|
||||||
|
|
||||||
|
// Bottom panel (row=1)
|
||||||
|
JPanel bottomPanel = new JPanel();
|
||||||
|
bottomPanel.setOpaque(false);
|
||||||
|
topPanel.setLayout(new GridBagLayout());
|
||||||
|
bottomPanel.setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
bottomPanel.add(playAreaPanel, c);
|
||||||
playAreaPanel.setVisible(true);
|
playAreaPanel.setVisible(true);
|
||||||
if (oddNumber) {
|
if (oddNumber) {
|
||||||
col++;
|
col++;
|
||||||
|
@ -646,13 +662,20 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
|
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
|
||||||
new PlayAreaPanelOptions(game.isPlayer(), false, game.isRollbackTurnsAllowed()));
|
new PlayAreaPanelOptions(game.isPlayer(), false, game.isRollbackTurnsAllowed()));
|
||||||
players.put(player.getPlayerId(), playerPanel);
|
players.put(player.getPlayerId(), playerPanel);
|
||||||
|
playersWhoLeft.put(player.getPlayerId(), false);
|
||||||
c = new GridBagConstraints();
|
c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
c.weightx = 0.5;
|
c.weightx = 0.5;
|
||||||
c.weighty = 0.5;
|
c.weighty = 0.5;
|
||||||
c.gridx = col;
|
c.gridx = col;
|
||||||
c.gridy = row;
|
c.gridy = 0;
|
||||||
this.pnlBattlefield.add(playerPanel, c);
|
|
||||||
|
if (row == 0) {
|
||||||
|
topPanel.add(playerPanel, c);
|
||||||
|
} else {
|
||||||
|
bottomPanel.add(playerPanel, c);
|
||||||
|
}
|
||||||
|
|
||||||
playerPanel.setVisible(true);
|
playerPanel.setVisible(true);
|
||||||
playerNum++;
|
playerNum++;
|
||||||
if (playerNum >= numSeats) {
|
if (playerNum >= numSeats) {
|
||||||
|
@ -665,6 +688,16 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
for (PlayAreaPanel p : players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
p.sizePlayer(smallMode);
|
p.sizePlayer(smallMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GridBagConstraints panelC = new GridBagConstraints();
|
||||||
|
panelC.fill = GridBagConstraints.BOTH;
|
||||||
|
panelC.weightx = 0.5;
|
||||||
|
panelC.weighty = 0.5;
|
||||||
|
panelC.gridwidth = 1;
|
||||||
|
panelC.gridy = 0;
|
||||||
|
this.pnlBattlefield.add(topPanel, panelC);
|
||||||
|
panelC.gridy = 1;
|
||||||
|
this.pnlBattlefield.add(bottomPanel, panelC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void updateGame(GameView game) {
|
public synchronized void updateGame(GameView game) {
|
||||||
|
@ -838,6 +871,42 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
CombatManager.getInstance().hideCombat(gameId);
|
CombatManager.getInstance().hideCombat(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (PlayerView player : game.getPlayers()) {
|
||||||
|
if (player.hasLeft() && !playersWhoLeft.get(player.getPlayerId())) {
|
||||||
|
PlayAreaPanel playerLeftPanel = players.get(player.getPlayerId());
|
||||||
|
playersWhoLeft.put(player.getPlayerId(), true);
|
||||||
|
|
||||||
|
Container parent = playerLeftPanel.getParent();
|
||||||
|
GridBagLayout layout = (GridBagLayout) parent.getLayout();
|
||||||
|
|
||||||
|
for (Component otherPanel : parent.getComponents()) {
|
||||||
|
|
||||||
|
if (otherPanel instanceof PlayAreaPanel) {
|
||||||
|
GridBagConstraints gbc = layout.getConstraints(otherPanel);
|
||||||
|
if (gbc.weightx > 0.1) {
|
||||||
|
gbc.weightx = 0.99;
|
||||||
|
}
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
if (gbc.gridx > 0) {
|
||||||
|
gbc.anchor = GridBagConstraints.EAST;
|
||||||
|
}
|
||||||
|
if (otherPanel == playerLeftPanel) {
|
||||||
|
gbc.weightx = 0.01;
|
||||||
|
Dimension d = playerLeftPanel.getPreferredSize();
|
||||||
|
d.width = 95;
|
||||||
|
otherPanel.setPreferredSize(d);
|
||||||
|
}
|
||||||
|
parent.remove(otherPanel);
|
||||||
|
parent.add(otherPanel, gbc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parent.validate();
|
||||||
|
parent.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
feedbackPanel.disableUndo();
|
feedbackPanel.disableUndo();
|
||||||
|
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
|
|
|
@ -112,6 +112,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
private static final Border RED_BORDER = new LineBorder(Color.red, 2);
|
private static final Border RED_BORDER = new LineBorder(Color.red, 2);
|
||||||
private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0);
|
private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0);
|
||||||
private final Color greenBackgroundColor = new Color(180, 255, 180, 200);
|
private final Color greenBackgroundColor = new Color(180, 255, 180, 200);
|
||||||
|
private final Color deadBackgroundColor = new Color(200, 180, 180, 200);
|
||||||
|
|
||||||
private int avatarId = -1;
|
private int avatarId = -1;
|
||||||
private String flagName;
|
private String flagName;
|
||||||
|
@ -222,7 +223,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
graveLabel.setText(Integer.toString(graveCards));
|
graveLabel.setText(Integer.toString(graveCards));
|
||||||
graveLabel.setToolTipText("Card Types: " + qtyCardTypes(player.getGraveyard()));
|
graveLabel.setToolTipText("Card Types: " + qtyCardTypes(player.getGraveyard()));
|
||||||
|
|
||||||
int exileCards = player.getExile().size();
|
int exileCards = player.getExile().size();
|
||||||
if (exileCards > 99) {
|
if (exileCards > 99) {
|
||||||
if (!changedFontExile) {
|
if (!changedFontExile) {
|
||||||
|
@ -282,6 +283,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
if (player.hasLeft()) {
|
if (player.hasLeft()) {
|
||||||
this.avatar.setBorder(RED_BORDER);
|
this.avatar.setBorder(RED_BORDER);
|
||||||
this.btnPlayer.setBorder(RED_BORDER);
|
this.btnPlayer.setBorder(RED_BORDER);
|
||||||
|
setDeadBackgroundColor();
|
||||||
} else {
|
} else {
|
||||||
this.avatar.setBorder(EMPTY_BORDER);
|
this.avatar.setBorder(EMPTY_BORDER);
|
||||||
this.btnPlayer.setBorder(EMPTY_BORDER);
|
this.btnPlayer.setBorder(EMPTY_BORDER);
|
||||||
|
@ -299,6 +301,10 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
panelBackground.setBackgroundColor(greenBackgroundColor);
|
panelBackground.setBackgroundColor(greenBackgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDeadBackgroundColor() {
|
||||||
|
panelBackground.setBackgroundColor(deadBackgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the avatar image and tooltip text
|
* Updates the avatar image and tooltip text
|
||||||
*/
|
*/
|
||||||
|
@ -878,7 +884,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
if (cardTypesPresent.isEmpty()) return 0;
|
if (cardTypesPresent.isEmpty()) return 0;
|
||||||
else return cardTypesPresent.size();
|
else return cardTypesPresent.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HoverButton avatar;
|
private HoverButton avatar;
|
||||||
private JLabel avatarFlag;
|
private JLabel avatarFlag;
|
||||||
private JButton btnPlayer;
|
private JButton btnPlayer;
|
||||||
|
|
Loading…
Reference in a new issue