Search in sources :

Example 1 with GamePane

use of mage.client.game.GamePane in project mage by magefree.

the class MagePaneMenuItem method replayGame.

public void replayGame(UUID gameId) {
    GamePane gamePane = new GamePane();
    desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
    gamePane.setVisible(true);
    gamePane.replayGame(gameId);
    setActive(gamePane);
}
Also used : GamePane(mage.client.game.GamePane)

Example 2 with GamePane

use of mage.client.game.GamePane in project mage by magefree.

the class MagePaneMenuItem method showGame.

/**
 * Shows a game for a player of the game
 *
 * @param gameId
 * @param playerId
 */
public void showGame(UUID gameId, UUID playerId) {
    GamePane gamePane = new GamePane();
    desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
    gamePane.setVisible(true);
    gamePane.showGame(gameId, playerId);
    setActive(gamePane);
}
Also used : GamePane(mage.client.game.GamePane)

Example 3 with GamePane

use of mage.client.game.GamePane in project mage by magefree.

the class MagePaneMenuItem method watchGame.

public void watchGame(UUID gameId) {
    for (Component component : desktopPane.getComponents()) {
        if (component instanceof GamePane && ((GamePane) component).getGameId().equals(gameId)) {
            setActive((GamePane) component);
            return;
        }
    }
    GamePane gamePane = new GamePane();
    desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
    gamePane.setVisible(true);
    gamePane.watchGame(gameId);
    setActive(gamePane);
}
Also used : GamePane(mage.client.game.GamePane)

Example 4 with GamePane

use of mage.client.game.GamePane in project mage by magefree.

the class MagePaneMenuItem method hideGames.

public void hideGames() {
    Component[] windows = desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
    for (Component window : windows) {
        if (window instanceof GamePane) {
            GamePane gamePane = (GamePane) window;
            gamePane.removeGame();
        }
        if (window instanceof DraftPane) {
            DraftPane draftPane = (DraftPane) window;
            draftPane.removeDraft();
        }
        if (window instanceof TournamentPane) {
            TournamentPane tournamentPane = (TournamentPane) window;
            tournamentPane.removeTournament();
        }
        // close & remove sideboarding or construction pane if open
        if (window instanceof DeckEditorPane) {
            DeckEditorPane deckEditorPane = (DeckEditorPane) window;
            if (deckEditorPane.getDeckEditorMode() == DeckEditorMode.LIMITED_BUILDING || deckEditorPane.getDeckEditorMode() == DeckEditorMode.SIDEBOARDING || deckEditorPane.getDeckEditorMode() == DeckEditorMode.VIEW_LIMITED_DECK) {
                deckEditorPane.removeFrame();
            }
        }
    }
}
Also used : TournamentPane(mage.client.tournament.TournamentPane) DeckEditorPane(mage.client.deckeditor.DeckEditorPane) GamePane(mage.client.game.GamePane) DraftPane(mage.client.draft.DraftPane)

Example 5 with GamePane

use of mage.client.game.GamePane 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)

Aggregations

GamePane (mage.client.game.GamePane)6 MageCard (mage.cards.MageCard)1 ActionCallback (mage.cards.action.ActionCallback)1 MagePane (mage.client.MagePane)1 DeckEditorPane (mage.client.deckeditor.DeckEditorPane)1 DraftPane (mage.client.draft.DraftPane)1 MageActionCallback (mage.client.plugins.adapters.MageActionCallback)1 TournamentPane (mage.client.tournament.TournamentPane)1