diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-06-05 15:27:36 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-05 10:27:36 +0200 |
commit | 44dfbbb419f1736530c04c02a651f7757cf83f3d (patch) | |
tree | 1e8171573680b9415cecf199d479d49f7ad1f48a /src/main/java/cc/polyfrost/oneconfig/gui | |
parent | 494d4f0bd0856e8e8d373003c82729ca722c6ccf (diff) | |
download | OneConfig-44dfbbb419f1736530c04c02a651f7757cf83f3d.tar.gz OneConfig-44dfbbb419f1736530c04c02a651f7757cf83f3d.tar.bz2 OneConfig-44dfbbb419f1736530c04c02a651f7757cf83f3d.zip |
rewrite command manager, stop using essential relocate, and reformat code (#34)
* reformat code
* reformat code
rewrite command manager
stop using essential relocate
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
23 files changed, 102 insertions, 108 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java index 72e8e58..52030fc 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java @@ -3,10 +3,10 @@ package cc.polyfrost.oneconfig.gui; import cc.polyfrost.oneconfig.config.core.ConfigCore; import cc.polyfrost.oneconfig.hud.BasicHud; import cc.polyfrost.oneconfig.hud.HudCore; -import cc.polyfrost.oneconfig.libs.universal.UKeyboard; -import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; -import cc.polyfrost.oneconfig.libs.universal.UScreen; import cc.polyfrost.oneconfig.lwjgl.RenderManager; +import gg.essential.universal.UKeyboard; +import gg.essential.universal.UMatrixStack; +import gg.essential.universal.UScreen; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 5985d12..a9da8c2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -9,14 +9,17 @@ import cc.polyfrost.oneconfig.gui.elements.ColorSelector; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; import cc.polyfrost.oneconfig.gui.pages.ModsPage; import cc.polyfrost.oneconfig.gui.pages.Page; -import cc.polyfrost.oneconfig.libs.universal.*; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.utils.GuiUtils; -import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import gg.essential.universal.UKeyboard; +import gg.essential.universal.UMatrixStack; +import gg.essential.universal.UResolution; +import gg.essential.universal.UScreen; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lwjgl.input.Mouse; @@ -25,9 +28,8 @@ import java.util.ArrayList; public class OneConfigGui extends UScreen { public static OneConfigGui INSTANCE; + public static OneConfigGui instanceToRestore = null; private final SideBar sideBar = new SideBar(); - protected Page currentPage; - protected Page prevPage; private final TextInputField textInputField = new TextInputField(248, 40, "Search...", false, false, SVGs.MAGNIFYING_GLASS_BOLD); private final ArrayList<Page> previousPages = new ArrayList<>(); private final ArrayList<Page> nextPages = new ArrayList<>(); @@ -36,9 +38,10 @@ public class OneConfigGui extends UScreen { private final ArrayList<Page> parents = new ArrayList<>(); public ColorSelector currentColorSelector; public boolean mouseDown; - private float scale = 1f; - public static OneConfigGui instanceToRestore = null; public boolean allowClose = true; + protected Page currentPage; + protected Page prevPage; + private float scale = 1f; private Animation animation; public OneConfigGui() { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java index 069a807..3f2a552 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java @@ -3,11 +3,11 @@ package cc.polyfrost.oneconfig.gui.animations; import cc.polyfrost.oneconfig.utils.GuiUtils; public abstract class Animation { + protected final boolean reverse; private final float duration; private final float start; private final float change; private float timePassed = 0; - protected final boolean reverse; /** * @param duration The duration of the animation diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java index a9ef863..2dcd634 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java @@ -1,7 +1,6 @@ package cc.polyfrost.oneconfig.gui.animations; import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import cc.polyfrost.oneconfig.utils.color.ColorUtils; public class ColorAnimation { private ColorPalette palette; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java index bc97aca..dc5bc26 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java @@ -1,6 +1,6 @@ package cc.polyfrost.oneconfig.gui.animations; -public class DummyAnimation extends Animation{ +public class DummyAnimation extends Animation { /** * @param value The value that is returned */ diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java index 9af6557..f43c75d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java @@ -1,6 +1,6 @@ package cc.polyfrost.oneconfig.gui.animations; -public class EaseInOutQuad extends Animation{ +public class EaseInOutQuad extends Animation { /** * @param duration The duration of the animation @@ -17,7 +17,7 @@ public class EaseInOutQuad extends Animation{ */ @Override protected float animate(float timePassed, float duration, float start, float change) { - if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed + start;; + if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed + start; return -change / 2 * ((--timePassed) * (timePassed - 2) - 1) + start; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java index a21aa73..9c3abe9 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java @@ -1,6 +1,6 @@ package cc.polyfrost.oneconfig.gui.animations; -public class EaseInOutQuart extends Animation{ +public class EaseInOutQuart extends Animation { /** * @param duration The duration of the animation @@ -17,7 +17,8 @@ public class EaseInOutQuart extends Animation{ */ @Override protected float animate(float timePassed, float duration, float start, float change) { - if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed * timePassed * timePassed + start; + if ((timePassed /= duration / 2) < 1) + return change / 2 * timePassed * timePassed * timePassed * timePassed + start; return -change / 2 * ((timePassed -= 2) * timePassed * timePassed * timePassed - 2) + start; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java index 6d9f88c..40acff6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -1,6 +1,5 @@ package cc.polyfrost.oneconfig.gui.elements; -import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.pages.Page; import cc.polyfrost.oneconfig.lwjgl.RenderManager; @@ -11,23 +10,21 @@ import org.jetbrains.annotations.NotNull; public class BasicButton extends BasicElement { - protected String text; - protected SVGs icon1, icon2; - private final int alignment; - private final float fontSize, cornerRadius; - private final int xSpacing, xPadding; - private final int iconSize; - public int x, y; public static final int ALIGNMENT_LEFT = 0; public static final int ALIGNMENT_CENTER = 2; public static final int ALIGNMENT_JUSTIFIED = 3; - public static final int SIZE_32 = 32; public static final int SIZE_36 = 36; public static final int SIZE_40 = 40; public static final int SIZE_48 = 48; - public static final int CUSTOM_COLOR = -100; + private final int alignment; + private final float fontSize, cornerRadius; + private final int xSpacing, xPadding; + private final int iconSize; + public int x, y; + protected String text; + protected SVGs icon1, icon2; private boolean toggleable = false; private Page page; private Runnable runnable; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java index 0e3fe23..aab94e5 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -8,6 +8,8 @@ import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Mouse; public class BasicElement { + protected final float radius; + public int currentColor; protected int width, height; protected ColorPalette colorPalette; protected int hitBoxX, hitBoxY; @@ -17,10 +19,8 @@ public class BasicElement { protected boolean clicked = false; protected boolean toggled = false; protected boolean disabled = false; - public int currentColor; - protected final float radius; - private boolean block = false; protected ColorAnimation colorAnimation; + private boolean block = false; public BasicElement(int width, int height, @NotNull ColorPalette colorPalette, boolean hoverFx) { this(width, height, colorPalette, hoverFx, 12f); @@ -79,14 +79,6 @@ public class BasicElement { hitBoxY = y; } - public void setWidth(int width) { - this.width = width; - } - - public void setHeight(int height) { - this.height = height; - } - public void setColorPalette(ColorPalette colorPalette) { if (this.colorPalette.equals(ColorPalette.TERTIARY) || this.colorPalette.equals(ColorPalette.TERTIARY_DESTRUCTIVE)) this.colorAnimation.setColors(colorPalette.getNormalColorf()); @@ -98,10 +90,18 @@ public class BasicElement { return width; } + public void setWidth(int width) { + this.width = width; + } + public int getHeight() { return height; } + public void setHeight(int height) { + this.height = height; + } + public boolean isHovered() { return hovered; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java index 1a53564..683be1e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -3,7 +3,10 @@ package cc.polyfrost.oneconfig.gui.elements; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.core.OneColor; import cc.polyfrost.oneconfig.gui.OneConfigGui; -import cc.polyfrost.oneconfig.gui.animations.*; +import cc.polyfrost.oneconfig.gui.animations.Animation; +import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; +import cc.polyfrost.oneconfig.gui.animations.EaseInOutCubic; +import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad; import cc.polyfrost.oneconfig.gui.elements.text.NumberInputField; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; import cc.polyfrost.oneconfig.lwjgl.RenderManager; @@ -23,21 +26,14 @@ import java.awt.datatransfer.StringSelection; import java.util.ArrayList; public class ColorSelector { - private int x; - private int y; private final OneColor color; - private Animation barMoveAnimation = new DummyAnimation(18); - private Animation moveAnimation = new DummyAnimation(1); - private int mouseX, mouseY; private final ArrayList<BasicElement> buttons = new ArrayList<>(); private final BasicElement closeBtn = new BasicElement(32, 32, false); - private final BasicButton copyBtn = new BasicButton(32, 32, SVGs.COPY, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); private final BasicButton pasteBtn = new BasicButton(32, 32, SVGs.PASTE, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); private final BasicButton guideBtn = new BasicButton(112, 32, "Guide", SVGs.HELP_CIRCLE, SVGs.POP_OUT, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); private final BasicButton faveBtn = new BasicButton(32, 32, SVGs.HEART_OUTLINE, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); private final BasicButton recentBtn = new BasicButton(32, 32, SVGs.HISTORY, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); - private final NumberInputField hueInput = new NumberInputField(90, 32, 0, 0, 360, 1); private final NumberInputField saturationInput = new NumberInputField(90, 32, 100, 0, 100, 1); private final NumberInputField brightnessInput = new NumberInputField(90, 32, 100, 0, 100, 1); @@ -46,10 +42,14 @@ public class ColorSelector { private final TextInputField hexInput = new TextInputField(88, 32, true, ""); private final ArrayList<ColorBox> favoriteColors = new ArrayList<>(); private final ArrayList<ColorBox> recentColors = new ArrayList<>(); - private final ColorSlider topSlider = new ColorSlider(384, 0, 360, 127); private final ColorSlider bottomSlider = new ColorSlider(384, 0, 255, 100); private final Slider speedSlider = new Slider(296, 1, 32, 0); + private int x; + private int y; + private Animation barMoveAnimation = new DummyAnimation(18); + private Animation moveAnimation = new DummyAnimation(1); + private int mouseX, mouseY; private int mode = 0, prevMode = 0; private boolean dragging, mouseWasDown; @@ -462,13 +462,13 @@ public class ColorSelector { update(x, y); } - public void setColor(OneColor color) { - this.color = color; - } - public OneColor getColor() { return color; } + + public void setColor(OneColor color) { + this.color = color; + } } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java index e8d4b2d..863a72d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -6,12 +6,12 @@ import cc.polyfrost.oneconfig.config.data.Mod; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; -import cc.polyfrost.oneconfig.libs.universal.wrappers.UPlayer; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import gg.essential.universal.wrappers.UPlayer; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.fml.common.ModMetadata; import org.jetbrains.annotations.NotNull; @@ -22,9 +22,9 @@ import java.util.ArrayList; public class ModCard extends BasicElement { private final Mod modData; private final BasicButton favoriteButton = new BasicButton(32, 32, SVGs.HEART_OUTLINE, BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY); - private boolean active, disabled, favorite; private final ColorAnimation colorFrame = new ColorAnimation(ColorPalette.SECONDARY); private final ColorAnimation colorToggle = new ColorAnimation(ColorPalette.PRIMARY); + private boolean active, disabled, favorite; private boolean isHoveredMain = false; public ModCard(@NotNull Mod mod, boolean active, boolean disabled, boolean favorite) { @@ -120,14 +120,14 @@ public class ModCard extends BasicElement { return disabled; } - public boolean isActive() { - return active; - } - public void setDisabled(boolean disabled) { this.disabled = disabled; } + public boolean isActive() { + return active; + } + public boolean isFavorite() { return favorite; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java index d58852f..19bf058 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java @@ -24,6 +24,17 @@ public class ConfigButton extends BasicOption { this.button.setClickAction(getRunnableFromField(field, parent)); } + private static Runnable getRunnableFromField(Field field, Object parent) { + Runnable runnable = () -> { + }; + try { + runnable = (Runnable) field.get(parent); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return runnable; + } + @Override public void draw(long vg, int x, int y) { button.disable(!isEnabled()); @@ -37,15 +48,4 @@ public class ConfigButton extends BasicOption { public int getHeight() { return 32; } - - private static Runnable getRunnableFromField(Field field, Object parent) { - Runnable runnable = () -> { - }; - try { - runnable = (Runnable) field.get(parent); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return runnable; - } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java index 16b1ea2..121416d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java @@ -29,7 +29,7 @@ public class ConfigColorElement extends BasicOption { @Override public void draw(long vg, int x, int y) { - if(!isEnabled()) RenderManager.setAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); hexField.disable(!isEnabled()); alphaField.disable(!isEnabled()); element.disable(!isEnabled()); @@ -81,7 +81,7 @@ public class ConfigColorElement extends BasicOption { open = !open; OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY())); } - if(OneConfigGui.INSTANCE.currentColorSelector == null) open = false; + if (OneConfigGui.INSTANCE.currentColorSelector == null) open = false; if (OneConfigGui.INSTANCE.currentColorSelector != null && open) { color = (OneConfigGui.INSTANCE.getColor()); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java index 156f782..472f80e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java @@ -6,9 +6,8 @@ import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import org.lwjgl.input.Mouse; import java.awt.*; @@ -18,7 +17,7 @@ import java.util.Arrays; public class ConfigDropdown extends BasicOption { private final String[] options; private final ColorAnimation backgroundColor = new ColorAnimation(ColorPalette.SECONDARY); - private final ColorAnimation atomColor = new ColorAnimation(new ColorPalette(OneConfigConfig.PRIMARY_600, OneConfigConfig.PRIMARY_500, OneConfigConfig.PRIMARY_500)); + private final ColorAnimation atomColor = new ColorAnimation(new ColorPalette(OneConfigConfig.PRIMARY_600, OneConfigConfig.PRIMARY_500, OneConfigConfig.PRIMARY_500)); private boolean opened = false; public ConfigDropdown(Field field, Object parent, String name, int size, String[] options) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java index 7a458c8..e7b1083 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java @@ -2,17 +2,18 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; -import cc.polyfrost.oneconfig.gui.animations.*; +import cc.polyfrost.oneconfig.gui.animations.Animation; +import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; +import cc.polyfrost.oneconfig.gui.animations.EaseInOutCubic; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.utils.InputUtils; -import cc.polyfrost.oneconfig.utils.MathUtils; import java.lang.reflect.Field; public class ConfigDualOption extends BasicOption { - private Animation posAnimation; private final String left, right; + private Animation posAnimation; public ConfigDualOption(Field field, Object parent, String name, int size, String[] options) { super(field, parent, name, size); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java index d873006..a448b14 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java @@ -5,11 +5,11 @@ import cc.polyfrost.oneconfig.config.core.OneKeyBind; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.elements.BasicButton; -import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import gg.essential.universal.UKeyboard; import java.lang.reflect.Field; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java index b464423..8b47045 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java @@ -9,8 +9,8 @@ import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import org.lwjgl.input.Mouse; import java.lang.reflect.Field; @@ -18,7 +18,7 @@ import java.lang.reflect.Field; public class ConfigPageButton extends BasicOption { public final OptionPage page; public final String description; - private ColorAnimation backgroundColor = new ColorAnimation(ColorPalette.SECONDARY); + private final ColorAnimation backgroundColor = new ColorAnimation(ColorPalette.SECONDARY); public ConfigPageButton(Field field, Object parent, String name, String description, OptionPage page) { super(field, parent, name, 2); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java index 9a38b98..45217c0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java @@ -14,8 +14,8 @@ import java.lang.reflect.Field; public class ConfigSlider extends BasicOption { private final NumberInputField inputField; private final float min, max; - private boolean isFloat = true; private final int step; + private boolean isFloat = true; private boolean dragging = false; private boolean mouseWasDown = false; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java index cb54f9b..090f5a6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java @@ -8,10 +8,8 @@ import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; -import cc.polyfrost.oneconfig.utils.MathUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import org.lwjgl.input.Mouse; import java.lang.reflect.Field; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java index 69b1584..ed05760 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java @@ -6,16 +6,15 @@ import cc.polyfrost.oneconfig.gui.elements.BasicElement; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import cc.polyfrost.oneconfig.utils.color.ColorUtils; public class NumberInputField extends TextInputField { private final BasicElement upArrow = new BasicElement(12, 14, false); private final BasicElement downArrow = new BasicElement(12, 14, false); + private final ColorAnimation colorTop = new ColorAnimation(ColorPalette.SECONDARY); + private final ColorAnimation colorBottom = new ColorAnimation(ColorPalette.SECONDARY); private float min; private float max; private float step; - private final ColorAnimation colorTop = new ColorAnimation(ColorPalette.SECONDARY); - private final ColorAnimation colorBottom = new ColorAnimation(ColorPalette.SECONDARY); private float current; public NumberInputField(int width, int height, float defaultValue, float min, float max, float step) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java index 91a8ff2..b16472d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java @@ -2,7 +2,6 @@ package cc.polyfrost.oneconfig.gui.elements.text; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.gui.elements.BasicElement; -import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; @@ -11,6 +10,7 @@ import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; import cc.polyfrost.oneconfig.utils.TextUtils; +import gg.essential.universal.UKeyboard; import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -23,24 +23,24 @@ import java.util.ArrayList; public class TextInputField extends BasicElement { protected final String defaultText; - protected String input, selectedText; protected final boolean multiLine; + protected String input, selectedText; protected boolean password; protected int caretPos; protected int x, y; protected float start, end; protected int startLine, endLine; - private long clickTimeD1; protected long vg; protected int prevCaret = 0; protected boolean isDoubleClick = false; protected boolean onlyNums = false; protected boolean errored = false; protected boolean centered = false; - private int lines = 1; protected SVGs icon; protected ArrayList<String> wrappedText = null; + private long clickTimeD1; + private int lines = 1; public TextInputField(int width, int height, String defaultText, boolean multiLine, boolean password, SVGs icon) { super(width, height, false); @@ -60,28 +60,28 @@ public class TextInputField extends BasicElement { this.centered = centered; } - public void onlyAcceptNumbers(boolean state) { - onlyNums = state; + public static boolean isAllowedCharacter(char character) { + return character != 167 && character >= ' ' && character != 127; } - public void setInput(String input) { - this.input = input; + public void onlyAcceptNumbers(boolean state) { + onlyNums = state; } public String getInput() { return input; } - public void setPassword(boolean password) { - this.password = password; + public void setInput(String input) { + this.input = input; } public boolean getPassword() { return password; } - public void setErrored(boolean errored) { - this.errored = errored; + public void setPassword(boolean password) { + this.password = password; } public void setCentered(boolean centered) { @@ -92,6 +92,10 @@ public class TextInputField extends BasicElement { return errored; } + public void setErrored(boolean errored) { + this.errored = errored; + } + @Override public void draw(long vg, int x, int y) { this.x = x; @@ -529,10 +533,6 @@ public class TextInputField extends BasicElement { return 0; } - public static boolean isAllowedCharacter(char character) { - return character != 167 && character >= ' ' && character != 127; - } - public int getLines() { return lines; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java index 2866008..3b8e172 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -67,9 +67,9 @@ public class ModsPage extends Page { for (BasicButton btn : modCategories) { btn.draw(vg, iXCat, y + 16); iXCat += btn.getWidth() + 8; - if(btn.isToggled()) selected = true; + if (btn.isToggled()) selected = true; } - if(!selected) modCategories.get(0).setToggled(true); + if (!selected) modCategories.get(0).setToggled(true); return 60; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java index 4e85cf5..fda6ea2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -1,22 +1,19 @@ package cc.polyfrost.oneconfig.gui.pages; import cc.polyfrost.oneconfig.gui.animations.Animation; -import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad; import cc.polyfrost.oneconfig.gui.animations.EaseOutQuad; import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; -import cc.polyfrost.oneconfig.utils.MathUtils; import org.lwjgl.input.Mouse; /** * A page is a 1056x728 rectangle of the GUI. It is the main content of the gui, and can be switched back and forwards easily. All the content of OneConfig is in a page. */ public abstract class Page { + protected final String title; private Animation scrollAnimation; private float scrollTarget; - protected final String title; - protected Page(String title) { this.title = title; } |