コード例 #1
0
  public ModPackFilterDialog(ModpacksPane instance) {
    super(LaunchFrame.getInstance(), true);
    this.pane = instance;

    setupGui();

    getRootPane().setDefaultButton(apply);

    this.pane = instance;

    ArrayList<String> mcVersions = new ArrayList<String>();
    mcVersion.addItem("All");
    mcVersions.add("All");
    for (ModPack pack : ModPack.getPackArray()) {
      if (!mcVersions.contains(pack.getMcVersion())) {
        mcVersions.add(pack.getMcVersion());
        mcVersion.addItem(pack.getMcVersion());
      }
    }

    mcVersion.setModel(new DefaultComboBoxModel(mcVersions.toArray()));
    origin.setModel(
        new DefaultComboBoxModel(
            new String[] {
              I18N.getLocaleString("MAIN_ALL"), "FTB", I18N.getLocaleString("FILTER_3THPARTY")
            }));
    availability.setModel(
        new DefaultComboBoxModel(
            new String[] {
              I18N.getLocaleString("MAIN_ALL"),
              I18N.getLocaleString("FILTER_PUBLIC"),
              I18N.getLocaleString("FILTER_PRIVATE")
            }));

    origin.setSelectedItem(pane.origin);
    mcVersion.setSelectedItem(pane.mcVersion);
    availability.setSelectedItem(pane.avaliability);

    pack();

    apply.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            pane.origin = (String) origin.getSelectedItem();
            pane.mcVersion = (String) mcVersion.getSelectedItem();
            pane.avaliability = (String) availability.getSelectedItem();
            pane.updateFilter();
            setVisible(false);
          }
        });

    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    search.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            SearchDialog sd = new SearchDialog(pane);
            sd.setVisible(true);
            setVisible(false);
          }
        });
  }
コード例 #2
0
ファイル: LaunchFrame.java プロジェクト: eightbitme/FTBLaunch
  /**
   * checks whether an update is needed, and then starts the update process off
   *
   * @param response - the response from the minecraft servers
   */
  private void runGameUpdater(final LoginResponse response) {
    final String installPath = Settings.getSettings().getInstallPath();
    final ModPack pack = ModPack.getSelectedPack();
    if (Settings.getSettings().getForceUpdate()
        && new File(installPath, pack.getDir() + File.separator + "version").exists()) {
      new File(installPath, pack.getDir() + File.separator + "version").delete();
    }
    if (!initializeMods()) {
      enableObjects();
      return;
    }
    try {
      TextureManager.updateTextures();
    } catch (Exception e1) {
    }
    MinecraftVersionDetector mvd = new MinecraftVersionDetector();
    if (!new File(installPath, pack.getDir() + "/minecraft/bin/minecraft.jar").exists()
        || mvd.shouldUpdate(installPath + "/" + pack.getDir() + "/minecraft")) {
      final ProgressMonitor progMonitor =
          new ProgressMonitor(this, "Downloading minecraft...", "", 0, 100);
      final GameUpdateWorker updater =
          new GameUpdateWorker(
              pack.getMcVersion(),
              new File(installPath, pack.getDir() + "/minecraft/bin").getPath()) {
            @Override
            public void done() {
              progMonitor.close();
              try {
                if (get()) {
                  Logger.logInfo("Game update complete");
                  FileUtils.killMetaInf();
                  launchMinecraft(
                      installPath + "/" + pack.getDir() + "/minecraft",
                      RESPONSE.getUsername(),
                      RESPONSE.getSessionID());
                } else {
                  ErrorUtils.tossError("Error occurred during downloading the game");
                }
              } catch (CancellationException e) {
                ErrorUtils.tossError("Game update canceled.");
              } catch (InterruptedException e) {
                ErrorUtils.tossError("Game update interrupted.");
              } catch (ExecutionException e) {
                ErrorUtils.tossError("Failed to download game.");
              } finally {
                enableObjects();
              }
            }
          };

      updater.addPropertyChangeListener(
          new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              if (progMonitor.isCanceled()) {
                updater.cancel(false);
              }
              if (!updater.isDone()) {
                int prog = updater.getProgress();
                if (prog < 0) {
                  prog = 0;
                } else if (prog > 100) {
                  prog = 100;
                }
                progMonitor.setProgress(prog);
                progMonitor.setNote(updater.getStatus());
              }
            }
          });
      updater.execute();
    } else {
      launchMinecraft(
          installPath + "/" + pack.getDir() + "/minecraft",
          RESPONSE.getUsername(),
          RESPONSE.getSessionID());
    }
  }
コード例 #3
0
  /*
   * GUI Code to add a modpack to the selection
   */
  public void addPack(final ModPack pack) {
    if (!modPacksAdded) {
      modPacksAdded = true;
      packs.removeAll();
      packs.repaint();
    }
    final int packIndex = packPanels.size();
    final JPanel p = new JPanel();
    p.setBounds(0, (packIndex * 55), 420, 55);
    p.setLayout(null);
    JLabel logo = new JLabel(new ImageIcon(pack.getLogo()));
    logo.setBounds(6, 6, 42, 42);
    logo.setVisible(true);

    JTextArea filler =
        new JTextArea(
            pack.getName()
                + " (v"
                + pack.getVersion()
                + ") Minecraft Version "
                + pack.getMcVersion()
                + "\n"
                + "By "
                + pack.getAuthor());
    filler.setBorder(null);
    filler.setEditable(false);
    filler.setForeground(LauncherStyle.getCurrentStyle().tabPaneForeground);
    filler.setBounds(58, 6, 362, 42);
    filler.setBackground(LauncherStyle.getCurrentStyle().tabPaneBackground);

    MouseAdapter lin =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              LaunchFrame.getInstance().doLaunch();
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {
            selectedPack = packIndex;
            updatePacks();
          }
        };
    p.addMouseListener(lin);
    filler.addMouseListener(lin);
    logo.addMouseListener(lin);
    p.add(filler);
    p.add(logo);
    packPanels.add(p);
    packs.add(p);

    packs.setMinimumSize(new Dimension(420, (packPanels.size() * 55)));
    packs.setPreferredSize(new Dimension(420, (packPanels.size() * 55)));

    //
    // packsScroll.revalidate();
    if (pack.getDir().equalsIgnoreCase(getLastPack())) {
      selectedPack = packIndex;
    }
  }
コード例 #4
0
 boolean mcVersionCheck(ModPack pack) {
   return (mcVersion.equalsIgnoreCase(I18N.getLocaleString("MAIN_ALL")))
       || (mcVersion.equalsIgnoreCase(pack.getMcVersion()));
 }
コード例 #5
0
 private static void sortPacks() {
   packPanels.clear();
   packs.removeAll();
   currentPacks.clear();
   int counter = 0;
   selectedPack = 0;
   packInfo.setText("");
   LaunchFrame.getInstance().modPacksPane.repaint();
   if (origin.equalsIgnoreCase("all")) {
     for (ModPack pack : ModPack.getPackArray()) {
       if (type.equalsIgnoreCase("client")) {
         if (mcVersion.equalsIgnoreCase("all")) {
           addPack(pack);
           currentPacks.put(counter, pack);
           counter++;
         } else if (mcVersion.equalsIgnoreCase(pack.getMcVersion())) {
           addPack(pack);
           currentPacks.put(counter, pack);
           counter++;
         }
       } else if (type.equalsIgnoreCase("server")) {
         if (!pack.getServerUrl().isEmpty()) {
           if (mcVersion.equalsIgnoreCase("all")) {
             addPack(pack);
             currentPacks.put(counter, pack);
             counter++;
           } else if (mcVersion.equalsIgnoreCase(pack.getMcVersion())) {
             addPack(pack);
             currentPacks.put(counter, pack);
             counter++;
           }
         }
       }
     }
   } else if (origin.equalsIgnoreCase("ftb")) {
     for (ModPack pack : ModPack.getPackArray()) {
       if (pack.getAuthor().equalsIgnoreCase("the ftb team")) {
         if (type.equalsIgnoreCase("client")) {
           if (mcVersion.equalsIgnoreCase("all")) {
             addPack(pack);
             currentPacks.put(counter, pack);
             counter++;
           } else if (mcVersion.equalsIgnoreCase(pack.getMcVersion())) {
             addPack(pack);
             currentPacks.put(counter, pack);
             counter++;
           }
         } else if (type.equalsIgnoreCase("server")) {
           if (!pack.getServerUrl().isEmpty()) {
             if (mcVersion.equalsIgnoreCase("all")) {
               addPack(pack);
               currentPacks.put(counter, pack);
               counter++;
             } else if (mcVersion.equalsIgnoreCase(pack.getMcVersion())) {
               addPack(pack);
               currentPacks.put(counter, pack);
               counter++;
             }
           }
         }
       }
     }
   } else {
     for (ModPack pack : ModPack.getPackArray()) {
       if (!pack.getAuthor().equalsIgnoreCase("the ftb team")) {
         if (type.equalsIgnoreCase("client")) {
           if (mcVersion.equalsIgnoreCase("all")) {
             addPack(pack);
             currentPacks.put(counter, pack);
             counter++;
           } else if (mcVersion.equalsIgnoreCase(pack.getMcVersion())) {
             addPack(pack);
             currentPacks.put(counter, pack);
             counter++;
           }
         } else if (type.equalsIgnoreCase("server")) {
           if (!pack.getServerUrl().isEmpty()) {
             if (mcVersion.equalsIgnoreCase("all")) {
               addPack(pack);
               currentPacks.put(counter, pack);
               counter++;
             } else if (mcVersion.equalsIgnoreCase(pack.getMcVersion())) {
               addPack(pack);
               currentPacks.put(counter, pack);
               counter++;
             }
           }
         }
       }
     }
   }
   updatePacks();
 }
コード例 #6
0
  /*
   * GUI Code to add a modpack to the selection
   */
  public static void addPack(ModPack pack) {
    if (!modPacksAdded) {
      modPacksAdded = true;
      packs.removeAll();
    }

    final int packIndex = packPanels.size();
    Logger.logInfo("Adding pack " + getModNum());
    final JPanel p = new JPanel();
    p.setBounds(0, (packIndex * 55), 420, 55);
    p.setLayout(null);
    JLabel logo = new JLabel(new ImageIcon(pack.getLogo()));
    logo.setBounds(6, 6, 42, 42);
    logo.setVisible(true);

    JTextArea filler =
        new JTextArea(
            pack.getName()
                + " (v"
                + pack.getVersion()
                + ") Minecraft Version "
                + pack.getMcVersion()
                + "\n"
                + "By "
                + pack.getAuthor());
    filler.setBorder(null);
    filler.setEditable(false);
    filler.setForeground(Color.white);
    filler.setBounds(58, 6, 378, 42);
    filler.setBackground(new Color(255, 255, 255, 0));
    MouseListener lin =
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            selectedPack = packIndex;
            updatePacks();
          }

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mousePressed(MouseEvent e) {
            selectedPack = packIndex;
            updatePacks();
          }

          @Override
          public void mouseExited(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}
        };
    p.addMouseListener(lin);
    filler.addMouseListener(lin);
    logo.addMouseListener(lin);
    p.add(filler);
    p.add(logo);
    packPanels.add(p);
    packs.add(p);
    if (origin.equals("All")) {
      packs.setMinimumSize(new Dimension(420, (ModPack.getPackArray().size() * 55)));
      packs.setPreferredSize(new Dimension(420, (ModPack.getPackArray().size() * 55)));
    } else {
      packs.setMinimumSize(new Dimension(420, (currentPacks.size() * 55)));
      packs.setPreferredSize(new Dimension(420, (currentPacks.size() * 55)));
    }
    packsScroll.revalidate();
    if (pack.getDir().equalsIgnoreCase(Settings.getSettings().getLastPack())) {
      selectedPack = packIndex;
    }
  }