forked from External/mage
Fixed Issue#37: graveyard dialog not displayed when multi games played
This commit is contained in:
parent
c1d88c7830
commit
36cb5f95b9
6 changed files with 47 additions and 26 deletions
|
|
@ -10,6 +10,8 @@ import java.awt.event.MouseEvent;
|
|||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -18,15 +20,23 @@ import java.util.UUID;
|
|||
public class DialogManager extends JComponent implements MouseListener,
|
||||
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);
|
||||
|
||||
public static DialogManager getManager() {
|
||||
if (dialogManager == null) {
|
||||
dialogManager = new DialogManager();
|
||||
dialogManager.setVisible(true);
|
||||
public static DialogManager getManager(UUID gameId) {
|
||||
if (!dialogManagers.containsKey(gameId)) {
|
||||
synchronized (dialogManagers) {
|
||||
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 {
|
||||
|
|
@ -59,6 +69,16 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
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) {
|
||||
this.screen_height = screen_height;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
private JButton jButtonSort = null;
|
||||
|
||||
private CardsView cards;
|
||||
private UUID gameId;
|
||||
|
||||
private int page = 1;
|
||||
private int maxPages;
|
||||
|
|
@ -57,6 +58,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
public ChoiceDialog(DlgParams params) {
|
||||
super(params);
|
||||
this.params = params;
|
||||
this.gameId = params.gameId;
|
||||
|
||||
cards = params.getCards();
|
||||
isOptional = params.isOptional();
|
||||
|
|
@ -171,7 +173,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
|
||||
jButtonOK.setObserver(new Command() {
|
||||
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;
|
||||
|
||||
public void execute() {
|
||||
DialogManager.getManager().fadeOut((DialogContainer) getParent());
|
||||
DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
|
||||
/*
|
||||
try {
|
||||
ConnectionManager.sendAddChosenCard(null);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public class StackDialog extends IDialogPanel {
|
|||
|
||||
private JLayeredPane jLayeredPane;
|
||||
private FeedbackPanel feedbackPanel;
|
||||
|
||||
private UUID gameId;
|
||||
|
||||
private class CustomLabel extends JLabel {
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ public class StackDialog extends IDialogPanel {
|
|||
public StackDialog(DlgParams params) {
|
||||
super(params);
|
||||
this.feedbackPanel = params.feedbackPanel;
|
||||
this.gameId = params.gameId;
|
||||
initialize();
|
||||
displayStack(params.getCards(), params.gameId, params.bigCard);
|
||||
}
|
||||
|
|
@ -145,7 +148,7 @@ public class StackDialog extends IDialogPanel {
|
|||
jButtonAccept.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
DialogManager.getManager().fadeOut((DialogContainer)getParent());
|
||||
DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
|
||||
//GameManager.getInputControl().getInput().selectButtonOK();
|
||||
StackDialog.this.feedbackPanel.doClick();
|
||||
}
|
||||
|
|
@ -168,7 +171,7 @@ public class StackDialog extends IDialogPanel {
|
|||
jButtonResponse.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
DialogManager.getManager().fadeOut((DialogContainer)getParent());
|
||||
DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue