1313import java .io .FileInputStream ;
1414import java .io .FileOutputStream ;
1515import java .io .IOException ;
16+ import java .net .MalformedURLException ;
1617import java .net .URL ;
1718import java .nio .file .Path ;
1819import java .util .Collections ;
1920import java .util .List ;
2021import java .util .Objects ;
22+ import java .util .Scanner ;
2123import java .util .concurrent .ExecutionException ;
2224import java .util .zip .ZipEntry ;
2325import 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! \n Error: %s" ,
521+ String msg = String .format ("An error occurred while attempting to download Iris and Sodium , please check your internet connection and try again! \n Error: %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! \n Error: %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! \n Error: %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 /**
0 commit comments