Search in sources :

Example 1 with ActionCallback

use of mage.cards.action.ActionCallback in project mage by magefree.

the class ReplayTask method initComponents.

@SuppressWarnings("unchecked")
private void initComponents() {
    abilityPicker = new mage.client.components.ability.AbilityPicker();
    jSplitPane1 = new javax.swing.JSplitPane();
    jSplitPane0 = new javax.swing.JSplitPane();
    jPanel2 = new javax.swing.JPanel();
    pnlHelperHandButtonsStackArea = new javax.swing.JPanel();
    pnlShortCuts = new javax.swing.JPanel();
    lblPhase = new javax.swing.JLabel();
    txtPhase = new javax.swing.JLabel();
    lblStep = new javax.swing.JLabel();
    txtStep = new javax.swing.JLabel();
    lblTurn = new javax.swing.JLabel();
    txtTurn = new javax.swing.JLabel();
    txtActivePlayer = new javax.swing.JLabel();
    lblActivePlayer = new javax.swing.JLabel();
    txtPriority = new javax.swing.JLabel();
    lblPriority = new javax.swing.JLabel();
    feedbackPanel = new mage.client.game.FeedbackPanel();
    txtSpellsCast = new javax.swing.JLabel();
    Border paddingBorder = BorderFactory.createEmptyBorder(4, 4, 4, 4);
    Border border = BorderFactory.createLineBorder(Color.DARK_GRAY, 2);
    txtSpellsCast.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
    txtSpellsCast.setBackground(Color.LIGHT_GRAY);
    txtSpellsCast.setOpaque(true);
    txtSpellsCast.setToolTipText("spells cast during the current turn");
    txtHoldPriority = new javax.swing.JLabel();
    txtHoldPriority.setText("Hold");
    txtHoldPriority.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
    txtHoldPriority.setBackground(Color.LIGHT_GRAY);
    txtHoldPriority.setOpaque(true);
    txtHoldPriority.setToolTipText("Holding priority after the next spell cast or ability activation");
    txtHoldPriority.setVisible(false);
    boolean displayButtonText = PreferencesDialog.getCurrentTheme().isShortcutsVisibleForSkipButtons();
    btnToggleMacro = new KeyboundButton(KEY_CONTROL_TOGGLE_MACRO, displayButtonText);
    // F3
    btnCancelSkip = new KeyboundButton(KEY_CONTROL_CANCEL_SKIP, displayButtonText);
    // F4
    btnSkipToNextTurn = new KeyboundButton(KEY_CONTROL_NEXT_TURN, displayButtonText);
    // F5
    btnSkipToEndTurn = new KeyboundButton(KEY_CONTROL_END_STEP, displayButtonText);
    // F7
    btnSkipToNextMain = new KeyboundButton(KEY_CONTROL_MAIN_STEP, displayButtonText);
    // F10
    btnSkipStack = new KeyboundButton(KEY_CONTROL_SKIP_STACK, displayButtonText);
    // F9
    btnSkipToYourTurn = new KeyboundButton(KEY_CONTROL_YOUR_TURN, displayButtonText);
    // F11
    btnSkipToEndStepBeforeYourTurn = new KeyboundButton(KEY_CONTROL_PRIOR_END, displayButtonText);
    btnConcede = new javax.swing.JButton();
    btnSwitchHands = new javax.swing.JButton();
    btnStopWatching = new javax.swing.JButton();
    bigCard = new mage.client.cards.BigCard();
    pnlReplay = new javax.swing.JPanel();
    btnStopReplay = new javax.swing.JButton();
    btnNextPlay = new javax.swing.JButton();
    btnPlay = new javax.swing.JButton();
    btnSkipForward = new javax.swing.JButton();
    btnPreviousPlay = new javax.swing.JButton();
    pnlBattlefield = new javax.swing.JPanel();
    gameChatPanel = new mage.client.chat.ChatPanelBasic();
    gameChatPanel.useExtendedView(ChatPanelBasic.VIEW_MODE.GAME);
    userChatPanel = new mage.client.chat.ChatPanelBasic();
    userChatPanel.setParentChat(gameChatPanel);
    userChatPanel.useExtendedView(ChatPanelBasic.VIEW_MODE.CHAT);
    userChatPanel.setChatType(ChatPanelBasic.ChatType.GAME);
    gameChatPanel.setConnectedChat(userChatPanel);
    gameChatPanel.disableInput();
    gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48));
    gameChatPanel.enableHyperlinks();
    jSplitPane2 = new javax.swing.JSplitPane();
    handContainer = new HandPanel();
    handCards = new HashMap<>();
    pnlShortCuts.setOpaque(false);
    pnlShortCuts.setPreferredSize(new Dimension(410, 72));
    stackObjects = new mage.client.cards.Cards();
    jSplitPane1.setBorder(null);
    jSplitPane1.setDividerSize(7);
    jSplitPane1.setResizeWeight(1.0);
    jSplitPane1.setOneTouchExpandable(true);
    jSplitPane1.setMinimumSize(new java.awt.Dimension(26, 48));
    jSplitPane0.setBorder(null);
    jSplitPane0.setDividerSize(7);
    jSplitPane0.setResizeWeight(1.0);
    jSplitPane0.setOneTouchExpandable(true);
    restoreDividerLocations();
    lblPhase.setLabelFor(txtPhase);
    lblPhase.setText("Phase:");
    txtPhase.setText("Phase");
    txtPhase.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true));
    txtPhase.setMinimumSize(new java.awt.Dimension(0, 16));
    lblStep.setLabelFor(txtStep);
    lblStep.setText("Step:");
    txtStep.setText("Step");
    txtStep.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true));
    txtStep.setMinimumSize(new java.awt.Dimension(0, 16));
    lblTurn.setLabelFor(txtTurn);
    lblTurn.setText("Turn:");
    txtTurn.setText("Turn");
    txtTurn.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true));
    txtTurn.setMinimumSize(new java.awt.Dimension(0, 16));
    txtActivePlayer.setText("Active Player");
    txtActivePlayer.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true));
    txtActivePlayer.setMinimumSize(new java.awt.Dimension(0, 16));
    lblActivePlayer.setLabelFor(txtActivePlayer);
    lblActivePlayer.setText("Active Player:");
    txtPriority.setText("Priority Player");
    txtPriority.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true));
    txtPriority.setMinimumSize(new java.awt.Dimension(0, 16));
    lblPriority.setLabelFor(txtPriority);
    lblPriority.setText("Priority Player:");
    bigCard.setBorder(new LineBorder(Color.black, 1, true));
    // CHATS and HINTS support
    // HOTKEYS
    int c = JComponent.WHEN_IN_FOCUSED_WINDOW;
    // special hotkeys for custom rendered dialogs without focus
    // call it before any user defined hotkeys
    this.abilityPicker.injectHotkeys(this, "ABILITY_PICKER");
    btnToggleMacro.setContentAreaFilled(false);
    btnToggleMacro.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnToggleMacro.setIcon(new ImageIcon(ImageManagerImpl.instance.getToggleRecordMacroButtonImage()));
    btnToggleMacro.setToolTipText("Toggle Record Macro (" + getCachedKeyText(KEY_CONTROL_TOGGLE_MACRO) + ").");
    btnToggleMacro.setFocusable(false);
    btnToggleMacro.addMouseListener(new FirstButtonMousePressedAction(e -> btnToggleMacroActionPerformed(null)));
    KeyStroke kst = getCachedKeystroke(KEY_CONTROL_TOGGLE_MACRO);
    this.getInputMap(c).put(kst, "F8_PRESS");
    this.getActionMap().put("F8_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnToggleMacroActionPerformed(actionEvent);
        }
    });
    KeyStroke ks3 = getCachedKeystroke(KEY_CONTROL_CANCEL_SKIP);
    this.getInputMap(c).put(ks3, "F3_PRESS");
    this.getActionMap().put("F3_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            restorePriorityActionPerformed(actionEvent);
        }
    });
    // SKIP BUTTONS (button's hint/state is dynamic)
    btnCancelSkip.setContentAreaFilled(false);
    btnCancelSkip.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnCancelSkip.setIcon(new ImageIcon(ImageManagerImpl.instance.getCancelSkipButtonImage()));
    btnCancelSkip.setToolTipText("CANCEL all skips");
    btnCancelSkip.setFocusable(false);
    btnCancelSkip.addMouseListener(new FirstButtonMousePressedAction(e -> restorePriorityActionPerformed(null)));
    btnSkipToNextTurn.setContentAreaFilled(false);
    btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnSkipToNextTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipNextTurnButtonImage()));
    btnSkipToNextTurn.setToolTipText("dynamic");
    btnSkipToNextTurn.setFocusable(false);
    btnSkipToNextTurn.addMouseListener(new FirstButtonMousePressedAction(e -> btnEndTurnActionPerformed(null)));
    KeyStroke ks = getCachedKeystroke(KEY_CONTROL_NEXT_TURN);
    this.getInputMap(c).put(ks, "F4_PRESS");
    this.getActionMap().put("F4_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnEndTurnActionPerformed(actionEvent);
        }
    });
    btnSkipToEndTurn.setContentAreaFilled(false);
    btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnSkipToEndTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipEndTurnButtonImage()));
    btnSkipToEndTurn.setToolTipText("dynamic");
    btnSkipToEndTurn.setFocusable(false);
    btnSkipToEndTurn.addMouseListener(new FirstButtonMousePressedAction(e -> btnUntilEndOfTurnActionPerformed(null)));
    ks = getCachedKeystroke(KEY_CONTROL_END_STEP);
    this.getInputMap(c).put(ks, "F5_PRESS");
    this.getActionMap().put("F5_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnUntilEndOfTurnActionPerformed(actionEvent);
        }
    });
    ks = getCachedKeystroke(KEY_CONTROL_SKIP_STEP);
    this.getInputMap(c).put(ks, "F6_PRESS");
    this.getActionMap().put("F6_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnEndTurnSkipStackActionPerformed(actionEvent);
        }
    });
    btnSkipToNextMain.setContentAreaFilled(false);
    btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipMainButtonImage()));
    btnSkipToNextMain.setToolTipText("dynamic");
    btnSkipToNextMain.setFocusable(false);
    btnSkipToNextMain.addMouseListener(new FirstButtonMousePressedAction(e -> btnUntilNextMainPhaseActionPerformed(null)));
    ks = getCachedKeystroke(KEY_CONTROL_MAIN_STEP);
    this.getInputMap(c).put(ks, "F7_PRESS");
    this.getActionMap().put("F7_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnUntilNextMainPhaseActionPerformed(actionEvent);
        }
    });
    btnSkipToYourTurn.setContentAreaFilled(false);
    btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnSkipToYourTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipYourNextTurnButtonImage()));
    btnSkipToYourTurn.setToolTipText("dynamic");
    btnSkipToYourTurn.setFocusable(false);
    btnSkipToYourTurn.addMouseListener(new FirstButtonMousePressedAction(e -> btnPassPriorityUntilNextYourTurnActionPerformed(null)));
    KeyStroke ks9 = getCachedKeystroke(KEY_CONTROL_YOUR_TURN);
    this.getInputMap(c).put(ks9, "F9_PRESS");
    this.getActionMap().put("F9_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnPassPriorityUntilNextYourTurnActionPerformed(actionEvent);
        }
    });
    btnSkipToEndStepBeforeYourTurn.setContentAreaFilled(false);
    btnSkipToEndStepBeforeYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnSkipToEndStepBeforeYourTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipEndStepBeforeYourTurnButtonImage()));
    btnSkipToEndStepBeforeYourTurn.setToolTipText("dynamic");
    btnSkipToEndStepBeforeYourTurn.setFocusable(false);
    btnSkipToEndStepBeforeYourTurn.addMouseListener(new FirstButtonMousePressedAction(e -> btnSkipToEndStepBeforeYourTurnActionPerformed(null)));
    KeyStroke ks11 = getCachedKeystroke(KEY_CONTROL_PRIOR_END);
    this.getInputMap(c).put(ks11, "F11_PRESS");
    this.getActionMap().put("F11_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnSkipToEndStepBeforeYourTurnActionPerformed(actionEvent);
        }
    });
    btnSkipStack.setContentAreaFilled(false);
    btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipStackButtonImage()));
    btnSkipStack.setToolTipText("dynamic");
    btnSkipStack.setFocusable(false);
    btnSkipStack.addMouseListener(new FirstButtonMousePressedAction(e -> btnPassPriorityUntilStackResolvedActionPerformed(null)));
    ks = getCachedKeystroke(KEY_CONTROL_SKIP_STACK);
    this.getInputMap(c).put(ks, "F10_PRESS");
    this.getActionMap().put("F10_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            btnPassPriorityUntilStackResolvedActionPerformed(actionEvent);
        }
    });
    btnConcede.setContentAreaFilled(false);
    btnConcede.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
    btnConcede.setIcon(new ImageIcon(ImageManagerImpl.instance.getConcedeButtonImage()));
    btnConcede.setToolTipText("CONCEDE current game");
    btnConcede.setFocusable(false);
    btnConcede.addMouseListener(new FirstButtonMousePressedAction(e -> btnConcedeActionPerformed(null)));
    // update button hint/states to default values
    updateSkipButtons();
    // HOTKEYS
    KeyStroke ks2 = getCachedKeystroke(KEY_CONTROL_CONFIRM);
    this.getInputMap(c).put(ks2, "F2_PRESS");
    this.getActionMap().put("F2_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            if (feedbackPanel != null) {
                feedbackPanel.pressOKYesOrDone();
            }
        }
    });
    KeyStroke ks12 = getCachedKeystroke(KEY_CONTROL_SWITCH_CHAT);
    this.getInputMap(c).put(ks12, "F12_PRESS");
    this.getActionMap().put("F12_PRESS", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            // if (isUserImputActive()) return;
            if (isChatInputActive()) {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().clearFocusOwner();
            } else if (!isUserImputActive()) {
                userChatPanel.getTxtMessageInputComponent().requestFocusInWindow();
            }
        }
    });
    KeyStroke ksAltE = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK);
    this.getInputMap(c).put(ksAltE, "ENLARGE");
    this.getActionMap().put("ENLARGE", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            ActionCallback callback = Plugins.instance.getActionCallback();
            ((MageActionCallback) callback).enlargeCard(EnlargeMode.NORMAL);
        }
    });
    KeyStroke ksAltS = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK);
    this.getInputMap(c).put(ksAltS, "ENLARGE_SOURCE");
    this.getActionMap().put("ENLARGE_SOURCE", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            ActionCallback callback = Plugins.instance.getActionCallback();
            ((MageActionCallback) callback).enlargeCard(EnlargeMode.ALTERNATE);
        }
    });
    KeyStroke ksAltD = KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.ALT_MASK);
    this.getInputMap(c).put(ksAltD, "BIG_IMAGE");
    this.getActionMap().put("BIG_IMAGE", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            imagePanelState = !imagePanelState;
            if (!imagePanelState) {
                jSplitPane0.resetToPreferredSizes();
                jSplitPane0.setDividerLocation(jSplitPane0.getSize().width - jSplitPane0.getInsets().right - jSplitPane0.getDividerSize() - 260);
            } else {
                jSplitPane0.setDividerLocation(1.0);
            }
        }
    });
    KeyStroke ksAlt1 = KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK);
    this.getInputMap(c).put(ksAlt1, "USEFIRSTMANAABILITY");
    this.getActionMap().put("USEFIRSTMANAABILITY", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_ON, gameId, null);
            setMenuStates(PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"), PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"), PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"), holdingPriority);
        }
    });
    final BasicSplitPaneUI myUi = (BasicSplitPaneUI) jSplitPane0.getUI();
    final BasicSplitPaneDivider divider = myUi.getDivider();
    final JButton upArrowButton = (JButton) divider.getComponent(0);
    upArrowButton.addActionListener(actionEvent -> PreferencesDialog.saveValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED, "up"));
    final JButton downArrowButton = (JButton) divider.getComponent(1);
    downArrowButton.addActionListener(actionEvent -> PreferencesDialog.saveValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED, "down"));
    KeyStroke ksAltEReleased = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK, true);
    this.getInputMap(c).put(ksAltEReleased, "ENLARGE_RELEASE");
    KeyStroke ksAltSReleased = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK, true);
    this.getInputMap(c).put(ksAltSReleased, "ENLARGE_RELEASE");
    this.getActionMap().put("ENLARGE_RELEASE", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            ActionCallback callback = Plugins.instance.getActionCallback();
            ((MageActionCallback) callback).hideEnlargedCard();
        }
    });
    KeyStroke ksAlt1Released = KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK, true);
    this.getInputMap(c).put(ksAlt1Released, "USEFIRSTMANAABILITY_RELEASE");
    this.getActionMap().put("USEFIRSTMANAABILITY_RELEASE", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (isUserImputActive())
                return;
            SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
            setMenuStates(PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"), PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"), PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"), holdingPriority);
        }
    });
    btnSwitchHands.setContentAreaFilled(false);
    btnSwitchHands.setBorder(new EmptyBorder(0, 0, 0, 0));
    btnSwitchHands.setIcon(new ImageIcon(ImageManagerImpl.instance.getSwitchHandsButtonImage()));
    btnSwitchHands.setFocusable(false);
    btnSwitchHands.setToolTipText("Switch between your hand cards and hand cards of controlled players.");
    btnSwitchHands.addMouseListener(new FirstButtonMousePressedAction(e -> btnSwitchHandActionPerformed(null)));
    btnStopWatching.setContentAreaFilled(false);
    btnStopWatching.setBorder(new EmptyBorder(0, 0, 0, 0));
    btnStopWatching.setIcon(new ImageIcon(ImageManagerImpl.instance.getStopWatchButtonImage()));
    btnStopWatching.setFocusable(false);
    btnStopWatching.setToolTipText("Stop watching this game.");
    btnStopWatching.addMouseListener(new FirstButtonMousePressedAction(e -> btnStopWatchingActionPerformed(null)));
    stackObjects.setBackgroundColor(new Color(0, 0, 0, 40));
    btnStopReplay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop.png")));
    btnStopReplay.addActionListener(evt -> btnStopReplayActionPerformed(evt));
    btnNextPlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop_right.png")));
    btnNextPlay.addActionListener(evt -> btnNextPlayActionPerformed(evt));
    btnPlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_right.png")));
    btnPlay.addActionListener(evt -> btnPlayActionPerformed(evt));
    btnSkipForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_double_stop_right.png")));
    btnSkipForward.addActionListener(evt -> btnSkipForwardActionPerformed(evt));
    btnPreviousPlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop_left.png")));
    btnPreviousPlay.addActionListener(evt -> btnPreviousPlayActionPerformed(evt));
    initPopupMenuTriggerOrder();
    setGUISize();
    // Replay panel to control replay of games
    javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
    pnlReplay.setLayout(gl_pnlReplay);
    gl_pnlReplay.setHorizontalGroup(gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(gl_pnlReplay.createSequentialGroup().addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)));
    gl_pnlReplay.setVerticalGroup(gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE).addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE).addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE).addComponent(btnPlay, 0, 0, Short.MAX_VALUE).addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE));
    // Game info panel (buttons on the right panel)
    javax.swing.GroupLayout gl_pnlShortCuts = new javax.swing.GroupLayout(pnlShortCuts);
    pnlShortCuts.setLayout(gl_pnlShortCuts);
    gl_pnlShortCuts.setHorizontalGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(gl_pnlShortCuts.createSequentialGroup().addComponent(btnSkipToNextTurn).addComponent(btnSkipToEndTurn).addComponent(btnSkipToNextMain).addComponent(btnSkipToYourTurn).addComponent(btnSkipStack).addComponent(btnSkipToEndStepBeforeYourTurn)).addGroup(gl_pnlShortCuts.createSequentialGroup().addComponent(txtHoldPriority).addComponent(txtSpellsCast).addComponent(btnSwitchHands).addComponent(btnCancelSkip).addComponent(btnConcede).addComponent(btnStopWatching)).addGroup(gl_pnlShortCuts.createSequentialGroup().addContainerGap().addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(51, Short.MAX_VALUE)));
    gl_pnlShortCuts.setVerticalGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(gl_pnlShortCuts.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 164, Short.MAX_VALUE).addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(btnSkipToNextTurn).addComponent(btnSkipToEndTurn).addComponent(btnSkipToNextMain).addComponent(btnSkipToYourTurn).addComponent(btnSkipStack).addComponent(btnSkipToEndStepBeforeYourTurn)).addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(txtHoldPriority).addComponent(txtSpellsCast).addComponent(btnSwitchHands).addComponent(btnCancelSkip).addComponent(btnConcede).addComponent(btnStopWatching))));
    pnlBattlefield.setLayout(new java.awt.GridBagLayout());
    jPhases = new JPanel();
    jPhases.setBackground(new Color(0, 0, 0, 0));
    jPhases.setLayout(null);
    jPhases.setPreferredSize(new Dimension(X_PHASE_WIDTH, 435));
    MouseAdapter phasesMouseAdapter = new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            mouseClickPhaseBar(evt);
        }
    };
    String[] phases = { "Untap", "Upkeep", "Draw", "Main1", "Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End", "Main2", "Cleanup", "Next_Turn" };
    for (String name : phases) {
        createPhaseButton(name, phasesMouseAdapter);
    }
    int i = 0;
    for (String name : hoverButtons.keySet()) {
        HoverButton hoverButton = hoverButtons.get(name);
        hoverButton.setAlignmentX(LEFT_ALIGNMENT);
        hoverButton.setBounds(X_PHASE_WIDTH - 36, i * 36, 36, 36);
        jPhases.add(hoverButton);
        i++;
    }
    jPhases.addMouseListener(phasesMouseAdapter);
    pnlReplay.setOpaque(false);
    helper = new HelperPanel();
    feedbackPanel.setHelperPanel(helper);
    jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane2.setResizeWeight(0.5);
    jSplitPane2.setLeftComponent(userChatPanel);
    jSplitPane2.setBottomComponent(gameChatPanel);
    phasesContainer = new JPanel();
    phasesContainer.setLayout(new RelativeLayout(RelativeLayout.Y_AXIS));
    phasesContainer.setBackground(new Color(0, 0, 0, 0));
    Float ratio = (float) 1;
    JPanel empty1 = new JPanel();
    empty1.setBackground(new Color(0, 0, 0, 0));
    phasesContainer.add(empty1, ratio);
    phasesContainer.add(jPhases);
    javax.swing.GroupLayout gl_helperHandButtonsStackArea = new javax.swing.GroupLayout(pnlHelperHandButtonsStackArea);
    gl_helperHandButtonsStackArea.setHorizontalGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING).addGroup(gl_helperHandButtonsStackArea.createSequentialGroup().addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING).addGroup(gl_helperHandButtonsStackArea.createSequentialGroup().addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING).addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING).addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE).addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE))).addGap(0).addGroup(gl_helperHandButtonsStackArea.createSequentialGroup().addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE).addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))));
    gl_helperHandButtonsStackArea.setVerticalGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.TRAILING).addGroup(gl_helperHandButtonsStackArea.createSequentialGroup().addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING).addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE).addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING).addGroup(gl_helperHandButtonsStackArea.createSequentialGroup().addGap(2).addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(stackObjects, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGroup(gl_helperHandButtonsStackArea.createSequentialGroup().addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))));
    pnlHelperHandButtonsStackArea.setLayout(gl_helperHandButtonsStackArea);
    jSplitPane1.setLeftComponent(pnlHelperHandButtonsStackArea);
    jSplitPane1.setRightComponent(jSplitPane2);
    // Set individual area sizes of big card pane
    GridBagLayout gbl = new GridBagLayout();
    jPanel2.setLayout(gbl);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    // size 4/5
    gbc.gridheight = 4;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbl.setConstraints(bigCard, gbc);
    jPanel2.add(bigCard);
    jPanel2.setOpaque(false);
    // game pane and chat/log pane
    jSplitPane0.setLeftComponent(jSplitPane1);
    // big card and buttons
    jSplitPane0.setRightComponent(jPanel2);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE));
}
Also used : MageActionCallback(mage.client.plugins.adapters.MageActionCallback) RelativeLayout(mage.client.components.layout.RelativeLayout) KeyboundButton(mage.client.components.KeyboundButton) Border(javax.swing.border.Border) PropertyVetoException(java.beans.PropertyVetoException) mage.view(mage.view) Logger(org.apache.log4j.Logger) PlayerAction(mage.constants.PlayerAction) Card(mage.cards.Card) mage.constants(mage.constants) ArrowBuilder(mage.client.util.gui.ArrowBuilder) Choice(mage.choices.Choice) Timer(javax.swing.Timer) MageComponents(mage.client.components.MageComponents) CancellationException(java.util.concurrent.CancellationException) MageDialogState(mage.client.util.gui.MageDialogState) mage.client.dialog(mage.client.dialog) Serializable(java.io.Serializable) HoverButton(mage.client.components.HoverButton) Plugins(mage.client.plugins.impl.Plugins) List(java.util.List) Alignment(javax.swing.GroupLayout.Alignment) BigCard(mage.client.cards.BigCard) Event(mage.client.util.Event) ShowType(mage.client.dialog.CardInfoWindowDialog.ShowType) java.awt.event(java.awt.event) EmptyBorder(javax.swing.border.EmptyBorder) PlayableObjectsList(mage.players.PlayableObjectsList) ImageManagerImpl(org.mage.plugins.card.utils.impl.ImageManagerImpl) FeedbackMode(mage.client.game.FeedbackPanel.FeedbackMode) mage.client.util(mage.client.util) java.util(java.util) MageFrame(mage.client.MageFrame) BasicSplitPaneUI(javax.swing.plaf.basic.BasicSplitPaneUI) AudioManager(mage.client.util.audio.AudioManager) LineBorder(javax.swing.border.LineBorder) ActionCallback(mage.cards.action.ActionCallback) CombatManager(mage.client.combat.CombatManager) ChatPanelBasic(mage.client.chat.ChatPanelBasic) MageCard(mage.cards.MageCard) PlayableObjectStats(mage.players.PlayableObjectStats) SessionHandler(mage.client.SessionHandler) DialogManager(mage.client.components.ext.dlg.DialogManager) java.awt(java.awt) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) PreferencesDialog(mage.client.dialog.PreferencesDialog) PlayerQueryEvent(mage.game.events.PlayerQueryEvent) BasicSplitPaneDivider(javax.swing.plaf.basic.BasicSplitPaneDivider) javax.swing(javax.swing) LineBorder(javax.swing.border.LineBorder) EmptyBorder(javax.swing.border.EmptyBorder) MageActionCallback(mage.client.plugins.adapters.MageActionCallback) ActionCallback(mage.cards.action.ActionCallback) BasicSplitPaneDivider(javax.swing.plaf.basic.BasicSplitPaneDivider) BigCard(mage.client.cards.BigCard) HoverButton(mage.client.components.HoverButton) RelativeLayout(mage.client.components.layout.RelativeLayout) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder) LineBorder(javax.swing.border.LineBorder) LineBorder(javax.swing.border.LineBorder) ChatPanelBasic(mage.client.chat.ChatPanelBasic) javax.swing(javax.swing) KeyboundButton(mage.client.components.KeyboundButton) BasicSplitPaneUI(javax.swing.plaf.basic.BasicSplitPaneUI) java.awt(java.awt)

Example 2 with ActionCallback

use of mage.cards.action.ActionCallback in project mage by magefree.

the class MagePaneMenuItem method setActive.

public static void setActive(MagePane frame) {
    // Always hide not hidden popup window or enlarged card view if a frame is set to active
    try {
        ActionCallback callback = Plugins.instance.getActionCallback();
        if (callback instanceof MageActionCallback) {
            ((MageActionCallback) callback).hideEnlargedCard();
        }
        Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
        if (container.isVisible()) {
            container.setVisible(false);
            container.repaint();
        }
    } catch (InterruptedException e) {
        LOGGER.fatal("MageFrame error", e);
        Thread.currentThread().interrupt();
    }
    // Nothing to do
    if (activeFrame == frame) {
        return;
    }
    // Deactivate current frame if there is one
    if (activeFrame != null) {
        activeFrame.deactivated();
    }
    // If null, no new frame to activate, return early
    if (frame == null) {
        activeFrame = null;
        return;
    }
    LOGGER.debug("Setting " + frame.getTitle() + " active");
    activeFrame = frame;
    desktopPane.moveToFront(frame);
    activeFrame.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
    activeFrame.revalidate();
    activeFrame.activated();
    activeFrame.setVisible(true);
    ArrowBuilder.getBuilder().hideAllPanels();
    if (frame instanceof GamePane) {
        ArrowBuilder.getBuilder().showPanel(((GamePane) frame).getGameId());
        MusicPlayer.playBGM();
    } else {
        MusicPlayer.stopBGM();
    }
}
Also used : MageActionCallback(mage.client.plugins.adapters.MageActionCallback) MageActionCallback(mage.client.plugins.adapters.MageActionCallback) ActionCallback(mage.cards.action.ActionCallback) GamePane(mage.client.game.GamePane)

Example 3 with ActionCallback

use of mage.cards.action.ActionCallback in project mage by magefree.

the class ReplayTask method hideAll.

private void hideAll() {
    hidePickDialogs();
    this.abilityPicker.setVisible(false);
    ActionCallback callback = Plugins.instance.getActionCallback();
    ((MageActionCallback) callback).hideGameUpdate(gameId);
}
Also used : MageActionCallback(mage.client.plugins.adapters.MageActionCallback) MageActionCallback(mage.client.plugins.adapters.MageActionCallback) ActionCallback(mage.cards.action.ActionCallback)

Aggregations

ActionCallback (mage.cards.action.ActionCallback)3 MageActionCallback (mage.client.plugins.adapters.MageActionCallback)3 java.awt (java.awt)1 java.awt.event (java.awt.event)1 PropertyVetoException (java.beans.PropertyVetoException)1 Serializable (java.io.Serializable)1 java.util (java.util)1 List (java.util.List)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 javax.swing (javax.swing)1 Alignment (javax.swing.GroupLayout.Alignment)1 Timer (javax.swing.Timer)1 Border (javax.swing.border.Border)1 EmptyBorder (javax.swing.border.EmptyBorder)1 LineBorder (javax.swing.border.LineBorder)1 BasicSplitPaneDivider (javax.swing.plaf.basic.BasicSplitPaneDivider)1 BasicSplitPaneUI (javax.swing.plaf.basic.BasicSplitPaneUI)1 Card (mage.cards.Card)1