コード例 #1
0
  public NewBattleDialog(RobocodeManager manager, BattleProperties battleProperties) {
    super(manager.getWindowManager().getRobocodeFrame(), true);
    this.manager = manager;
    this.battleProperties = battleProperties;

    initialize();
  }
コード例 #2
0
  /** Initialize the class. */
  private void initialize() {
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("New Battle");
    setContentPane(getNewBattleDialogContentPane());
    addCancelByEscapeKey();

    battleProperties.setNumRounds(manager.getProperties().getNumberOfRounds());
    processBattleProperties();
  }
コード例 #3
0
ファイル: Robocode.java プロジェクト: santhoshvivek/Robocode
  public JPanel initialize(String selected_robots) {
    try {
      manager = new RobocodeManager(false, null);

      Thread.currentThread().setName("Application Thread");

      BattleProperties battleProperties = manager.getBattleManager().getBattleProperties();
      // battleProperties.setSelectedRobots("test.mtest12,test.mtest14");
      battleProperties.setSelectedRobots(selected_robots);
      manager.getBattleManager().startNewBattle(battleProperties, true, false);
      manager.getBattleManager().getBattle().setDesiredTPS(20);

      JPanel panel = manager.getWindowManager().getRobocodeFrame().getRobocodeContentPane();
      panel.setBounds(100, 100, 500, 600);
      panel.setOpaque(true);
      return panel;
    } catch (Throwable e) {
      Logger.log(e);
      return null;
    }
  }
コード例 #4
0
  public void finishButtonActionPerformed() {
    if (robotSelectionPanel.getSelectedRobotsCount() > 24) {
      if (JOptionPane.showConfirmDialog(
              this,
              "Warning:  The battle you are about to start ("
                  + robotSelectionPanel.getSelectedRobotsCount()
                  + " robots) "
                  + " is very large and will consume a lot of CPU and memory.  Do you wish to proceed?",
              "Large Battle Warning",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE)
          == JOptionPane.NO_OPTION) {
        return;
      }
    }
    if (robotSelectionPanel.getSelectedRobotsCount() == 1) {
      if (JOptionPane.showConfirmDialog(
              this,
              "You have only selected one robot.  For normal battles you should select at least 2.\nDo you wish to proceed anyway?",
              "Just one robot?",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE)
          == JOptionPane.NO_OPTION) {
        return;
      }
    }
    battleProperties.setSelectedRobots(robotSelectionPanel.getSelectedRobotsAsString());
    battleProperties.setBattlefieldWidth(getBattleFieldTab().getBattleFieldWidth());
    battleProperties.setBattlefieldHeight(getBattleFieldTab().getBattleFieldHeight());
    battleProperties.setNumRounds(getRobotSelectionPanel().getNumRounds());
    battleProperties.setGunCoolingRate(getRulesTab().getGunCoolingRate());
    battleProperties.setInactivityTime(getRulesTab().getInactivityTime());

    // Dispose this dialog before starting the battle due to pause/resume battle state
    dispose();

    // Start new battle after the dialog has been disposed and hence has called resumeBattle()
    manager.getBattleManager().startNewBattle(battleProperties, false);
  }
コード例 #5
0
  /**
   * Return the Page property value.
   *
   * @return JPanel
   */
  private RobotSelectionPanel getRobotSelectionPanel() {
    if (robotSelectionPanel == null) {
      String selectedRobots = "";

      if (battleProperties != null) {
        selectedRobots = battleProperties.getSelectedRobots();
      }
      robotSelectionPanel =
          new RobotSelectionPanel(
              manager,
              MIN_ROBOTS,
              MAX_ROBOTS,
              true,
              "Select robots for the battle",
              false,
              false,
              false,
              false,
              false,
              !manager.getProperties().getOptionsTeamShowTeamRobots(),
              selectedRobots);
    }
    return robotSelectionPanel;
  }