Search in sources :

Example 1 with JPanelBuilder

use of swinglib.JPanelBuilder in project triplea by triplea-game.

the class MapOptionsPanel method build.

static JPanel build(final GameData gameData, final StagingScreen screen) {
    final GameProperties properties = gameData.getProperties();
    final List<IEditableProperty> props = properties.getEditableProperties();
    final JPanelBuilder panelBuilder = JPanelBuilder.builder().gridBagLayout(2).add(new JLabel("<html><h2>Map Options</h2></html>")).add(new JPanel());
    props.stream().filter(prop -> !prop.getName().contains("bid")).forEach(prop -> {
        panelBuilder.add(JLabelBuilder.builder().textWithMaxLength(prop.getName(), 25).tooltip(prop.getName()).build());
        panelBuilder.add(screen != StagingScreen.NETWORK_CLIENT ? prop.getEditorComponent() : prop.getEditorComponentDisabled());
    });
    return panelBuilder.build();
}
Also used : GameProperties(games.strategy.engine.data.properties.GameProperties) GameProperties(games.strategy.engine.data.properties.GameProperties) GameData(games.strategy.engine.data.GameData) List(java.util.List) JLabelBuilder(swinglib.JLabelBuilder) JLabel(javax.swing.JLabel) JPanelBuilder(swinglib.JPanelBuilder) JPanel(javax.swing.JPanel) IEditableProperty(games.strategy.engine.data.properties.IEditableProperty) JPanel(javax.swing.JPanel) JPanelBuilder(swinglib.JPanelBuilder) JLabel(javax.swing.JLabel) IEditableProperty(games.strategy.engine.data.properties.IEditableProperty)

Example 2 with JPanelBuilder

use of swinglib.JPanelBuilder in project triplea by triplea-game.

the class HandicapPanel method build.

/**
 * Builds a 'Handicap' panel, see class comment for more details.
 */
public static List<JComponent> build(final GameData gameData) {
    final List<JComponent> selectionPanels = new ArrayList<>();
    final Set<String> alliances = gameData.getAllianceTracker().getAlliances();
    for (final String alliance : alliances) {
        final JPanelBuilder allianceSelection = JPanelBuilder.builder().borderEtched().gridBagLayout(4).addLabel("<html><h2>" + alliance + "</h2></html").addLabel("<html><b>Bid</b></html").addLabel("<html><b>Income<br />Bonus</b></html").addLabel("<html><b>Income<br />Multiplier</b></html");
        for (final PlayerID player : gameData.getAllianceTracker().getPlayersInAlliance(alliance)) {
            allianceSelection.add(new JLabel(player.getName()));
            final JTextField bid = new JTextField("0", 3);
            allianceSelection.add(JPanelBuilder.builder().flowLayout().add(bid).add(Box.createVerticalGlue()).build());
            final JTextField income = new JTextField("0", 3);
            allianceSelection.add(JPanelBuilder.builder().flowLayout().add(income).add(Box.createVerticalGlue()).build());
            final JTextField multiplier = new JTextField("100%", 5);
            allianceSelection.add(JPanelBuilder.builder().flowLayout().add(multiplier).add(Box.createVerticalGlue()).build());
        }
        selectionPanels.add(allianceSelection.build());
    }
    return selectionPanels;
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) JPanelBuilder(swinglib.JPanelBuilder) JComponent(javax.swing.JComponent) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 3 with JPanelBuilder

use of swinglib.JPanelBuilder in project triplea by triplea-game.

the class PlayerSelectionPanel method networkClientAlliancePanel.

/**
 * <pre>
 * .
 * [Country Label] [Player Label | Play button] [stand button]
 * </pre>
 */
private JPanel networkClientAlliancePanel(final String alliance) {
    // TODO: make the alliance label a button to play the entire alliance
    final JPanelBuilder panelBuilder = JPanelBuilder.builder().borderEtched().gridBagLayout(2).addHtmlLabel("<h2>" + alliance + "</h2>").addEmptyLabel();
    for (final PlayerID country : playerSelectionModel.getPlayersInAlliance(alliance)) {
        panelBuilder.addLabel(country.getName());
        panelBuilder.add(swingComponents.buildPlayerIndicator(StagingScreen.NETWORK_CLIENT, country));
    }
    return panelBuilder.build();
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) JPanelBuilder(swinglib.JPanelBuilder)

Example 4 with JPanelBuilder

use of swinglib.JPanelBuilder in project triplea by triplea-game.

the class PlayerSelectionPanel method singlePlayerAlliancePanel.

private JPanel singlePlayerAlliancePanel(final String alliance) {
    // first row, just the alliance 'h2' label and then spacers to fill out the columns
    final JPanelBuilder panelBuilder = JPanelBuilder.builder().borderEtched().gridBagLayout(2).addHtmlLabel("<h2>" + alliance + "</h2>").addEmptyLabel();
    // next we build one row per country
    for (final PlayerID country : playerSelectionModel.getPlayersInAlliance(alliance)) {
        panelBuilder.addLabel(country.getName());
        panelBuilder.add(swingComponents.buildAiSelectionCombo(country));
    }
    return panelBuilder.build();
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) JPanelBuilder(swinglib.JPanelBuilder)

Example 5 with JPanelBuilder

use of swinglib.JPanelBuilder in project triplea by triplea-game.

the class PlayerSelectionPanel method networkHostAlliancePanel.

/**
 * <pre>
 * .
 * [Country Label] [Player Label | Play Button] [Kick Button | Stand up button] [Ai/Human Combo]
 * </pre>
 */
private JPanel networkHostAlliancePanel(final String alliance) {
    final JPanelBuilder panelBuilder = JPanelBuilder.builder().borderEtched().gridBagLayout(3).addHtmlLabel("<h2>" + alliance + "</h2>").addEmptyLabel().addEmptyLabel();
    for (final PlayerID country : playerSelectionModel.getPlayersInAlliance(alliance)) {
        panelBuilder.addLabel(country.getName());
        panelBuilder.add(swingComponents.buildPlayerIndicator(StagingScreen.NETWORK_HOST, country));
        if (playerSelectionModel.isCountryTakenByCurrentPlayer(country)) {
            panelBuilder.add(swingComponents.buildAiSelectionCombo(country));
        } else {
            panelBuilder.addEmptyLabel();
        }
    }
    return panelBuilder.build();
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) JPanelBuilder(swinglib.JPanelBuilder)

Aggregations

JPanelBuilder (swinglib.JPanelBuilder)5 PlayerID (games.strategy.engine.data.PlayerID)4 JLabel (javax.swing.JLabel)2 GameData (games.strategy.engine.data.GameData)1 GameProperties (games.strategy.engine.data.properties.GameProperties)1 IEditableProperty (games.strategy.engine.data.properties.IEditableProperty)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JComponent (javax.swing.JComponent)1 JPanel (javax.swing.JPanel)1 JTextField (javax.swing.JTextField)1 JLabelBuilder (swinglib.JLabelBuilder)1