mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
added watch game methods
This commit is contained in:
parent
8225a4080c
commit
4bb7ffd452
22 changed files with 235 additions and 114 deletions
|
|
@ -665,7 +665,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
});
|
||||
}
|
||||
|
||||
public void watchGame(final UUID gameId) {
|
||||
@Override
|
||||
public void watchGame(final UUID gameId, final UUID chatId, final GameView game) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -681,7 +682,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setMaximum(true);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.watchGame(gameId);
|
||||
gamePane.watchGame(gameId, chatId, game);
|
||||
setActive(gamePane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
|
|
@ -1524,13 +1525,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
@Override
|
||||
public void gameStarted(UUID gameId, UUID playerId) {
|
||||
// try {
|
||||
GameManager.getInstance().setCurrentPlayerUUID(playerId);
|
||||
showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
GameManager.getInstance().setCurrentPlayerUUID(playerId);
|
||||
showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
|
||||
if (Plugins.getInstance().isCounterPluginLoaded()) {
|
||||
Plugins.getInstance().addGamesPlayed();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import java.util.UUID;
|
|||
import javax.swing.SwingUtilities;
|
||||
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||
import mage.client.MagePane;
|
||||
import mage.view.GameView;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -74,10 +75,10 @@ public class GamePane extends MagePane {
|
|||
this.removeFrame();
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
public void watchGame(UUID gameId, UUID chatId, GameView game) {
|
||||
this.setTitle("Watching " + gameId);
|
||||
this.gameId = gameId;
|
||||
gamePanel.watchGame(gameId, this);
|
||||
gamePanel.watchGame(gameId, chatId, game, this);
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void watchGame(UUID gameId, GamePane gamePane) {
|
||||
public synchronized void watchGame(UUID gameId, UUID chatId, GameView game, GamePane gamePane) {
|
||||
this.gameId = gameId;
|
||||
this.gamePane = gamePane;
|
||||
this.playerId = null;
|
||||
|
|
@ -423,13 +423,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
this.pnlReplay.setVisible(false);
|
||||
this.gameChatPanel.clear();
|
||||
UUID chatId = client.watchGame(gameId);
|
||||
if (chatId == null) {
|
||||
removeGame();
|
||||
}
|
||||
else {
|
||||
this.gameChatPanel.connect(chatId);
|
||||
}
|
||||
this.init(game);
|
||||
for (PlayAreaPanel panel : getPlayers().values()) {
|
||||
panel.setPlayingMode(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,6 +271,11 @@ public class MultiConnectTest {
|
|||
public void tournamentStarted(UUID tournamentId) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watchGame(UUID gameId, UUID chatId, GameView game) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue