use of games.strategy.triplea.delegate.EditDelegate in project triplea by triplea-game.
the class TripleA method startGame.
@Override
public void startGame(final IGame game, final Set<IGamePlayer> players, final boolean headless) throws InterruptedException {
this.game = game;
if (game.getData().getDelegateList().getDelegate("edit") == null) {
// An evil hack: instead of modifying the XML, force an EditDelegate by adding one here
final EditDelegate delegate = new EditDelegate();
delegate.initialize("edit", "edit");
game.getData().getDelegateList().addDelegate(delegate);
if (game instanceof ServerGame) {
((ServerGame) game).addDelegateMessenger(delegate);
}
}
final LocalPlayers localPlayers = new LocalPlayers(players);
if (headless) {
final UiContext uiContext = new HeadlessUiContext();
uiContext.setDefaultMapDir(game.getData());
uiContext.setLocalPlayers(localPlayers);
display = new HeadlessDisplay();
soundChannel = new HeadlessSoundChannel();
game.addDisplay(display);
game.addSoundChannel(soundChannel);
// technically not needed because we won't have any "local human players" in a headless game.
connectPlayers(players, null);
} else {
SwingAction.invokeAndWait(() -> {
final TripleAFrame frame = new TripleAFrame(game, localPlayers);
LookAndFeelSwingFrameListener.register(frame);
display = new TripleADisplay(frame);
game.addDisplay(display);
soundChannel = new DefaultSoundChannel(localPlayers);
game.addSoundChannel(soundChannel);
frame.setSize(700, 400);
frame.setVisible(true);
ClipPlayer.play(SoundPath.CLIP_GAME_START);
connectPlayers(players, frame);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.toFront();
});
}
}
Aggregations