Search in sources :

Example 1 with PBEMMessagePoster

use of games.strategy.engine.pbem.PBEMMessagePoster in project triplea by triplea-game.

the class AbstractForumPosterPanel method waitForDone.

protected void waitForDone(final TripleAFrame frame, final IPlayerBridge bridge) {
    tripleAFrame = frame;
    playerBridge = bridge;
    // Nothing to do if there are no PBEM messengers
    pbemMessagePoster = new PBEMMessagePoster(getData(), getCurrentPlayer(), getRound(), getTitle());
    if (!pbemMessagePoster.hasMessengers()) {
        return;
    }
    if (skipPosting() || GameStepPropertiesHelper.isSkipPosting(getData())) {
        return;
    }
    final boolean hasPosted = getHasPostedTurnSummary();
    SwingUtilities.invokeLater(() -> {
        removeAll();
        add(actionLabel);
        add(forumPosterComponent.layoutComponents(pbemMessagePoster, getForumPosterDelegate(), tripleAFrame, hasPosted, allowIncludeTerritorySummary(), allowIncludeTerritoryAllPlayersSummary(), allowIncludeProductionSummary(), allowDiceBattleDetails(), allowDiceStatistics()));
        validate();
    });
    waitForRelease();
}
Also used : PBEMMessagePoster(games.strategy.engine.pbem.PBEMMessagePoster)

Example 2 with PBEMMessagePoster

use of games.strategy.engine.pbem.PBEMMessagePoster in project triplea by triplea-game.

the class FileMenu method addPostPbem.

private JMenuItem addPostPbem() {
    final JMenuItem menuPbem = new JMenuItem(SwingAction.of("Post PBEM/PBF Gamesave", e -> {
        if (!PBEMMessagePoster.gameDataHasPlayByEmailOrForumMessengers(gameData)) {
            return;
        }
        final String title = "Manual Gamesave Post";
        try {
            gameData.acquireReadLock();
            final GameStep step = gameData.getSequence().getStep();
            final PlayerID currentPlayer = (step == null ? PlayerID.NULL_PLAYERID : (step.getPlayerId() == null ? PlayerID.NULL_PLAYERID : step.getPlayerId()));
            final int round = gameData.getSequence().getRound();
            final HistoryLog historyLog = new HistoryLog();
            historyLog.printFullTurn(gameData, true, GameStepPropertiesHelper.getTurnSummaryPlayers(gameData));
            final PBEMMessagePoster poster = new PBEMMessagePoster(gameData, currentPlayer, round, title);
            PBEMMessagePoster.postTurn(title, historyLog, true, poster, null, frame, null);
        } finally {
            gameData.releaseReadLock();
        }
    }));
    menuPbem.setMnemonic(KeyEvent.VK_P);
    menuPbem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    return menuPbem;
}
Also used : KeyStroke(javax.swing.KeyStroke) SystemProperties(games.strategy.engine.framework.system.SystemProperties) GameStepPropertiesHelper(games.strategy.triplea.delegate.GameStepPropertiesHelper) JMenu(javax.swing.JMenu) HistoryLog(games.strategy.triplea.ui.history.HistoryLog) KeyEvent(java.awt.event.KeyEvent) JOptionPane(javax.swing.JOptionPane) File(java.io.File) TripleAFrame(games.strategy.triplea.ui.TripleAFrame) GameData(games.strategy.engine.data.GameData) PlayerID(games.strategy.engine.data.PlayerID) JMenuItem(javax.swing.JMenuItem) MacQuitMenuWrapper(games.strategy.triplea.ui.MacQuitMenuWrapper) IGame(games.strategy.engine.framework.IGame) GameStep(games.strategy.engine.data.GameStep) PBEMMessagePoster(games.strategy.engine.pbem.PBEMMessagePoster) Toolkit(java.awt.Toolkit) SwingAction(games.strategy.ui.SwingAction) PlayerID(games.strategy.engine.data.PlayerID) GameStep(games.strategy.engine.data.GameStep) HistoryLog(games.strategy.triplea.ui.history.HistoryLog) JMenuItem(javax.swing.JMenuItem) PBEMMessagePoster(games.strategy.engine.pbem.PBEMMessagePoster)

Aggregations

PBEMMessagePoster (games.strategy.engine.pbem.PBEMMessagePoster)2 GameData (games.strategy.engine.data.GameData)1 GameStep (games.strategy.engine.data.GameStep)1 PlayerID (games.strategy.engine.data.PlayerID)1 IGame (games.strategy.engine.framework.IGame)1 SystemProperties (games.strategy.engine.framework.system.SystemProperties)1 GameStepPropertiesHelper (games.strategy.triplea.delegate.GameStepPropertiesHelper)1 MacQuitMenuWrapper (games.strategy.triplea.ui.MacQuitMenuWrapper)1 TripleAFrame (games.strategy.triplea.ui.TripleAFrame)1 HistoryLog (games.strategy.triplea.ui.history.HistoryLog)1 SwingAction (games.strategy.ui.SwingAction)1 Toolkit (java.awt.Toolkit)1 KeyEvent (java.awt.event.KeyEvent)1 File (java.io.File)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 JOptionPane (javax.swing.JOptionPane)1 KeyStroke (javax.swing.KeyStroke)1