From 5f8c2788c2a7a62bf8b522ecfa39c6801333b577 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Tue, 3 Aug 2021 18:16:55 +0900 Subject: - Fix copyright on Penguin - Fix Parameter edit not resizing correctly - Debug can now be enabled via config - Config resizes according to user's minecraft size --- .../config/guiconfig/nyu/GuiConfigV2.java | 11 +++- .../config/guiconfig/nyu/MCategory.java | 9 ++- .../config/guiconfig/nyu/MParameterEdit.java | 2 +- .../dungeonsguide/features/FeatureRegistry.java | 4 +- .../features/impl/advanced/FeatureDebug.java | 66 +++++++++++++++++++++ src/main/resources/assets/dg/penguin.png | Bin 290076 -> 51869 bytes 6 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java index 8b3e3eb4..5ab53b67 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java @@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig.nyu; import kr.syeyoung.dungeonsguide.gui.MGui; import lombok.Getter; import net.minecraft.client.Minecraft; +import net.minecraft.util.MathHelper; import java.awt.*; @@ -40,8 +41,14 @@ public class GuiConfigV2 extends MGui { super.initGui(); int dw = Minecraft.getMinecraft().displayWidth; int dh = Minecraft.getMinecraft().displayHeight; - rootConfigPanel.setBounds(new Rectangle((dw-1500)/2, (dh-800)/2, 1500,800)); - rootConfigPanel.setScale(2.0); + int width = MathHelper.clamp_int(dw - 200, 1250, 1500), height = MathHelper.clamp_int(dh - 200, 600, 800); + double scale = 2.0; + if (dw <= width || dh <= height) { + width = width/2; height = height/2; + scale = 1.0; + } + rootConfigPanel.setBounds(new Rectangle((dw-width)/2, (dh-height)/2, width,height)); + rootConfigPanel.setScale(scale); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java index cf57619f..7fbffbf8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java @@ -48,7 +48,8 @@ public class MCategory extends MPanel { @Override public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f)); - Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); + if (getBounds().height >= 28) + Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); Gui.drawRect(0,17,getBounds().width, 18,RenderUtils.blendAlpha(0x141414, 0.12f)); @@ -70,7 +71,11 @@ public class MCategory extends MPanel { @Override public Dimension getPreferredSize() { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int descriptionHeight = fr.listFormattedStringToWidth(FeatureRegistry.getCategoryDescription().getOrDefault(nestedCategory.categoryFull(), ""), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT; + + int descriptionHeight = + FeatureRegistry.getCategoryDescription().containsKey(nestedCategory.categoryFull()) ? + fr.listFormattedStringToWidth(FeatureRegistry.getCategoryDescription().get(nestedCategory.categoryFull()), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT + : -11; return new Dimension(100, descriptionHeight + 28); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MParameterEdit.java index 341705ee..4bf958db 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MParameterEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MParameterEdit.java @@ -143,7 +143,7 @@ public class MParameterEdit extends MPanel { @Override public Dimension getPreferredSize() { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int descriptionHeight = fr.listFormattedStringToWidth(FeatureRegistry.getCategoryDescription().getOrDefault(featureParameter.getDescription(), ""), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT; + int descriptionHeight = fr.listFormattedStringToWidth(featureParameter.getDescription(), 2*bounds.width /3-10).size() * fr.FONT_HEIGHT; return new Dimension(100, Math.max(Math.max(30, descriptionHeight + 23), valueEditHolder.getPreferredSize().height)); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index d70b9066..c5bff650 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.features; import kr.syeyoung.dungeonsguide.config.types.AColor; +import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureDebug; import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureDebuggableMap; import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureRoomCoordDisplay; import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureRoomDebugInfo; @@ -59,6 +60,7 @@ public class FeatureRegistry { } public static T register(T abstractFeature) { + if (featureByKey.containsKey(abstractFeature.getKey())) throw new IllegalArgumentException("DUPLICATE FEATURE DEFINITION"); featureList.add(abstractFeature); featureByKey.put(abstractFeature.getKey(), abstractFeature); List features = featuresByCategory.get(abstractFeature.getCategory()); @@ -69,7 +71,7 @@ public class FeatureRegistry { return abstractFeature; } - public static final SimpleFeature DEBUG = register(new SimpleFeature("hidden", "Debug", "Toggles debug mode", "debug", false)); + public static final SimpleFeature DEBUG = register(new FeatureDebug()); public static final SimpleFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("Advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false)); public static final FeatureRoomDebugInfo ADVANCED_DEBUG_ROOM = register(new FeatureRoomDebugInfo()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java new file mode 100644 index 00000000..e4b18e3e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java @@ -0,0 +1,66 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * 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.features.impl.advanced; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.config.guiconfig.nyu.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.nyu.MFeatureEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.nyu.MParameterEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.nyu.RootConfigPanel; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; + +public class FeatureDebug extends SimpleFeature { + public FeatureDebug() { + super("Advanced", "Debug", "Toggles debug mode", "debug", false); + parameters.put("Key", new FeatureParameter("Key", "Secret Key given by syeyoung", "Put the debug enable key here to enable debug mode", "","string")); + } + @Override + public boolean isEnabled() { + return "just hide it".equals(this.getParameter("Key").getValue()); + } + @Override + public boolean isDisyllable() { + return false; + } + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @Override + public MPanel get() { + MFeatureEdit featureEdit = new MFeatureEdit(FeatureDebug.this, rootConfigPanel); + for (FeatureParameter parameter: getParameters()) { + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureDebug.this, parameter, rootConfigPanel)); + } + featureEdit.addParameterEdit("IsEnabled", new MParameterEdit(FeatureDebug.this, new FeatureParameter("Key Status", "Key Status", "Key Enabled? Or not?", "", "idk"), rootConfigPanel, new MLabel() { + @Override + public String getText() { + return isEnabled() ? "Enabled!" : "Incorrect Key"; + } + })); + return featureEdit; + } + }); + return "base." + getKey() ; + } +} diff --git a/src/main/resources/assets/dg/penguin.png b/src/main/resources/assets/dg/penguin.png index ab93270f..68aed924 100644 Binary files a/src/main/resources/assets/dg/penguin.png and b/src/main/resources/assets/dg/penguin.png differ -- cgit