Fixed Issue#37: graveyard dialog not displayed when multi games played

This commit is contained in:
magenoxx 2012-08-08 11:31:35 +04:00
parent c1d88c7830
commit 36cb5f95b9
6 changed files with 47 additions and 26 deletions

View file

@ -190,10 +190,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
initComponents(); initComponents();
setSize(1024, 768); setSize(1024, 768);
SettingsManager.getInstance().setScreenWidthAndHeight(1024, 768); SettingsManager.getInstance().setScreenWidthAndHeight(1024, 768);
DialogManager.getManager().setScreenWidth(1024); DialogManager.updateParams(768, 1024, false);
DialogManager.getManager().setScreenHeight(768);
DialogManager.getManager().setBounds(0, 0, 1024, 768);
DialogManager.getManager().setVisible(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setExtendedState(JFrame.MAXIMIZED_BOTH);
session = new SessionImpl(this); session = new SessionImpl(this);

View file

@ -10,6 +10,8 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
@ -18,15 +20,23 @@ import java.util.UUID;
public class DialogManager extends JComponent implements MouseListener, public class DialogManager extends JComponent implements MouseListener,
MouseMotionListener { MouseMotionListener {
private static DialogManager dialogManager = null; private static Map<UUID, DialogManager> dialogManagers = new HashMap<UUID, DialogManager>();
//private static final Logger log = Logger.getLogger(DialogManager.class); //private static final Logger log = Logger.getLogger(DialogManager.class);
public static DialogManager getManager() { public static DialogManager getManager(UUID gameId) {
if (dialogManager == null) { if (!dialogManagers.containsKey(gameId)) {
dialogManager = new DialogManager(); synchronized (dialogManagers) {
dialogManager.setVisible(true); if (!dialogManagers.containsKey(gameId)) {
DialogManager dialogManager = new DialogManager();
dialogManager.setScreenWidth(768);
dialogManager.setScreenHeight(1024);
dialogManager.setBounds(0, 0, 768, 1024);
dialogManager.setVisible(false);
dialogManagers.put(gameId, dialogManager);
}
}
} }
return dialogManager; return dialogManagers.get(gameId);
} }
public enum MTGDialogs { public enum MTGDialogs {
@ -59,6 +69,16 @@ public class DialogManager extends JComponent implements MouseListener,
this.screen_width = screen_width; this.screen_width = screen_width;
} }
public static void updateParams(int width, int height, boolean isVisible) {
synchronized (dialogManagers) {
for (DialogManager dialogManager : dialogManagers.values()) {
dialogManager.setScreenWidth(width);
dialogManager.setScreenHeight(height);
dialogManager.setBounds(0, 0, width, height);
}
}
}
public void setScreenHeight(int screen_height) { public void setScreenHeight(int screen_height) {
this.screen_height = screen_height; this.screen_height = screen_height;
} }

View file

@ -37,6 +37,7 @@ public class ChoiceDialog extends IDialogPanel {
private JButton jButtonSort = null; private JButton jButtonSort = null;
private CardsView cards; private CardsView cards;
private UUID gameId;
private int page = 1; private int page = 1;
private int maxPages; private int maxPages;
@ -57,6 +58,7 @@ public class ChoiceDialog extends IDialogPanel {
public ChoiceDialog(DlgParams params) { public ChoiceDialog(DlgParams params) {
super(params); super(params);
this.params = params; this.params = params;
this.gameId = params.gameId;
cards = params.getCards(); cards = params.getCards();
isOptional = params.isOptional(); isOptional = params.isOptional();
@ -171,7 +173,7 @@ public class ChoiceDialog extends IDialogPanel {
jButtonOK.setObserver(new Command() { jButtonOK.setObserver(new Command() {
public void execute() { public void execute() {
DialogManager.getManager().fadeOut((DialogContainer) getParent()); DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
} }
}); });
} }
@ -328,7 +330,7 @@ public class ChoiceDialog extends IDialogPanel {
private static final long serialVersionUID = -567322540616089486L; private static final long serialVersionUID = -567322540616089486L;
public void execute() { public void execute() {
DialogManager.getManager().fadeOut((DialogContainer) getParent()); DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
/* /*
try { try {
ConnectionManager.sendAddChosenCard(null); ConnectionManager.sendAddChosenCard(null);

View file

@ -33,6 +33,8 @@ public class StackDialog extends IDialogPanel {
private JLayeredPane jLayeredPane; private JLayeredPane jLayeredPane;
private FeedbackPanel feedbackPanel; private FeedbackPanel feedbackPanel;
private UUID gameId;
private class CustomLabel extends JLabel { private class CustomLabel extends JLabel {
@ -57,6 +59,7 @@ public class StackDialog extends IDialogPanel {
public StackDialog(DlgParams params) { public StackDialog(DlgParams params) {
super(params); super(params);
this.feedbackPanel = params.feedbackPanel; this.feedbackPanel = params.feedbackPanel;
this.gameId = params.gameId;
initialize(); initialize();
displayStack(params.getCards(), params.gameId, params.bigCard); displayStack(params.getCards(), params.gameId, params.bigCard);
} }
@ -145,7 +148,7 @@ public class StackDialog extends IDialogPanel {
jButtonAccept.setObserver(new Command() { jButtonAccept.setObserver(new Command() {
@Override @Override
public void execute() { public void execute() {
DialogManager.getManager().fadeOut((DialogContainer)getParent()); DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
//GameManager.getInputControl().getInput().selectButtonOK(); //GameManager.getInputControl().getInput().selectButtonOK();
StackDialog.this.feedbackPanel.doClick(); StackDialog.this.feedbackPanel.doClick();
} }
@ -168,7 +171,7 @@ public class StackDialog extends IDialogPanel {
jButtonResponse.setObserver(new Command() { jButtonResponse.setObserver(new Command() {
@Override @Override
public void execute() { public void execute() {
DialogManager.getManager().fadeOut((DialogContainer)getParent()); DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
} }
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
}); });

View file

@ -225,9 +225,9 @@ public class GamePanel extends javax.swing.JPanel {
int height = pnlBattlefield.getHeight(); int height = pnlBattlefield.getHeight();
phasesContainer.setPreferredSize(new Dimension(X_PHASE_WIDTH, height)); phasesContainer.setPreferredSize(new Dimension(X_PHASE_WIDTH, height));
DialogManager.getManager().setScreenWidth(rect.width); DialogManager.getManager(gameId).setScreenWidth(rect.width);
DialogManager.getManager().setScreenHeight(rect.height); DialogManager.getManager(gameId).setScreenHeight(rect.height);
DialogManager.getManager().setBounds(0, 0, rect.width, rect.height); DialogManager.getManager(gameId).setBounds(0, 0, rect.width, rect.height);
} }
public synchronized void showGame(UUID gameId, UUID playerId) { public synchronized void showGame(UUID gameId, UUID playerId) {
@ -597,13 +597,13 @@ public class GamePanel extends javax.swing.JPanel {
public void playMana(String message, GameView gameView) { public void playMana(String message, GameView gameView) {
updateGame(gameView); updateGame(gameView);
DialogManager.getManager().fadeOut(); DialogManager.getManager(gameId).fadeOut();
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), null); this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), null);
} }
public void playXMana(String message, GameView gameView) { public void playXMana(String message, GameView gameView) {
updateGame(gameView); updateGame(gameView);
DialogManager.getManager().fadeOut(); DialogManager.getManager(gameId).fadeOut();
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null); this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null);
} }
@ -612,7 +612,7 @@ public class GamePanel extends javax.swing.JPanel {
} }
public void pickAbility(AbilityPickerView choices) { public void pickAbility(AbilityPickerView choices) {
DialogManager.getManager().fadeOut(); DialogManager.getManager(gameId).fadeOut();
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition()); this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
} }
@ -1143,7 +1143,7 @@ public class GamePanel extends javax.swing.JPanel {
public void installComponents() { public void installComponents() {
jLayeredPane.setOpaque(false); jLayeredPane.setOpaque(false);
jLayeredPane.add(abilityPicker); jLayeredPane.add(abilityPicker);
jLayeredPane.add(DialogManager.getManager(), JLayeredPane.MODAL_LAYER, 0); jLayeredPane.add(DialogManager.getManager(gameId), JLayeredPane.MODAL_LAYER, 0);
abilityPicker.setVisible(false); abilityPicker.setVisible(false);
} }

View file

@ -42,7 +42,6 @@ import mage.client.cards.BigCard;
import mage.client.components.HoverButton; import mage.client.components.HoverButton;
import mage.client.components.MageRoundPane; import mage.client.components.MageRoundPane;
import mage.client.components.ext.dlg.DialogManager; import mage.client.components.ext.dlg.DialogManager;
import mage.client.dialog.ShowCardsDialog;
import mage.client.plugins.adapters.MageActionCallback; import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil; import mage.client.util.CardsViewUtil;
@ -82,7 +81,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private Session session; private Session session;
private PlayerView player; private PlayerView player;
private ShowCardsDialog graveyard; //private ShowCardsDialog graveyard;
private BigCard bigCard; private BigCard bigCard;
private static final int AVATAR_COUNT = 77; private static final int AVATAR_COUNT = 77;
@ -512,11 +511,11 @@ public class PlayerPanelExt extends javax.swing.JPanel {
} }
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) {
graveyard = new ShowCardsDialog(); graveyard = new ShowCardsDialog();
} }*/
//graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false); //graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
DialogManager.getManager().showChoiceDialog(CardsViewUtil.convertSimple(player.getGraveyard()), bigCard, gameId); DialogManager.getManager(gameId).showChoiceDialog(CardsViewUtil.convertSimple(player.getGraveyard()), bigCard, gameId);
} }
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed