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);
  }
Beispiel #2
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();
            }
          }
        });
  }
  /*
   * 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;
    }
  }