Skip to content

Commit 3a70237

Browse files
committed
Comp Installer - Work in progress
1 parent 5c4aeae commit 3a70237

File tree

6 files changed

+102
-39
lines changed

6 files changed

+102
-39
lines changed

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Version and packaging info
5-
version=3.0.1
6-
maven_group=net.hypercubemc
7-
archives_base_name=Iris-Installer
5+
version=1.0.0
6+
maven_group=
7+
archives_base_name=Complementary-Installer
88

99
# Main class to start with when the jar is run
1010
main_class=net.hypercubemc.iris_installer.NewInstaller

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'Iris Installer'
1+
rootProject.name = 'Complementary Installer'

src/main/java/net/hypercubemc/iris_installer/NewInstaller.form

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Properties>
99
<Property name="defaultCloseOperation" type="int" value="3"/>
1010
<Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
11-
<Connection code="new ImageIcon(Objects.requireNonNull(Utils.class.getClassLoader().getResource(&quot;iris_profile_icon.png&quot;))).getImage()" type="code"/>
11+
<Connection code="new ImageIcon(Objects.requireNonNull(Utils.class.getClassLoader().getResource(&quot;comp_icon.png&quot;))).getImage()" type="code"/>
1212
</Property>
1313
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
1414
<Dimension value="[480, 550]"/>
@@ -49,9 +49,9 @@
4949
</Property>
5050
<Property name="horizontalAlignment" type="int" value="0"/>
5151
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
52-
<Image iconType="3" name="/iris_profile_icon.png"/>
52+
<Image iconType="3" name="/comp_icon.png"/>
5353
</Property>
54-
<Property name="text" type="java.lang.String" value=" Iris &amp; Sodium"/>
54+
<Property name="text" type="java.lang.String" value=" Complementary"/>
5555
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
5656
<Dimension value="[350, 64]"/>
5757
</Property>
@@ -70,7 +70,7 @@
7070
</FontInfo>
7171
</Property>
7272
<Property name="horizontalAlignment" type="int" value="0"/>
73-
<Property name="text" type="java.lang.String" value="Select game version:"/>
73+
<Property name="text" type="java.lang.String" value="Select Minecraft version:"/>
7474
<Property name="toolTipText" type="java.lang.String" value=""/>
7575
<Property name="horizontalTextPosition" type="int" value="0"/>
7676
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
@@ -101,7 +101,7 @@
101101
<Color blue="0" green="cc" red="ff" type="rgb"/>
102102
</Property>
103103
<Property name="horizontalAlignment" type="int" value="0"/>
104-
<Property name="text" type="java.lang.String" value="Warning: We have ended support for &lt;version&gt;."/>
104+
<Property name="text" type="java.lang.String" value="Warning: Iris shader loader have ended support for &lt;version&gt;."/>
105105
<Property name="horizontalTextPosition" type="int" value="0"/>
106106
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
107107
<Dimension value="[400, 21]"/>
@@ -208,7 +208,7 @@
208208
</Property>
209209
<Property name="selected" type="boolean" value="true"/>
210210
<Property name="text" type="java.lang.String" value="Iris Install"/>
211-
<Property name="toolTipText" type="java.lang.String" value="This installs Iris and Sodium by itself, without any mods."/>
211+
<Property name="toolTipText" type="java.lang.String" value="Installs Iris + Sodium by itself, and adds Complementary."/>
212212
</Properties>
213213
<Events>
214214
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="standaloneTypeMouseClicked"/>
@@ -230,7 +230,7 @@
230230
</FontInfo>
231231
</Property>
232232
<Property name="text" type="java.lang.String" value="Fabric Install"/>
233-
<Property name="toolTipText" type="java.lang.String" value="This installs Iris and Sodium alongside an installation of Fabric."/>
233+
<Property name="toolTipText" type="java.lang.String" value="Installs Iris + Sodium on an installation of Fabric Loader, and adds Complementary."/>
234234
</Properties>
235235
<Events>
236236
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="fabricTypeMouseClicked"/>

src/main/java/net/hypercubemc/iris_installer/NewInstaller.java

Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
import java.io.FileInputStream;
1414
import java.io.FileOutputStream;
1515
import java.io.IOException;
16+
import java.net.MalformedURLException;
1617
import java.net.URL;
1718
import java.nio.file.Path;
1819
import java.util.Collections;
1920
import java.util.List;
2021
import java.util.Objects;
22+
import java.util.Scanner;
2123
import java.util.concurrent.ExecutionException;
2224
import java.util.zip.ZipEntry;
2325
import java.util.zip.ZipInputStream;
@@ -38,7 +40,7 @@ public class NewInstaller extends JFrame {
3840

3941
private static boolean dark = false;
4042
private boolean installAsMod;
41-
private String outdatedPlaceholder = "Warning: We have ended support for <version>.";
43+
private String outdatedPlaceholder = "Warning: Iris shader loader have ended support for <version>.";
4244
private String snapshotPlaceholder = "Warning: <version> is a snapshot build and may";
4345
private String BASE_URL = "https://raw.githubusercontent.com/IrisShaders/Iris-Installer-Files/master/";
4446
private boolean finishedSuccessfulInstall;
@@ -51,7 +53,7 @@ public class NewInstaller extends JFrame {
5153
* Creates new form Installer
5254
*/
5355
public NewInstaller() {
54-
super("Iris Installer");
56+
super("Complementary Installer");
5557
Main.LOADER_META = new MetaHandler(Reference.getMetaServerEndpoint("v2/versions/loader"));
5658

5759
try {
@@ -229,7 +231,7 @@ private void initComponents() {
229231
installButton = new javax.swing.JButton();
230232

231233
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
232-
setIconImage(new ImageIcon(Objects.requireNonNull(Utils.class.getClassLoader().getResource("iris_profile_icon.png"))).getImage());
234+
setIconImage(new ImageIcon(Objects.requireNonNull(Utils.class.getClassLoader().getResource("comp_icon.png"))).getImage());
233235
setMaximumSize(new java.awt.Dimension(480, 600));
234236
setMinimumSize(new java.awt.Dimension(480, 600));
235237
setPreferredSize(new java.awt.Dimension(480, 600));
@@ -238,8 +240,8 @@ private void initComponents() {
238240

239241
irisInstallerLabel.setFont(irisInstallerLabel.getFont().deriveFont((float)36));
240242
irisInstallerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
241-
irisInstallerLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iris_profile_icon.png"))); // NOI18N
242-
irisInstallerLabel.setText(" Iris & Sodium");
243+
irisInstallerLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/comp_icon.png"))); // NOI18N
244+
irisInstallerLabel.setText(" Complementary");
243245
irisInstallerLabel.setMaximumSize(new java.awt.Dimension(350, 64));
244246
gridBagConstraints = new java.awt.GridBagConstraints();
245247
gridBagConstraints.gridx = 1;
@@ -249,7 +251,7 @@ private void initComponents() {
249251

250252
gameVersionLabel.setFont(gameVersionLabel.getFont().deriveFont(gameVersionLabel.getFont().getStyle() | java.awt.Font.BOLD, 16));
251253
gameVersionLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
252-
gameVersionLabel.setText("Select game version:");
254+
gameVersionLabel.setText("Select Minecraft version:");
253255
gameVersionLabel.setToolTipText("");
254256
gameVersionLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
255257
gameVersionLabel.setMaximumSize(new java.awt.Dimension(300, 24));
@@ -266,7 +268,7 @@ private void initComponents() {
266268
outdatedText1.setFont(outdatedText1.getFont().deriveFont((float)16));
267269
outdatedText1.setForeground(new java.awt.Color(255, 204, 0));
268270
outdatedText1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
269-
outdatedText1.setText("Warning: We have ended support for <version>.");
271+
outdatedText1.setText("Warning: Iris shader loader have ended support for <version>.");
270272
outdatedText1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
271273
outdatedText1.setMaximumSize(new java.awt.Dimension(400, 21));
272274
outdatedText1.setMinimumSize(new java.awt.Dimension(310, 21));
@@ -322,7 +324,7 @@ private void initComponents() {
322324
standaloneType.setFont(standaloneType.getFont().deriveFont((float)16));
323325
standaloneType.setSelected(true);
324326
standaloneType.setText("Iris Install");
325-
standaloneType.setToolTipText("This installs Iris and Sodium by itself, without any mods.");
327+
standaloneType.setToolTipText("Installs Iris + Sodium by itself, and adds Complementary.");
326328
standaloneType.addMouseListener(new java.awt.event.MouseAdapter() {
327329
public void mouseClicked(java.awt.event.MouseEvent evt) {
328330
standaloneTypeMouseClicked(evt);
@@ -333,7 +335,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
333335
installType.add(fabricType);
334336
fabricType.setFont(fabricType.getFont().deriveFont((float)16));
335337
fabricType.setText("Fabric Install");
336-
fabricType.setToolTipText("This installs Iris and Sodium alongside an installation of Fabric.");
338+
fabricType.setToolTipText("Installs Iris + Sodium on an installation of Fabric Loader, and adds Complementary.");
337339
fabricType.addMouseListener(new java.awt.event.MouseAdapter() {
338340
public void mouseClicked(java.awt.event.MouseEvent evt) {
339341
fabricTypeMouseClicked(evt);
@@ -502,21 +504,21 @@ private void installButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
502504
progressBar.setValue(0);
503505

504506
String zipName = (betaSelection.isSelected() ? "Iris-Sodium-Beta" : "Iris-Sodium") + "-" + selectedVersion.name + ".zip";
505-
String downloadURL = "https://github.com/IrisShaders/Iris-Installer-Files/releases/latest/download/" + zipName;
507+
String irisDownURL = "https://github.com/IrisShaders/Iris-Installer-Files/releases/latest/download/" + zipName;
506508
File saveLocation = getStorageDirectory().resolve(zipName).toFile();
507509

508-
final Downloader downloader = new Downloader(downloadURL, saveLocation);
509-
downloader.addPropertyChangeListener(event -> {
510-
if ("progress".equals(event.getPropertyName())) {
511-
progressBar.setValue((Integer) event.getNewValue());
512-
} else if (event.getNewValue() == SwingWorker.StateValue.DONE) {
510+
final Downloader downloaderI = new Downloader(irisDownURL, saveLocation);
511+
downloaderI.addPropertyChangeListener(eventI -> {
512+
if ("progress".equals(eventI.getPropertyName())) {
513+
progressBar.setValue(((Integer) eventI.getNewValue() ) * 3 / 4);
514+
} else if (eventI.getNewValue() == SwingWorker.StateValue.DONE) {
513515
try {
514-
downloader.get();
516+
downloaderI.get();
515517
} catch (InterruptedException | ExecutionException e) {
516-
System.out.println("Failed to download zip!");
518+
System.out.println("Failed to download Iris!");
517519
e.getCause().printStackTrace();
518520

519-
String msg = String.format("An error occurred while attempting to download the required files, please check your internet connection and try again! \nError: %s",
521+
String msg = String.format("An error occurred while attempting to download Iris and Sodium, please check your internet connection and try again! \nError: %s",
520522
e.getCause().toString());
521523
installButton.setEnabled(true);
522524
installButton.setText("Download Failed!");
@@ -527,8 +529,6 @@ private void installButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
527529
return;
528530
}
529531

530-
installButton.setText("Download Complete!");
531-
532532
boolean cancelled = false;
533533

534534
File installDir = getInstallDir().toFile();
@@ -610,15 +610,78 @@ private void installButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
610610
modsFolder.mkdir();
611611
}
612612

613-
boolean installSuccess = installFromZip(saveLocation);
613+
boolean installISuccess = installFromZip(saveLocation);
614+
615+
if (installISuccess) {
616+
URL url = null;
617+
String shaderName = null;
618+
try {
619+
url = new URL("https://www.complementary.dev/changelogs/reimagined-ch/rLatest.txt");
620+
Scanner scan = new Scanner(url.openStream());
621+
shaderName = scan.nextLine();
622+
} catch (IOException e) {
623+
System.out.println("Failed to download Comp!");
624+
e.getCause().printStackTrace();
625+
626+
String msg = String.format("An error occurred while attempting to download Complementary files, please check your internet connection and try again! \nError: %s",
627+
e.getCause().toString());
628+
installButton.setEnabled(true);
629+
installButton.setText("Download Failed!");
630+
progressBar.setForeground(new Color(204, 0, 0));
631+
progressBar.setValue(100);
632+
JOptionPane.showMessageDialog(this,
633+
msg, "Download Failed!", JOptionPane.ERROR_MESSAGE, null);
634+
return;
635+
}
614636

615-
if (installSuccess) {
616-
installButton.setText("Completed!");
617-
//installButton.setMargin(new java.awt.Insets(10, 80, 10, 80));
637+
String compDownURL = "https://github.com/ComplementaryDevelopment/ComplementaryReimagined/releases/download/latest/"+shaderName;
638+
File shaderDir = getVanillaGameDir().resolve("shaderpacks").toFile();
639+
if (!shaderDir.exists() || !shaderDir.isDirectory()) {
640+
shaderDir.mkdir();
641+
}
642+
File shaderLoc = getVanillaGameDir().resolve("shaderpacks").resolve(shaderName).toFile();
643+
644+
final Downloader downloaderC = new Downloader(compDownURL, shaderLoc);
645+
String finalShaderName = shaderName;
646+
downloaderC.addPropertyChangeListener(eventC -> {
647+
if ("progress".equals(eventC.getPropertyName())) {
648+
progressBar.setValue(285 + ((Integer) eventC.getNewValue() ) / 4);
649+
} else if (eventC.getNewValue() == SwingWorker.StateValue.DONE) {
650+
try {
651+
downloaderC.get();
652+
} catch (InterruptedException | ExecutionException e) {
653+
System.out.println("Failed to download Comp!");
654+
e.getCause().printStackTrace();
655+
656+
String msg = String.format("An error occurred while attempting to download Complementary files, please check your internet connection and try again! \nError: %s",
657+
e.getCause().toString());
658+
installButton.setEnabled(true);
659+
installButton.setText("Download Failed!");
660+
progressBar.setForeground(new Color(204, 0, 0));
661+
progressBar.setValue(100);
662+
JOptionPane.showMessageDialog(this,
663+
msg, "Download Failed!", JOptionPane.ERROR_MESSAGE, null);
664+
return;
665+
}
618666

619-
progressBar.setForeground(new Color(39, 195, 75));
620-
installButton.setEnabled(true);
621-
finishedSuccessfulInstall = true;
667+
installButton.setText("Completed!");
668+
//installButton.setMargin(new java.awt.Insets(10, 80, 10, 80));
669+
670+
progressBar.setForeground(new Color(39, 195, 75));
671+
installButton.setEnabled(false);
672+
finishedSuccessfulInstall = true;
673+
674+
System.out.println("Finished Successful Install");
675+
String msg = "Successfully installed Iris, Sodium, and "
676+
+finalShaderName;
677+
JOptionPane.showMessageDialog(this,
678+
msg, "Installation Complete!", JOptionPane.PLAIN_MESSAGE, new ImageIcon(Objects.requireNonNull(Utils.class.getClassLoader().getResource("green_tick.png"))));
679+
System.exit(111);
680+
return;
681+
}
682+
});
683+
684+
downloaderC.execute();
622685
} else {
623686
installButton.setText("Failed!");
624687
progressBar.setForeground(new Color(204, 0, 0));
@@ -628,7 +691,7 @@ private void installButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
628691
}
629692
});
630693

631-
downloader.execute();
694+
downloaderI.execute();
632695
}//GEN-LAST:event_installButtonMouseClicked
633696

634697
/**

src/main/resources/comp_icon.png

6.91 KB
Loading

src/main/resources/green_tick.png

1.63 KB
Loading

0 commit comments

Comments
 (0)