aboutsummaryrefslogtreecommitdiff
path: root/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2023-02-07 14:21:12 +0900
committersyeyoung <cyoung06@naver.com>2023-02-07 14:21:12 +0900
commit8e81545ee8bf3d360a4437427e86bab6c3fca0f4 (patch)
tree1e744c9b7c2554974bdd18c31f22151227cb8ee3 /loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui
parenta22beb3bcd6b262a5c893330006c3fa3286ac785 (diff)
downloadSkyblock-Dungeons-Guide-8e81545ee8bf3d360a4437427e86bab6c3fca0f4.tar.gz
Skyblock-Dungeons-Guide-8e81545ee8bf3d360a4437427e86bab6c3fca0f4.tar.bz2
Skyblock-Dungeons-Guide-8e81545ee8bf3d360a4437427e86bab6c3fca0f4.zip
- Default Loader now settable!!
- Better Error Messages Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui')
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java2
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/BranchButton.java44
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/TriConsumer.java24
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranch.java126
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranchVersion.java122
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseVersion.java76
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfo.java73
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfoRemote.java51
8 files changed, 517 insertions, 1 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java
index fc5e569e..1ac4556b 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java
@@ -45,7 +45,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class WidgetPrivacyPolicy extends AnnotatedImportOnlyWidget {
- private static final ExecutorService executor = Executors.newSingleThreadExecutor();
+ public static final ExecutorService executor = Executors.newSingleThreadExecutor();
@Bind(variableName = "policy")
public final BindableAttribute<Widget> policy = new BindableAttribute<>(Widget.class);
@Bind(variableName = "policyVisibility")
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/BranchButton.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/BranchButton.java
new file mode 100644
index 00000000..c14d9b94
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/BranchButton.java
@@ -0,0 +1,44 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen.version;
+
+import kr.syeyoung.dungeonsguide.launcher.guiv2.BindableAttribute;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.AnnotatedImportOnlyWidget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.Bind;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.On;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.util.ResourceLocation;
+
+public class BranchButton extends AnnotatedImportOnlyWidget {
+ @Bind(variableName = "branch")
+ public final BindableAttribute<String> branch = new BindableAttribute<>(String.class);
+ private final Runnable onClick;
+ public BranchButton(String branch, Runnable onClick) {
+ super(new ResourceLocation("dungeons_guide_loader:gui/versions/branchButton.gui"));
+ this.branch.setValue(branch);
+ this.onClick = onClick;
+ }
+
+ @On(functionName = "click")
+ public void click() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ this.onClick.run();
+ }
+}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/TriConsumer.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/TriConsumer.java
new file mode 100644
index 00000000..14050466
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/TriConsumer.java
@@ -0,0 +1,24 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen.version;
+
+@FunctionalInterface
+public interface TriConsumer<A,B,C> {
+ void accept(A a, B b, C c);
+}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranch.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranch.java
new file mode 100644
index 00000000..a78bffc4
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranch.java
@@ -0,0 +1,126 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen.version;
+
+import kr.syeyoung.dungeonsguide.launcher.branch.UpdateBranch;
+import kr.syeyoung.dungeonsguide.launcher.branch.UpdateRetrieverUtil;
+import kr.syeyoung.dungeonsguide.launcher.gui.screen.WidgetPrivacyPolicy;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.BindableAttribute;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.Widget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.elements.Column;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.elements.Text;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.AnnotatedImportOnlyWidget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.Bind;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.On;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.data.WidgetList;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.util.ResourceLocation;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+public class WidgetChooseBranch extends AnnotatedImportOnlyWidget {
+ @Bind(variableName = "versionListVisibility")
+ public final BindableAttribute<String> visibility = new BindableAttribute<>(String.class, "loading");
+ @Bind(variableName = "versionList")
+ public final BindableAttribute<Column> versionList = new BindableAttribute<>(Column.class);
+
+ @Bind(variableName = "widgetList")
+ public final BindableAttribute<List<Widget>> widgetList = new BindableAttribute(WidgetList.class);
+
+ public Consumer<UpdateBranch> onBranchChoose;
+ public Runnable onLocalChoose;
+ public Runnable onJarChoose;
+
+ public WidgetChooseBranch(Consumer<UpdateBranch> onBranch, Runnable onLocal, Runnable onJar) {
+ super(new ResourceLocation("dungeons_guide_loader:gui/versions/branchList.gui"));
+ this.onBranchChoose = onBranch;
+ this.onLocalChoose = onLocal;
+ this.onJarChoose = onJar;
+ widgetList.setValue(new ArrayList<>());
+ reload0();
+ }
+
+ @On(functionName = "reload")
+ public void reload() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ reload0();
+ }
+
+ private volatile boolean isLoading = false;
+ private void reload0() {
+ if (isLoading) return;
+ isLoading = true;
+ visibility.setValue("loading");
+ WidgetPrivacyPolicy.executor.submit(() -> {
+ try {
+ List<Widget> widgets = new ArrayList<>();
+ if (this.getClass().getResource("/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.class") != null)
+ widgets.add(new BranchButton("Local", () -> {
+ onLocalChoose.run();
+ }));
+ if (this.getClass().getResource("/mod.jar") != null)
+ widgets.add(new BranchButton("Jar", () -> {
+ onJarChoose.run();
+ }));
+
+ try {
+ List<UpdateBranch> branches = UpdateRetrieverUtil.getUpdateBranches().stream()
+ .filter(updateBranch ->
+ Optional.ofNullable(updateBranch.getMetadata())
+ .filter(a -> a.has("additionalMeta"))
+ .map(a -> a.getJSONObject("additionalMeta"))
+ .filter(a -> a.has("type"))
+ .map(a -> a.getString("type")).orElse("").equals("mod"))
+ .collect(Collectors.toList());
+ for (UpdateBranch branch : branches) {
+ widgets.add(new BranchButton("Remote: "+branch.getName(), () -> {
+ onBranchChoose.accept(branch);
+ }));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ widgets.add(new Text("Remote Error", 0xFFFFFFFF, Text.TextAlign.CENTER, Text.WordBreak.WORD, 1.0, 8.0));
+ }
+ if (widgets.isEmpty()) {
+ widgets.add(new Text("Seems Empty", 0xFFFFFFFF, Text.TextAlign.CENTER, Text.WordBreak.WORD, 1.0, 8.0));
+ }
+
+ widgetList.setValue(widgets);
+ if (versionList.getValue().getDomElement().getWidget() != null) {
+ versionList.getValue().removeAll();
+ for (Widget widget : widgets) {
+ versionList.getValue().addWidget(widget);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ visibility.setValue("loaded");
+ isLoading = false;
+ }
+ });
+ }
+}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranchVersion.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranchVersion.java
new file mode 100644
index 00000000..3a393adf
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseBranchVersion.java
@@ -0,0 +1,122 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen.version;
+
+import kr.syeyoung.dungeonsguide.launcher.branch.Update;
+import kr.syeyoung.dungeonsguide.launcher.branch.UpdateBranch;
+import kr.syeyoung.dungeonsguide.launcher.branch.UpdateRetrieverUtil;
+import kr.syeyoung.dungeonsguide.launcher.gui.screen.WidgetPrivacyPolicy;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.BindableAttribute;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.Widget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.elements.Column;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.elements.Text;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.AnnotatedImportOnlyWidget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.Bind;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.On;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.data.WidgetList;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.util.ResourceLocation;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+public class WidgetChooseBranchVersion extends AnnotatedImportOnlyWidget {
+ @Bind(variableName = "versionListVisibility")
+ public final BindableAttribute<String> visibility = new BindableAttribute<>(String.class, "loading");
+ @Bind(variableName = "versionList")
+ public final BindableAttribute<Column> versionList = new BindableAttribute<>(Column.class);
+
+ @Bind(variableName = "widgetList")
+ public final BindableAttribute<List<Widget>> widgetList = new BindableAttribute(WidgetList.class);
+ @Bind(variableName = "branch")
+ public final BindableAttribute<String> branchName = new BindableAttribute<>(String.class);
+
+ public TriConsumer<UpdateBranch, Update, Boolean> onVersionChoose;
+ private UpdateBranch branch;
+
+ @Bind(variableName = "back")
+ public final BindableAttribute<Runnable> back = new BindableAttribute<>(Runnable.class);
+
+ public WidgetChooseBranchVersion(TriConsumer<UpdateBranch, Update, Boolean> onVersion, UpdateBranch branch, Runnable back) {
+ super(new ResourceLocation("dungeons_guide_loader:gui/versions/branchVersionList.gui"));
+ this.onVersionChoose = onVersion;
+ this.branch = branch;
+ this.branchName.setValue(branch.getName());
+ this.back.setValue(back);
+
+ widgetList.setValue(new ArrayList<>());
+ reload0();
+ }
+
+ @On(functionName = "reload")
+ public void reload() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ reload0();
+ }
+
+ private volatile boolean isLoading = false;
+ private void reload0() {
+ if (isLoading) return;
+ isLoading = true;
+ visibility.setValue("loading");
+ WidgetPrivacyPolicy.executor.submit(() -> {
+ try {
+ List<Widget> widgets = new ArrayList<>();
+ try {
+ List<Update> branches = UpdateRetrieverUtil.getLatestUpdates(branch.getId(), 0);
+ if (!branches.isEmpty()) {
+ widgets.add(new BranchButton("Latest", () -> {
+ onVersionChoose.accept(branch, branches.get(0), true);
+ }));
+ }
+
+ for (Update update : branches) {
+ widgets.add(new BranchButton(update.getName(), () -> {
+ onVersionChoose.accept(branch, update, false);
+ }));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ widgets.add(new Text("Remote Error", 0xFFFFFFFF, Text.TextAlign.CENTER, Text.WordBreak.WORD, 1.0, 8.0));
+ }
+ if (widgets.isEmpty()) {
+ widgets.add(new Text("Seems Empty", 0xFFFFFFFF, Text.TextAlign.CENTER, Text.WordBreak.WORD, 1.0, 8.0));
+ }
+
+ widgetList.setValue(widgets);
+ if (versionList.getValue().getDomElement().getWidget() != null) {
+ versionList.getValue().removeAll();
+ for (Widget widget : widgets) {
+ versionList.getValue().addWidget(widget);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ visibility.setValue("loaded");
+ isLoading = false;
+ }
+ });
+ }
+}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseVersion.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseVersion.java
new file mode 100644
index 00000000..b62cd91f
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetChooseVersion.java
@@ -0,0 +1,76 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen.version;
+
+import kr.syeyoung.dungeonsguide.launcher.branch.Update;
+import kr.syeyoung.dungeonsguide.launcher.branch.UpdateBranch;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.BindableAttribute;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.Widget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.AnnotatedImportOnlyWidget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.Bind;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.Export;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.On;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.util.ResourceLocation;
+
+public class WidgetChooseVersion extends AnnotatedImportOnlyWidget {
+
+ @Bind(variableName = "branchWidget")
+ public final BindableAttribute<Widget> branchWidget = new BindableAttribute<>(Widget.class, new WidgetChooseBranch(this::branch, this::local, this::jar));
+ @Bind(variableName = "versionWidget")
+ public final BindableAttribute<Widget> versionWidget = new BindableAttribute<>(Widget.class);
+
+ @Bind(variableName = "listVisibility")
+ public final BindableAttribute<String> listVisibility = new BindableAttribute<>(String.class, "branch");
+ @Bind(variableName = "infoVisibility")
+ public final BindableAttribute<String> infoVisibility = new BindableAttribute<>(String.class, "hide");
+
+ @Bind(variableName = "infoWidget")
+ public final BindableAttribute<Widget> infoWidget = new BindableAttribute<>(Widget.class);
+ private void back() {
+ listVisibility.setValue("branch");
+ }
+
+ private void jar() {
+ }
+
+ private void local() {
+ }
+
+ private void remote(UpdateBranch branch, Update update, boolean isLatest) {
+ infoWidget.setValue(new WidgetInfoRemote(branch, update, isLatest));
+ infoVisibility.setValue("show");
+ }
+
+ private void branch(UpdateBranch updateBranch) {
+ versionWidget.setValue(new WidgetChooseBranchVersion(this::remote, updateBranch, this::back));
+ listVisibility.setValue("version");
+ }
+
+ public WidgetChooseVersion() {
+ super(new ResourceLocation("dungeons_guide_loader:gui/versions/versionChooser.gui"));
+ }
+
+ @On(functionName = "exit")
+ public void exit() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+}
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
new file mode 100644
index 00000000..7196c5e2
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfo.java
@@ -0,0 +1,73 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen.version;
+
+import kr.syeyoung.dungeonsguide.launcher.Main;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.BindableAttribute;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.AnnotatedImportOnlyWidget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.Bind;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.On;
+import kr.syeyoung.dungeonsguide.launcher.loader.IDGLoader;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.common.config.Configuration;
+
+import java.io.File;
+
+public abstract class WidgetInfo extends AnnotatedImportOnlyWidget {
+ @Bind(variableName = "default")
+ public final BindableAttribute<Boolean> makeItDefault = new BindableAttribute<>(Boolean.class, true);
+ @Bind(variableName = "updatelog")
+ public final BindableAttribute<String> updateLog = new BindableAttribute<>(String.class, "");
+
+ @Bind(variableName = "version")
+ public final BindableAttribute<String> version = new BindableAttribute<>(String.class, "");
+
+ public WidgetInfo() {
+ super(new ResourceLocation("dungeons_guide_loader:gui/versions/versionInfo.gui"));
+ makeItDefault.addOnUpdate((old, neu) ->{
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ });
+ }
+
+ public void setUpdateLog(String log) {
+ updateLog.setValue(log);
+ }
+ public void setVersion(String version) {this.version.setValue(version);}
+
+ public abstract IDGLoader getLoader();
+
+ public void setConfiguration(Configuration configuration) {}
+
+ @On(functionName = "load")
+ public void load() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ IDGLoader idgLoader = getLoader();
+
+ if (makeItDefault.getValue()) {
+ File f = new File(Main.getConfigDir(), "loader.cfg");
+ Configuration configuration = new Configuration(f);
+ configuration.load();
+ setConfiguration(configuration);
+ configuration.save();
+ }
+ // do smth
+ }
+}
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
new file mode 100644
index 00000000..6b450a67
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/version/WidgetInfoRemote.java
@@ -0,0 +1,51 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen.version;
+
+import kr.syeyoung.dungeonsguide.launcher.branch.Update;
+import kr.syeyoung.dungeonsguide.launcher.branch.UpdateBranch;
+import kr.syeyoung.dungeonsguide.launcher.loader.IDGLoader;
+import net.minecraftforge.common.config.Configuration;
+
+public class WidgetInfoRemote extends WidgetInfo {
+ private UpdateBranch updateBranch;
+ private Update update;
+ private boolean isLatest;
+ public WidgetInfoRemote(UpdateBranch branch, Update update, boolean isLatest) {
+ super();
+ this.updateBranch = branch;
+ this.update = update;
+ this.isLatest = isLatest;
+ setUpdateLog(update.getUpdateLog());
+ this.isLatest = isLatest;
+ setVersion(branch.getName()+"/"+update.getName()+ " ("+branch.getId()+"/"+update.getId()+")");
+ }
+
+ @Override
+ public void setConfiguration(Configuration configuration) {
+ configuration.get("loader", "modsource", "").set("remote");
+ configuration.get("loader", "remoteBranch", "").set(updateBranch.getName());
+ configuration.get("loader", "remoteVersion", "").set(isLatest ? "latest" : update.getName());
+ }
+
+ @Override
+ public IDGLoader getLoader() {
+ return null;
+ }
+}