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);
}
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);
}
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);
}
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();
}
}
}
}
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();
}
}
Aggregations