From 9fdf5d426d2a6267dbd218cec49abdeebd00e153 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Fri, 3 Feb 2023 11:57:43 +0900 Subject: - time for FeatureParameter fix Signed-off-by: syeyoung --- .../configv3/DefaultConfigurePageWidget.java | 39 ++++++++++++++++++++++ .../mod/config/guiconfig/configv3/FeatureItem.java | 14 +++++++- .../config/guiconfig/configv3/MainPageWidget.java | 30 +++++++++++++++++ .../guiconfig/location2/HUDWidgetWrapper.java | 5 ++- .../mod/features/AbstractFeature.java | 22 +++++++++--- .../mod/features/AbstractHUDFeature.java | 6 ++-- .../mechanicbrowser/FeatureMechanicBrowse.java | 10 ++---- .../mod/features/text/TextHUDFeature.java | 6 ++-- .../mod/guiv2/xml/DomElementRegistry.java | 1 + 9 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/DefaultConfigurePageWidget.java (limited to 'mod/src/main/java') diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/DefaultConfigurePageWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/DefaultConfigurePageWidget.java new file mode 100644 index 00000000..74369e29 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/DefaultConfigurePageWidget.java @@ -0,0 +1,39 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3; + +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; +import net.minecraft.util.ResourceLocation; + +import java.util.List; + +public class DefaultConfigurePageWidget extends AnnotatedImportOnlyWidget { + + @Bind(variableName = "widgets") + public final BindableAttribute bindableAttribute = new BindableAttribute(WidgetList.class); + + public DefaultConfigurePageWidget(List widgets) { + super(new ResourceLocation("dungeonsguide:gui/config/configure.gui")); + bindableAttribute.setValue(widgets); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java index e91b20d3..5a0c99dc 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java @@ -51,6 +51,13 @@ public class FeatureItem extends AnnotatedImportOnlyWidget { @Bind(variableName = "isEnabled") public final BindableAttribute enabled = new BindableAttribute<>(Boolean.class); + + @Bind(variableName = "iconVisibility") + public final BindableAttribute iconVisibility = new BindableAttribute<>(String.class, "hide"); + @Bind(variableName = "icon") + public final BindableAttribute icon = new BindableAttribute<>(String.class, "dungeonsguide:textures/darklogo.png"); + + private AbstractFeature feature; public FeatureItem(AbstractFeature feature) { @@ -61,7 +68,7 @@ public class FeatureItem extends AnnotatedImportOnlyWidget { this.description.setValue(feature.getDescription()); guiRelocateShow.setValue(feature instanceof AbstractHUDFeature ? "show" : "hide"); - configureShow.setValue("show"); + configureShow.setValue(feature.getConfigureWidget() != null ? "show" : "hide"); enableShow.setValue(feature.isDisyllable() ? "show" : "hide"); enabled.setValue(feature.isEnabled()); @@ -69,6 +76,11 @@ public class FeatureItem extends AnnotatedImportOnlyWidget { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); feature.setEnabled(neu); }); + + if (feature.getIcon() != null) { + icon.setValue(feature.getIcon()); + iconVisibility.setValue("show"); + } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java index 232bb090..8c67ab4c 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java @@ -23,9 +23,14 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; import net.minecraft.util.ResourceLocation; +import java.awt.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.List; import java.util.stream.Collectors; @@ -47,4 +52,29 @@ public class MainPageWidget extends AnnotatedImportOnlyWidget { .collect(Collectors.toList()); } + @On(functionName = "discord") + public void discord() { + try { + Desktop.getDesktop().browse(new URI("https://discord.gg/VuxayCWGE8")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + } + + @On(functionName = "github") + public void github() { + try { + Desktop.getDesktop().browse(new URI("https://github.com/Dungeons-Guide/Skyblock-Dungeons-Guide/")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + } + @On(functionName = "store") + public void store() { + try { + Desktop.getDesktop().browse(new URI("https://store.dungeons.guide/")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location2/HUDWidgetWrapper.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location2/HUDWidgetWrapper.java index 63e6d44d..f47b5e4f 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location2/HUDWidgetWrapper.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location2/HUDWidgetWrapper.java @@ -39,6 +39,7 @@ import org.lwjgl.input.Mouse; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedList; import java.util.List; public class HUDWidgetWrapper extends Widget implements Layouter { @@ -157,8 +158,10 @@ public class HUDWidgetWrapper extends Widget implements Layouter { if (mouseButton == 0) return false; if (!enable) return false; + List widgets = new LinkedList<>(); + abstractHUDFeature.getTooltipForEditor(widgets); PopupMgr.getPopupMgr(getDomElement()).openPopup(new AbsLocationPopup( - absMouseX, absMouseY, new WidgetPopupMenu(abstractHUDFeature.getTooltipForEditor()), true + absMouseX, absMouseY, new WidgetPopupMenu(widgets), true ), null); return true; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java index 4d1e4892..ad24b68f 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java @@ -25,16 +25,15 @@ import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3.DefaultConfigurePageWidget; import kr.syeyoung.dungeonsguide.mod.config.types.TypeConverter; import kr.syeyoung.dungeonsguide.mod.config.types.TypeConverterRegistry; import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; import lombok.Getter; import lombok.Setter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public abstract class AbstractFeature implements IFeature { @Getter @@ -109,6 +108,21 @@ public abstract class AbstractFeature implements IFeature { return "base." + key ; } + public Widget getConfigureWidget() { + List widgets = new LinkedList<>(); + setupConfigureWidget(widgets); + if (widgets.isEmpty()) return null; + return new DefaultConfigurePageWidget(widgets); + } + + public void setupConfigureWidget(List widgets) { + + } + + public String getIcon() { + return null; + } + public void onParameterReset() {} public boolean isDisyllable() { diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java index 06eff88d..2b990d8e 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java @@ -113,9 +113,8 @@ public abstract class AbstractHUDFeature extends AbstractGuiFeature { return object; } - public List getTooltipForEditor() { - ArrayList mPanels = new ArrayList<>(); - mPanels.add(new Text(getName(), 0xFFFFFFFF, Text.TextAlign.CENTER, Text.WordBreak.WORD, 1.0, 8.0)); + public void getTooltipForEditor(List widgets) { + widgets.add(new Text(getName(), 0xFFFFFFFF, Text.TextAlign.CENTER, Text.WordBreak.WORD, 1.0, 8.0)); // mPanels.add(new MButton() { // { // setText("Edit"); @@ -142,6 +141,5 @@ public abstract class AbstractHUDFeature extends AbstractGuiFeature { // AbstractHUDFeature.this.setEnabled(isEnabled()); // }); } // })); - return mPanels; } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java index 7b238aba..32f46f5b 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java @@ -52,10 +52,8 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import java.awt.*; +import java.util.*; import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; public class FeatureMechanicBrowse extends RawRenderingGuiFeature { @@ -157,16 +155,14 @@ public class FeatureMechanicBrowse extends RawRenderingGuiFeature { } } @Override - public List getTooltipForEditor() { - List mPanels = super.getTooltipForEditor(); + public void getTooltipForEditor(List widgets) { + super.getTooltipForEditor(widgets); // mPanels.add(new MPassiveLabelAndElement("Scale", new MFloatSelectionButton(FeatureMechanicBrowse.this.getParameter("scale").getValue()) {{ // setOnUpdate(() ->{ // FeatureMechanicBrowse.this.getParameter("scale").setValue(this.getData()); // }); } // })); - - return mPanels; } @DGEventHandler diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java index 6f1a80df..3c0d21ca 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java @@ -255,8 +255,8 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style } @Override - public List getTooltipForEditor() { - List mPanels = super.getTooltipForEditor(); + public void getTooltipForEditor(List widgets) { + super.getTooltipForEditor(widgets); // StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(this.getParameter("alignment").getValue()); // MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); // mStringSelectionButton.setOnUpdate(() -> { @@ -270,7 +270,7 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style // }); } // })); - return mPanels; +// return mPanels; } @Override diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java index 4fcd3fbe..f0d77ec9 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java @@ -85,6 +85,7 @@ public class DomElementRegistry { register("ColorButton", new DelegatingWidgetConverter(new ResourceLocation("dungeonsguide:gui/elements/simpleButton.gui"))); register("RoundButton", new DelegatingWidgetConverter(new ResourceLocation("dungeonsguide:gui/elements/dgButton.gui"))); + register("IconButton", new DelegatingWidgetConverter(new ResourceLocation("dungeonsguide:gui/elements/iconButton.gui"))); register("SimpleToggleButton", new DelegatingWidgetConverter(new ResourceLocation("dungeonsguide:gui/elements/simpleToggleButton.gui"))); register("SimpleHorizontalScrollBar", new DelegatingWidgetConverter(new ResourceLocation("dungeonsguide:gui/elements/simpleHorizontalScrollBar.gui"))); register("SimpleVerticalScrollBar", new DelegatingWidgetConverter(new ResourceLocation("dungeonsguide:gui/elements/simpleVerticalScrollBar.gui"))); -- cgit