mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* PopUp Menus -Added F2/F3/F4/F9 to menu. Set correct popup menu for watcher.
This commit is contained in:
parent
b4d43649b4
commit
c22a75a6c3
4 changed files with 119 additions and 15 deletions
|
@ -62,6 +62,7 @@ import java.util.*;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com, nantuko8
|
* @author BetaSteward_at_googlemail.com, nantuko8
|
||||||
|
@ -351,7 +352,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerView player = game.getPlayers().get(playerSeat);
|
PlayerView player = game.getPlayers().get(playerSeat);
|
||||||
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, true, game.getPriorityTime());
|
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, true, game.getPriorityTime(), game.isPlayer(), this);
|
||||||
players.put(player.getPlayerId(), sessionPlayer);
|
players.put(player.getPlayerId(), sessionPlayer);
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
@ -383,7 +384,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
col = numColumns - 1;
|
col = numColumns - 1;
|
||||||
}
|
}
|
||||||
player = game.getPlayers().get(playerNum);
|
player = game.getPlayers().get(playerNum);
|
||||||
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, false, game.getPriorityTime());
|
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, false, game.getPriorityTime(), game.isPlayer(), this);
|
||||||
players.put(player.getPlayerId(), playerPanel);
|
players.put(player.getPlayerId(), playerPanel);
|
||||||
c = new GridBagConstraints();
|
c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
@ -1249,6 +1250,14 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
return gameChatPanel.getText();
|
return gameChatPanel.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Session getSession() {
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeedbackPanel getFeedbackPanel() {
|
||||||
|
return feedbackPanel;
|
||||||
|
}
|
||||||
|
|
||||||
private mage.client.components.ability.AbilityPicker abilityPicker;
|
private mage.client.components.ability.AbilityPicker abilityPicker;
|
||||||
private mage.client.cards.BigCard bigCard;
|
private mage.client.cards.BigCard bigCard;
|
||||||
private javax.swing.JButton btnConcede;
|
private javax.swing.JButton btnConcede;
|
||||||
|
@ -1296,7 +1305,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
private boolean imagePanelState;
|
private boolean imagePanelState;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
|
|
||||||
private Session session;
|
private Session session;
|
||||||
|
|
|
@ -52,20 +52,26 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private boolean smallMode = false;
|
private boolean smallMode = false;
|
||||||
private boolean playingMode = true;
|
private boolean playingMode = true;
|
||||||
|
private GamePanel gamePanel;
|
||||||
|
|
||||||
public static final int PANEL_HEIGHT = 242;
|
public static final int PANEL_HEIGHT = 242;
|
||||||
public static final int PANEL_HEIGHT_SMALL = 190;
|
public static final int PANEL_HEIGHT_SMALL = 190;
|
||||||
|
|
||||||
/** Creates new form PlayAreaPanel */
|
/** Creates new form PlayAreaPanel */
|
||||||
public PlayAreaPanel() {
|
public PlayAreaPanel(boolean isPlayer) {
|
||||||
initComponents();
|
initComponents();
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
battlefieldPanel.setOpaque(false);
|
battlefieldPanel.setOpaque(false);
|
||||||
addPopupMenu();
|
if (isPlayer) {
|
||||||
|
addPopupMenu();
|
||||||
|
} else {
|
||||||
|
addPopupMenuWatcher();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me, int priorityTime) {
|
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me, int priorityTime, boolean isPlayer, GamePanel gamePanel) {
|
||||||
this();
|
this(isPlayer);
|
||||||
|
this.gamePanel = gamePanel;
|
||||||
init(player, bigCard, gameId, priorityTime);
|
init(player, bigCard, gameId, priorityTime);
|
||||||
update(player);
|
update(player);
|
||||||
}
|
}
|
||||||
|
@ -76,6 +82,57 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
Pmenu = new JPopupMenu();
|
Pmenu = new JPopupMenu();
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("F2 - Confirm");
|
||||||
|
Pmenu.add(menuItem);
|
||||||
|
|
||||||
|
// Confirm (F2)
|
||||||
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (gamePanel.getFeedbackPanel() != null) {
|
||||||
|
gamePanel.getFeedbackPanel().pressOKYesOrDone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("F3 - Cancel previous F4/F9 skip action");
|
||||||
|
Pmenu.add(menuItem);
|
||||||
|
|
||||||
|
// Cancel (F3)
|
||||||
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
gamePanel.getSession().restorePriority(gameId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Pmenu.addSeparator();
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("F4 - Skip phases until next turn (stop on stack/attack/block)");
|
||||||
|
Pmenu.add(menuItem);
|
||||||
|
|
||||||
|
// Skip to next turn (F4)
|
||||||
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
gamePanel.getSession().passTurnPriority(gameId);;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("F9 - Skip everything until own next turn (stop on attack/block)");
|
||||||
|
Pmenu.add(menuItem);
|
||||||
|
|
||||||
|
// Skip to next own turn (F9)
|
||||||
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
gamePanel.getSession().passPriorityUntilNextYourTurn(gameId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Pmenu.addSeparator();
|
||||||
|
|
||||||
menuItem = new JMenuItem("Concede game");
|
menuItem = new JMenuItem("Concede game");
|
||||||
Pmenu.add(menuItem);
|
Pmenu.add(menuItem);
|
||||||
|
|
||||||
|
@ -89,22 +146,56 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
menuItem = new JMenuItem("Quit match");
|
Pmenu.addSeparator();
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("Concede complete match");
|
||||||
Pmenu.add(menuItem);
|
Pmenu.add(menuItem);
|
||||||
|
|
||||||
// Quit match
|
// Quit match
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to quit the match?", "Confirm quit match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the complete match?", "Confirm concede match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
MageFrame.getSession().quitMatch(gameId);
|
MageFrame.getSession().quitMatch(gameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
menuItem = new JMenuItem("Cancel");
|
// Pmenu.addSeparator();
|
||||||
|
//
|
||||||
|
// menuItem = new JMenuItem("Cancel");
|
||||||
|
// Pmenu.add(menuItem);
|
||||||
|
|
||||||
|
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent Me) {
|
||||||
|
if (Me.isPopupTrigger() && playingMode) {
|
||||||
|
Pmenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPopupMenuWatcher() {
|
||||||
|
final JPopupMenu Pmenu;
|
||||||
|
JMenuItem menuItem;
|
||||||
|
|
||||||
|
Pmenu = new JPopupMenu();
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("Stop watching");
|
||||||
Pmenu.add(menuItem);
|
Pmenu.add(menuItem);
|
||||||
|
|
||||||
|
// Stop watching
|
||||||
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to stop watching the game?", "Confirm stop watching game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
|
gamePanel.getSession().stopWatching(gameId);
|
||||||
|
gamePanel.hideGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent Me) {
|
public void mouseReleased(MouseEvent Me) {
|
||||||
|
|
|
@ -64,7 +64,6 @@ public class GameView implements Serializable {
|
||||||
private SimpleCardsView hand;
|
private SimpleCardsView hand;
|
||||||
private Map<String, SimpleCardsView> opponentHands;
|
private Map<String, SimpleCardsView> opponentHands;
|
||||||
private CardsView stack = new CardsView();
|
private CardsView stack = new CardsView();
|
||||||
//private List<UUID> stackOrder = new ArrayList<UUID>();
|
|
||||||
private List<ExileView> exiles = new ArrayList<ExileView>();
|
private List<ExileView> exiles = new ArrayList<ExileView>();
|
||||||
private List<RevealedView> revealed = new ArrayList<RevealedView>();
|
private List<RevealedView> revealed = new ArrayList<RevealedView>();
|
||||||
private List<LookedAtView> lookedAt = new ArrayList<LookedAtView>();
|
private List<LookedAtView> lookedAt = new ArrayList<LookedAtView>();
|
||||||
|
@ -76,10 +75,12 @@ public class GameView implements Serializable {
|
||||||
private String priorityPlayerName = "";
|
private String priorityPlayerName = "";
|
||||||
private int turn;
|
private int turn;
|
||||||
private boolean special = false;
|
private boolean special = false;
|
||||||
|
private boolean isPlayer;
|
||||||
|
|
||||||
|
|
||||||
public GameView(GameState state, Game game) {
|
public GameView(GameState state, Game game, boolean isPlayer) {
|
||||||
priorityTime = game.getPriorityTime();
|
this.isPlayer = isPlayer;
|
||||||
|
this.priorityTime = game.getPriorityTime();
|
||||||
for (Player player: state.getPlayers().values()) {
|
for (Player player: state.getPlayers().values()) {
|
||||||
players.add(new PlayerView(player, state, game));
|
players.add(new PlayerView(player, state, game));
|
||||||
}
|
}
|
||||||
|
@ -275,4 +276,8 @@ public class GameView implements Serializable {
|
||||||
return activePlayerId;
|
return activePlayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPlayer() {
|
||||||
|
return isPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class ReplaySession implements GameCallback {
|
||||||
replay.start();
|
replay.start();
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame())));
|
user.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame(), false)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class ReplaySession implements GameCallback {
|
||||||
else {
|
else {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game)));
|
user.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game, false)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue