Search in sources :

Example 1 with UserRequestMessage

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());
            }
        }
    });
}
Also used : UserRequestMessage(mage.view.UserRequestMessage)

Example 2 with UserRequestMessage

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);
}
Also used : UserRequestMessage(mage.view.UserRequestMessage)

Example 3 with UserRequestMessage

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);
    }
}
Also used : UserRequestMessage(mage.view.UserRequestMessage)

Example 4 with UserRequestMessage

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();
    }
}
Also used : UserRequestMessage(mage.view.UserRequestMessage)

Example 5 with UserRequestMessage

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);
            }
        });
    }
}
Also used : UserRequestMessage(mage.view.UserRequestMessage)

Aggregations

UserRequestMessage (mage.view.UserRequestMessage)10 java.awt (java.awt)1 java.awt.event (java.awt.event)1 Field (java.lang.reflect.Field)1 Set (java.util.Set)1 UUID (java.util.UUID)1 BackingStoreException (java.util.prefs.BackingStoreException)1 Preferences (java.util.prefs.Preferences)1 javax.swing (javax.swing)1 Alignment (javax.swing.GroupLayout.Alignment)1 ComponentPlacement (javax.swing.LayoutStyle.ComponentPlacement)1 ChangeListener (javax.swing.event.ChangeListener)1 DeckImporter (mage.cards.decks.importer.DeckImporter)1 MageFrame (mage.client.MageFrame)1 SessionHandler (mage.client.SessionHandler)1 BigCard (mage.client.cards.BigCard)1 PreferencesDialog (mage.client.dialog.PreferencesDialog)1 GUISizeHelper (mage.client.util.GUISizeHelper)1 PlayerAction (mage.constants.PlayerAction)1 GameView (mage.view.GameView)1