aboutsummaryrefslogtreecommitdiff
path: root/loader/src/main
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2022-12-15 17:00:27 +0900
committersyeyoung <cyoung06@naver.com>2022-12-15 17:00:27 +0900
commite4d75b0f5d953c7a62cf194308c4b304551705bd (patch)
tree9f7bf369b020eff6d2035eb2b3dddb885382989f /loader/src/main
parentecc627800828857a1e617d1135ca37b08b4dc24c (diff)
downloadSkyblock-Dungeons-Guide-e4d75b0f5d953c7a62cf194308c4b304551705bd.tar.gz
Skyblock-Dungeons-Guide-e4d75b0f5d953c7a62cf194308c4b304551705bd.tar.bz2
Skyblock-Dungeons-Guide-e4d75b0f5d953c7a62cf194308c4b304551705bd.zip
- Splash Progress
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'loader/src/main')
-rwxr-xr-xloader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java29
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiChooseVersion.java10
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java7
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java5
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java9
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/util/ProgressStateHolder.java24
6 files changed, 74 insertions, 10 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
index 8041f82c..ed11d7c1 100755
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
@@ -31,6 +31,7 @@ import kr.syeyoung.dungeonsguide.launcher.gui.screen.GuiUnloadingError;
import kr.syeyoung.dungeonsguide.launcher.gui.tooltip.Notification;
import kr.syeyoung.dungeonsguide.launcher.gui.tooltip.NotificationManager;
import kr.syeyoung.dungeonsguide.launcher.loader.*;
+import kr.syeyoung.dungeonsguide.launcher.util.ProgressStateHolder;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IReloadableResourceManager;
@@ -45,6 +46,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.lwjgl.LWJGLException;
import java.io.*;
import java.security.Security;
@@ -109,9 +111,25 @@ public class Main
}
}
- public void tryReloading(IDGLoader loader) {
+ public void tryReloadingWithSplash(IDGLoader loader) {
SplashProgress.start();
try {
+ SplashProgress.drawVanillaScreen(Minecraft.getMinecraft().renderEngine);
+ } catch (LWJGLException e) {
+ e.printStackTrace();
+ }
+ try {
+ tryReloading(loader);
+ } finally {
+ try {
+ SplashProgress.finish();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+ public void tryReloading(IDGLoader loader) {
+ try {
reload(loader);
} catch (DungeonsGuideLoadingException e) {
e.printStackTrace();
@@ -124,8 +142,6 @@ public class Main
GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e));
} catch (DungeonsGuideUnloadingException e) {
GuiDisplayer.INSTANCE.displayGui(new GuiUnloadingError(e));
- } finally {
- SplashProgress.finish();
}
}
@@ -188,13 +204,16 @@ public class Main
IDGLoader loader = reqLoader;
reqLoader = null;
- tryReloading(loader);
+ tryReloadingWithSplash(loader);
}
}
public void reload(IDGLoader newLoader) throws DungeonsGuideLoadingException, DungeonsGuideUnloadingException {
try {
+ ProgressStateHolder.pushProgress("Loading Dungeons Guide...", 2);
+ ProgressStateHolder.step("Unloading Currently Loaded Version...");
unload();
+ ProgressStateHolder.step("Loading New Version...");
load(newLoader);
} catch (DungeonsGuideLoadingException | DungeonsGuideUnloadingException e) {
dgInterface = null;
@@ -202,6 +221,8 @@ public class Main
e.printStackTrace();
throw e;
+ } finally {
+ ProgressStateHolder.pop();
}
}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiChooseVersion.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiChooseVersion.java
index e4e315a0..e1e91003 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiChooseVersion.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiChooseVersion.java
@@ -106,7 +106,7 @@ public class GuiChooseVersion extends SpecialGuiScreen {
button.enabled = this.getClass().getResourceAsStream("/mod.jar") != null;
this.buttonList.add(button = new GuiButton(4, tenth,sr.getScaledHeight()-100 ,"Refresh Options"));
- this.buttonList.add(new GuiCheckBox(5, sr.getScaledWidth() - tenth,sr.getScaledHeight()-100 ,"Save This Loader", false));
+ this.buttonList.add(new GuiCheckBox(5, sr.getScaledWidth() - tenth-200,sr.getScaledHeight()-100 ,"Save This Loader", false));
int k = 0;
for (UpdateBranch updateBranch : branchList) {
@@ -137,10 +137,10 @@ public class GuiChooseVersion extends SpecialGuiScreen {
.build());
} else if (button.id == 0) {
dismiss();
- Main.getMain().tryReloading(new LocalLoader());
+ Main.getMain().tryReloadingWithSplash(new LocalLoader());
} else if (button.id == 1) {
dismiss();
- Main.getMain().tryReloading(new JarLoader());
+ Main.getMain().tryReloadingWithSplash(new JarLoader());
} else if (button.id == 3) {
dismiss();
} else if (button.id == 4) {
@@ -155,12 +155,12 @@ public class GuiChooseVersion extends SpecialGuiScreen {
int idx = button.id - 10;
current = branchList.get(idx);
fetchUpdates(branchList.get(idx));
- } else {
+ } else if (button.id < branchList.size() + 10 + updates.size()){
int idx = button.id - branchList.size() - 10;
Update update = updates.get(idx);
dismiss();
- Main.getMain().tryReloading(new RemoteLoader(current.getName(),current.getId(),update.getId()));
+ Main.getMain().tryReloadingWithSplash(new RemoteLoader(current.getName(),current.getId(),update.getId()));
}
}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java
index e6d46b7d..6c29b1f6 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java
@@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.launcher.loader;
import kr.syeyoung.dungeonsguide.launcher.DGInterface;
import kr.syeyoung.dungeonsguide.launcher.exceptions.DungeonsGuideLoadingException;
import kr.syeyoung.dungeonsguide.launcher.exceptions.DungeonsGuideUnloadingException;
+import kr.syeyoung.dungeonsguide.launcher.util.ProgressStateHolder;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.apache.commons.io.IOUtils;
@@ -70,7 +71,8 @@ public class JarLoader implements IDGLoader {
@Override
public DGInterface loadDungeonsGuide() throws DungeonsGuideLoadingException {
if (dgInterface != null) throw new IllegalStateException("Already loaded");
-
+ ProgressStateHolder.pushProgress("Loading - Jar Loader", 1);
+ ProgressStateHolder.step("Loading");
try {
classLoader = new JarClassLoader((LaunchClassLoader) this.getClass().getClassLoader(), new ZipInputStream(JarLoader.class.getResourceAsStream("/mod.jar")));
phantomReference = new PhantomReference<>(classLoader, refQueue);
@@ -79,6 +81,8 @@ public class JarLoader implements IDGLoader {
return dgInterface;
} catch (Throwable e) {
throw new DungeonsGuideLoadingException(e);
+ } finally {
+ ProgressStateHolder.pop();
}
}
@@ -96,6 +100,7 @@ public class JarLoader implements IDGLoader {
dgInterface.unload();
} catch (Throwable e) {
dgInterface = null;
+ ProgressStateHolder.pop();
throw new DungeonsGuideUnloadingException(e);
}
if (classLoader != null)
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java
index f1cabf1f..1a88f475 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java
@@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.launcher.loader;
import kr.syeyoung.dungeonsguide.launcher.DGInterface;
import kr.syeyoung.dungeonsguide.launcher.exceptions.DungeonsGuideLoadingException;
import kr.syeyoung.dungeonsguide.launcher.exceptions.DungeonsGuideUnloadingException;
+import kr.syeyoung.dungeonsguide.launcher.util.ProgressStateHolder;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.apache.commons.io.IOUtils;
@@ -62,6 +63,8 @@ public class LocalLoader implements IDGLoader {
@Override
public DGInterface loadDungeonsGuide() throws DungeonsGuideLoadingException {
if (dgInterface != null) throw new IllegalStateException("Already loaded");
+ ProgressStateHolder.pushProgress("Loading - Local Loader", 1);
+ ProgressStateHolder.step("Loading");
try {
classLoader = new LocalClassLoader((LaunchClassLoader) this.getClass().getClassLoader());
@@ -71,6 +74,8 @@ public class LocalLoader implements IDGLoader {
return dgInterface;
} catch (Throwable e) {
throw new DungeonsGuideLoadingException(e);
+ } finally {
+ ProgressStateHolder.pop();
}
}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java
index 734e1463..26e1a6d4 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java
@@ -25,6 +25,7 @@ import kr.syeyoung.dungeonsguide.launcher.exceptions.DungeonsGuideLoadingExcepti
import kr.syeyoung.dungeonsguide.launcher.exceptions.InvalidSignatureException;
import kr.syeyoung.dungeonsguide.launcher.exceptions.NoVersionFoundException;
import kr.syeyoung.dungeonsguide.launcher.exceptions.DungeonsGuideUnloadingException;
+import kr.syeyoung.dungeonsguide.launcher.util.ProgressStateHolder;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.apache.commons.io.IOUtils;
@@ -82,18 +83,23 @@ public class RemoteLoader implements IDGLoader {
@Override
public DGInterface loadDungeonsGuide() throws DungeonsGuideLoadingException {
if (dgInterface != null) throw new IllegalStateException("Already loaded");
+ ProgressStateHolder.pushProgress("Loading - Remote Loader", 4);
try {
Update target;
try {
target = UpdateRetrieverUtil.getUpdate(branchId, updateId);
+ ProgressStateHolder.step("Getting Update Meta");
friendlyVersionName = target.getName();
} catch (Exception e) {
throw new NoVersionFoundException(friendlyBranchName, friendlyVersionName, branchId+"@"+updateId, e);
}
InputStream in;
+
+ ProgressStateHolder.step("Downloading Mod");
byte[] mod = IOUtils.toByteArray(in = UpdateRetrieverUtil.downloadFile(target, "mod.jar"));
in.close();
+ ProgressStateHolder.step("Downloading Signature");
byte[] signature = IOUtils.toByteArray(in = UpdateRetrieverUtil.downloadFile(target, "mod.jar.asc"));
in.close();
@@ -101,11 +107,14 @@ public class RemoteLoader implements IDGLoader {
classLoader = new JarClassLoader((LaunchClassLoader) this.getClass().getClassLoader(), new ZipInputStream(new ByteArrayInputStream(mod)));
phantomReference = new PhantomReference<>(classLoader, refQueue);
+ ProgressStateHolder.step("Instantiating");
dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance();
return dgInterface;
} catch (Throwable e) { // the reason why I am catching throwable here: in case NoClassDefFoundError.
throw new DungeonsGuideLoadingException(e);
+ } finally {
+ ProgressStateHolder.pop();
}
}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/util/ProgressStateHolder.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/util/ProgressStateHolder.java
new file mode 100644
index 00000000..b5e35d9c
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/util/ProgressStateHolder.java
@@ -0,0 +1,24 @@
+package kr.syeyoung.dungeonsguide.launcher.util;
+
+import net.minecraftforge.fml.common.ProgressManager;
+
+import java.util.Stack;
+
+public class ProgressStateHolder {
+ private static Stack<ProgressManager.ProgressBar> progressBarStack = new Stack<>();
+
+ public static void pushProgress(String name, int steps) {
+ progressBarStack.push(ProgressManager.push(name, steps));
+ }
+
+ public static void step(String title) {
+ progressBarStack.peek().step(title);
+ }
+
+ public static void pop() {
+ ProgressManager.ProgressBar progressBar = progressBarStack.peek();
+ while (progressBar.getStep() < progressBar.getSteps())
+ progressBar.step("");
+ ProgressManager.pop(progressBarStack.pop());
+ }
+}