use of mage.view.UserRequestMessage in project mage by magefree.
the class PlayAreaPanel method addPopupMenuWatcher.
private void addPopupMenuWatcher() {
JMenuItem menuItem;
menuItem = new JMenuItem("Stop watching");
popupMenu.add(menuItem);
// Stop watching
menuItem.addActionListener(e -> {
UserRequestMessage message = new UserRequestMessage("Confirm stop watching game", "Are you sure you want to stop watching the game?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_STOP_WATCHING);
message.setGameId(gameId);
MageFrame.getInstance().showUserRequestDialog(message);
});
menuItem = new JMenuItem("Request permission to see hand cards");
popupMenu.add(menuItem);
// Request to see hand cards
menuItem.addActionListener(e -> SessionHandler.sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId));
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
this.checkMenu(e);
}
// neccessary for linux and mac systems
@Override
public void mousePressed(MouseEvent e) {
this.checkMenu(e);
}
private void checkMenu(MouseEvent e) {
if (e.isPopupTrigger() && playingMode) {
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
}
use of mage.view.UserRequestMessage in project mage by magefree.
the class MagePaneMenuItem method downloadAdditionalResources.
// GEN-LAST:event_btnSymbolsActionPerformed
public void downloadAdditionalResources() {
UserRequestMessage message = new UserRequestMessage("Download additional resources", "Do you want to download game symbols and additional image files?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_DOWNLOAD_SYMBOLS);
showUserRequestDialog(message);
}
use of mage.view.UserRequestMessage in project mage by magefree.
the class MagePaneMenuItem method exitApp.
public void exitApp() {
if (SessionHandler.isConnected()) {
UserRequestMessage message = new UserRequestMessage("Confirm disconnect", "You are currently connected. Are you sure you want to disconnect?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_EXIT);
MageFrame.getInstance().showUserRequestDialog(message);
} else {
UserRequestMessage message = new UserRequestMessage("Confirm exit", "Are you sure you want to exit?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_EXIT);
MageFrame.getInstance().showUserRequestDialog(message);
}
}
use of mage.view.UserRequestMessage in project mage by magefree.
the class MagePaneMenuItem method btnConnectActionPerformed.
// GEN-LAST:event_btnDeckEditorActionPerformed
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_btnConnectActionPerformed
if (SessionHandler.isConnected()) {
UserRequestMessage message = new UserRequestMessage("Confirm disconnect", "Are you sure you want to disconnect?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_DISCONNECT);
showUserRequestDialog(message);
} else {
connectDialog.showDialog();
setWindowTitle();
}
}
use of mage.view.UserRequestMessage in project mage by magefree.
the class MagePaneMenuItem method disconnected.
@Override
public void disconnected(final boolean askToReconnect) {
if (SwingUtilities.isEventDispatchThread()) {
// Returns true if the current thread is an AWT event dispatching thread.
// REMOTE task, e.g. connecting
LOGGER.info("Disconnected from remote task");
setConnectButtonText(NOT_CONNECTED_BUTTON);
disableButtons();
hideGames();
hideTables();
} else {
// USER mode, e.g. user plays and got disconnect
LOGGER.info("Disconnected from user mode");
SwingUtilities.invokeLater(() -> {
// user already disconnected, can't do any online actions like quite chat
SessionHandler.disconnect(false);
setConnectButtonText(NOT_CONNECTED_BUTTON);
disableButtons();
hideGames();
hideTables();
if (askToReconnect) {
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + MagePreferences.getLastServerAddress() + "?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
showUserRequestDialog(message);
}
});
}
}
Aggregations