1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-10 01:01:05 -09:00

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();
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));

View file

@ -77,13 +77,7 @@ public class GamePane extends MagePane {
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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
@ -95,20 +89,20 @@ public class GamePane extends MagePane {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
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.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();
}// </editor-fold>//GEN-END:initComponents
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.game.GamePanel gamePanel;
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.prefs.Preferences;
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 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 */
public GamePanel() {
initComponents();
hand.setHScrollSpeed(8);
hand.setBackgroundColor(new Color(0, 0, 0, 100));
hand.setVisibleIfEmpty(false);
combat = new CombatDialog();
pickNumber = new PickNumberDialog();
MageFrame.getDesktop().add(combat, JLayeredPane.POPUP_LAYER);
@ -156,7 +143,7 @@ public class GamePanel extends javax.swing.JPanel {
components.put("jSplitPane1", jSplitPane1);
components.put("pnlBattlefield", pnlBattlefield);
components.put("jPanel3", jPanel3);
components.put("hand", hand);
components.put("hand", handContainer);
components.put("gameChatPanel", gameChatPanel);
components.put("userChatPanel", userChatPanel);
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) {
this.gameId = gameId;
this.playerId = playerId;
@ -202,6 +205,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameChatPanel.connect(session.getGameChatId(gameId));
if (!session.joinGame(gameId))
hideGame();
sizeToScreen();
}
public synchronized void watchGame(UUID gameId) {
@ -219,6 +223,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameChatPanel.connect(session.getGameChatId(gameId));
if (!session.watchGame(gameId))
hideGame();
sizeToScreen();
}
public synchronized void replayGame(UUID gameId) {
@ -235,6 +240,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameChatPanel.clear();
if (!session.startReplay(gameId))
hideGame();
sizeToScreen();
}
public void hideGame() {
@ -321,7 +327,7 @@ public class GamePanel extends javax.swing.JPanel {
public synchronized void updateGame(GameView game) {
if (playerId == null || game.getHand() == null) {
this.hand.setVisible(false);
this.handContainer.setVisible(false);
} else {
handCards.clear();
handCards.put(YOUR_HAND, game.getHand());
@ -336,8 +342,7 @@ public class GamePanel extends javax.swing.JPanel {
if (!handCards.containsKey(chosenHandKey)) {
chosenHandKey = YOUR_HAND;
}
this.hand.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
hand.setPreferredSize(new java.awt.Dimension((getHandCardDimension().width + 5) * game.getHand().size() + 5, getHandCardDimension().height + 20)); // for scroll
handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
// set visible only if we have any other hand visible than ours
boolean previous = btnSwitchHands.isVisible();
@ -547,21 +552,9 @@ public class GamePanel extends javax.swing.JPanel {
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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// </editor-fold>//GEN-END:initComponents
private void initComponents() {
//abilityPicker = new mage.client.game.AbilityPicker();
abilityPicker = new mage.client.components.ability.AbilityPicker();
jSplitPane1 = new javax.swing.JSplitPane();
jPanel3 = new javax.swing.JPanel();
@ -589,7 +582,6 @@ public class GamePanel extends javax.swing.JPanel {
btnSkipForward = new javax.swing.JButton();
btnPreviousPlay = new javax.swing.JButton();
pnlBattlefield = new javax.swing.JPanel();
hand = new mage.client.cards.Cards(true);
gameChatPanel = new mage.client.chat.ChatPanel();
gameChatPanel.useExtendedView(ChatPanel.VIEW_MODE.GAME);
userChatPanel = new mage.client.chat.ChatPanel();
@ -597,10 +589,9 @@ public class GamePanel extends javax.swing.JPanel {
userChatPanel.useExtendedView(ChatPanel.VIEW_MODE.CHAT);
gameChatPanel.setConnectedChat(userChatPanel);
gameChatPanel.disableInput();
// jTabbedPane1 = new JTabbedPane();
jSplitPane2 = new javax.swing.JSplitPane();
handContainer = new HandPanel();
hand.setCardDimension(getHandCardDimension());
handCards = new HashMap<String, SimpleCardsView>();
jSplitPane1.setBorder(null);
@ -608,8 +599,6 @@ public class GamePanel extends javax.swing.JPanel {
jSplitPane1.setResizeWeight(1.0);
jSplitPane1.setOneTouchExpandable(true);
jSplitPane1.setMinimumSize(new java.awt.Dimension(26, 48));
//jSplitPane1.setDividerLocation(Integer.MAX_VALUE);
//pnlGameInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlGameInfo.setOpaque(false);
lblPhase.setLabelFor(txtPhase);
@ -668,7 +657,6 @@ public class GamePanel extends javax.swing.JPanel {
btnSwitchHandActionPerformed(null);
}
});
//btnSwitchHands.setBorder(BorderFactory.createLineBorder(Color.red));
btnStopWatching.setText("Stop Watching");
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);
pnlReplay.setLayout(pnlReplayLayout);
pnlReplayLayout.setHorizontalGroup(
pnlReplayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlReplayLayout.createSequentialGroup()
javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
pnlReplay.setLayout(gl_pnlReplay);
gl_pnlReplay.setHorizontalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(gl_pnlReplay.createSequentialGroup()
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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)
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pnlReplayLayout.setVerticalGroup(
pnlReplayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
gl_pnlReplay.setVerticalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
.addComponent(btnNextPlay, 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)
);
javax.swing.GroupLayout pnlGameInfoLayout = new javax.swing.GroupLayout(pnlGameInfo);
pnlGameInfo.setLayout(pnlGameInfoLayout);
pnlGameInfoLayout.setHorizontalGroup(
pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
/*.addGroup(pnlGameInfoLayout.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()
javax.swing.GroupLayout gl_pnlGameInfo = new javax.swing.GroupLayout(pnlGameInfo);
pnlGameInfo.setLayout(gl_pnlGameInfo);
gl_pnlGameInfo.setHorizontalGroup(
gl_pnlGameInfo.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(gl_pnlGameInfo.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(btnConcede)
.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(feedbackPanel, 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()
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(51, Short.MAX_VALUE))
);
pnlGameInfoLayout.setVerticalGroup(
pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlGameInfoLayout.createSequentialGroup()
gl_pnlGameInfo.setVerticalGroup(
gl_pnlGameInfo.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(gl_pnlGameInfo.createSequentialGroup()
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(1, 1, 1)
.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)
.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)
.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(btnSwitchHands)
.addComponent(btnStopWatching)))
@ -862,45 +811,39 @@ public class GamePanel extends javax.swing.JPanel {
jPhases.add(endOfTurn);
jPhases.add(endButtonTip);
//hand.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 20)); // for scroll
hand.setBorder(emptyBorder);
hand.setZone(Constants.Zone.HAND.toString());
HandContainer handContainer = new HandContainer(hand);
pnlReplay.setOpaque(false);
HelperPanel helper = new HelperPanel();
feedbackPanel.setHelperPanel(helper);
jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane2.setResizeWeight(0.5);
jSplitPane2.setLeftComponent(userChatPanel);
jSplitPane2.setBottomComponent(gameChatPanel);
// jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
// jTabbedPane1.addTab("Game", gameChatPanel);
// jTabbedPane1.addTab("Chat", userChatPanel);
// jTabbedPane1.setSelectedIndex(1);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.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)
))
javax.swing.GroupLayout gl_jPanel3 = new javax.swing.GroupLayout(jPanel3);
gl_jPanel3.setHorizontalGroup(
gl_jPanel3.createParallelGroup(Alignment.LEADING)
.addGroup(gl_jPanel3.createSequentialGroup()
.addComponent(pnlGameInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(0)
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(pnlBattlefield, javax.swing.GroupLayout.DEFAULT_SIZE, 794, Short.MAX_VALUE)
.addGap(0, 0, 0)
.addComponent(handContainer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPhases, GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(pnlGameInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
gl_jPanel3.setVerticalGroup(
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_jPanel3.createSequentialGroup()
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.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);
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) {
this.chosenHandKey = chosenHandKey;
SimpleCardsView cards = handCards.get(chosenHandKey);
this.hand.loadCards(cards, bigCard, gameId);
hand.setPreferredSize(new java.awt.Dimension((getHandCardDimension().width + 5) * cards.size() + 5, getHandCardDimension().height + 20)); // for scroll
handContainer.loadCards(cards, bigCard, gameId);
}
}
@ -978,58 +920,6 @@ public class GamePanel extends javax.swing.JPanel {
session.skipForward(gameId, 10);
}//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) {
this.jLayeredPane = jLayeredPane;
}
@ -1070,15 +960,12 @@ public class GamePanel extends javax.swing.JPanel {
private javax.swing.JLabel txtPriority;
private javax.swing.JLabel txtStep;
private javax.swing.JLabel txtTurn;
// End of variables declaration//GEN-END:variables
private mage.client.cards.Cards hand;
private Map<String, SimpleCardsView> handCards;
private mage.client.cards.Cards stack;
// private JTabbedPane jTabbedPane1;
private HandPanel handContainer;
private javax.swing.JSplitPane jSplitPane2;
private Border emptyBorder = new EmptyBorder(0,0,0,0);
private Color prevBGColor;
private final static Color DEFAULT_FOREGROUND_COLOR = Color.BLACK;
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.border.Border;
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;
/** Creates new form PlayAreaPanel */
public PlayAreaPanel(boolean me) {
initComponents(me);
public PlayAreaPanel() {
initComponents();
setOpaque(false);
jPanel1.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) {
this(me);
this();
init(player, bigCard, gameId);
update(player);
}
@ -97,25 +99,16 @@ public class PlayAreaPanel extends javax.swing.JPanel {
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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents(boolean me) {
private void initComponents() {
setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0)));
jPanel1 = new javax.swing.JPanel();
playerPanel = new PlayerPanelExt(me);
playerPanel.setPreferredSize(new Dimension(92, 250));
//manaPool = new mage.client.game.ManaPool();
playerPanel = new PlayerPanelExt();
playerPanel.setPreferredSize(new Dimension(92, 212));
btnCheat = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
battlefieldPanel = new mage.client.game.BattlefieldPanel(jScrollPane1);
//jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
btnCheat.setText("Cheat");
btnCheat.addActionListener(new java.awt.event.ActionListener() {
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);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//.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)
javax.swing.GroupLayout gl_jPanel1 = new javax.swing.GroupLayout(jPanel1);
gl_jPanel1.setHorizontalGroup(
gl_jPanel1.createParallelGroup(Alignment.LEADING)
.addComponent(playerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(playerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//.addGap(0, 0, 0)
//.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)
)
gl_jPanel1.setVerticalGroup(
gl_jPanel1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_jPanel1.createSequentialGroup()
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, 212, Short.MAX_VALUE)
.addContainerGap())
);
jPanel1.setLayout(gl_jPanel1);
jScrollPane1.setViewportView(battlefieldPanel);
Border empty = new EmptyBorder(0,0,0,0);
@ -148,22 +135,29 @@ public class PlayAreaPanel extends javax.swing.JPanel {
jScrollPane1.setViewportBorder(empty);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE)
)
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)
.addGap(0))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
layout.createParallelGroup(Alignment.TRAILING)
.addGroup(Alignment.LEADING, layout.createSequentialGroup()
.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
public void sizePlayer() {
this.playerPanel.sizePlayerPanel();
}
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
try {
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.logging.Level;
import java.util.logging.Logger;
import javax.swing.GroupLayout.Alignment;
/**
* Enhanced player pane.
@ -96,8 +97,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private int avatarId = -1;
/** Creates new form PlayerPanel */
public PlayerPanelExt(boolean me) {
initComponents(me);
public PlayerPanelExt() {
initComponents();
}
public void init(UUID gameId, UUID playerId, BigCard bigCard) {
@ -116,22 +117,23 @@ public class PlayerPanelExt extends javax.swing.JPanel {
libraryLabel.setText(Integer.toString(player.getLibraryCount()));
graveLabel.setText(Integer.toString(player.getGraveyard().size()));
int id = player.getUserData().getAvatarId();
if (id > 0 && id != avatarId) {
avatarId = id;
String path = "/avatars/" + String.valueOf(avatarId) + ".jpg";
if (avatarId == 64) {
path = "/avatars/i64.jpg";
} else if (avatarId >= 1000) {
avatarId = avatarId - 1000;
path = "/avatars/special/" + String.valueOf(avatarId) + ".gif";
}
Image image = ImageHelper.getImageFromResources(path);
Rectangle r = new Rectangle(80, 80);
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
this.avatar.update("player", resized, resized, resized, resized, r);
}
if (!MageFrame.isLite()) {
int id = player.getUserData().getAvatarId();
if (id > 0 && id != avatarId) {
avatarId = id;
String path = "/avatars/" + String.valueOf(avatarId) + ".jpg";
if (avatarId == 64) {
path = "/avatars/i64.jpg";
} else if (avatarId >= 1000) {
avatarId = avatarId - 1000;
path = "/avatars/special/" + String.valueOf(avatarId) + ".gif";
}
Image image = ImageHelper.getImageFromResources(path);
Rectangle r = new Rectangle(80, 80);
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
this.avatar.update("player", resized, resized, resized, resized, r);
}
}
this.avatar.setText(player.getName());
if (player.isActive()) {
this.avatar.setBorder(greenBorder);
@ -178,74 +180,71 @@ public class PlayerPanelExt extends javax.swing.JPanel {
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents(boolean me) {
setLayout(null);
private void initComponents() {
panelBackground = new MageRoundPane();
Rectangle r = new Rectangle(80, 80);
lifeLabel = new JLabel();
handLabel = new JLabel();
poisonLabel = new JLabel();
libraryLabel = new JLabel();
setOpaque(false);
panelBackground = new MageRoundPane();
panelBackground.setXOffset(3);
panelBackground.setYOffset(3);
panelBackground.setLayout(null);
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
Image image = ImageHelper.getImageFromResources("/avatars/unknown.jpg");
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
avatar = new HoverButton("player", resized, resized, resized, r);
avatar.setBounds(6, 6, r.width, r.height);
panelBackground.add(avatar);
avatar.setObserver(new Command() {
@Override
public void execute() {
session.sendPlayerUUID(gameId, playerId);
}
});
// Life count
lifeLabel = new JLabel();
lifeLabel.setBounds(30, 82, 30, 30);
r = new Rectangle(18, 18);
life = (ImagePanel)addParam(panelBackground, "Life", lifeLabel, r, "/info/life.png", false);
life.setBounds(9, 90, r.width, r.height);
// Hand count
handLabel = new JLabel();
handLabel.setBounds(70, 82, 50, 30);
lifeLabel.setToolTipText("Life");
Image imageLife = ImageHelper.getImageFromResources("/info/life.png");
BufferedImage resizedLife = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLife, BufferedImage.TYPE_INT_ARGB), r);
life = new ImagePanel(resizedLife, ImagePanel.ACTUAL);
life.setToolTipText("Life");
life.setOpaque(false);
r = new Rectangle(18, 18);
hand = (ImagePanel)addParam(panelBackground, "Hand", handLabel, r, "/info/hand.png", false);
hand.setBounds(48, 90, r.width, r.height);
handLabel.setToolTipText("Hand");
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
poisonLabel = new JLabel();
poisonLabel.setText("0");
poisonLabel.setBounds(30, 112, 20, 20);
//poisonLabel.setBorder(greenBorder);
r = new Rectangle(14, 14);
poison = (ImagePanel)addParam(panelBackground, "Poison", poisonLabel, r, "/info/poison.png", false);
poison.setBounds(12, 116, r.width, r.height);
// Library count
libraryLabel = new JLabel();
libraryLabel.setBounds(70, 107, 30, 30);
poisonLabel.setToolTipText("Poison");
Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png");
BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r);
poison = new ImagePanel(resizedPoison, ImagePanel.ACTUAL);
poison.setToolTipText("Poison");
poison.setOpaque(false);
r = new Rectangle(19, 19);
library = (ImagePanel)addParam(panelBackground, "Library", libraryLabel, r, "/info/library.png", false);
library.setBounds(48, 113, r.width, r.height);
libraryLabel.setToolTipText("Library");
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
graveLabel = new JLabel();
r = new Rectangle(21, 21);
graveLabel.setBounds(35, 250 - r.height - 5, r.width, r.height);
grave = (HoverButton)addParam(panelBackground, "Graveyard", graveLabel, r, "/info/grave.png", true);
grave.setBounds(9, 250 - r.height - 5, r.width, r.height);
graveLabel.setToolTipText("Graveyard");
Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png");
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() {
@Override
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);
cheat = new JButton();
cheat.setIcon(new ImageIcon(resized));
panelBackground.add(cheat);
cheat.setBounds(55, 250 - r.height - 5, r.width, r.height);
cheat.setToolTipText("Cheat button");
cheat.addActionListener(new ActionListener() {
@Override
@ -270,28 +267,225 @@ public class PlayerPanelExt extends javax.swing.JPanel {
});
// Add mana symbols
addManaImagePanel("W", new Rectangle(11, 140, 15, 15), panelBackground);
addManaImagePanel("U", new Rectangle(11, 160, 15, 15), panelBackground);
addManaImagePanel("B", new Rectangle(11, 180, 15, 15), panelBackground);
addManaImagePanel("R", new Rectangle(50, 140, 15, 15), panelBackground);
addManaImagePanel("G", new Rectangle(50, 160, 15, 15), panelBackground);
addManaImagePanel("X", new Rectangle(50, 180, 15, 15), panelBackground);
BufferedImage imageManaW = ManaSymbols.getManaSymbolImageSmall("W");
ImagePanel manaW = new ImagePanel(imageManaW, ImagePanel.ACTUAL);
manaW.setOpaque(false);
JLabel manaCountLabelW = new JLabel();
manaCountLabelW.setText("0");
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) {
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);
}
public void sizePlayerPanel() {
Dimension r = new Dimension(60, 60);
this.avatar.setSize(r);
this.avatar.setPreferredSize(r);
}
// 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.
@ -302,27 +496,27 @@ public class PlayerPanelExt extends javax.swing.JPanel {
* @param imagePath
* @return
*/
private JComponent addParam(JPanel containerPanel, String tooltip, JLabel text, Rectangle r, String imagePath, boolean isButton) {
if (text != null) {
text.setForeground(Color.black);
containerPanel.add(text);
text.setToolTipText(tooltip);
}
Image image = ImageHelper.getImageFromResources(imagePath);
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
JComponent component = null;
if (isButton) {
component = new HoverButton(null, resized, resized, resized, r);
} else {
component = new ImagePanel(resized, ImagePanel.ACTUAL);
}
component.setToolTipText(tooltip);
component.setOpaque(false);
containerPanel.add(component);
return component;
}
// private JComponent addParam(JPanel containerPanel, String tooltip, JLabel text, Rectangle r, String imagePath, boolean isButton) {
// if (text != null) {
// text.setForeground(Color.black);
// containerPanel.add(text);
// text.setToolTipText(tooltip);
// }
//
// Image image = ImageHelper.getImageFromResources(imagePath);
// BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
// JComponent component = null;
// if (isButton) {
// component = new HoverButton(null, resized, resized, resized, r);
// } else {
// component = new ImagePanel(resized, ImagePanel.ACTUAL);
// }
// component.setToolTipText(tooltip);
// component.setOpaque(false);
// containerPanel.add(component);
//
// return component;
// }
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
if (graveyard == null) {