diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-09-07 22:20:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-07 16:20:00 -0400 |
commit | 7c077e278b7266950a968a7e7f2f28b9a140ed96 (patch) | |
tree | 56b351874c48126f70e4ef6cbcf914ea832bdcd9 /src/main/java/cc/polyfrost/oneconfig/internal | |
parent | 17cfe96255f1ec3ab5609aa153d4abed2075c435 (diff) | |
download | OneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.tar.gz OneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.tar.bz2 OneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.zip |
new: option descriptions (#127)
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal')
4 files changed, 91 insertions, 16 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java b/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java index cafedde..5ccf384 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java @@ -51,6 +51,7 @@ public class SVGs { public static final SVG X_CIRCLE_BOLD = new SVG("/assets/oneconfig/icons/XCircleBold.svg"); public static final SVG CARET_LEFT = new SVG("/assets/oneconfig/icons/CaretLeftBold.svg"); public static final SVG CARET_RIGHT = new SVG("/assets/oneconfig/icons/CaretRightBold.svg"); + public static final SVG INFO_ARROW = new SVG("/assets/oneconfig/icons/InfoArrow.svg"); // OLD ICONS public static final SVG BOX = new SVG("/assets/oneconfig/old-icons/Box.svg"); diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java index 66375cc..07c1e2a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java @@ -85,35 +85,35 @@ public class VigilanceConfig extends Config { ArrayList<BasicOption> options = ConfigUtils.getSubCategory(page, getCategory(attributes), getSubcategory(attributes)).options; switch (attributes.getType()) { case SWITCH: - options.add(new ConfigSwitch(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2)); + options.add(new ConfigSwitch(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2)); break; case CHECKBOX: - options.add(new ConfigCheckbox(getFieldOfProperty(option), option.getInstance(), getName(attributes),getCategory(attributes), getSubcategory(attributes), 2)); + options.add(new ConfigCheckbox(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2)); break; case PARAGRAPH: case TEXT: - options.add(new ConfigTextBox(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder(), attributes.getProtected(), attributes.getType() == PropertyType.PARAGRAPH)); + options.add(new ConfigTextBox(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder(), attributes.getProtected(), attributes.getType() == PropertyType.PARAGRAPH)); break; case SELECTOR: - options.add(new ConfigDropdown(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2, attributes.getOptions().toArray(new String[0]))); + options.add(new ConfigDropdown(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2, attributes.getOptions().toArray(new String[0]))); break; case PERCENT_SLIDER: - options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 0, 1, 0)); + options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 0, 1, 0)); break; case DECIMAL_SLIDER: - options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), attributes.getMinF(), attributes.getMaxF(), 0)); + options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), attributes.getMinF(), attributes.getMaxF(), 0)); break; case NUMBER: - options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 1)); + options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 1)); break; case SLIDER: - options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 0)); + options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 0)); break; case COLOR: - options.add(new CompatConfigColorElement(getFieldOfProperty(option), option.getInstance(), getCategory(attributes), getSubcategory(attributes), getName(attributes), 2)); + options.add(new CompatConfigColorElement(getFieldOfProperty(option), option.getInstance(), getCategory(attributes), attributes.getDescription(), getSubcategory(attributes), getName(attributes), 2)); break; case BUTTON: - options.add(new ConfigButton(() -> ((CallablePropertyValue) option.getValue()).invoke(option.getInstance()), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder().isEmpty() ? "Activate" : attributes.getPlaceholder())); + options.add(new ConfigButton(() -> ((CallablePropertyValue) option.getValue()).invoke(option.getInstance()), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder().isEmpty() ? "Activate" : attributes.getPlaceholder())); break; } if (attributes.getType() == PropertyType.SWITCH || attributes.getType() == PropertyType.CHECKBOX) { @@ -194,8 +194,8 @@ public class VigilanceConfig extends Config { private Color prevColor = null; private OneColor cachedColor = null; - public CompatConfigColorElement(Field color, Vigilant parent, String name, String category, String subcategory, int size) { - super(null, parent, name, category, subcategory, size, true); + public CompatConfigColorElement(Field color, Vigilant parent, String name, String description, String category, String subcategory, int size) { + super(null, parent, name, description, category, subcategory, size, true); this.color = color; } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java index 6169896..ef5a25a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java @@ -30,14 +30,15 @@ import cc.polyfrost.oneconfig.gui.GuiPause; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.hud.Hud; import cc.polyfrost.oneconfig.hud.Position; -import cc.polyfrost.oneconfig.internal.hud.utils.GrabOffset; -import cc.polyfrost.oneconfig.internal.hud.utils.SnappingLine; import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; import cc.polyfrost.oneconfig.internal.hud.HudCore; +import cc.polyfrost.oneconfig.internal.hud.utils.GrabOffset; +import cc.polyfrost.oneconfig.internal.hud.utils.SnappingLine; import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; import cc.polyfrost.oneconfig.libs.universal.UResolution; import cc.polyfrost.oneconfig.libs.universal.UScreen; +import cc.polyfrost.oneconfig.renderer.AssetLoader; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.utils.MathUtils; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; @@ -45,8 +46,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; +import java.lang.reflect.Field; +import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; public class HudGui extends UScreen implements GuiPause { private static final int SNAPPING_DISTANCE = 10; @@ -155,6 +158,7 @@ public class HudGui extends UScreen implements GuiPause { } else if (keyCode == UKeyboard.KEY_RIGHT) { setHudPositions(1f, 0f, false); } + superSecretMethod(typedChar); super.onKeyPressed(keyCode, typedChar, modifiers); } @@ -292,4 +296,73 @@ public class HudGui extends UScreen implements GuiPause { } return lines; } + + private String superSecretString = ""; + + private void superSecretMethod(char charTyped) { + superSecretString += charTyped; + superSecretString = superSecretString.toLowerCase(); + if (!"blahaj".substring(0, superSecretString.length()).equals(superSecretString) + && !"blåhaj".substring(0, superSecretString.length()).equals(superSecretString) + && !"bigrat".substring(0, superSecretString.length()).equals(superSecretString)) { + superSecretString = ""; + return; + } else if (!"blahaj".equals(superSecretString) + && !"blåhaj".equals(superSecretString) + && !"bigrat".equals(superSecretString)) { + return; + } + String url; + switch (superSecretString) { + case "blahaj": + case "blåhaj": + url = "https://blahaj.shop/api/random/image?" + UUID.randomUUID(); + break; + case "bigrat": + url = "https://bigrat.monster/media/bigrat.png"; + break; + default: + return; + } + superSecretString = ""; + AtomicBoolean loaded = new AtomicBoolean(); + RenderManager.setupAndDraw((vg) -> loaded.set(AssetLoader.INSTANCE.loadImage(vg, url))); + if (!loaded.get()) return; + int w = AssetLoader.INSTANCE.getNVGImage(url).getWidth(); + int h = AssetLoader.INSTANCE.getNVGImage(url).getHeight(); + float s = Math.min(300f / w, 300f / h); + float width = w * s; + float height = h * s; + HudCore.huds.put(new Map.Entry<Field, Object>() { + @Override + public Field getKey() { + return null; + } + + @Override + public Object getValue() { + return null; + } + + @Override + public Object setValue(Object o) { + return null; + } + }, new Hud(true) { + @Override + protected void draw(UMatrixStack matrices, float x, float y, float scale, boolean example) { + RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawImage(vg, url, x, y, width * scale, height * scale)); + } + + @Override + protected float getWidth(float scale, boolean example) { + return width * scale; + } + + @Override + protected float getHeight(float scale, boolean example) { + return height * scale; + } + }); + } }
\ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java index f557c8d..05fb6e6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java @@ -52,6 +52,7 @@ public class HudCore { public static void reInitHuds() { for (Map.Entry<Field, Object> field : huds.keySet()) { + if (field == null || field.getKey() == null || field.getValue() == null) continue; try { field.getKey().setAccessible(true); Hud oldHud = huds.get(field); |