Exemplo n.º 1
0
  public void reloadTeams() {
    loadingDialog = new LoadingDialog("Chargement des équipes...");
    loadingDialog.setVisible(true);
    List<String> othersTeam = new ArrayList<>();
    for (String key : availableTeams.keySet()) {
      if (availableTeams.get(key) instanceof ScriptedTeam) othersTeam.add(key);
    }
    for (String key : othersTeam) availableTeams.remove(key);

    TeamLoader tl = new TeamLoader();
    // On initialise la liste des équipes existantes dans le dossier "teams"
    try {
      availableTeams.putAll(tl.loadAllAvailableTeams(false));
    } catch (Exception e) {
      e.printStackTrace();
    }

    loadingDialog.setVisible(false);
  }
Exemplo n.º 2
0
  public WarMain() {
    WarGame.addWarGameListener(this);

    availableTeams = new HashMap<>();
    settings = new WarGameSettings();

    // On récupère les équipes
    loadingDialog = new LoadingDialog("Chargement des équipes...");
    loadingDialog.setVisible(true);

    TeamLoader tl = new TeamLoader();

    // On initialise la liste des équipes existantes dans le dossier "teams"
    availableTeams = tl.loadAllAvailableTeams(true);
    // On vérifie qu'au moins une équipe a été chargée
    if (availableTeams.size() > 0) {
      // On lance la launcher interface
      final WarMain warMain = this;
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              launcherInterface = new WarLauncherInterface(warMain, settings);
              launcherInterface.setVisible(true);

              LwjglApplicationConfiguration configCanvas = new LwjglApplicationConfiguration();
              gdxGame = new WarViewerGdx(800, 600);
              LwjglCanvas gameCanvas = new LwjglCanvas(gdxGame, configCanvas);
              gdxFrame = new JFrame("Warbot 2.5D !!");
              gdxFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
              gdxFrame.addWindowListener(
                  new WindowAdapter() {
                    @Override
                    public void windowClosing(WindowEvent e) {
                      WarGame.getInstance().setGamePaused();
                      int confirmation =
                          JOptionPane.showConfirmDialog(
                              null,
                              "Voulez-vous fermer la fenêtre graphique ?",
                              "Demande de confirmation",
                              JOptionPane.YES_NO_OPTION);
                      if (confirmation == JOptionPane.YES_OPTION)
                        gdxFrame.setExtendedState(JFrame.ICONIFIED);
                      //			            		gdxFrame.setVisible(false);
                      WarGame.getInstance().setGameResumed();
                    }
                  });
              gdxFrame.setAlwaysOnTop(true);
              gdxFrame.add(gameCanvas.getCanvas());
              gdxFrame.setSize(800, 600);
              gdxFrame.setMinimumSize(new Dimension(450, 450));
              gdxFrame.setVisible(true);
              gdxFrame.setExtendedState(JFrame.ICONIFIED);
              //					while(gdxFrame.isVisible())
              //						gdxFrame.setVisible(false);
            }
          });
    } else {
      JOptionPane.showMessageDialog(
          null,
          "Aucune équipe n'a été trouvé dans le dossier \"" + TEAMS_DIRECTORY_NAME + "\"",
          "Aucune équipe",
          JOptionPane.ERROR_MESSAGE);
    }

    loadingDialog.setVisible(false);
  }
Exemplo n.º 3
0
 @Override
 public void onGameStarted() {
   loadingDialog.setVisible(false);
   if (settings.isEnabledEnhancedGraphism()) gdxFrame.setExtendedState(JFrame.NORMAL);
   //        	gdxFrame.setVisible(true);
 }
Exemplo n.º 4
0
 public void startGame() {
   loadingDialog.setMessage("Lancement de la simulation...");
   loadingDialog.setVisible(true);
   start();
 }