savePrincessProperties(); setVisible(false); getPresetPrincessBehavior(); setPrincessFields(); } else if (destinationEdgeCombo.equals(e.getSource())) { if (CardinalEdge.getCardinalEdge(destinationEdgeCombo.getSelectedIndex()) == CardinalEdge.NEAREST_OR_NONE) { launchPrincessHelp();
public void actionPerformed(ActionEvent e) { if (butOK.equals(e.getSource())) { getPrincessFields(); dialogAborted = false; setVisible(false); } else { super.actionPerformed(e); } }
public BotConfigDialog(JFrame parent, Set<IPlayer> ghostPlayers) { super(parent, "Configure Bot", true); // setLocationRelativeTo(parent); if (ghostPlayers != null) { this.ghostPlayers.addAll(ghostPlayers); } this.replacePlayer = !this.ghostPlayers.isEmpty(); setLayout(new BorderLayout()); add(switchBotPanel(), BorderLayout.NORTH); botSpecificCardsPanel = new JPanel(new CardLayout()); botSpecificCardsPanel.add(new JPanel(), TESTBOT_PANEL); JScrollPane princessScroll = new JScrollPane(princessPanel()); botSpecificCardsPanel.add(princessScroll, PRINCESS_PANEL); CardLayout cardlayout = (CardLayout) (botSpecificCardsPanel.getLayout()); cardlayout.show(botSpecificCardsPanel, PRINCESS_PANEL); add(botSpecificCardsPanel, BorderLayout.CENTER); butOK.addActionListener(this); add(okayPanel(), BorderLayout.SOUTH); if (replacePlayer) { add(selectPlayerToReplacePanel(), BorderLayout.WEST); } validate(); pack(); setSize(new Dimension(600, 600)); setLocationRelativeTo(parent); }
BotConfigDialog botConfigDialog = new BotConfigDialog(this.frame, ghostPlayers); botConfigDialog.setModal(true); botConfigDialog.setVisible(true); if (botConfigDialog.dialogAborted) { return; BotClient botClient = botConfigDialog.getSelectedBot(client.getHost(), client.getPort()); String args[]; Collection<String> playersToReplace = botConfigDialog.getPlayerToReplace(); Collection<String[]> replaceCommands = new HashSet<>(playersToReplace.size()); if (botClient instanceof Princess) {
constraints.gridy++; constraints.gridwidth = 3; JPanel sliderPanel = buildSliderPanel(); layout.setConstraints(sliderPanel, constraints); panel.add(sliderPanel); constraints.gridx = 0; constraints.gridwidth = 3; panel.add(buildStrategicTargetsButtonPanel(), constraints); getPresetPrincessBehavior(); setPrincessFields(); panel.validate(); return panel;
c.getLocalPlayer().getName()); } else if (ev.getSource().equals(butAddBot)) { BotConfigDialog bcd = new BotConfigDialog(clientgui.frame); bcd.setVisible(true); if (bcd.dialogAborted) { return; // user didn't click 'ok', add no bot if (clientgui.getBots().containsKey(bcd.getBotName())) { clientgui.doAlertDialog(Messages.getString("ChatLounge.AlertExistsBot.title"), Messages.getString("ChatLounge.AlertExistsBot.message")); //$NON-NLS-1$ //$NON-NLS-2$ } else { BotClient c = bcd.getSelectedBot(clientgui.getClient().getHost(), clientgui.getClient().getPort()); c.setClientGUI(clientgui); c.getGame().addGameListener(new BotGUI(c)); Messages.getString("ChatLounge.AlertBot.message")); //$NON-NLS-1$ //$NON-NLS-2$ clientgui.getBots().put(bcd.getBotName(), c);
BotConfigDialog bcd = new BotConfigDialog(frame); bcd.setVisible(true); if (bcd.dialogAborted) { return; // user didn't click 'ok', add no bot client = bcd.getSelectedBot(cd.serverAddr, cd.port); client.getGame().addGameListener(new BotGUI((BotClient) client)); ClientGUI gui = new ClientGUI(client, controller);
public PrincessBehaviorDialog(JFrame parent, BehaviorSettings princessBehavior, String name) { super(parent, null); try { this.princessBehavior = princessBehavior.getCopy(); } catch(Exception e) { handleError("PrincessBehaviorDialog", e); } this.setName(name); this.nameField.setText(name); super.setPrincessFields(); }
private JSlider buildSlider(String minMsgProperty, String maxMsgProperty, String toolTip, String title) { JSlider thisSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 10, 5); Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>(3); sliderLabels.put(0, buildSliderLabel("0 - " + minMsgProperty)); sliderLabels.put(10, buildSliderLabel("10 - " + maxMsgProperty)); sliderLabels.put(5, buildSliderLabel("5")); thisSlider.setToolTipText(toolTip); thisSlider.setLabelTable(sliderLabels); thisSlider.setPaintLabels(true); thisSlider.setMinorTickSpacing(1); thisSlider.setMajorTickSpacing(2); thisSlider.setSnapToTicks(true); thisSlider.setBorder(new TitledBorder(new LineBorder(Color.black), title)); thisSlider.setEnabled(true); return thisSlider; }
/** * gets the selected, configured bot from the dialog * * @param host The game server's host address. * @param port The gme server's host port. * @return A new bot-controlled client. */ BotClient getSelectedBot(String host, int port) { if (testBotRadiobutton.isSelected()) { return new TestBot(getBotName(), host, port); } else if (princessRadiobutton.isSelected()) { Princess toReturn = new Princess(getBotName(), host, port, LogLevel.getLogLevel((String) verbosityCombo.getSelectedItem())); toReturn.setBehaviorSettings(princessBehavior); toReturn.log(getClass(), "getSelectedBot(String, int)", LogLevel.DEBUG, toReturn.getBehaviorSettings().toLog()); return toReturn; } return null; // shouldn't happen }
braverySlidebar = buildSlider(Messages.getString("BotConfigDialog.braverySliderMin"), Messages.getString("BotConfigDialog.braverySliderMax"), Messages.getString("BotConfigDialog.braveryTooltip"), selfPreservationSlidebar = buildSlider(Messages.getString("BotConfigDialog.selfPreservationSliderMin"), Messages.getString("BotConfigDialog.selfPreservationSliderMax"), Messages.getString("BotConfigDialog.selfPreservationTooltip"), aggressionSlidebar = buildSlider(Messages.getString("BotConfigDialog.aggressionSliderMin"), Messages.getString("BotConfigDialog.aggressionSliderMax"), Messages.getString("BotConfigDialog.aggressionTooltip"), herdingSlidebar = buildSlider(Messages.getString("BotConfigDialog.herdingSliderMin"), Messages.getString("BotConfigDialog.herdingSliderMax"), Messages.getString("BotConfigDialog.herdingToolTip"), fallShameSlidebar = buildSlider(Messages.getString("BotConfigDialog.fallShameSliderMin"), Messages.getString("BotConfigDialog.fallShameSliderMax"), Messages.getString("BotConfigDialog.fallShameToolTip"),