public static void awaitShutdown(IStartedGame startedGame) { final MutableInt gameStopped = new MutableInt(0); startedGame.setGameExitListener(game -> { gameStopped.value = 1; synchronized (gameStopped) { gameStopped.notifyAll(); } }); ((GameRunner) startedGame).stopGame(); synchronized (gameStopped) { while (gameStopped.value == 0 && !startedGame.isShutdownFinished()) { try { gameStopped.wait(); } catch (InterruptedException e) { } } } }
this.map = game.getMap(); if(map instanceof IDirectGridProvider) { IDirectGridProvider dgp = (IDirectGridProvider) map; this.gameTimeProvider = game.getGameTimeProvider(); this.textDrawPosition = textDrawPosition; this.messenger = new Messenger(this.gameTimeProvider); this.controls = new OriginalControls(this, game.getInGamePlayer()); } else { this.controls = controls;
public IMapInterfaceConnector showStartedGame(IStartedGame startedGame) { MapContent content = new MapContent(startedGame, soundPlayer, SettingsManager.getInstance().getFpsLimit(), ETextDrawPosition.TOP_RIGHT); SwingUtilities.invokeLater(() -> setContent(content)); startedGame.setGameExitListener(exitGame -> SwingUtilities.invokeLater(this::showMainMenu)); return content.getInterfaceConnector(); } }