aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java37
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));
+
+
}