Search in sources :

Example 6 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGameTableModelTest method updateGameAddsIfDoesNotExist.

@Test
public void updateGameAddsIfDoesNotExist() {
    testObj.getLobbyGameBroadcaster().gameUpdated(new GUID(), new GameDescription());
    TestUtil.waitForSwingThreads();
    assertThat(testObj.getRowCount(), is(2));
}
Also used : GUID(games.strategy.net.GUID) GameDescription(games.strategy.engine.lobby.server.GameDescription) Test(org.junit.jupiter.api.Test)

Example 7 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class GameRunner method joinGame.

public static void joinGame(final GameDescription description, final Messengers messengers, final Container parent) {
    final GameDescription.GameStatus status = description.getStatus();
    if (GameDescription.GameStatus.LAUNCHING == status) {
        return;
    }
    final Version engineVersionOfGameToJoin = new Version(description.getEngineVersion());
    final String newClassPath = null;
    if (!GameEngineVersion.of(ClientContext.engineVersion()).isCompatibleWithEngineVersion(engineVersionOfGameToJoin)) {
        JOptionPane.showMessageDialog(parent, "Host is using version " + engineVersionOfGameToJoin.toStringFull() + ". You need to have a compatible engine version in order to join this game.", "Incompatible TripleA engine", JOptionPane.ERROR_MESSAGE);
        return;
    }
    joinGame(description.getPort(), description.getHostedBy().getAddress().getHostAddress(), newClassPath, messengers);
}
Also used : Version(games.strategy.util.Version) GameEngineVersion(games.strategy.engine.GameEngineVersion) GameDescription(games.strategy.engine.lobby.server.GameDescription)

Example 8 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGamePanel method mouseOnGamesList.

private void mouseOnGamesList(final MouseEvent e) {
    if (!e.isPopupTrigger()) {
        return;
    }
    if (!SwingUtilities.isRightMouseButton(e)) {
        return;
    }
    final int selectedIndex = gameTable.getSelectedRow();
    if (selectedIndex == -1) {
        return;
    }
    final JPopupMenu menu = new JPopupMenu();
    getUserGamesListContextActions().forEach(menu::add);
    if (isAdmin()) {
        final Collection<Action> generalAdminActions = getGeneralAdminGamesListContextActions();
        if (!generalAdminActions.isEmpty()) {
            menu.addSeparator();
            generalAdminActions.forEach(menu::add);
        }
        final GameDescription gameDescription = gameTableModel.get(gameTable.convertRowIndexToModel(selectedIndex));
        if (gameDescription.isBot()) {
            final Collection<Action> botAdminActions = getBotAdminGamesListContextActions(gameDescription);
            if (!botAdminActions.isEmpty()) {
                menu.addSeparator();
                botAdminActions.forEach(menu::add);
            }
        }
    }
    if (menu.getComponentCount() > 0) {
        menu.show(gameTable, e.getX(), e.getY());
    }
}
Also used : Action(javax.swing.Action) SwingAction(games.strategy.ui.SwingAction) GameDescription(games.strategy.engine.lobby.server.GameDescription) JPopupMenu(javax.swing.JPopupMenu)

Example 9 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGamePanel method joinGame.

private void joinGame() {
    final int selectedIndex = gameTable.getSelectedRow();
    if (selectedIndex == -1) {
        return;
    }
    // we sort the table, so get the correct index
    final GameDescription description = gameTableModel.get(gameTable.convertRowIndexToModel(selectedIndex));
    GameRunner.joinGame(description, messengers, getParent());
}
Also used : GameDescription(games.strategy.engine.lobby.server.GameDescription)

Aggregations

GameDescription (games.strategy.engine.lobby.server.GameDescription)9 Test (org.junit.jupiter.api.Test)3 GameEngineVersion (games.strategy.engine.GameEngineVersion)1 GUID (games.strategy.net.GUID)1 INode (games.strategy.net.INode)1 Node (games.strategy.net.Node)1 SwingAction (games.strategy.ui.SwingAction)1 Version (games.strategy.util.Version)1 Component (java.awt.Component)1 Action (javax.swing.Action)1 JPopupMenu (javax.swing.JPopupMenu)1