diff options
| author | bowser0000 <bowser0000@gmail.com> | 2021-04-08 08:43:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-08 08:43:19 -0400 |
| commit | 14efcd8b81763d1c06a4291eeb6a0f1aaeb770fe (patch) | |
| tree | 5b58218f51e6f358e5dd15946580dd7b7159c79a /src/main/java | |
| parent | 435d8dfd5a7f36803ceefcbd245e814ec735aced (diff) | |
| parent | 8b1c19bff9ca13034e794ef76086e75aaf59bd14 (diff) | |
| download | SkyblockMod-14efcd8b81763d1c06a4291eeb6a0f1aaeb770fe.tar.gz SkyblockMod-14efcd8b81763d1c06a4291eeb6a0f1aaeb770fe.tar.bz2 SkyblockMod-14efcd8b81763d1c06a4291eeb6a0f1aaeb770fe.zip | |
Merge pull request #91 from bowser0000/developmentv1.8.6
1.8.6
Diffstat (limited to 'src/main/java')
92 files changed, 9286 insertions, 5835 deletions
diff --git a/src/main/java/DefenitlyNotAJoikedInstallerFrame.java b/src/main/java/DefenitlyNotAJoikedInstallerFrame.java new file mode 100644 index 0000000..bd5e218 --- /dev/null +++ b/src/main/java/DefenitlyNotAJoikedInstallerFrame.java @@ -0,0 +1,685 @@ +import me.Danker.DankersSkyblockMod; + +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.util.Locale; +import java.util.Objects; +import java.util.jar.JarFile; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; + +public class DefenitlyNotAJoikedInstallerFrame extends JFrame implements ActionListener, MouseListener { + + private static final Pattern IN_MODS_SUBFOLDER = Pattern.compile("1\\.8\\.9[/\\\\]?$"); + + private JLabel logo = null; + private JLabel versionInfo = null; + private JLabel labelFolder = null; + + private JPanel panelCenter = null; + private JPanel panelBottom = null; + private JPanel totalContentPane = null; + + private JTextArea descriptionText = null; + private JTextArea forgeDescriptionText = null; + + private JTextField textFieldFolderLocation = null; + private JButton buttonChooseFolder = null; + + private JButton buttonInstall = null; + private JButton buttonOpenFolder = null; + private JButton buttonClose = null; + + private static final int TOTAL_HEIGHT = 442; //435 + private static final int TOTAL_WIDTH = 404; + + private int x = 0; + private int y = 0; + + private int w = TOTAL_WIDTH; + private int h; + private int margin; + + public DefenitlyNotAJoikedInstallerFrame() { + try { + setName("DankersSkyblockModInstallerFrame"); + setTitle("DSM Installer"); + setResizable(false); + setSize(TOTAL_WIDTH, TOTAL_HEIGHT); + setContentPane(getPanelContentPane()); + + getButtonFolder().addActionListener(this); + getButtonInstall().addActionListener(this); + getButtonOpenFolder().addActionListener(this); + getButtonClose().addActionListener(this); + getForgeTextArea().addMouseListener(this); + + pack(); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + getFieldFolder().setText(getModsFolder().getPath()); + getButtonInstall().setEnabled(true); + getButtonInstall().requestFocus(); + } catch (Exception ex) { + showErrorPopup(ex); + } + } + + public static void main(String[] args) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + DefenitlyNotAJoikedInstallerFrame frame = new DefenitlyNotAJoikedInstallerFrame(); + frame.centerFrame(frame); + frame.show(); + + } catch (Exception ex) { + showErrorPopup(ex); + } + } + + private JPanel getPanelContentPane() { + if (totalContentPane == null) { + try { + totalContentPane = new JPanel(); + totalContentPane.setName("PanelContentPane"); + totalContentPane.setLayout(new BorderLayout(5, 5)); + totalContentPane.setPreferredSize(new Dimension(TOTAL_WIDTH, TOTAL_HEIGHT)); + totalContentPane.add(getPanelCenter(), "Center"); + totalContentPane.add(getPanelBottom(), "South"); + } catch (Throwable ivjExc) { + showErrorPopup(ivjExc); + } + } + return totalContentPane; + } + + private JPanel getPanelCenter() { + if (panelCenter == null) { + try { + (panelCenter = new JPanel()).setName("PanelCenter"); + panelCenter.setLayout(null); + panelCenter.add(getPictureLabel(), getPictureLabel().getName()); + panelCenter.add(getVersionInfo(), getVersionInfo().getName()); + panelCenter.add(getTextArea(), getTextArea().getName()); + panelCenter.add(getForgeTextArea(), getForgeTextArea().getName()); + panelCenter.add(getLabelFolder(), getLabelFolder().getName()); + panelCenter.add(getFieldFolder(), getFieldFolder().getName()); + panelCenter.add(getButtonFolder(), getButtonFolder().getName()); + } catch (Throwable ivjExc) { + showErrorPopup(ivjExc); + } + } + return panelCenter; + } + + private JLabel getPictureLabel() { + if (logo == null) { + try { + h = w/2; + margin = 5; + + BufferedImage myPicture = ImageIO.read(Objects.requireNonNull(getClass().getClassLoader() + .getResourceAsStream("assets/dsm/icons/logo.png"), "Logo not found.")); + Image scaled = myPicture.getScaledInstance(w-margin*2, h-margin, Image.SCALE_SMOOTH); + logo = new JLabel(new ImageIcon(scaled)); + logo.setName("logo"); + logo.setBounds(x+margin, y+margin, w-margin*2, h-margin); + logo.setFont(new Font(Font.DIALOG, Font.BOLD, 18)); + logo.setHorizontalAlignment(SwingConstants.CENTER); + logo.setPreferredSize(new Dimension(w, h)); + + y += h; + } catch (Throwable ivjExc) { + showErrorPopup(ivjExc); + } + } + return logo; + } + + private JLabel getVersionInfo() { + if (versionInfo == null) { + try { + h = 47; //34 + + versionInfo = new JLabel(); + versionInfo.setName("LabelMcVersion"); + versionInfo.setBounds(x, y+1, w, h); + versionInfo.setFont(new Font(Font.DIALOG, Font.BOLD, 14)); + versionInfo.setHorizontalAlignment(SwingConstants.CENTER); + versionInfo.setPreferredSize(new Dimension(w, h)); + versionInfo.setText("<html><body>Danker's Skyblock Mod - Installer by Biscuit <br><center> for Minecraft 1.8.9</center></body></html>"); + + y += h-5; + } catch (Throwable ivjExc) { + showErrorPopup(ivjExc); + } + } + return versionInfo; + } + + + private JTextArea getTextArea() { + if (descriptionText == null) { + try { + h = 60; + margin = 10; + + descriptionText = new JTextArea(); + descriptionText.setName("TextArea"); + setTextAreaProperties(descriptionText); + descriptionText.setText("This installer will copy Danker's Skyblock Mod into your forge mods folder for you, and replace any old versions that already exist. " + + "Close this if you prefer to do this yourself!"); + descriptionText.setWrapStyleWord(true); + + y += h; + } catch (Throwable ivjExc) { + showErrorPopup(ivjExc); + } + } + return descriptionText; + } + + private void setTextAreaProperties(JTextArea textArea) { + textArea.setBounds(x+margin, y+margin, w-margin*2, h-margin); + textArea.setEditable(false); + textArea.setHighlighter(null); + textArea.setEnabled(true); + textArea.setFont(new Font(Font.DIALOG, Font.PLAIN, 12)); + textArea.setLineWrap(true); + textArea.setOpaque(false); + textArea.setPreferredSize(new Dimension(w-margin*2, h-margin)); + } + + private JTextArea getForgeTextArea() { + if (forgeDescriptionText == null) { + try { + h = 55; + margin = 10; + + forgeDescriptionText = new JTextArea(); + forgeDescriptionText.setName("TextAreaForge"); + + + setTextAreaProperties(forgeDescriptionText); + + + + + + forgeDescriptionText.setText("However, you still need to install Forge client in order to be able to run this mod. Click here to visit the download page for Forge 1.8.9!"); + forgeDescriptionText.setForeground(Color.BLUE.darker()); + forgeDescriptionText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + forgeDescriptionText.setWrapStyleWord(true); + + |
