예제 #1
0
  // WTF: this does not update packs!!
  // only updating info for selected pack. pulldown menus and info area!
  void updatePacks() {
    for (int i = 0; i < packPanels.size(); i++) {
      if (selectedPack == i && getIndex() >= 0) {
        ModPack pack = ModPack.getPackArray().get(getIndex());
        if (pack != null) {
          String mods = "";
          if (pack.getMods() != null) {
            mods += "<p>This pack contains the following mods by default:</p><ul>";
            for (String name : pack.getMods()) {
              mods += "<li>" + name + "</li>";
            }
            mods += "</ul>";
          }
          packPanels.get(i).setBackground(UIManager.getColor("control").darker().darker());
          packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
          File tempDir =
              new File(
                  OSUtils.getCacheStorageLocation(), "ModPacks" + File.separator + pack.getDir());
          packInfo.setText(
              "<html><img src='file:///"
                  + tempDir.getPath()
                  + File.separator
                  + pack.getImageName()
                  + "' width=400 height=200></img> <br>"
                  + pack.getInfo()
                  + mods);
          packInfo.setCaretPosition(0);

          if (ModPack.getSelectedPack(isFTB()).getServerUrl().equals("")
              || ModPack.getSelectedPack(isFTB()).getServerUrl() == null) {
            server.setEnabled(false);
          } else {
            server.setEnabled(true);
          }
          String tempVer = Settings.getSettings().getPackVer(pack.getDir());
          version.removeActionListener(al);
          version.removeAllItems();
          version.addItem("Recommended");
          if (pack.getOldVersions() != null) {
            for (String s : pack.getOldVersions()) {
              version.addItem(s);
            }
            version.setSelectedItem(tempVer);
          }
          version.addActionListener(al);
        }
      } else {
        packPanels.get(i).setBackground(UIManager.getColor("control"));
        packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      }
    }
  }
예제 #2
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);
    String info = "";
    if (pack.getInfo().length() > 60) {
      info = pack.getInfo().substring(0, 59) + "...";
    } else {
      info = pack.getInfo();
    }
    JTextArea filler = new JTextArea(pack.getName() + " : " + pack.getAuthor() + "\n" + info);
    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();
  }