diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-07 15:25:44 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-07 15:25:44 +0900 |
commit | 399f681abc0bc738e01d659f2a6ae73e5fc64f71 (patch) | |
tree | 095f5a63c2a1fcfe47a3305f875c322182f884d4 | |
parent | d566771b9fdba45c56b272b28e5fc0dbf2508958 (diff) | |
download | Skyblock-Dungeons-Guide-399f681abc0bc738e01d659f2a6ae73e5fc64f71.tar.gz Skyblock-Dungeons-Guide-399f681abc0bc738e01d659f2a6ae73e5fc64f71.tar.bz2 Skyblock-Dungeons-Guide-399f681abc0bc738e01d659f2a6ae73e5fc64f71.zip |
- loading and unloading
Signed-off-by: syeyoung <cyoung06@naver.com>
4 files changed, 47 insertions, 11 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfo.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfo.java index 780a3548..63ccad23 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfo.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfo.java @@ -40,6 +40,12 @@ public abstract class WidgetInfo extends AnnotatedImportOnlyWidget { @Bind(variableName = "version") public final BindableAttribute<String> version = new BindableAttribute<>(String.class, ""); + @Bind(variableName = "loadVisibility") + public final BindableAttribute<String> loadVisibility = new BindableAttribute<>(String.class, "loadable"); + + @Bind(variableName = "reason") + public final BindableAttribute<String> reason = new BindableAttribute<>(String.class, ""); + public WidgetInfo() { super(new ResourceLocation("dungeons_guide_loader:gui/versions/versionInfo.gui")); makeItDefault.addOnUpdate((old, neu) ->{ @@ -53,6 +59,11 @@ public abstract class WidgetInfo extends AnnotatedImportOnlyWidget { public void setVersion(String version) {this.version.setValue(version);} public void setDefault(boolean bool) {this.makeItDefault.setValue(bool);} + public void setNotLoadable(String reason) { + this.reason.setValue(reason); + this.loadVisibility.setValue("notloadable"); + } + public abstract IDGLoader getLoader(); public void setConfiguration(Configuration configuration) {} diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfoRemote.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfoRemote.java index dc4e2331..64b92d09 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfoRemote.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfoRemote.java @@ -18,8 +18,10 @@ package kr.syeyoung.dungeonsguide.launcher.gui.screen.version; +import kr.syeyoung.dungeonsguide.launcher.LoaderMeta; import kr.syeyoung.dungeonsguide.launcher.branch.Update; import kr.syeyoung.dungeonsguide.launcher.branch.UpdateBranch; +import kr.syeyoung.dungeonsguide.launcher.exceptions.DungeonsGuideLoadingException; import kr.syeyoung.dungeonsguide.launcher.loader.IDGLoader; import kr.syeyoung.dungeonsguide.launcher.loader.RemoteLoader; import net.minecraftforge.common.config.Configuration; @@ -37,6 +39,12 @@ public class WidgetInfoRemote extends WidgetInfo { this.isLatest = isLatest; setVersion((isLatest ? "Latest :: " : "") + branch.getName()+"/"+update.getName()+ " ("+branch.getId()+"/"+update.getId()+")"); setDefault(isLatest); + + + int reqVersion = update.getMetadata().has("loaderVersion") ? update.getMetadata().getInt("loaderVersion") : 0; + if (reqVersion > LoaderMeta.LOADER_VERSION) { + setNotLoadable("This version of Dungeons Guide requires loader version: " + reqVersion +" But current loader version: "+ LoaderMeta.LOADER_VERSION); + } } @Override diff --git a/loader/src/main/resources/assets/dungeons_guide_loader/gui/versions/versionInfo.gui b/loader/src/main/resources/assets/dungeons_guide_loader/gui/versions/versionInfo.gui index cccbefde..0707899e 100644 --- a/loader/src/main/resources/assets/dungeons_guide_loader/gui/versions/versionInfo.gui +++ b/loader/src/main/resources/assets/dungeons_guide_loader/gui/versions/versionInfo.gui @@ -22,17 +22,26 @@ <UnconstrainedBox> <bgcolor backgroundColor="#CC222222"> <padding right="3" bottom="3" top="3" left="3"> - <row mainAlign="END" crossAlign="CENTER"> - <Text text="Make this version default" color="#FFFFFFFF"/> - <size width="5" height="0"/> - <size width="40" height="15"> - <SimpleToggleButton bind:enabled="default"/> - </size> - <size width="5" height="0"/> - <size width="40" height="15"> - <RoundButton text="Load" on:click="load"/> - </size> - </row> + <SelectiveContainer bind:visible="loadVisibility"> + <slot slot="loadable"> + <row mainAlign="END" crossAlign="CENTER"> + <Text text="Make this version default" color="#FFFFFFFF"/> + <size width="5" height="0"/> + <size width="40" height="15"> + <SimpleToggleButton bind:enabled="default"/> + </size> + <size width="5" height="0"/> + <size width="40" height="15"> + <RoundButton text="Load" on:click="load"/> + </size> + </row> + </slot> + <slot slot="notloadable"> + <ConstrainedBox maxWidth="200"> + <Text bind:text="reason" color="#FFFFAAAA"/> + </ConstrainedBox> + </slot> + </SelectiveContainer> </padding> </bgcolor> </UnconstrainedBox> diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java index f3622b22..303caea8 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java @@ -381,6 +381,14 @@ public class DungeonsGuide implements DGInterface { ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class,(ThreadDownloadImageData) value, null, "imageBuffer", "field_110563_c", "k"); } } + Set<ResourceLocation> toRemove = new HashSet<>(); + for (Map.Entry<ResourceLocation, ITextureObject> resourceLocationITextureObjectEntry : mapTextureObjects.entrySet()) { + if (resourceLocationITextureObjectEntry.getKey().getResourceDomain().equalsIgnoreCase("dungeonsguide")) + toRemove.add(resourceLocationITextureObjectEntry.getKey()); + } + for (ResourceLocation resourceLocation : toRemove) { + ITextureObject textureObject = mapTextureObjects.remove(resourceLocation); + } |