mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
[UI] Added popup menu. Moved Concede action to popup.
This commit is contained in:
parent
44a3c05ba8
commit
2de4506ad2
3 changed files with 37 additions and 8 deletions
|
@ -294,4 +294,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
this.add(jScrollPane);
|
this.add(jScrollPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JComponent getMainPanel() {
|
||||||
|
return jPanel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,12 +130,6 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
bigCard.setDefaultImage();
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, JComponent> getUIComponents(JLayeredPane jLayeredPane) {
|
private Map<String, JComponent> getUIComponents(JLayeredPane jLayeredPane) {
|
||||||
|
|
|
@ -36,6 +36,10 @@ import javax.swing.*;
|
||||||
import javax.swing.GroupLayout.Alignment;
|
import javax.swing.GroupLayout.Alignment;
|
||||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||||
import java.awt.*;
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,9 +55,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
public PlayAreaPanel() {
|
public PlayAreaPanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
//jScrollPane1.setOpaque(false);
|
|
||||||
//jScrollPane1.getViewport().setOpaque(false);
|
|
||||||
battlefieldPanel.setOpaque(false);
|
battlefieldPanel.setOpaque(false);
|
||||||
|
addPopupMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) {
|
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) {
|
||||||
|
@ -62,6 +65,35 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
update(player);
|
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) {
|
public final void init(PlayerView player, BigCard bigCard, UUID gameId) {
|
||||||
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
|
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
|
||||||
this.battlefieldPanel.init(gameId, bigCard);
|
this.battlefieldPanel.init(gameId, bigCard);
|
||||||
|
|
Loading…
Reference in a new issue