diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-28 19:18:53 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-28 19:18:53 +0200 |
commit | ff0a0079ffc9dccdf1fffd0616ec724eb048f771 (patch) | |
tree | 2503b4eb2291dd4c72845b78daefb1e13b38c109 /src/main/java/io/polyfrost/oneconfig | |
parent | 8a1f8f6a1972216b8ba7b0ce97d4be9ffc45dd7c (diff) | |
parent | d99504188ba1866043cd7f652df8b66c24ea3052 (diff) | |
download | OneConfig-ff0a0079ffc9dccdf1fffd0616ec724eb048f771.tar.gz OneConfig-ff0a0079ffc9dccdf1fffd0616ec724eb048f771.tar.bz2 OneConfig-ff0a0079ffc9dccdf1fffd0616ec724eb048f771.zip |
Merge branch 'master' of github.com:Polyfrost/OneConfig
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig')
3 files changed, 37 insertions, 3 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java index f9a9111..6f3c1b4 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java @@ -9,7 +9,6 @@ import net.minecraft.util.ChatAllowedCharacters; import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; import java.awt.*; import java.awt.datatransfer.DataFlavor; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java index 8d6fd0e..8a718bb 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java @@ -41,8 +41,6 @@ public class ConfigPage extends BasicOption { RenderManager.drawString(vg, name, x + 24, y + 70, OneConfigConfig.WHITE, 14, Fonts.INTER_MEDIUM); RenderManager.drawImage(vg, "/assets/oneconfig/textures/arrow.png", x + 995f, y + (description.equals("") ? 20f : 36f), 13, 22); - RenderManager.drawRect(vg, x, y, 1024, 20, OneConfigConfig.WHITE); - RenderManager.drawRect(vg, x, y + 64 - 20, 1024, 20, OneConfigConfig.WHITE); if (clicked) OneConfigGui.INSTANCE.openPage(new ModConfigPage(page)); NanoVG.nvgGlobalAlpha(vg, 1f); diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java index a65e873..214bd16 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java @@ -1,10 +1,24 @@ package io.polyfrost.oneconfig.gui.elements.config; +import io.polyfrost.oneconfig.config.OneConfigConfig; import io.polyfrost.oneconfig.config.interfaces.BasicOption; +import io.polyfrost.oneconfig.lwjgl.RenderManager; +import io.polyfrost.oneconfig.lwjgl.font.Fonts; +import io.polyfrost.oneconfig.utils.ColorUtils; +import io.polyfrost.oneconfig.utils.InputUtils; +import io.polyfrost.oneconfig.utils.MathUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChatComponentText; +import org.lwjgl.input.Cursor; +import org.lwjgl.input.Mouse; import java.lang.reflect.Field; public class ConfigSwitch extends BasicOption { + private int color; + private float percentOn = 0f; + private boolean clicked = false; + private boolean toggled = false; public ConfigSwitch(Field field, String name, int size) { super(field, name, size); @@ -12,6 +26,29 @@ public class ConfigSwitch extends BasicOption { @Override public void draw(long vg, int x, int y) { + boolean hovered = InputUtils.isAreaHovered(x, y, 480, 32); + int x2 = x + 19 + (int) (percentOn * 18); + color = ColorUtils.smoothColor(color, OneConfigConfig.GRAY_400, OneConfigConfig.BLUE_500, toggled, 20f); + if(color == -15123643) { + color = OneConfigConfig.GRAY_400; + } + RenderManager.drawRoundedRect(vg, x + 16, y + 4, 42, 24, color, 12f); + RenderManager.drawRoundedRect(vg, x2, y + 7, 18, 18, OneConfigConfig.WHITE, 9f); + RenderManager.drawString(vg, name, x + 66, y + 17, OneConfigConfig.WHITE, 18f, Fonts.INTER_MEDIUM); + + if (Mouse.isButtonDown(0) && !this.clicked && hovered) + { + toggled = !toggled; + try { + set(toggled); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + this.clicked = Mouse.isButtonDown(0) && hovered; + percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 10)); + + } |