From 78bd86a9e64c9f3b0356fa9d8800544d9b7acb96 Mon Sep 17 00:00:00 2001 From: Moudoux Date: Fri, 11 May 2018 14:41:37 +0200 Subject: [PATCH] Update build --- build.gradle | 20 ++++++ .../deftware/emc/installer/ui/DialogUI.java | 53 ++++++++++++++- .../emc/installer/ui/InstallerUI.java | 68 +++++++++++++++++-- 3 files changed, 136 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 003174b..8b0acf6 100644 --- a/build.gradle +++ b/build.gradle @@ -23,8 +23,28 @@ repositories { mavenCentral() } +configurations { + extraLibs +} + dependencies { + compile 'com.intellij:forms_rt:7.0.3' compile group: 'com.google.code.gson', name: 'gson', version: '2.7' compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2' + extraLibs group: 'com.google.code.gson', name: 'gson', version: '2.7' + extraLibs group: 'org.apache.commons', name: 'commons-io', version: '1.3.2' + extraLibs 'com.intellij:forms_rt:7.0.3' testCompile group: 'junit', name: 'junit', version: '4.12' } + +jar { + from { + configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } + } + manifest.attributes( + "Main-Class": "me.deftware.emc.installer.Main", + "Manifest-Version": 1.0 + ) +} + + diff --git a/src/main/java/me/deftware/emc/installer/ui/DialogUI.java b/src/main/java/me/deftware/emc/installer/ui/DialogUI.java index b752088..40f7178 100644 --- a/src/main/java/me/deftware/emc/installer/ui/DialogUI.java +++ b/src/main/java/me/deftware/emc/installer/ui/DialogUI.java @@ -1,5 +1,9 @@ package me.deftware.emc.installer.ui; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; + import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; @@ -21,7 +25,7 @@ public DialogUI(String text, String title, boolean continueButton, DialogCallbac addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - onContinue(); + onContinue(); } }); buttonOK.setVisible(continueButton); @@ -39,6 +43,53 @@ public void onContinue() { dispose(); } + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + buttonOK = new JButton(); + buttonOK.setText("Continue"); + panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + modalText = new JLabel(); + modalText.setText("Label"); + panel3.add(modalText, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel3.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel3.add(spacer3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + @FunctionalInterface public interface DialogCallback { diff --git a/src/main/java/me/deftware/emc/installer/ui/InstallerUI.java b/src/main/java/me/deftware/emc/installer/ui/InstallerUI.java index fd6d0b0..3d311f9 100644 --- a/src/main/java/me/deftware/emc/installer/ui/InstallerUI.java +++ b/src/main/java/me/deftware/emc/installer/ui/InstallerUI.java @@ -28,7 +28,7 @@ public class InstallerUI { public InstallerUI(JsonObject json, JFrame frame) { try { String line; - InputStream in = Main.class.getResourceAsStream("/EMC.json"); + InputStream in = Main.class.getResourceAsStream("/emc.json"); StringBuilder result = new StringBuilder(""); while ((line = new BufferedReader(new InputStreamReader(in)).readLine()) != null) { result.append(line); @@ -73,7 +73,7 @@ private void install() { String mcVersion = comboBox1.getSelectedItem().toString(); String[] jsonValue = json.get(mcVersion).getAsString().split(","); String optifineVersion = jsonValue[1], emcVersion = jsonValue[0]; - DialogUI dialog = new DialogUI("Installing " + clientName + ", please wait...","",false, () -> { + DialogUI dialog = new DialogUI("Installing " + clientName + ", please wait...", "", false, () -> { new DialogUI("Install complete, the installer will now exit", "Done", true, () -> System.exit(0)).setVisible(true); }); new Thread(() -> { @@ -108,11 +108,11 @@ private void install() { JsonObject json = JSONGenerator.generateClientJSON(clientName, mcVersion, emcVersion, withOptiFineRadioButton.isSelected() ? optifineVersion : ""); File clientDir = new File(Utils.getMinecraftRoot() + "versions" + File.separator + mcVersion + "-" + clientName + File.separator); clientDir.mkdirs(); - try (Writer writer = new FileWriter(new File(clientDir.getAbsolutePath() + File.separator + mcVersion + "-" + clientName + ".json"))) { + try (Writer writer = new FileWriter(new File(clientDir.getAbsolutePath() + File.separator + mcVersion + "-" + clientName + ".json"))) { new GsonBuilder().setPrettyPrinting().create().toJson(json, writer); } // Install launcher profile - File profiles_json = new File(Utils.getMinecraftRoot() + "launcher_profiles.json"); + File profiles_json = new File(Utils.getMinecraftRoot() + "launcher_profiles.json"); JsonObject launcherJson = new JsonParser().parse(Files.newBufferedReader(profiles_json.toPath())).getAsJsonObject(); JsonObject profiles = launcherJson.get("profiles").getAsJsonObject(); if (!profiles.has(mcVersion + "-" + clientName)) { @@ -142,4 +142,64 @@ private void install() { }).start(); } + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(12, 2, new Insets(0, 0, 0, 0), -1, -1)); + installButton = new JButton(); + installButton.setEnabled(true); + installButton.setText("Install"); + mainPanel.add(installButton, new com.intellij.uiDesigner.core.GridConstraints(9, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cancelButton = new JButton(); + cancelButton.setEnabled(true); + cancelButton.setText("Cancel"); + mainPanel.add(cancelButton, new com.intellij.uiDesigner.core.GridConstraints(9, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + comboBox1 = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + comboBox1.setModel(defaultComboBoxModel1); + mainPanel.add(comboBox1, new com.intellij.uiDesigner.core.GridConstraints(1, 0, 5, 2, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + withOptiFineRadioButton = new JRadioButton(); + withOptiFineRadioButton.setSelected(false); + withOptiFineRadioButton.setText("With OptiFine"); + mainPanel.add(withOptiFineRadioButton, new com.intellij.uiDesigner.core.GridConstraints(8, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + forForgeRadioButton = new JRadioButton(); + forForgeRadioButton.setText("For Forge"); + mainPanel.add(forForgeRadioButton, new com.intellij.uiDesigner.core.GridConstraints(8, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final com.intellij.uiDesigner.core.Spacer spacer1 = new com.intellij.uiDesigner.core.Spacer(); + mainPanel.add(spacer1, new com.intellij.uiDesigner.core.GridConstraints(10, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("Select below if you want to install for Forge or OptiFine. "); + mainPanel.add(label1, new com.intellij.uiDesigner.core.GridConstraints(6, 0, 1, 2, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final com.intellij.uiDesigner.core.Spacer spacer2 = new com.intellij.uiDesigner.core.Spacer(); + mainPanel.add(spacer2, new com.intellij.uiDesigner.core.GridConstraints(10, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("Leave blank if you wish to use Aristois without Forge/OptiFine"); + mainPanel.add(label2, new com.intellij.uiDesigner.core.GridConstraints(7, 0, 1, 2, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("Select which Minecraft version you want to install for:"); + mainPanel.add(label3, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 2, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("Made by https://deftware.me/"); + mainPanel.add(label4, new com.intellij.uiDesigner.core.GridConstraints(11, 0, 1, 2, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } }