diff --git a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java index fc63aa95ef..fa09fec63f 100644 --- a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java @@ -294,4 +294,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { this.add(jScrollPane); } + public JComponent getMainPanel() { + return jPanel; + } } diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index 1da48b3136..b715441ee3 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -130,12 +130,6 @@ public class GamePanel extends javax.swing.JPanel { throw new RuntimeException(e); } - /*SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - bigCard.setDefaultImage(); - } - });*/ } private Map getUIComponents(JLayeredPane jLayeredPane) { diff --git a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java index db618469cd..65ac7d53fa 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -36,6 +36,10 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; import javax.swing.LayoutStyle.ComponentPlacement; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.UUID; /** @@ -51,9 +55,8 @@ public class PlayAreaPanel extends javax.swing.JPanel { public PlayAreaPanel() { initComponents(); setOpaque(false); - //jScrollPane1.setOpaque(false); - //jScrollPane1.getViewport().setOpaque(false); battlefieldPanel.setOpaque(false); + addPopupMenu(); } public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) { @@ -62,6 +65,35 @@ public class PlayAreaPanel extends javax.swing.JPanel { update(player); } + private void addPopupMenu() { + final JPopupMenu Pmenu; + JMenuItem menuItem; + + Pmenu = new JPopupMenu(); + menuItem = new JMenuItem("Concede"); + Pmenu.add(menuItem); + + // Concede + menuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede?", "Confirm concede", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + MageFrame.getSession().concedeGame(gameId); + } + } + }); + + menuItem = new JMenuItem("Cancel"); + Pmenu.add(menuItem); + + battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent Me) { + if (Me.isPopupTrigger()) { + Pmenu.show(Me.getComponent(), Me.getX(), Me.getY()); + } + } + }); + } + public final void init(PlayerView player, BigCard bigCard, UUID gameId) { this.playerPanel.init(gameId, player.getPlayerId(), bigCard); this.battlefieldPanel.init(gameId, bigCard);