partial fix for issue 81

This commit is contained in:
BetaSteward 2011-11-21 08:29:21 -05:00
parent 0e7851e164
commit b975d98bf5
6 changed files with 497 additions and 338 deletions

View file

@ -624,7 +624,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
lblStatus = new javax.swing.JLabel(); lblStatus = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(1024, 768)); setMinimumSize(new Dimension(800, 600));
desktopPane.setBackground(new java.awt.Color(204, 204, 204)); desktopPane.setBackground(new java.awt.Color(204, 204, 204));

View file

@ -77,13 +77,7 @@ public class GamePane extends MagePane {
gamePanel.replayGame(gameId); gamePanel.replayGame(gameId);
} }
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
@ -95,20 +89,20 @@ public class GamePane extends MagePane {
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 894, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)
.addGap(0, 600, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 651, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
.addGap(0, 400, Short.MAX_VALUE)
); );
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }
// Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.game.GamePanel gamePanel; private mage.client.game.GamePanel gamePanel;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
} }

View file

@ -64,6 +64,8 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import mage.client.components.MageComponents; import mage.client.components.MageComponents;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
/** /**
* *
@ -87,25 +89,10 @@ public class GamePanel extends javax.swing.JPanel {
private JLayeredPane jLayeredPane; private JLayeredPane jLayeredPane;
private String chosenHandKey = "You"; private String chosenHandKey = "You";
private static final int HAND_CARD_WIDTH = 75;
private static final Dimension handCardDimension = new Dimension(HAND_CARD_WIDTH, (int)(HAND_CARD_WIDTH * 3.5f / 2.5f));
private static final Dimension handCardDimensionBig;
static {
double factor = Config.handScalingFactor;
if (factor < 1) factor = 1;
if (factor > 2) factor = 2;
int width = (int)(factor * HAND_CARD_WIDTH);
handCardDimensionBig = new Dimension(width, (int)(width * 3.5f / 2.5f));
}
/** Creates new form GamePanel */ /** Creates new form GamePanel */
public GamePanel() { public GamePanel() {
initComponents(); initComponents();
hand.setHScrollSpeed(8);
hand.setBackgroundColor(new Color(0, 0, 0, 100));
hand.setVisibleIfEmpty(false);
combat = new CombatDialog(); combat = new CombatDialog();
pickNumber = new PickNumberDialog(); pickNumber = new PickNumberDialog();
MageFrame.getDesktop().add(combat, JLayeredPane.POPUP_LAYER); MageFrame.getDesktop().add(combat, JLayeredPane.POPUP_LAYER);
@ -156,7 +143,7 @@ public class GamePanel extends javax.swing.JPanel {
components.put("jSplitPane1", jSplitPane1); components.put("jSplitPane1", jSplitPane1);
components.put("pnlBattlefield", pnlBattlefield); components.put("pnlBattlefield", pnlBattlefield);
components.put("jPanel3", jPanel3); components.put("jPanel3", jPanel3);
components.put("hand", hand); components.put("hand", handContainer);
components.put("gameChatPanel", gameChatPanel); components.put("gameChatPanel", gameChatPanel);
components.put("userChatPanel", userChatPanel); components.put("userChatPanel", userChatPanel);
components.put("jLayeredPane", jLayeredPane); components.put("jLayeredPane", jLayeredPane);
@ -186,6 +173,22 @@ public class GamePanel extends javax.swing.JPanel {
} }
} }
private void sizeToScreen() {
Rectangle rect = this.getBounds();
if (rect.height < 768) {
Dimension bbDimension = new Dimension(128, 184);
bigCard.setMaximumSize(bbDimension);
bigCard.setMinimumSize(bbDimension);
bigCard.setPreferredSize(bbDimension);
this.handContainer.sizeHand(0.6);
for (PlayAreaPanel p: players.values()) {
p.sizePlayer();
}
}
this.revalidate();
this.repaint();
}
public synchronized void showGame(UUID gameId, UUID playerId) { public synchronized void showGame(UUID gameId, UUID playerId) {
this.gameId = gameId; this.gameId = gameId;
this.playerId = playerId; this.playerId = playerId;
@ -202,6 +205,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameChatPanel.connect(session.getGameChatId(gameId)); this.gameChatPanel.connect(session.getGameChatId(gameId));
if (!session.joinGame(gameId)) if (!session.joinGame(gameId))
hideGame(); hideGame();
sizeToScreen();
} }
public synchronized void watchGame(UUID gameId) { public synchronized void watchGame(UUID gameId) {
@ -219,6 +223,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameChatPanel.connect(session.getGameChatId(gameId)); this.gameChatPanel.connect(session.getGameChatId(gameId));
if (!session.watchGame(gameId)) if (!session.watchGame(gameId))
hideGame(); hideGame();
sizeToScreen();
} }
public synchronized void replayGame(UUID gameId) { public synchronized void replayGame(UUID gameId) {
@ -235,6 +240,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameChatPanel.clear(); this.gameChatPanel.clear();
if (!session.startReplay(gameId)) if (!session.startReplay(gameId))
hideGame(); hideGame();
sizeToScreen();
} }
public void hideGame() { public void hideGame() {
@ -321,7 +327,7 @@ public class GamePanel extends javax.swing.JPanel {
public synchronized void updateGame(GameView game) { public synchronized void updateGame(GameView game) {
if (playerId == null || game.getHand() == null) { if (playerId == null || game.getHand() == null) {
this.hand.setVisible(false); this.handContainer.setVisible(false);
} else { } else {
handCards.clear(); handCards.clear();
handCards.put(YOUR_HAND, game.getHand()); handCards.put(YOUR_HAND, game.getHand());
@ -336,8 +342,7 @@ public class GamePanel extends javax.swing.JPanel {
if (!handCards.containsKey(chosenHandKey)) { if (!handCards.containsKey(chosenHandKey)) {
chosenHandKey = YOUR_HAND; chosenHandKey = YOUR_HAND;
} }
this.hand.loadCards(handCards.get(chosenHandKey), bigCard, gameId); handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
hand.setPreferredSize(new java.awt.Dimension((getHandCardDimension().width + 5) * game.getHand().size() + 5, getHandCardDimension().height + 20)); // for scroll
// set visible only if we have any other hand visible than ours // set visible only if we have any other hand visible than ours
boolean previous = btnSwitchHands.isVisible(); boolean previous = btnSwitchHands.isVisible();
@ -547,21 +552,9 @@ public class GamePanel extends javax.swing.JPanel {
return players; return players;
} }
/*public javax.swing.JPanel getBattlefield() {
return pnlBattlefield;
}*/
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// </editor-fold>//GEN-END:initComponents
private void initComponents() { private void initComponents() {
//abilityPicker = new mage.client.game.AbilityPicker();
abilityPicker = new mage.client.components.ability.AbilityPicker(); abilityPicker = new mage.client.components.ability.AbilityPicker();
jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane1 = new javax.swing.JSplitPane();
jPanel3 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel();
@ -589,7 +582,6 @@ public class GamePanel extends javax.swing.JPanel {
btnSkipForward = new javax.swing.JButton(); btnSkipForward = new javax.swing.JButton();
btnPreviousPlay = new javax.swing.JButton(); btnPreviousPlay = new javax.swing.JButton();
pnlBattlefield = new javax.swing.JPanel(); pnlBattlefield = new javax.swing.JPanel();
hand = new mage.client.cards.Cards(true);
gameChatPanel = new mage.client.chat.ChatPanel(); gameChatPanel = new mage.client.chat.ChatPanel();
gameChatPanel.useExtendedView(ChatPanel.VIEW_MODE.GAME); gameChatPanel.useExtendedView(ChatPanel.VIEW_MODE.GAME);
userChatPanel = new mage.client.chat.ChatPanel(); userChatPanel = new mage.client.chat.ChatPanel();
@ -597,10 +589,9 @@ public class GamePanel extends javax.swing.JPanel {
userChatPanel.useExtendedView(ChatPanel.VIEW_MODE.CHAT); userChatPanel.useExtendedView(ChatPanel.VIEW_MODE.CHAT);
gameChatPanel.setConnectedChat(userChatPanel); gameChatPanel.setConnectedChat(userChatPanel);
gameChatPanel.disableInput(); gameChatPanel.disableInput();
// jTabbedPane1 = new JTabbedPane();
jSplitPane2 = new javax.swing.JSplitPane(); jSplitPane2 = new javax.swing.JSplitPane();
handContainer = new HandPanel();
hand.setCardDimension(getHandCardDimension());
handCards = new HashMap<String, SimpleCardsView>(); handCards = new HashMap<String, SimpleCardsView>();
jSplitPane1.setBorder(null); jSplitPane1.setBorder(null);
@ -608,8 +599,6 @@ public class GamePanel extends javax.swing.JPanel {
jSplitPane1.setResizeWeight(1.0); jSplitPane1.setResizeWeight(1.0);
jSplitPane1.setOneTouchExpandable(true); jSplitPane1.setOneTouchExpandable(true);
jSplitPane1.setMinimumSize(new java.awt.Dimension(26, 48)); jSplitPane1.setMinimumSize(new java.awt.Dimension(26, 48));
//jSplitPane1.setDividerLocation(Integer.MAX_VALUE);
//pnlGameInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlGameInfo.setOpaque(false); pnlGameInfo.setOpaque(false);
lblPhase.setLabelFor(txtPhase); lblPhase.setLabelFor(txtPhase);
@ -668,7 +657,6 @@ public class GamePanel extends javax.swing.JPanel {
btnSwitchHandActionPerformed(null); btnSwitchHandActionPerformed(null);
} }
}); });
//btnSwitchHands.setBorder(BorderFactory.createLineBorder(Color.red));
btnStopWatching.setText("Stop Watching"); btnStopWatching.setText("Stop Watching");
btnStopWatching.addActionListener(new java.awt.event.ActionListener() { btnStopWatching.addActionListener(new java.awt.event.ActionListener() {
@ -714,11 +702,11 @@ public class GamePanel extends javax.swing.JPanel {
} }
}); });
javax.swing.GroupLayout pnlReplayLayout = new javax.swing.GroupLayout(pnlReplay); javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
pnlReplay.setLayout(pnlReplayLayout); pnlReplay.setLayout(gl_pnlReplay);
pnlReplayLayout.setHorizontalGroup( gl_pnlReplay.setHorizontalGroup(
pnlReplayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlReplayLayout.createSequentialGroup() .addGroup(gl_pnlReplay.createSequentialGroup()
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
@ -729,8 +717,8 @@ public class GamePanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
); );
pnlReplayLayout.setVerticalGroup( gl_pnlReplay.setVerticalGroup(
pnlReplayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE) .addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE) .addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE) .addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
@ -738,27 +726,11 @@ public class GamePanel extends javax.swing.JPanel {
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE) .addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
); );
javax.swing.GroupLayout pnlGameInfoLayout = new javax.swing.GroupLayout(pnlGameInfo); javax.swing.GroupLayout gl_pnlGameInfo = new javax.swing.GroupLayout(pnlGameInfo);
pnlGameInfo.setLayout(pnlGameInfoLayout); pnlGameInfo.setLayout(gl_pnlGameInfo);
pnlGameInfoLayout.setHorizontalGroup( gl_pnlGameInfo.setHorizontalGroup(
pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_pnlGameInfo.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
/*.addGroup(pnlGameInfoLayout.createSequentialGroup() .addGroup(gl_pnlGameInfo.createSequentialGroup()
.addContainerGap()
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPriority)
.addComponent(lblPhase)
.addComponent(lblStep)
.addComponent(lblTurn)
.addComponent(lblActivePlayer))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtActivePlayer, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
.addComponent(txtPriority, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
.addComponent(txtTurn, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
.addComponent(txtStep, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
.addComponent(txtPhase, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE))
.addContainerGap())*/
.addGroup(pnlGameInfoLayout.createSequentialGroup()
.addGap(10, 10, 10) .addGap(10, 10, 10)
.addComponent(btnConcede) .addComponent(btnConcede)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -769,45 +741,22 @@ public class GamePanel extends javax.swing.JPanel {
.addComponent(bigCard, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE) .addComponent(bigCard, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
.addComponent(feedbackPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE) .addComponent(feedbackPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
.addComponent(stack, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE) .addComponent(stack, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
.addGroup(pnlGameInfoLayout.createSequentialGroup() .addGroup(gl_pnlGameInfo.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(51, Short.MAX_VALUE)) .addContainerGap(51, Short.MAX_VALUE))
); );
pnlGameInfoLayout.setVerticalGroup( gl_pnlGameInfo.setVerticalGroup(
pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_pnlGameInfo.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlGameInfoLayout.createSequentialGroup() .addGroup(gl_pnlGameInfo.createSequentialGroup()
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(1, 1, 1) .addGap(1, 1, 1)
.addComponent(feedbackPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(feedbackPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
/*.addGap(7, 7, 7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPhase)
.addComponent(txtPhase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblStep)
.addComponent(txtStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblTurn)
.addComponent(txtTurn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblActivePlayer)
.addComponent(txtActivePlayer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPriority)
.addComponent(txtPriority, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
*/
.addComponent(stack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(stack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 164, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 164, Short.MAX_VALUE)
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(gl_pnlGameInfo.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnConcede) .addComponent(btnConcede)
.addComponent(btnSwitchHands) .addComponent(btnSwitchHands)
.addComponent(btnStopWatching))) .addComponent(btnStopWatching)))
@ -862,45 +811,39 @@ public class GamePanel extends javax.swing.JPanel {
jPhases.add(endOfTurn); jPhases.add(endOfTurn);
jPhases.add(endButtonTip); jPhases.add(endButtonTip);
//hand.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 20)); // for scroll pnlReplay.setOpaque(false);
hand.setBorder(emptyBorder); HelperPanel helper = new HelperPanel();
hand.setZone(Constants.Zone.HAND.toString()); feedbackPanel.setHelperPanel(helper);
HandContainer handContainer = new HandContainer(hand);
jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane2.setResizeWeight(0.5); jSplitPane2.setResizeWeight(0.5);
jSplitPane2.setLeftComponent(userChatPanel); jSplitPane2.setLeftComponent(userChatPanel);
jSplitPane2.setBottomComponent(gameChatPanel); jSplitPane2.setBottomComponent(gameChatPanel);
// jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM); javax.swing.GroupLayout gl_jPanel3 = new javax.swing.GroupLayout(jPanel3);
// jTabbedPane1.addTab("Game", gameChatPanel); gl_jPanel3.setHorizontalGroup(
// jTabbedPane1.addTab("Chat", userChatPanel); gl_jPanel3.createParallelGroup(Alignment.LEADING)
// jTabbedPane1.setSelectedIndex(1); .addGroup(gl_jPanel3.createSequentialGroup()
.addComponent(pnlGameInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); .addGap(0)
jPanel3.setLayout(jPanel3Layout); .addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
jPanel3Layout.setHorizontalGroup( .addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(pnlGameInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(handContainer, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE)
.addComponent(pnlBattlefield, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE)
.addComponent(jPhases, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE)
))
); );
jPanel3Layout.setVerticalGroup( gl_jPanel3.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_jPanel3.createParallelGroup(Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addGroup(gl_jPanel3.createSequentialGroup()
.addComponent(pnlBattlefield, javax.swing.GroupLayout.DEFAULT_SIZE, 794, Short.MAX_VALUE) .addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)
.addGap(0, 0, 0) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(handContainer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(jPhases, GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(pnlGameInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPhases, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(pnlGameInfo, GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
); );
jPanel3.setLayout(gl_jPanel3);
jPanel3.setMinimumSize(new Dimension(1024, 768)); jPanel3.setMinimumSize(new Dimension(800, 600));
jSplitPane1.setLeftComponent(jPanel3); jSplitPane1.setLeftComponent(jPanel3);
gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48)); gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48));
@ -938,8 +881,7 @@ public class GamePanel extends javax.swing.JPanel {
if (chosenHandKey != null && chosenHandKey.length() > 0) { if (chosenHandKey != null && chosenHandKey.length() > 0) {
this.chosenHandKey = chosenHandKey; this.chosenHandKey = chosenHandKey;
SimpleCardsView cards = handCards.get(chosenHandKey); SimpleCardsView cards = handCards.get(chosenHandKey);
this.hand.loadCards(cards, bigCard, gameId); handContainer.loadCards(cards, bigCard, gameId);
hand.setPreferredSize(new java.awt.Dimension((getHandCardDimension().width + 5) * cards.size() + 5, getHandCardDimension().height + 20)); // for scroll
} }
} }
@ -978,58 +920,6 @@ public class GamePanel extends javax.swing.JPanel {
session.skipForward(gameId, 10); session.skipForward(gameId, 10);
}//GEN-LAST:event_btnSkipForwardActionPerformed }//GEN-LAST:event_btnSkipForwardActionPerformed
private Dimension getHandCardDimension() {
Preferences pref = MageFrame.getPreferences();
String useBigCards = pref.get(PreferencesDialog.KEY_HAND_USE_BIG_CARDS, "false");
if (useBigCards.equals("true")) {
return handCardDimensionBig;
}
return handCardDimension;
}
private class HandContainer extends JPanel {
public HandContainer(Cards hand) {
super();
initComponents(hand);
}
public void initComponents(Cards hand) {
jPanel = new JPanel();
jScrollPane1 = new JScrollPane(jPanel);
jScrollPane1.getViewport().setBackground(new Color(0,0,0,0));
jPanel.setLayout(new GridBagLayout()); // centers hand
jPanel.setBackground(new Color(0,0,0,0));
jPanel.add(hand);
HelperPanel helper = new HelperPanel();
//helper.setBackground(new Color(0, 0, 0, 80));
//helper.setPreferredSize(new Dimension(0, 35));
//feedbackPanel.setPreferredSize(new Dimension(0, 70));
setOpaque(false);
jPanel.setOpaque(false);
jScrollPane1.setOpaque(false);
pnlReplay.setOpaque(false);
jPanel.setBorder(emptyBorder);
jScrollPane1.setBorder(emptyBorder);
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(8);
setLayout(new BorderLayout());
add(jScrollPane1, BorderLayout.CENTER);
//add(helper, BorderLayout.PAGE_END);
//add(feedbackPanel, BorderLayout.PAGE_END);
feedbackPanel.setHelperPanel(helper);
}
private JPanel jPanel;
private javax.swing.JScrollPane jScrollPane1;
}
public void setJLayeredPane(JLayeredPane jLayeredPane) { public void setJLayeredPane(JLayeredPane jLayeredPane) {
this.jLayeredPane = jLayeredPane; this.jLayeredPane = jLayeredPane;
} }
@ -1070,15 +960,12 @@ public class GamePanel extends javax.swing.JPanel {
private javax.swing.JLabel txtPriority; private javax.swing.JLabel txtPriority;
private javax.swing.JLabel txtStep; private javax.swing.JLabel txtStep;
private javax.swing.JLabel txtTurn; private javax.swing.JLabel txtTurn;
// End of variables declaration//GEN-END:variables
private mage.client.cards.Cards hand;
private Map<String, SimpleCardsView> handCards; private Map<String, SimpleCardsView> handCards;
private mage.client.cards.Cards stack; private mage.client.cards.Cards stack;
private HandPanel handContainer;
// private JTabbedPane jTabbedPane1;
private javax.swing.JSplitPane jSplitPane2; private javax.swing.JSplitPane jSplitPane2;
private Border emptyBorder = new EmptyBorder(0,0,0,0);
private Color prevBGColor; private Color prevBGColor;
private final static Color DEFAULT_FOREGROUND_COLOR = Color.BLACK; private final static Color DEFAULT_FOREGROUND_COLOR = Color.BLACK;
private JPanel jPhases; private JPanel jPhases;

View file

@ -0,0 +1,90 @@
package mage.client.game;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.util.UUID;
import java.util.prefs.Preferences;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import mage.Constants;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.Config;
import mage.view.SimpleCardsView;
public class HandPanel extends JPanel {
private static final int CARD_WIDTH = 75;
private Dimension handCardDimensionBig;
private Dimension handCardDimension;
public HandPanel() {
double factor = 1;
sizeHand(factor);
initComponents();
}
public void initComponents() {
hand = new mage.client.cards.Cards(true);
hand.setCardDimension(getHandCardDimension());
jPanel = new JPanel();
jScrollPane1 = new JScrollPane(jPanel);
jScrollPane1.getViewport().setBackground(new Color(0,0,0,0));
jPanel.setLayout(new GridBagLayout()); // centers hand
jPanel.setBackground(new Color(0,0,0,0));
jPanel.add(hand);
setOpaque(false);
jPanel.setOpaque(false);
jScrollPane1.setOpaque(false);
jPanel.setBorder(emptyBorder);
jScrollPane1.setBorder(emptyBorder);
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(8);
setLayout(new BorderLayout());
add(jScrollPane1, BorderLayout.CENTER);
hand.setHScrollSpeed(8);
hand.setBackgroundColor(new Color(0, 0, 0, 100));
hand.setVisibleIfEmpty(false);
hand.setBorder(emptyBorder);
hand.setZone(Constants.Zone.HAND.toString());
}
public void loadCards(SimpleCardsView cards, BigCard bigCard, UUID gameId) {
hand.loadCards(cards, bigCard, gameId);
hand.setPreferredSize(new java.awt.Dimension((getHandCardDimension().width + 5) * cards.size() + 5, getHandCardDimension().height + 20)); // for scroll
}
private Dimension getHandCardDimension() {
Preferences pref = MageFrame.getPreferences();
String useBigCards = pref.get(PreferencesDialog.KEY_HAND_USE_BIG_CARDS, "false");
if (useBigCards.equals("true")) {
return handCardDimensionBig;
}
return handCardDimension;
}
public void sizeHand(double factor) {
int width = (int)(factor * CARD_WIDTH);
handCardDimension = new Dimension(CARD_WIDTH, (int)(CARD_WIDTH * 3.5f / 2.5f));
handCardDimensionBig = new Dimension(CARD_WIDTH, (int)(width * 3.5f / 2.5f));
}
private JPanel jPanel;
private javax.swing.JScrollPane jScrollPane1;
private Border emptyBorder = new EmptyBorder(0,0,0,0);
private mage.client.cards.Cards hand;
}

View file

@ -49,6 +49,8 @@ import mage.view.PlayerView;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
/** /**
* *
@ -60,8 +62,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
UUID gameId; UUID gameId;
/** Creates new form PlayAreaPanel */ /** Creates new form PlayAreaPanel */
public PlayAreaPanel(boolean me) { public PlayAreaPanel() {
initComponents(me); initComponents();
setOpaque(false); setOpaque(false);
jPanel1.setOpaque(false); jPanel1.setOpaque(false);
jScrollPane1.setOpaque(false); jScrollPane1.setOpaque(false);
@ -70,7 +72,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
} }
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) { public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) {
this(me); this();
init(player, bigCard, gameId); init(player, bigCard, gameId);
update(player); update(player);
} }
@ -97,25 +99,16 @@ public class PlayAreaPanel extends javax.swing.JPanel {
return battlefieldPanel; return battlefieldPanel;
} }
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {
private void initComponents(boolean me) {
setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0))); setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0)));
jPanel1 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel();
playerPanel = new PlayerPanelExt(me); playerPanel = new PlayerPanelExt();
playerPanel.setPreferredSize(new Dimension(92, 250)); playerPanel.setPreferredSize(new Dimension(92, 212));
//manaPool = new mage.client.game.ManaPool();
btnCheat = new javax.swing.JButton(); btnCheat = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
battlefieldPanel = new mage.client.game.BattlefieldPanel(jScrollPane1); battlefieldPanel = new mage.client.game.BattlefieldPanel(jScrollPane1);
//jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
btnCheat.setText("Cheat"); btnCheat.setText("Cheat");
btnCheat.addActionListener(new java.awt.event.ActionListener() { btnCheat.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -123,24 +116,18 @@ public class PlayAreaPanel extends javax.swing.JPanel {
} }
}); });
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout gl_jPanel1 = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); gl_jPanel1.setHorizontalGroup(
jPanel1Layout.setHorizontalGroup( gl_jPanel1.createParallelGroup(Alignment.LEADING)
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(playerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//.addComponent(manaPool, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
.addComponent(playerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//.addComponent(btnCheat, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
); );
jPanel1Layout.setVerticalGroup( gl_jPanel1.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_jPanel1.createParallelGroup(Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(gl_jPanel1.createSequentialGroup()
.addComponent(playerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, 212, Short.MAX_VALUE)
//.addGap(0, 0, 0) .addContainerGap())
//.addComponent(manaPool, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
//.addComponent(btnCheat)
)
); );
jPanel1.setLayout(gl_jPanel1);
jScrollPane1.setViewportView(battlefieldPanel); jScrollPane1.setViewportView(battlefieldPanel);
Border empty = new EmptyBorder(0,0,0,0); Border empty = new EmptyBorder(0,0,0,0);
@ -148,22 +135,29 @@ public class PlayAreaPanel extends javax.swing.JPanel {
jScrollPane1.setViewportBorder(empty); jScrollPane1.setViewportBorder(empty);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)
) .addGap(0))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(Alignment.TRAILING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE) .addGroup(Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(Alignment.TRAILING)
.addComponent(jScrollPane1)
.addComponent(jPanel1, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE))
.addGap(0))
); );
this.setLayout(layout);
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
public void sizePlayer() {
this.playerPanel.sizePlayerPanel();
}
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
try { try {
MageFrame.getSession().cheat(gameId, playerId, Sets.loadDeck("cheat.dck")); MageFrame.getSession().cheat(gameId, playerId, Sets.loadDeck("cheat.dck"));

View file

@ -69,6 +69,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.GroupLayout.Alignment;
/** /**
* Enhanced player pane. * Enhanced player pane.
@ -96,8 +97,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private int avatarId = -1; private int avatarId = -1;
/** Creates new form PlayerPanel */ /** Creates new form PlayerPanel */
public PlayerPanelExt(boolean me) { public PlayerPanelExt() {
initComponents(me); initComponents();
} }
public void init(UUID gameId, UUID playerId, BigCard bigCard) { public void init(UUID gameId, UUID playerId, BigCard bigCard) {
@ -116,6 +117,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
libraryLabel.setText(Integer.toString(player.getLibraryCount())); libraryLabel.setText(Integer.toString(player.getLibraryCount()));
graveLabel.setText(Integer.toString(player.getGraveyard().size())); graveLabel.setText(Integer.toString(player.getGraveyard().size()));
if (!MageFrame.isLite()) {
int id = player.getUserData().getAvatarId(); int id = player.getUserData().getAvatarId();
if (id > 0 && id != avatarId) { if (id > 0 && id != avatarId) {
avatarId = id; avatarId = id;
@ -131,7 +133,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
this.avatar.update("player", resized, resized, resized, resized, r); this.avatar.update("player", resized, resized, resized, resized, r);
} }
}
this.avatar.setText(player.getName()); this.avatar.setText(player.getName());
if (player.isActive()) { if (player.isActive()) {
this.avatar.setBorder(greenBorder); this.avatar.setBorder(greenBorder);
@ -178,74 +180,71 @@ public class PlayerPanelExt extends javax.swing.JPanel {
* always regenerated by the Form Editor. * always regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {
private void initComponents(boolean me) {
setLayout(null);
setOpaque(false);
panelBackground = new MageRoundPane(); panelBackground = new MageRoundPane();
Rectangle r = new Rectangle(80, 80);
lifeLabel = new JLabel();
handLabel = new JLabel();
poisonLabel = new JLabel();
libraryLabel = new JLabel();
setOpaque(false);
panelBackground.setXOffset(3); panelBackground.setXOffset(3);
panelBackground.setYOffset(3); panelBackground.setYOffset(3);
panelBackground.setLayout(null);
panelBackground.setVisible(true); panelBackground.setVisible(true);
panelBackground.setBounds(0, 0, 92, 250);
add(panelBackground);
Rectangle r = new Rectangle(80, 80);
Image image = ImageHelper.getImageFromResources("/avatars/unknown.jpg");
topCardPanel = Plugins.getInstance().getMageCard(new CardView(Sets.findCard("Forest")), bigCard, topCardDimension, gameId, true);
topCardPanel.setVisible(false);
panelBackground.add(topCardPanel);
// Avatar // Avatar
Image image = ImageHelper.getImageFromResources("/avatars/unknown.jpg");
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
avatar = new HoverButton("player", resized, resized, resized, r); avatar = new HoverButton("player", resized, resized, resized, r);
avatar.setBounds(6, 6, r.width, r.height);
panelBackground.add(avatar);
avatar.setObserver(new Command() { avatar.setObserver(new Command() {
@Override @Override
public void execute() { public void execute() {
session.sendPlayerUUID(gameId, playerId); session.sendPlayerUUID(gameId, playerId);
} }
}); });
// Life count
lifeLabel = new JLabel();
lifeLabel.setBounds(30, 82, 30, 30);
r = new Rectangle(18, 18); r = new Rectangle(18, 18);
life = (ImagePanel)addParam(panelBackground, "Life", lifeLabel, r, "/info/life.png", false); lifeLabel.setToolTipText("Life");
life.setBounds(9, 90, r.width, r.height); Image imageLife = ImageHelper.getImageFromResources("/info/life.png");
BufferedImage resizedLife = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLife, BufferedImage.TYPE_INT_ARGB), r);
// Hand count life = new ImagePanel(resizedLife, ImagePanel.ACTUAL);
handLabel = new JLabel(); life.setToolTipText("Life");
handLabel.setBounds(70, 82, 50, 30); life.setOpaque(false);
r = new Rectangle(18, 18); r = new Rectangle(18, 18);
hand = (ImagePanel)addParam(panelBackground, "Hand", handLabel, r, "/info/hand.png", false); handLabel.setToolTipText("Hand");
hand.setBounds(48, 90, r.width, r.height); Image imageHand = ImageHelper.getImageFromResources("/info/hand.png");
BufferedImage resizedHand = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageHand, BufferedImage.TYPE_INT_ARGB), r);
hand = new ImagePanel(resizedHand, ImagePanel.ACTUAL);
hand.setToolTipText("Hand");
hand.setOpaque(false);
// Poison count // Poison count
poisonLabel = new JLabel();
poisonLabel.setText("0"); poisonLabel.setText("0");
poisonLabel.setBounds(30, 112, 20, 20);
//poisonLabel.setBorder(greenBorder);
r = new Rectangle(14, 14); r = new Rectangle(14, 14);
poison = (ImagePanel)addParam(panelBackground, "Poison", poisonLabel, r, "/info/poison.png", false); poisonLabel.setToolTipText("Poison");
poison.setBounds(12, 116, r.width, r.height); Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png");
BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r);
// Library count poison = new ImagePanel(resizedPoison, ImagePanel.ACTUAL);
libraryLabel = new JLabel(); poison.setToolTipText("Poison");
libraryLabel.setBounds(70, 107, 30, 30); poison.setOpaque(false);
r = new Rectangle(19, 19); r = new Rectangle(19, 19);
library = (ImagePanel)addParam(panelBackground, "Library", libraryLabel, r, "/info/library.png", false); libraryLabel.setToolTipText("Library");
library.setBounds(48, 113, r.width, r.height); Image imageLibrary = ImageHelper.getImageFromResources("/info/library.png");
BufferedImage resizedLibrary = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLibrary, BufferedImage.TYPE_INT_ARGB), r);
library = new ImagePanel(resizedLibrary, ImagePanel.ACTUAL);
library.setToolTipText("Library");
library.setOpaque(false);
// Grave count and open graveyard button // Grave count and open graveyard button
graveLabel = new JLabel(); graveLabel = new JLabel();
r = new Rectangle(21, 21); r = new Rectangle(21, 21);
graveLabel.setBounds(35, 250 - r.height - 5, r.width, r.height); graveLabel.setToolTipText("Graveyard");
grave = (HoverButton)addParam(panelBackground, "Graveyard", graveLabel, r, "/info/grave.png", true); Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png");
grave.setBounds(9, 250 - r.height - 5, r.width, r.height); BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r);
grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r);
grave.setToolTipText("Graveyard");
grave.setOpaque(false);
grave.setObserver(new Command() { grave.setObserver(new Command() {
@Override @Override
public void execute() { public void execute() {
@ -259,8 +258,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
cheat = new JButton(); cheat = new JButton();
cheat.setIcon(new ImageIcon(resized)); cheat.setIcon(new ImageIcon(resized));
panelBackground.add(cheat);
cheat.setBounds(55, 250 - r.height - 5, r.width, r.height);
cheat.setToolTipText("Cheat button"); cheat.setToolTipText("Cheat button");
cheat.addActionListener(new ActionListener() { cheat.addActionListener(new ActionListener() {
@Override @Override
@ -270,29 +267,226 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}); });
// Add mana symbols // Add mana symbols
addManaImagePanel("W", new Rectangle(11, 140, 15, 15), panelBackground); BufferedImage imageManaW = ManaSymbols.getManaSymbolImageSmall("W");
addManaImagePanel("U", new Rectangle(11, 160, 15, 15), panelBackground); ImagePanel manaW = new ImagePanel(imageManaW, ImagePanel.ACTUAL);
addManaImagePanel("B", new Rectangle(11, 180, 15, 15), panelBackground); manaW.setOpaque(false);
addManaImagePanel("R", new Rectangle(50, 140, 15, 15), panelBackground); JLabel manaCountLabelW = new JLabel();
addManaImagePanel("G", new Rectangle(50, 160, 15, 15), panelBackground); manaCountLabelW.setText("0");
addManaImagePanel("X", new Rectangle(50, 180, 15, 15), panelBackground); manaLabels.put("W", manaCountLabelW);
BufferedImage imageManaU = ManaSymbols.getManaSymbolImageSmall("U");
ImagePanel manaU = new ImagePanel(imageManaU, ImagePanel.ACTUAL);
manaU.setOpaque(false);
JLabel manaCountLabelU = new JLabel();
manaCountLabelU.setText("0");
manaLabels.put("U", manaCountLabelU);
BufferedImage imageManaB = ManaSymbols.getManaSymbolImageSmall("B");
ImagePanel manaB = new ImagePanel(imageManaB, ImagePanel.ACTUAL);
manaB.setOpaque(false);
JLabel manaCountLabelB = new JLabel();
manaCountLabelB.setText("0");
manaLabels.put("B", manaCountLabelB);
BufferedImage imageManaR = ManaSymbols.getManaSymbolImageSmall("R");
ImagePanel manaR = new ImagePanel(imageManaR, ImagePanel.ACTUAL);
manaR.setOpaque(false);
JLabel manaCountLabelR = new JLabel();
manaCountLabelR.setText("0");
manaLabels.put("R", manaCountLabelR);
BufferedImage imageManaG = ManaSymbols.getManaSymbolImageSmall("G");
ImagePanel manaG = new ImagePanel(imageManaG, ImagePanel.ACTUAL);
manaG.setOpaque(false);
JLabel manaCountLabelG = new JLabel();
manaCountLabelG.setText("0");
manaLabels.put("G", manaCountLabelG);
BufferedImage imageManaX = ManaSymbols.getManaSymbolImageSmall("X");
ImagePanel manaX = new ImagePanel(imageManaX, ImagePanel.ACTUAL);
manaX.setOpaque(false);
JLabel manaCountLabelX = new JLabel();
manaCountLabelX.setText("0");
manaLabels.put("X", manaCountLabelX);
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
gl_panelBackground.setHorizontalGroup(
gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(9)
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
.addGap(3)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(4)
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(9)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(3)
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(manaW, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(manaU, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(manaB, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(20)
.addComponent(manaR, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
.addGap(3)
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(19)
.addComponent(manaX, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)))
.addGap(5)
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(20)
.addComponent(manaG, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(5)
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
);
gl_panelBackground.setVerticalGroup(
gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
.addGap(3)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(1)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(4)
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
.addGap(4)
.addComponent(manaW, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(2)
.addComponent(manaU, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(2)
.addComponent(manaB, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(5)
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(2)
.addComponent(manaR, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(14)
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(14)
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
.addGap(4)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(8)
.addComponent(manaX, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(39)
.addComponent(manaG, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(31)
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(31)
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
);
panelBackground.setLayout(gl_panelBackground);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, 92, GroupLayout.PREFERRED_SIZE)
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, 212, GroupLayout.PREFERRED_SIZE)
);
setLayout(groupLayout);
} }
private void addManaImagePanel(String mana, Rectangle rect, JPanel container) { public void sizePlayerPanel() {
BufferedImage imageMana = ManaSymbols.getManaSymbolImageSmall(mana); Dimension r = new Dimension(60, 60);
if (imageMana != null) { this.avatar.setSize(r);
ImagePanel manaB = new ImagePanel(imageMana, ImagePanel.ACTUAL); this.avatar.setPreferredSize(r);
manaB.setBounds(rect.x, rect.y, rect.width, rect.height);
manaB.setOpaque(false);
container.add(manaB);
}
JLabel manaCountLabel = new JLabel();
manaCountLabel.setText("0");
manaCountLabel.setBounds(rect.x + rect.width + 5, rect.y - 8, 30, 30);
container.add(manaCountLabel);
manaLabels.put(mana, manaCountLabel);
} }
// private void addManaImagePanel(String mana, Rectangle rect, JPanel container) {
// BufferedImage imageMana = ManaSymbols.getManaSymbolImageSmall(mana);
// if (imageMana != null) {
// ImagePanel manaB = new ImagePanel(imageMana, ImagePanel.ACTUAL);
// manaB.setBounds(rect.x, rect.y, rect.width, rect.height);
// manaB.setOpaque(false);
// container.add(manaB);
// }
// JLabel manaCountLabel = new JLabel();
// manaCountLabel.setText("0");
// manaCountLabel.setBounds(rect.x + rect.width + 5, rect.y - 8, 30, 30);
// container.add(manaCountLabel);
// manaLabels.put(mana, manaCountLabel);
// }
/** /**
* Adds image panel and label to the container panel. * Adds image panel and label to the container panel.
* *
@ -302,27 +496,27 @@ public class PlayerPanelExt extends javax.swing.JPanel {
* @param imagePath * @param imagePath
* @return * @return
*/ */
private JComponent addParam(JPanel containerPanel, String tooltip, JLabel text, Rectangle r, String imagePath, boolean isButton) { // private JComponent addParam(JPanel containerPanel, String tooltip, JLabel text, Rectangle r, String imagePath, boolean isButton) {
if (text != null) { // if (text != null) {
text.setForeground(Color.black); // text.setForeground(Color.black);
containerPanel.add(text); // containerPanel.add(text);
text.setToolTipText(tooltip); // text.setToolTipText(tooltip);
} // }
//
Image image = ImageHelper.getImageFromResources(imagePath); // Image image = ImageHelper.getImageFromResources(imagePath);
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); // BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
JComponent component = null; // JComponent component = null;
if (isButton) { // if (isButton) {
component = new HoverButton(null, resized, resized, resized, r); // component = new HoverButton(null, resized, resized, resized, r);
} else { // } else {
component = new ImagePanel(resized, ImagePanel.ACTUAL); // component = new ImagePanel(resized, ImagePanel.ACTUAL);
} // }
component.setToolTipText(tooltip); // component.setToolTipText(tooltip);
component.setOpaque(false); // component.setOpaque(false);
containerPanel.add(component); // containerPanel.add(component);
//
return component; // return component;
} // }
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
if (graveyard == null) { if (graveyard == null) {