mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
catch spell and activated ability errors and rollback state - show error dialog on client
This commit is contained in:
parent
b90ac39de7
commit
48d7afa375
7 changed files with 114 additions and 68 deletions
|
|
@ -106,6 +106,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
private static Session session;
|
||||
private ConnectDialog connectDialog;
|
||||
private ErrorDialog errorDialog;
|
||||
private static CallbackClient callbackClient;
|
||||
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
|
||||
private JLabel title;
|
||||
|
|
@ -188,6 +189,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
callbackClient = new CallbackClientImpl(this);
|
||||
connectDialog = new ConnectDialog();
|
||||
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
|
||||
errorDialog = new ErrorDialog();
|
||||
desktopPane.add(errorDialog, JLayeredPane.POPUP_LAYER);
|
||||
ui.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
|
||||
|
||||
try {
|
||||
|
|
@ -834,6 +837,21 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
}
|
||||
|
||||
public void showErrorDialog(final String title, final String message) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
errorDialog.showDialog(title, message);
|
||||
}
|
||||
else {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
errorDialog.showDialog(title, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showCollectionViewer() {
|
||||
this.collectionViewerPane.setVisible(true);
|
||||
setActive(collectionViewerPane);
|
||||
|
|
|
|||
|
|
@ -141,10 +141,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("gameError")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.modalMessage((String) callback.getData());
|
||||
}
|
||||
frame.showErrorDialog("Game Error", (String) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameAsk")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue