Esempio n. 1
0
 public void updateLocale() {
   lblInstallFolder.setText(I18N.getLocaleString("INSTALL_FOLDER"));
   tglbtnForceUpdate.setText(I18N.getLocaleString("FORCE_UPDATE"));
   ;
   lblRamMaximum.setText(I18N.getLocaleString("RAM_MAX"));
   lblLocale.setText(I18N.getLocaleString("LANGUAGE"));
 }
 boolean avaliabilityCheck(ModPack pack) {
   return (avaliability.equalsIgnoreCase(I18N.getLocaleString("MAIN_ALL")))
       || (avaliability.equalsIgnoreCase(I18N.getLocaleString("FILTER_PUBLIC"))
           && !pack.isPrivatePack())
       || (avaliability.equalsIgnoreCase(I18N.getLocaleString("FILTER_PRIVATE"))
           && pack.isPrivatePack());
 }
Esempio n. 3
0
 /** updates the buttons/text to language specific */
 public void updateLocale() {
   if (I18N.currentLocale == Locale.deDE) {
     edit.setBounds(420, 20, 120, 30);
     donate.setBounds(330, 20, 80, 30);
     mapInstall.setBounds(620, 20, 190, 30);
     mapInstallLocation.setBounds(420, 20, 190, 30);
     serverbutton.setBounds(420, 20, 390, 30);
     tpInstallLocation.setBounds(420, 20, 190, 30);
     tpInstall.setBounds(620, 20, 190, 30);
   } else {
     edit.setBounds(480, 20, 60, 30);
     donate.setBounds(390, 20, 80, 30);
     mapInstall.setBounds(650, 20, 160, 30);
     mapInstallLocation.setBounds(480, 20, 160, 30);
     serverbutton.setBounds(480, 20, 330, 30);
     tpInstallLocation.setBounds(480, 20, 160, 30);
     tpInstall.setBounds(650, 20, 160, 30);
   }
   launch.setText(I18N.getLocaleString("LAUNCH_BUTTON"));
   edit.setText(I18N.getLocaleString("EDIT_BUTTON"));
   serverbutton.setText(I18N.getLocaleString("DOWNLOAD_SERVER_PACK"));
   mapInstall.setText(I18N.getLocaleString("INSTALL_MAP"));
   serverMap.setText(I18N.getLocaleString("DOWNLOAD_MAP_SERVER"));
   tpInstall.setText(I18N.getLocaleString("INSTALL_TEXTUREPACK"));
   donate.setText(I18N.getLocaleString("DONATE_BUTTON"));
   dropdown_[0] = I18N.getLocaleString("PROFILE_SELECT");
   dropdown_[1] = I18N.getLocaleString("PROFILE_CREATE");
   writeUsers((String) users.getSelectedItem());
   optionsPane.updateLocale();
   modPacksPane.updateLocale();
   mapsPane.updateLocale();
   tpPane.updateLocale();
 }
Esempio n. 4
0
 public void updateLocale() {
   filter.setText(I18N.getLocaleString("FILTER_SETTINGS"));
   editModPack.setText(I18N.getLocaleString("MODS_EDIT_PACK"));
   if (I18N.currentLocale == Locale.deDE) {
     editModPack.setBounds(290, 5, 120, 25);
     typeLbl.setBounds(115, 5, 165, 25);
   } else {
     editModPack.setBounds(300, 5, 110, 25);
     typeLbl.setBounds(115, 5, 175, 25);
   }
 }
Esempio n. 5
0
 /**
  * Opens dialogwith OK and ignore buttons. Callee should check return value Does not write error
  * or warning messages into log
  *
  * @param message String to show in dialog
  * @param severity JOptionPane message type
  * @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user
  *     closed the dialog
  */
 public static int tossOKIgnoreDialog(String message, int severity) {
   Object[] options = {I18N.getLocaleString("BUTTON_OK"), I18N.getLocaleString("BUTTON_IGNORE")};
   return JOptionPane.showOptionDialog(
       LaunchFrame.getInstance(),
       message + "\n" + I18N.getLocaleString("NAG_SCREEN_MESSAGE"),
       null,
       JOptionPane.DEFAULT_OPTION,
       JOptionPane.ERROR_MESSAGE,
       null,
       options,
       options[0]);
 }
 public void updateLocale() {
   origin = I18N.getLocaleString("MAIN_ALL");
   mcVersion = I18N.getLocaleString("MAIN_ALL");
   avaliability = I18N.getLocaleString("MAIN_ALL");
   filter.setText(I18N.getLocaleString("FILTER_SETTINGS"));
   updateFilterText();
   editModPack.setText(I18N.getLocaleString("MODS_EDIT_PACK"));
   if (I18N.currentLocale == I18N.Locale.deDE) {
     editModPack.setBounds(290, 5, 120, 25);
     typeLbl.setBounds(115, 5, 165, 25);
   } else {
     editModPack.setBounds(300, 5, 110, 25);
     typeLbl.setBounds(115, 5, 175, 25);
   }
 }
Esempio n. 7
0
  private void setupGui() {
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("UPDATEMODPACK_TITLE"));
    setResizable(true);

    Container panel = getContentPane();
    panel.setLayout(new MigLayout());

    messageLbl = new JLabel(I18N.getLocaleString("UPDATEMODPACK_ISAVALIBLE"));
    updateLbl = new JLabel(I18N.getLocaleString("UPDATE_WICHUPDATE"));
    backupCFG = new JCheckBox(I18N.getLocaleString("UPDATEMODPACK_BACKUPCFG"));
    backupSave = new JCheckBox(I18N.getLocaleString("UPDATEMODPACK_BACKUPSAVE"));
    update = new JButton(I18N.getLocaleString("MAIN_YES"));
    abort = new JButton(I18N.getLocaleString("MAIN_NO"));

    panel.add(messageLbl, GuiConstants.WRAP);
    panel.add(updateLbl, GuiConstants.WRAP);
    panel.add(backupCFG, GuiConstants.CENTER_SINGLE_LINE);
    panel.add(backupSave, GuiConstants.CENTER_SINGLE_LINE);
    panel.add(update, GuiConstants.CENTER_TWO);
    panel.add(abort);

    pack();
    setLocationRelativeTo(getOwner());
  }
Esempio n. 8
0
  public MapFilterDialog(MapUtils instance) {
    super(LaunchFrame.getInstance(), true);
    this.pane = instance;

    setupGui();

    getRootPane().setDefaultButton(apply);

    this.pane = instance;

    type.setSelectedItem(pane.type);
    origin.setSelectedItem(pane.origin);
    compatiblePack.setSelectedItem(pane.compatible);

    ArrayList<String> packs = new ArrayList<String>();
    compatiblePack.addItem(I18N.getLocaleString("MAIN_ALL"));
    packs.add(I18N.getLocaleString("MAIN_ALL"));
    for (int i = 0; i < Map.getMapArray().size(); i++) {
      String[] compat = Map.getMap(i).getCompatible();
      for (String compatable : compat) {
        if (!compatable.isEmpty()
            && !packs.contains(ModPack.getPack(compatable.trim()).getName())) {
          packs.add(ModPack.getPack(compatable.trim()).getName());
          compatiblePack.addItem(ModPack.getPack(compatable.trim()).getName());
        }
      }
    }

    type.setModel(new DefaultComboBoxModel(new String[] {"Client", "Server"}));
    origin.setModel(
        new DefaultComboBoxModel(
            new String[] {
              I18N.getLocaleString("MAIN_ALL"), "FTB", I18N.getLocaleString("FILTER_3THPARTY")
            }));
    compatiblePack.setModel(new DefaultComboBoxModel(packs.toArray()));

    apply.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            pane.compatible = (String) compatiblePack.getSelectedItem();
            pane.type = (String) type.getSelectedItem();
            pane.origin = (String) origin.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);
          }
        });
  }
Esempio n. 9
0
  private void setupGui() {
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("FILTER_TITLE"));
    setResizable(false);

    Container panel = getContentPane();
    SpringLayout layout = new SpringLayout();
    panel.setLayout(layout);

    originLbl = new JLabel(I18N.getLocaleString("FILTER_ORIGIN"));
    typeLbl = new JLabel(I18N.getLocaleString("FILTER_PACKTYPE"));
    compatiblePackLbl = new JLabel(I18N.getLocaleString("FILTER_COMPERTIBLEPACK"));
    origin = new JComboBox();
    type = new JComboBox();
    compatiblePack = new JComboBox();
    apply = new JButton(I18N.getLocaleString("FILTER_APPLY"));
    cancel = new JButton(I18N.getLocaleString("MAIN_CANCEL"));
    search = new JButton(I18N.getLocaleString("FILTER_SEARCHMAP"));

    origin.setPrototypeDisplayValue("xxxxxxxxxxxxxxxxxxxxxxxxxx");
    type.setPrototypeDisplayValue("xxxxxxxxxxxxxxxxxxxxxxxxxx");
    compatiblePack.setPrototypeDisplayValue("xxxxxxxxxxxxxxxxxxxxxxxxxx");

    panel.add(typeLbl);
    panel.add(type);
    panel.add(originLbl);
    panel.add(origin);
    panel.add(compatiblePackLbl);
    panel.add(compatiblePack);
    panel.add(apply);
    panel.add(cancel);
    panel.add(search);

    Spring hSpring;
    Spring columnWidth;

    hSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.WEST, typeLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, originLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, compatiblePackLbl, hSpring, SpringLayout.WEST, panel);

    columnWidth =
        SwingUtils.springMax(
            Spring.width(typeLbl), Spring.width(originLbl), Spring.width(compatiblePackLbl));

    hSpring = SwingUtils.springSum(hSpring, columnWidth, Spring.constant(10));

    layout.putConstraint(SpringLayout.WEST, type, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, origin, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, compatiblePack, hSpring, SpringLayout.WEST, panel);

    columnWidth =
        SwingUtils.springMax(
            Spring.width(type), Spring.width(origin), Spring.width(compatiblePack));

    hSpring = Spring.sum(hSpring, columnWidth);

    layout.putConstraint(SpringLayout.EAST, type, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, origin, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, compatiblePack, hSpring, SpringLayout.WEST, panel);

    hSpring = Spring.sum(hSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.EAST, panel, hSpring, SpringLayout.WEST, panel);

    layout.putConstraint(SpringLayout.WEST, search, 10, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, search, -5, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.WEST, cancel, 5, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.EAST, cancel, -10, SpringLayout.EAST, panel);

    layout.putConstraint(SpringLayout.WEST, apply, 10, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, apply, -10, SpringLayout.EAST, panel);

    Spring vSpring;
    Spring rowHeight;

    vSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.BASELINE, typeLbl, 0, SpringLayout.BASELINE, type);
    layout.putConstraint(SpringLayout.NORTH, type, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.max(Spring.height(typeLbl), Spring.height(type));

    vSpring = SwingUtils.springSum(vSpring, rowHeight, Spring.constant(5));

    layout.putConstraint(SpringLayout.BASELINE, originLbl, 0, SpringLayout.BASELINE, origin);
    layout.putConstraint(SpringLayout.NORTH, origin, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.max(Spring.height(originLbl), Spring.height(origin));

    vSpring = SwingUtils.springSum(vSpring, rowHeight, Spring.constant(5));

    layout.putConstraint(
        SpringLayout.BASELINE, compatiblePackLbl, 0, SpringLayout.BASELINE, compatiblePack);
    layout.putConstraint(SpringLayout.NORTH, compatiblePack, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(compatiblePackLbl);
    rowHeight = Spring.max(rowHeight, Spring.height(compatiblePack));

    vSpring = SwingUtils.springSum(vSpring, rowHeight, Spring.constant(10));

    layout.putConstraint(SpringLayout.NORTH, search, vSpring, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, cancel, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.max(Spring.height(search), Spring.height(cancel));

    vSpring = SwingUtils.springSum(vSpring, rowHeight, Spring.constant(5));

    layout.putConstraint(SpringLayout.NORTH, apply, vSpring, SpringLayout.NORTH, panel);

    vSpring = SwingUtils.springSum(vSpring, Spring.height(apply), Spring.constant(10));

    layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);

    pack();
    setLocationRelativeTo(this.getOwner());
  }
Esempio n. 10
0
  /** Create the frame. */
  public LaunchFrame(final int tab) {
    setFont(new Font("a_FuturaOrto", Font.PLAIN, 12));
    setResizable(false);
    setTitle("Feed the Beast Launcher v" + version);
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));

    panel = new JPanel();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    if (OSUtils.getCurrentOS() == OS.WINDOWS) {
      setBounds(100, 100, 842, 480);
    } else {
      setBounds(100, 100, 850, 480);
    }
    panel.setBounds(0, 0, 850, 480);
    panel.setLayout(null);
    footer.setBounds(0, 380, 850, 100);
    footer.setLayout(null);
    footer.setBackground(LauncherStyle.getCurrentStyle().footerColor);
    tabbedPane.setBounds(0, 0, 850, 380);
    panel.add(tabbedPane);
    panel.add(footer);
    setContentPane(panel);

    // Footer
    // footerLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    // footerLogo.setBounds(20, 20, 42, 42);
    // footerLogo.addMouseListener(new MouseAdapter() {
    // @Override
    // public void mouseClicked(MouseEvent event) {
    // OSUtils.browse("http://www.feed-the-beast.com");
    // }
    // });

    footerCreeper.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    footerCreeper.setBounds(25, 20, 150, 42);
    footerCreeper.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent event) {
            OSUtils.browse("http://www.mckhaos.net");
          }
        });

    dropdown_[0] = I18N.getLocaleString("PROFILE_SELECT");
    dropdown_[1] = I18N.getLocaleString("PROFILE_CREATE");

    String[] dropdown =
        concatenateArrays(dropdown_, UserManager.getNames().toArray(new String[] {}));
    users = new JComboBox(dropdown);
    if (Settings.getSettings().getLastUser() != null) {
      for (int i = 0; i < dropdown.length; i++) {
        if (dropdown[i].equalsIgnoreCase(Settings.getSettings().getLastUser())) {
          users.setSelectedIndex(i);
        }
      }
    }

    donate = new JButton(I18N.getLocaleString("DONATE_BUTTON"));
    donate.setBounds(390, 20, 80, 30);
    donate.setEnabled(false);
    donate.setToolTipText("Coming Soon...");
    donate.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {}
        });

    users.setBounds(550, 20, 150, 30);
    users.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (users.getSelectedIndex() == 1) {
              ProfileAdderDialog p = new ProfileAdderDialog(getInstance(), true);
              users.setSelectedIndex(0);
              p.setVisible(true);
            }
            edit.setEnabled(users.getSelectedIndex() > 1);
          }
        });

    edit = new JButton(I18N.getLocaleString("EDIT_BUTTON"));
    edit.setBounds(480, 20, 60, 30);
    edit.setVisible(true);
    edit.setEnabled(users.getSelectedIndex() > 1);
    edit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (users.getSelectedIndex() > 1) {
              ProfileEditorDialog p =
                  new ProfileEditorDialog(getInstance(), (String) users.getSelectedItem(), true);
              users.setSelectedIndex(0);
              p.setVisible(true);
            }
            edit.setEnabled(users.getSelectedIndex() > 1);
          }
        });

    launch.setText(I18N.getLocaleString("LAUNCH_BUTTON"));
    launch.setBounds(711, 20, 100, 30);
    launch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            doLaunch();
          }
        });

    serverbutton.setBounds(480, 20, 330, 30);
    serverbutton.setText(I18N.getLocaleString("DOWNLOAD_SERVER_PACK"));
    serverbutton.setVisible(false);
    serverbutton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (!ModPack.getSelectedPack().getServerUrl().isEmpty()) {
              if (getSelectedModIndex() >= 0) {
                try {
                  String version =
                      (Settings.getSettings().getPackVer().equalsIgnoreCase("recommended version")
                              || Settings.getSettings()
                                  .getPackVer()
                                  .equalsIgnoreCase("newest version"))
                          ? ModPack.getSelectedPack().getVersion().replace(".", "_")
                          : Settings.getSettings().getPackVer().replace(".", "_");
                  if (ModPack.getSelectedPack().isPrivatePack()) {
                    OSUtils.browse(
                        DownloadUtils.getCreeperhostLink(
                            "privatepacks%5E"
                                + ModPack.getSelectedPack().getDir()
                                + "%5E"
                                + version
                                + "%5E"
                                + ModPack.getSelectedPack().getServerUrl()));
                  } else {
                    OSUtils.browse(
                        DownloadUtils.getCreeperhostLink(
                            "modpacks%5E"
                                + ModPack.getSelectedPack().getDir()
                                + "%5E"
                                + version
                                + "%5E"
                                + ModPack.getSelectedPack().getServerUrl()));
                  }
                  TrackerUtils.sendPageView(
                      ModPack.getSelectedPack().getName() + " Server Download",
                      ModPack.getSelectedPack().getName());
                } catch (NoSuchAlgorithmException e) {
                }
              }
            }
          }
        });

    mapInstall.setBounds(650, 20, 160, 30);
    mapInstall.setText(I18N.getLocaleString("INSTALL_MAP"));
    mapInstall.setVisible(false);
    mapInstall.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            if (getSelectedMapIndex() >= 0) {
              MapManager man = new MapManager(new JFrame(), true);
              man.setVisible(true);
              MapManager.cleanUp();
            }
          }
        });

    mapInstallLocation = new JComboBox();
    mapInstallLocation.setBounds(480, 20, 160, 30);
    mapInstallLocation.setToolTipText("Install to...");
    mapInstallLocation.setVisible(false);

    serverMap.setBounds(480, 20, 330, 30);
    serverMap.setText(I18N.getLocaleString("DOWNLOAD_MAP_SERVER"));
    serverMap.setVisible(false);
    serverMap.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (getSelectedMapIndex() >= 0) {
              try {
                OSUtils.browse(
                    DownloadUtils.getCreeperhostLink(
                        "maps%5E"
                            + Map.getMap(LaunchFrame.getSelectedMapIndex()).getMapName()
                            + "%5E"
                            + Map.getMap(LaunchFrame.getSelectedMapIndex()).getVersion()
                            + "%5E"
                            + Map.getMap(LaunchFrame.getSelectedMapIndex()).getUrl()));
              } catch (NoSuchAlgorithmException e) {
              }
            }
          }
        });

    tpInstall.setBounds(650, 20, 160, 30);
    tpInstall.setText(I18N.getLocaleString("INSTALL_TEXTUREPACK"));
    tpInstall.setVisible(false);
    tpInstall.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            if (getSelectedTexturePackIndex() >= 0) {
              TextureManager man = new TextureManager(new JFrame(), true);
              man.setVisible(true);
            }
          }
        });

    tpInstallLocation = new JComboBox();
    tpInstallLocation.setBounds(480, 20, 160, 30);
    tpInstallLocation.setToolTipText("Install to...");
    tpInstallLocation.setVisible(false);

    tpInstallLocLbl.setText("Install to...");
    tpInstallLocLbl.setBounds(480, 20, 80, 30);
    tpInstallLocLbl.setVisible(false);

    footer.add(edit);
    footer.add(users);
    footer.add(footerLogo);
    footer.add(footerCreeper);
    footer.add(launch);
    footer.add(donate);
    footer.add(serverbutton);
    footer.add(mapInstall);
    footer.add(mapInstallLocation);
    footer.add(serverMap);
    footer.add(tpInstall);
    footer.add(tpInstallLocation);

    newsPane = new NewsPane();
    modPacksPane = new ModpacksPane();
    mapsPane = new MapsPane();
    tpPane = new TexturepackPane();
    optionsPane = new OptionsPane(Settings.getSettings());

    getRootPane().setDefaultButton(launch);
    updateLocale();

    tabbedPane.add(newsPane, 0);
    tabbedPane.add(optionsPane, 1);
    tabbedPane.add(modPacksPane, 2);
    tabbedPane.add(mapsPane, 3);
    tabbedPane.add(tpPane, 4);
    setNewsIcon();
    tabbedPane.setIconAt(1, new ImageIcon(this.getClass().getResource("/image/tabs/options.png")));
    tabbedPane.setIconAt(2, new ImageIcon(this.getClass().getResource("/image/tabs/modpacks.png")));
    tabbedPane.setIconAt(3, new ImageIcon(this.getClass().getResource("/image/tabs/maps.png")));
    tabbedPane.setIconAt(
        4, new ImageIcon(this.getClass().getResource("/image/tabs/texturepacks.png")));
    tabbedPane.setSelectedIndex(tab);

    tabbedPane.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent event) {
            if (tabbedPane.getSelectedComponent() instanceof ILauncherPane) {
              ((ILauncherPane) tabbedPane.getSelectedComponent()).onVisible();
              currentPane = Panes.values()[tabbedPane.getSelectedIndex()];
              updateFooter();
            }
          }
        });
  }
@SuppressWarnings("unchecked")
public abstract class AbstractModPackPane extends JPanel {
  // container for packs. Upgraded by appPack()
  JPanel packs;
  // array to store packs. Upgraded by addPack
  public ArrayList<JPanel> packPanels;
  public JScrollPane packsScroll;

  int numberOfPacks;

  JLabel typeLbl;
  JButton filter, editModPack;

  JButton server;

  JButton privatePack;
  JComboBox version;
  int selectedPack = 0;
  boolean modPacksAdded = false;
  // pack hashes. Updated by updateDatas()
  HashMap<Integer, ModPack> currentPacks = Maps.newHashMap();
  HashMap<Integer, Integer> packMapping = Maps.newHashMap();

  JEditorPane packInfo;

  //	private JLabel loadingImage;
  public String origin = I18N.getLocaleString("MAIN_ALL"),
      mcVersion = I18N.getLocaleString("MAIN_ALL"),
      avaliability = I18N.getLocaleString("MAIN_ALL");
  public boolean loaded = false;

  public AbstractModPackPane() {}

  JScrollPane infoScroll;
  final ActionListener al =
      new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
          if (version.getItemCount() > 0) {
            Settings.getSettings()
                .setPackVer(
                    (String.valueOf(version.getSelectedItem()).equalsIgnoreCase("recommended")
                        ? "Recommended Version"
                        : String.valueOf(version.getSelectedItem())));
            Settings.getSettings().save();
          }
        }
      };

  /*
   * 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;
    }
  }

  // TODO handle changes & removals here as well!!!
  @Subscribe
  public void packChange(PackChangeEvent evt) {
    final PackChangeEvent event = evt;
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            if (event.getType() == PackChangeEvent.TYPE.ADD) {
              boolean doneWork = false;
              if (event.getPacks() != null) {
                for (ModPack p : event.getPacks()) {
                  if (filterForTab(p)) {
                    addPack(p);
                    // TODO: fix
                    Logger.logInfo(
                        "Adding "
                            + getPaneShortName()
                            + " Pack: "
                            + packPanels.size()
                            + " ("
                            + p.getName()
                            + ")");
                    doneWork = true;
                    numberOfPacks++;
                  }
                }
                if (doneWork) {
                  if (!currentPacks.isEmpty()) {
                    updateDatas();
                    updatePacks();
                  } else {
                    updateDatas();
                    updatePacks();
                  }
                  loaded = true;
                }
              }
            } else if (event.getType() == PackChangeEvent.TYPE.REMOVE) {
              filterPacks();
            }
          }
        });
  }

  public void updateDatas() {
    currentPacks.clear();
    packMapping.clear();
    int counter = 0;
    // Are we going to save list of modpack there or here?!
    for (ModPack pack : ModPack.getPackArray()) {
      if (filterForTab(pack)
          && mcVersionCheck(pack)
          && avaliabilityCheck(pack)
          && textSearch(pack)) {
        currentPacks.put(counter, pack);
        packMapping.put(counter, pack.getIndex());
        counter++;
      }
    }
  }

  public void filterPacks() {
    packPanels.clear();
    packs.removeAll();
    currentPacks.clear();
    packMapping.clear();
    int counter = 0;
    selectedPack = 0;
    packInfo.setText("");
    // all removed, repaint
    packs.repaint();
    // not really needed
    // modPacksAdded = false;
    for (ModPack pack : ModPack.getPackArray()) {
      if (filterForTab(pack)
          && mcVersionCheck(pack)
          && avaliabilityCheck(pack)
          && textSearch(pack)) {
        currentPacks.put(counter, pack);
        packMapping.put(counter, pack.getIndex());
        addPack(pack);
        counter++;
      }
    }
    updateDatas();
    updatePacks();
  }

  // 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));
      }
    }
  }

  public void updateFilterText() {
    String filterTextColor =
        LauncherStyle.getColorAsString(LauncherStyle.getCurrentStyle().filterTextColor);
    String filterInnerTextColor =
        LauncherStyle.getColorAsString(LauncherStyle.getCurrentStyle().filterInnerTextColor);
    String typeLblText = "<html><body>";
    typeLblText += "<strong><font color=rgb\"(" + filterTextColor + ")\">Filter: </strong></font>";
    typeLblText += "<font color=rgb\"(" + filterInnerTextColor + ")\">" + origin + "</font>";
    typeLblText += "<font color=rgb\"(" + filterTextColor + ")\"> / </font>";
    typeLblText += "<font color=rgb\"(" + filterInnerTextColor + ")\">" + mcVersion + "</font>";
    typeLblText += "</body></html>";

    typeLbl.setText(typeLblText);
  }

  public void updateFilter() {
    updateFilterText();
    filterPacks();
    LaunchFrame.getInstance().updateFooter();
  }

  int getIndex() {
    if (packMapping.get(selectedPack) == null) {
      return -1;
    } else return packMapping.get(selectedPack);
  }

  public void updateLocale() {
    origin = I18N.getLocaleString("MAIN_ALL");
    mcVersion = I18N.getLocaleString("MAIN_ALL");
    avaliability = I18N.getLocaleString("MAIN_ALL");
    filter.setText(I18N.getLocaleString("FILTER_SETTINGS"));
    updateFilterText();
    editModPack.setText(I18N.getLocaleString("MODS_EDIT_PACK"));
    if (I18N.currentLocale == I18N.Locale.deDE) {
      editModPack.setBounds(290, 5, 120, 25);
      typeLbl.setBounds(115, 5, 165, 25);
    } else {
      editModPack.setBounds(300, 5, 110, 25);
      typeLbl.setBounds(115, 5, 175, 25);
    }
  }

  boolean avaliabilityCheck(ModPack pack) {
    return (avaliability.equalsIgnoreCase(I18N.getLocaleString("MAIN_ALL")))
        || (avaliability.equalsIgnoreCase(I18N.getLocaleString("FILTER_PUBLIC"))
            && !pack.isPrivatePack())
        || (avaliability.equalsIgnoreCase(I18N.getLocaleString("FILTER_PRIVATE"))
            && pack.isPrivatePack());
  }

  boolean mcVersionCheck(ModPack pack) {
    return (mcVersion.equalsIgnoreCase(I18N.getLocaleString("MAIN_ALL")))
        || (mcVersion.equalsIgnoreCase(pack.getMcVersion()));
  }

  boolean textSearch(ModPack pack) {
    String searchString = SearchDialog.lastPackSearch.toLowerCase();
    return ((searchString.isEmpty())
        || pack.getName().toLowerCase().contains(searchString)
        || pack.getAuthor().toLowerCase().contains(searchString));
  }

  abstract boolean filterForTab(ModPack pack);

  abstract String getLastPack();

  abstract String getPaneShortName();

  abstract boolean isFTB();
}
 boolean mcVersionCheck(ModPack pack) {
   return (mcVersion.equalsIgnoreCase(I18N.getLocaleString("MAIN_ALL")))
       || (mcVersion.equalsIgnoreCase(pack.getMcVersion()));
 }
Esempio n. 13
0
  public OptionsPane() {
    this.setBorder(new EmptyBorder(5, 5, 5, 5));
    currentRam = new JLabel();
    currentRam.setBounds(427, 114, 85, 23);
    long ram = 0;
    OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
    Method m;
    try {
      m = operatingSystemMXBean.getClass().getDeclaredMethod("getTotalPhysicalMemorySize");
      m.setAccessible(true);
      Object value = m.invoke(operatingSystemMXBean);
      if (value != null) {
        ram = Long.valueOf(value.toString()) / 1024 / 1024;
      } else {
        Logger.logWarn("Could not get RAM Value");
        ram = 8192;
      }
    } catch (Exception e) {
      Logger.logError(e.getMessage(), e);
    }

    ramMaximum = new JSlider();
    ramMaximum.setBounds(190, 114, 222, 23);
    ramMaximum.setSnapToTicks(true);
    ramMaximum.setMajorTickSpacing(256);
    ramMaximum.setMinorTickSpacing(256);
    ramMaximum.setMinimum(256);
    String vmType = System.getProperty("sun.arch.data.model");
    if (vmType != null) {
      if (vmType.equals("64")) {
        ramMaximum.setMaximum((int) ram);
      } else if (vmType.equals("32")) {
        if (ram < 1024) {
          ramMaximum.setMaximum((int) ram);
        } else {
          ramMaximum.setMaximum(1024);
        }
      }
    }
    int ramMax =
        (Integer.parseInt(Settings.getSettings().getRamMax()) > ramMaximum.getMaximum())
            ? ramMaximum.getMaximum()
            : Integer.parseInt(Settings.getSettings().getRamMax());
    ramMaximum.setValue(ramMax);
    currentRam.setText(getAmount());
    ramMaximum.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent arg0) {
            currentRam.setText(getAmount());
          }
        });
    ramMaximum.addFocusListener(settingsChangeListener);

    JButton installBrowseBtn = new JButton("...");
    installBrowseBtn.setBounds(786, 11, 49, 23);
    installBrowseBtn.addActionListener(new ChooseDir(this));
    setLayout(null);
    add(installBrowseBtn);

    lblInstallFolder = new JLabel(I18N.getLocaleString("INSTALL_FOLDER"));
    lblInstallFolder.setBounds(10, 11, 127, 23);
    add(lblInstallFolder);

    installFolderTextField = new JTextField();
    installFolderTextField.setBounds(147, 11, 629, 23);
    installFolderTextField.addFocusListener(settingsChangeListener);
    installFolderTextField.setColumns(10);
    installFolderTextField.setText(Settings.getSettings().getInstallPath());
    add(installFolderTextField);

    tglbtnForceUpdate = new JToggleButton(I18N.getLocaleString("FORCE_UPDATE"));
    tglbtnForceUpdate.setBounds(147, 45, 629, 29);
    tglbtnForceUpdate.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            tglbtnForceUpdate.setEnabled(false);
            saveSettingsInto(Settings.getSettings());
          }
        });
    tglbtnForceUpdate.getModel().setPressed(Settings.getSettings().getForceUpdate());
    add(tglbtnForceUpdate);

    lblRamMaximum = new JLabel(I18N.getLocaleString("RAM_MAX"));
    lblRamMaximum.setBounds(10, 114, 195, 23);
    add(lblRamMaximum);
    add(ramMaximum);
    add(currentRam);

    ArrayList<String> locales = new ArrayList<String>();
    for (Map.Entry<Integer, String> entry : I18N.localeIndices.entrySet()) {
      Logger.logInfo(
          "[i18n] Added "
              + entry.getKey().toString()
              + " "
              + entry.getValue()
              + " to options pane");
      locales.add(entry.getKey(), I18N.localeFiles.get(entry.getValue()));
    }

    locale = new JComboBox(locales.toArray());
    locale.setBounds(190, 148, 222, 23);
    locale.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            I18N.setLocale(I18N.localeIndices.get(locale.getSelectedIndex()));
            if (LaunchFrame.getInstance() != null) {
              LaunchFrame.getInstance().updateLocale();
            }
          }
        });
    locale.addFocusListener(settingsChangeListener);
    locale.setSelectedItem(I18N.localeFiles.get(Settings.getSettings().getLocale()));

    lblLocale = new JLabel(I18N.getLocaleString("LANGUAGE"));
    lblLocale.setBounds(10, 148, 195, 23);
    add(lblLocale);
    add(locale);

    minecraftSize = new JLabel("Size for Minecraft Window");
    minecraftSize.setBounds(10, 182, 195, 23);
    add(minecraftSize);

    minecraftX = new JTextField();
    minecraftX.setBounds(190, 182, 85, 22);
    minecraftX.setDocument(new documentFilter("\\D++"));
    minecraftX.setText(Settings.getSettings().getMinecraftX());
    minecraftX.addFocusListener(settingsChangeListener);
    add(minecraftX);

    lblX = new JLabel("x");
    lblX.setBounds(297, 182, 6, 20);
    add(lblX);

    minecraftY = new JTextField();
    minecraftY.setBounds(327, 182, 85, 23);
    minecraftY.setDocument(new documentFilter("\\D++"));
    minecraftY.setText(Settings.getSettings().getMinecraftY());
    minecraftY.addFocusListener(settingsChangeListener);
    add(minecraftY);
    minecraftY.setColumns(5);

    JLabel minecraftPos = new JLabel("Position of Minecraft Window");
    minecraftPos.setBounds(10, 216, 195, 23);
    add(minecraftPos);

    xPosField = new JTextField();
    xPosField.setBounds(190, 217, 85, 22);
    xPosField.setDocument(new documentFilter("\\D++"));
    xPosField.setText(Settings.getSettings().getMinecraftXPos());
    xPosField.addFocusListener(settingsChangeListener);
    add(xPosField);
    xPosField.setColumns(10);

    JLabel lblX_1 = new JLabel("x");
    lblX_1.setBounds(297, 216, 6, 23);
    add(lblX_1);

    yPosField = new JTextField();
    yPosField.setBounds(327, 216, 85, 23);
    yPosField.setDocument(new documentFilter("\\D++"));
    yPosField.setText(Settings.getSettings().getMinecraftYPos());
    yPosField.addFocusListener(settingsChangeListener);
    add(yPosField);
    yPosField.setColumns(10);

    tglbtnCenterScreen = new JToggleButton("Center Window on Screen");
    tglbtnCenterScreen.setBounds(190, 252, 222, 23);
    tglbtnCenterScreen.setSelected(Boolean.parseBoolean(Settings.getSettings().getCenterWindow()));
    tglbtnCenterScreen.addFocusListener(settingsChangeListener);
    add(tglbtnCenterScreen);

    downloadServers = new JComboBox(getDownloadServerNames());
    downloadServers.setBounds(613, 115, 222, 23);
    downloadServers.addFocusListener(settingsChangeListener);
    if (DownloadUtils.serversLoaded) {
      if (DownloadUtils.downloadServers.containsKey(Settings.getSettings().getDownloadServer())) {
        downloadServers.setSelectedItem(Settings.getSettings().getDownloadServer());
      }
    }
    add(downloadServers);

    JLabel downloadLocation = new JLabel("Download Location");
    downloadLocation.setBounds(490, 118, 110, 14);
    add(downloadLocation);

    chckbxShowConsole = new JCheckBox("Show Console?");
    chckbxShowConsole.addFocusListener(settingsChangeListener);
    chckbxShowConsole.setSelected(Boolean.parseBoolean(Settings.getSettings().getConsoleActive()));
    chckbxShowConsole.setBounds(613, 148, 183, 23);
    add(chckbxShowConsole);

    autoMaxCheck = new JCheckBox("Automatically Maximize?");
    autoMaxCheck.addFocusListener(settingsChangeListener);
    autoMaxCheck.setSelected(Boolean.parseBoolean(Settings.getSettings().getAutoMaximize()));
    autoMaxCheck.setBounds(613, 184, 183, 23);
    add(autoMaxCheck);

    JLabel javaLocLabel = new JLabel("Java Location");
    javaLocLabel.setBounds(490, 220, 110, 14);
    add(javaLocLabel);

    javaInstallDir = new JTextField();
    javaInstallDir.setEditable(false);
    String javaInstall = Settings.getSettings().getJavaInstall();
    javaInstallDir.setText(javaInstall);
    javaInstallDir.setToolTipText(javaInstall);
    javaInstallDir.setBounds(613, 220, 230, 23);
    add(javaInstallDir);

    JButton dirChooserButton = new JButton("Change");
    dirChooserButton.setBounds(763, 240, 80, 23);
    dirChooserButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser(Settings.getSettings().getJavaInstall());
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int option = chooser.showOpenDialog(OptionsPane.this);
            if (JFileChooser.APPROVE_OPTION == option) {
              File selectedDir = chooser.getSelectedFile();
              String javaExecutableName = "java";
              if (OS.WINDOWS.equals(OSUtils.getCurrentOS())) {
                javaExecutableName += ".exe";
              }
              File javaExecutable =
                  new File(
                      selectedDir
                          + System.getProperty("file.separator")
                          + "bin"
                          + System.getProperty("file.separator")
                          + javaExecutableName);
              if (javaExecutable.exists()) {
                javaInstallDir.setText(selectedDir.getAbsolutePath());
                saveSettingsInto(Settings.getSettings());
              } else {
                JOptionPane.showMessageDialog(
                    OptionsPane.this,
                    "The selected directoy is not a proper Java installation.",
                    "Error",
                    JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });
    add(dirChooserButton);
  }
Esempio n. 14
0
  public ModpacksPane() {
    super();
    this.setBorder(new EmptyBorder(5, 5, 5, 5));
    this.setLayout(null);

    splash = new JLabel();
    splash.setBounds(420, 0, 410, 200);
    this.add(splash);

    packPanels = new ArrayList<JPanel>();

    // TODO: Set loading animation while we wait
    //		try {
    //			loadingImage = new JLabel(new ImageIcon(new
    // URL("http://cdn.nirmaltv.com/images/generatorphp-thumb.gif")));
    //		} catch (MalformedURLException e1) { e1.printStackTrace(); }
    //		loadingImage.setLocation(58, 36);

    packs = new JPanel();
    packs.setLayout(null);
    packs.setOpaque(false);

    // stub for a real wait message
    final JPanel p = new JPanel();
    p.setBounds(0, 0, 420, 55);
    p.setLayout(null);

    filter = new JButton(I18N.getLocaleString("FILTER_SETTINGS"));
    filter.setBounds(5, 5, 105, 25);
    filter.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (loaded) {
              FilterDialog filterDia = new FilterDialog(instance);
              filterDia.setVisible(true);
            }
          }
        });
    add(filter);

    typeLbl =
        new JLabel(
            "<html><body><strong><font color=rgb\"(243,119,31)\">Filter:</strong></font> "
                + type
                + "<font color=rgb\"(243,119,31)\"> / </font>"
                + origin
                + "</body></html>");
    typeLbl.setBounds(115, 5, 175, 25);
    typeLbl.setHorizontalAlignment(SwingConstants.CENTER);
    add(typeLbl);

    editModPack = new JButton(I18N.getLocaleString("MODS_EDIT_PACK"));
    editModPack.setBounds(300, 5, 110, 25);
    editModPack.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (packPanels.size() > 0) {
              if (getSelectedModIndex() >= 0) {
                EditModPackDialog empd = new EditModPackDialog(LaunchFrame.getInstance());
                empd.setVisible(true);
              }
            }
          }
        });
    add(editModPack);

    JTextArea filler = new JTextArea(I18N.getLocaleString("MODS_WAIT_WHILE_LOADING"));
    filler.setBorder(null);
    filler.setEditable(false);
    filler.setForeground(Color.white);
    filler.setBounds(58, 6, 378, 42);
    filler.setBackground(new Color(255, 255, 255, 0));
    //		p.add(loadingImage);
    p.add(filler);
    packs.add(p);

    packsScroll = new JScrollPane();
    packsScroll.setBounds(0, 30, 420, 280);
    packsScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    packsScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    packsScroll.setWheelScrollingEnabled(true);
    packsScroll.setOpaque(false);
    packsScroll.setViewportView(packs);
    add(packsScroll);

    packInfo = new JEditorPane();
    packInfo.setEditable(false);
    packInfo.setContentType("text/html");
    packInfo.addHyperlinkListener(
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                LaunchFrame.getInstance().hLink(event.getURL().toURI());
              } catch (URISyntaxException e) {
              }
            }
          }
        });
    packInfo.setBounds(420, 210, 410, 90);
    // TODO: Fix darker background for text area? Or is it better blending in?
    packInfo.setBackground(UIManager.getColor("control").darker().darker());
    add(packInfo);

    JScrollPane infoScroll = new JScrollPane();
    infoScroll.setBounds(420, 210, 410, 90);
    infoScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    infoScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    infoScroll.setWheelScrollingEnabled(true);
    infoScroll.setViewportView(packInfo);
    infoScroll.setOpaque(false);
    add(infoScroll);
  }
  private void setupGui() {
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("FILTER_TITLE"));
    setResizable(false);

    Container panel = getContentPane();
    SpringLayout layout = new SpringLayout();
    panel.setLayout(layout);

    originLbl = new JLabel(I18N.getLocaleString("FILTER_ORIGIN"));
    availabilityLbl = new JLabel(I18N.getLocaleString("FILTER_MODPACKAVALIABILITY"));
    mcVersionLbl = new JLabel(I18N.getLocaleString("FILTER_MCVERSION"));
    origin = new JComboBox();
    mcVersion = new JComboBox();
    availability = new JComboBox();
    apply = new JButton(I18N.getLocaleString("FILTER_APPLY"));
    cancel = new JButton(I18N.getLocaleString("MAIN_CANCEL"));
    search = new JButton(I18N.getLocaleString("FILTER_SEARCHPACK"));

    origin.setPrototypeDisplayValue("xxxxxxxxxxxx");
    mcVersion.setPrototypeDisplayValue("xxxxxxxxxxxx");
    availability.setPrototypeDisplayValue("xxxxxxxxxxxx");

    panel.add(mcVersionLbl);
    panel.add(mcVersion);
    panel.add(originLbl);
    panel.add(origin);
    panel.add(availability);
    panel.add(availabilityLbl);
    panel.add(apply);
    panel.add(cancel);
    panel.add(search);

    Spring hSpring;
    Spring columnWidth;

    hSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.WEST, mcVersionLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, originLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, availabilityLbl, hSpring, SpringLayout.WEST, panel);

    columnWidth = Spring.width(mcVersionLbl);
    columnWidth = Spring.max(columnWidth, Spring.width(originLbl));
    columnWidth = Spring.max(columnWidth, Spring.width(availabilityLbl));

    hSpring = Spring.sum(hSpring, columnWidth);
    hSpring = Spring.sum(hSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.WEST, mcVersion, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, origin, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, availability, hSpring, SpringLayout.WEST, panel);

    columnWidth = Spring.width(mcVersion);
    columnWidth = Spring.max(columnWidth, Spring.width(origin));
    columnWidth = Spring.max(columnWidth, Spring.width(availability));

    hSpring = Spring.sum(hSpring, columnWidth);

    layout.putConstraint(SpringLayout.EAST, mcVersion, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, origin, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, availability, hSpring, SpringLayout.WEST, panel);

    hSpring = Spring.sum(hSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.EAST, panel, hSpring, SpringLayout.WEST, panel);

    layout.putConstraint(SpringLayout.WEST, search, 10, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, search, -5, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.WEST, cancel, 5, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.EAST, cancel, -10, SpringLayout.EAST, panel);

    layout.putConstraint(SpringLayout.WEST, apply, 10, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, apply, -10, SpringLayout.EAST, panel);

    Spring vSpring;
    Spring rowHeight;

    vSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.BASELINE, mcVersionLbl, 0, SpringLayout.BASELINE, mcVersion);
    layout.putConstraint(SpringLayout.NORTH, mcVersion, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(mcVersionLbl);
    rowHeight = Spring.max(rowHeight, Spring.height(mcVersion));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(SpringLayout.BASELINE, originLbl, 0, SpringLayout.BASELINE, origin);
    layout.putConstraint(SpringLayout.NORTH, origin, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(originLbl);
    rowHeight = Spring.max(rowHeight, Spring.height(origin));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(
        SpringLayout.BASELINE, availabilityLbl, 0, SpringLayout.BASELINE, availability);
    layout.putConstraint(SpringLayout.NORTH, availability, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(availabilityLbl);
    rowHeight = Spring.max(rowHeight, Spring.height(availability));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.NORTH, search, vSpring, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, cancel, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(search);
    rowHeight = Spring.max(rowHeight, Spring.height(cancel));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(SpringLayout.NORTH, apply, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(apply));
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);

    pack();
    setLocationRelativeTo(this.getOwner());
  }
  private void setupGui() {
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("UPDATEMODPACK_TITLE"));
    setResizable(false);

    Container panel = getContentPane();
    SpringLayout layout = new SpringLayout();
    panel.setLayout(layout);

    messageLbl = new JLabel(I18N.getLocaleString("UPDATEMODPACK_ISAVALIBLE"));
    updateLbl = new JLabel(I18N.getLocaleString("UPDATE_WICHUPDATE"));
    backup = new JCheckBox(I18N.getLocaleString("UPDATEMODPACK_BACKUP"));
    update = new JButton(I18N.getLocaleString("MAIN_YES"));
    abort = new JButton(I18N.getLocaleString("MAIN_NO"));

    messageLbl.setHorizontalAlignment(SwingConstants.CENTER);
    updateLbl.setHorizontalAlignment(SwingConstants.CENTER);
    backup.setHorizontalAlignment(SwingConstants.CENTER);

    panel.add(messageLbl);
    panel.add(updateLbl);
    panel.add(backup);
    panel.add(update);
    panel.add(abort);

    Spring hSpring;
    Spring columnWidth;

    hSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.WEST, messageLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, updateLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, backup, hSpring, SpringLayout.WEST, panel);

    columnWidth = Spring.width(messageLbl);
    columnWidth = Spring.max(columnWidth, Spring.width(updateLbl));
    columnWidth = Spring.max(columnWidth, Spring.width(backup));

    hSpring = Spring.sum(hSpring, columnWidth);

    layout.putConstraint(SpringLayout.EAST, messageLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, updateLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, backup, hSpring, SpringLayout.WEST, panel);

    hSpring = Spring.sum(hSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.EAST, panel, hSpring, SpringLayout.WEST, panel);

    layout.putConstraint(
        SpringLayout.HORIZONTAL_CENTER, backup, 0, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.EAST, update, -5, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.WEST, abort, 5, SpringLayout.HORIZONTAL_CENTER, panel);

    Spring vSpring;
    Spring rowHeight;

    vSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.NORTH, messageLbl, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(messageLbl));
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(SpringLayout.NORTH, updateLbl, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(updateLbl));
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.NORTH, backup, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(backup));
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.NORTH, update, vSpring, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, abort, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(update);
    rowHeight = Spring.max(rowHeight, Spring.height(abort));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);

    pack();
    setLocationRelativeTo(getOwner());
  }
  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);
          }
        });
  }
  private void setupGui() {
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("PROFILEADDER_TITLE"));
    setResizable(false);

    Container panel = getContentPane();
    SpringLayout layout = new SpringLayout();
    panel.setLayout(layout);

    usernameLbl = new JLabel(I18N.getLocaleString("PROFILEADDER_USERNAME"));
    username = new JTextField(16);
    passwordLbl = new JLabel(I18N.getLocaleString("PROFILEADDER_PASSWORD"));
    password = new JPasswordField(16);
    nameLbl = new JLabel(I18N.getLocaleString("PROFILEADDER_NAME"));
    name = new JTextField(16);
    savePassword = new JCheckBox(I18N.getLocaleString("PROFILEADDER_SAVEPASSWORD"));
    add = new JButton(I18N.getLocaleString("MAIN_ADD"));

    usernameLbl.setLabelFor(username);
    passwordLbl.setLabelFor(password);
    nameLbl.setLabelFor(name);

    panel.add(usernameLbl);
    panel.add(username);
    panel.add(passwordLbl);
    panel.add(password);
    panel.add(nameLbl);
    panel.add(name);
    panel.add(savePassword);
    panel.add(add);

    Spring hSpring;
    Spring columnWidth;

    hSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.WEST, usernameLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, passwordLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, nameLbl, hSpring, SpringLayout.WEST, panel);

    columnWidth = Spring.width(usernameLbl);
    columnWidth = Spring.max(columnWidth, Spring.width(passwordLbl));
    columnWidth = Spring.max(columnWidth, Spring.width(nameLbl));

    hSpring = Spring.sum(hSpring, columnWidth);
    hSpring = Spring.sum(hSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.WEST, username, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, password, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, name, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, savePassword, hSpring, SpringLayout.WEST, panel);

    columnWidth = Spring.width(username);
    columnWidth = Spring.max(columnWidth, Spring.width(password));
    columnWidth = Spring.max(columnWidth, Spring.width(name));
    columnWidth = Spring.max(columnWidth, Spring.width(savePassword));

    hSpring = Spring.sum(hSpring, columnWidth);
    hSpring = Spring.sum(hSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.EAST, panel, hSpring, SpringLayout.WEST, panel);

    layout.putConstraint(
        SpringLayout.HORIZONTAL_CENTER, add, 0, SpringLayout.HORIZONTAL_CENTER, panel);

    Spring vSpring;
    Spring rowHeight;

    vSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.BASELINE, usernameLbl, 0, SpringLayout.BASELINE, username);
    layout.putConstraint(SpringLayout.NORTH, username, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(usernameLbl);
    rowHeight = Spring.max(rowHeight, Spring.height(username));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(SpringLayout.BASELINE, passwordLbl, 0, SpringLayout.BASELINE, password);
    layout.putConstraint(SpringLayout.NORTH, password, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(passwordLbl);
    rowHeight = Spring.max(rowHeight, Spring.height(password));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(SpringLayout.BASELINE, nameLbl, 0, SpringLayout.BASELINE, name);
    layout.putConstraint(SpringLayout.NORTH, name, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(nameLbl);
    rowHeight = Spring.max(rowHeight, Spring.height(name));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(SpringLayout.NORTH, savePassword, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(savePassword));
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.NORTH, add, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(add));
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);

    pack();
    setLocationRelativeTo(getOwner());
  }