aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-21 14:19:44 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-21 14:19:44 +0100
commit260d48126cbedb4341c5c5865bfd8e605f90955a (patch)
tree563f65d65d708f24df33759c411b0f2338c1933e
parent30df910cf3b2f5b0683ce01e391c35829d8a5850 (diff)
downloadOneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.gz
OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.bz2
OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.zip
more gui things like text field and button
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java7
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java40
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java47
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java33
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java88
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java13
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/font/FontManager.java9
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/font/Fonts.java18
-rw-r--r--src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java7
-rw-r--r--src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java25
-rw-r--r--src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java9
-rw-r--r--src/main/resources/assets/oneconfig/textures/icon.pngbin0 -> 1819 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/search.pngbin0 -> 555 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/share.pngbin0 -> 480 bytes
-rw-r--r--src/main/resources/assets/oneconfig/textures/share2.pngbin0 -> 430 bytes
15 files changed, 240 insertions, 56 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
index 570d379..14cad6c 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
@@ -27,9 +27,10 @@ public class OneConfigConfig extends Config {
public static int GRAY_400 = new Color(55, 59, 69, 255).getRGB(); // Gray 400 // button gray hover
public static int GRAY_400_80 = new Color(55, 59, 69, 204).getRGB(); // Gray 400 80% // button gray pressed
- public static int BLUE_700 = new Color(18, 71, 178, 255).getRGB(); // Blue 700 // button blue normal
- public static int BLUE_600 = new Color(20, 82, 204, 255).getRGB(); // Blue 600
- public static int BLUE_500 = new Color(25, 103, 255, 255).getRGB(); // Blue 500
+ public static int BLUE_700 = new Color(18, 71, 178, 255).getRGB(); // Blue 700
+ public static int BLUE_600 = new Color(20, 82, 204, 255).getRGB(); // Blue 600 // button blue normal
+ public static int BLUE_600_80 = new Color(20, 82, 204, 204).getRGB(); // Blue 600 80% // button blue click
+ public static int BLUE_500 = new Color(25, 103, 255, 255).getRGB(); // Blue 500 // button blue hover
public static int WHITE_60 = new Color(255, 255, 255, 153).getRGB(); // White 60%
public static int WHITE_90 = new Color(255, 255, 255, 229).getRGB(); // White 90%
public static int WHITE = new Color(255, 255, 255, 255).getRGB(); // White 100%
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
index cbe1c6a..24bfe19 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -1,16 +1,24 @@
package io.polyfrost.oneconfig.gui;
-import io.polyfrost.oneconfig.OneConfig;
import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.gui.elements.BasicButton;
import io.polyfrost.oneconfig.gui.elements.BasicElement;
+import io.polyfrost.oneconfig.gui.elements.TextInputField;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import net.minecraft.client.gui.GuiScreen;
-
-import java.awt.*;
+import org.lwjgl.input.Keyboard;
public class OneConfigGui extends GuiScreen {
+ public static OneConfigGui INSTANCE;
private final BasicElement element = new BasicElement(200, 200, 1, true);
+ private final TextInputField textInputField = new TextInputField(776, 32, "Search all of OneConfig...", false, false);
+ private final BasicButton btn = new BasicButton(184, 36, "Socials", "/assets/oneconfig/textures/share.png", "/assets/oneconfig/textures/share2.png", 1, true);
+
+ public OneConfigGui() {
+ INSTANCE = this;
+ }
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
@@ -26,18 +34,32 @@ public class OneConfigGui extends GuiScreen {
RenderManager.drawLine(vg, 544, 212, 1600, 212, 1, OneConfigConfig.GRAY_700);
RenderManager.drawLine(vg, 544, 140, 544, 940, 1, OneConfigConfig.GRAY_700);
- RenderManager.drawString(vg, "OneConfig", 389, 163, OneConfigConfig.WHITE, 18f, "inter-bold");
- RenderManager.drawString(vg, "By Polyfrost", 389, 183, OneConfigConfig.WHITE, 12f, "inter-regular");
- element.setColorPalette(0);
- element.draw(vg, 0, 0);
+ RenderManager.drawString(vg, "OneConfig", 389, 163, OneConfigConfig.WHITE, 18f, Fonts.INTER_BOLD);
+ RenderManager.drawString(vg, "By Polyfrost", 389, 183, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR);
+ //element.setColorPalette(0);
+ try {
+ //element.draw(vg, 0, 0);
+ textInputField.draw(vg, 792, 548);
+ btn.draw(vg, 976, 870);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
//RenderManager.drawGradientRoundedRect(vg, 100, 100, 500, 100, OneConfigConfig.BLUE_600, OneConfigConfig.BLUE_500, OneConfigConfig.CORNER_RADIUS_WIN);
-
-
});
}
+ protected void keyTyped(char key, int keyCode) {
+ Keyboard.enableRepeatEvents(true);
+ try {
+ super.keyTyped(key, keyCode);
+ textInputField.keyTyped(key, keyCode);
+ } catch (Exception e) {
+ System.out.println("this should literally never happen");
+ }
+ }
+
@Override
public boolean doesGuiPauseGame() {
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
new file mode 100644
index 0000000..e918287
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -0,0 +1,47 @@
+package io.polyfrost.oneconfig.gui.elements;
+
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import io.polyfrost.oneconfig.utils.ColorUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static org.lwjgl.nanovg.NanoVG.nvgTextBounds;
+
+public class BasicButton extends BasicElement {
+
+ protected String text;
+ protected String fileNameLeftIco, fileNameRightIco;
+
+ public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, boolean hoverFx) {
+ super(width, height, colorPalette, hoverFx);
+ this.text = text;
+ this.fileNameLeftIco = fileNameLeftIco;
+ this.fileNameRightIco = fileNameRightIco;
+ }
+
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ RenderManager.drawRectangle(vg, x, y, this.width, this.height, this.currentColor);
+ final float fontSize;
+ if(colorPalette == -1) {
+ fontSize = 24f;
+ } else fontSize = 14f;
+ float width = RenderManager.getTextWidth(vg, text, fontSize);
+ int middle = x + this.width / 2;
+ RenderManager.drawString(vg, text,middle - width / 2, y + ((float) height / 2),-1, fontSize, Fonts.INTER_MEDIUM);
+ if(fileNameLeftIco != null) {
+ RenderManager.drawImage(vg, fileNameLeftIco, middle - width - 8, y + 8, 20, 20);
+ }
+ if(fileNameRightIco != null) {
+ RenderManager.drawImage(vg, fileNameRightIco, middle + width - 8, y + 8, 20, 20);
+ }
+ this.update(x, y);
+ if(hoverFx) {
+ currentColor = ColorUtils.getColor(currentColor, 1, hovered, clicked);
+ }
+ }
+
+
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java
index 0b7d604..765a271 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java
@@ -6,19 +6,14 @@ import net.minecraft.client.Minecraft;
import org.lwjgl.input.Mouse;
public class BasicElement {
- private int width;
- private int height;
- private int colorPalette;
-
- private int hitBoxX, hitBoxY;
-
- private final boolean hoverFx;
-
- private boolean hovered = false;
- private boolean clicked = false;
- private boolean toggled = false;
-
- private int currentColor;
+ protected int width, height;
+ protected int colorPalette;
+ protected int hitBoxX, hitBoxY;
+ protected final boolean hoverFx;
+ protected boolean hovered = false;
+ protected boolean clicked = false;
+ protected boolean toggled = false;
+ protected int currentColor;
public BasicElement(int width, int height, int colorPalette, boolean hoverFx) {
this.height = height;
@@ -37,6 +32,14 @@ public class BasicElement {
public void draw(long vg, int x, int y) {
RenderManager.drawRectangle(vg, x, y, width, height, currentColor);
+
+ update(x, y);
+ if (hoverFx) {
+ currentColor = ColorUtils.getColor(currentColor, colorPalette, hovered, clicked);
+ }
+ }
+
+ public void update(int x, int y) {
int mouseX = Mouse.getX();
int mouseY = Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY());
int buttonRight = x + width;
@@ -47,10 +50,6 @@ public class BasicElement {
toggled = !toggled;
}
clicked = Mouse.isButtonDown(0) && hovered;
-
- if (hoverFx) {
- currentColor = ColorUtils.getColor(currentColor, colorPalette, hovered, clicked);
- }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java
new file mode 100644
index 0000000..7b56a40
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java
@@ -0,0 +1,88 @@
+package io.polyfrost.oneconfig.gui.elements;
+
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import net.minecraft.client.gui.GuiScreen;
+import org.lwjgl.input.Keyboard;
+
+public class TextInputField extends BasicElement {
+
+ protected final String defaultText;
+ protected String input;
+ protected final boolean mulitLine;
+ protected boolean password;
+
+ public TextInputField(int width, int height, String defaultText, boolean multiLine, boolean password) {
+ super(width, height, false);
+ this.mulitLine = multiLine;
+ this.defaultText = defaultText;
+ this.password = password;
+ this.input = defaultText;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setPassword(boolean password) {
+ this.password = password;
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ RenderManager.drawRectangle(vg, x, y, width, height, OneConfigConfig.GRAY_700);
+ RenderManager.drawRectangle(vg, x + 2, y + 2, width - 2, height - 4, OneConfigConfig.GRAY_900);
+ super.update(x, y);
+ int color = toggled ? OneConfigConfig.WHITE : OneConfigConfig.WHITE_60;
+ float width = RenderManager.getTextWidth(vg, input, 14f);
+
+ if(toggled) {
+ RenderManager.drawLine(vg, x + width + 12, (float) y + 7, x + width + 13, (float) y + height - 7, 1, OneConfigConfig.WHITE);
+ }
+
+ if(input.equals("")){
+ RenderManager.drawString(vg, defaultText, x + 12, y + 17, color, 14f, Fonts.INTER_REGULAR);
+ }
+ RenderManager.drawString(vg, input, x + 12, y + 17, color, 14f, Fonts.INTER_REGULAR);
+
+ }
+
+ public void keyTyped(char c, int key) {
+ if (toggled) {
+ if(GuiScreen.isCtrlKeyDown()) {
+ if(key == Keyboard.KEY_BACK) {
+ try {
+ input = input.substring(0, input.lastIndexOf(" "));
+ } catch (Exception e) {
+ input = "";
+ }
+ }
+ return;
+ }
+ if (key == Keyboard.KEY_BACK) {
+ if (input.length() > 0) {
+ input = input.substring(0, input.length() - 1);
+ return;
+ }
+ }
+ if(key == Keyboard.KEY_TAB) {
+ input += " ";
+ return;
+ }
+
+ if(key == Keyboard.KEY_RETURN) {
+ toggled = false;
+ }
+
+ if(key == Keyboard.KEY_LCONTROL || key == Keyboard.KEY_RCONTROL || key == Keyboard.KEY_LMENU || key == Keyboard.KEY_RMENU || key == Keyboard.KEY_LMETA || key == Keyboard.KEY_RMETA || key == Keyboard.KEY_LSHIFT || key == Keyboard.KEY_RSHIFT || key == Keyboard.KEY_RETURN || key == Keyboard.KEY_CAPITAL || key == 221) {
+ return;
+ }
+ input += c;
+ }
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
index d728670..2ed8404 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -3,6 +3,7 @@ package io.polyfrost.oneconfig.lwjgl;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.lwjgl.font.Font;
import io.polyfrost.oneconfig.lwjgl.font.FontManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.lwjgl.image.Image;
import io.polyfrost.oneconfig.lwjgl.image.ImageLoader;
import net.minecraft.client.Minecraft;
@@ -131,14 +132,11 @@ public final class RenderManager {
nvgColor.free();
}
- public static void drawString(long vg, String text, float x, float y, int color, float size, Font font) {
- drawString(vg, text, x, y, color, size, font.getName());
- }
- public static void drawString(long vg, String text, float x, float y, int color, float size, String fontName) {
+ public static void drawString(long vg, String text, float x, float y, int color, float size, Fonts font) {
nvgBeginPath(vg);
nvgFontSize(vg, size);
- nvgFontFace(vg, fontName);
+ nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
NVGColor nvgColor = color(vg, color);
nvgText(vg, x, y, text);
@@ -216,6 +214,11 @@ public final class RenderManager {
}
}
+ public static float getTextWidth(long vg, String text, float fontSize) {
+ float[] bounds = new float[4];
+ return (nvgTextBounds(vg, 0, 0, text, bounds) / 12) * fontSize;
+ }
+
public static void drawLine(long vg, float x, float y, float endX, float endY, float width, int color) {
nvgBeginPath(vg);
nvgMoveTo(vg, x, y);
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/font/FontManager.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/font/FontManager.java
index 08d108b..0ec2b87 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/font/FontManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/font/FontManager.java
@@ -4,20 +4,15 @@ import io.polyfrost.oneconfig.lwjgl.IOUtil;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
import static org.lwjgl.nanovg.NanoVG.nvgCreateFontMem;
public class FontManager {
public static FontManager INSTANCE = new FontManager();
- private final ArrayList<Font> fonts = new ArrayList<>();
public void initialize(long vg) {
- fonts.add(new Font("inter-bold", "/assets/oneconfig/font/Inter-Bold.ttf"));
- fonts.add(new Font("inter-regular", "/assets/oneconfig/font/Inter-Regular.otf"));
- fonts.add(new Font("inter-semibold", "/assets/oneconfig/font/Inter-SemiBold.otf"));
- fonts.add(new Font("mc-regular", "/assets/oneconfig/font/Minecraft-Regular.otf"));
- for (Font font : fonts) {
+ for (Fonts fonts : Fonts.values()) {
+ Font font = fonts.font;
int loaded = -1;
try {
ByteBuffer buffer = IOUtil.resourceToByteBuffer(font.getFileName());
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/font/Fonts.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/font/Fonts.java
new file mode 100644
index 0000000..5d36271
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/font/Fonts.java
@@ -0,0 +1,18 @@
+package io.polyfrost.oneconfig.lwjgl.font;
+
+public enum Fonts {
+
+ INTER_BOLD(new Font("inter-bold", "/assets/oneconfig/font/Inter-Bold.ttf")),
+ INTER_REGULAR(new Font("inter-regular", "/assets/oneconfig/font/Inter-Regular.otf")),
+ INTER_SEMIBOLD(new Font("inter-semibold", "/assets/oneconfig/font/Inter-SemiBold.otf")),
+ INTER_MEDIUM(new Font("inter-medium", "/assets/oneconfig/font/Inter-Medium.otf")),
+ MC_REGULAR(new Font("mc-regular", "/assets/oneconfig/font/Minecraft-Regular.otf"));
+
+ public final Font font;
+
+ Fonts(Font font) {
+ this.font = font;
+ }
+
+
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
index 862ff35..313da70 100644
--- a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
@@ -1,6 +1,7 @@
package io.polyfrost.oneconfig.test;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import net.minecraft.client.gui.GuiScreen;
import java.awt.*;
@@ -15,13 +16,13 @@ public class TestNanoVGGui extends GuiScreen {
RenderManager.setupAndDraw((vg) -> {
RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB());
RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8);
- RenderManager.drawString(vg, "Hello!", 80, 20, Color.WHITE.getRGB(), 50, "mc-regular");
- RenderManager.drawString(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, "inter-bold");
+ RenderManager.drawString(vg, "Hello!", 80, 20, Color.WHITE.getRGB(), 50, Fonts.MC_REGULAR);
+ RenderManager.drawString(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.INTER_BOLD);
RenderManager.drawImage(vg, "/assets/oneconfig/textures/hudsettings.png", 10, 10, 400, 400);
RenderManager.drawSVGImage(vg, "textures/pc.svg", 1000, 1000, 500, 500);
RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB());
RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB());
- RenderManager.drawString(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, "inter-bold");
+ RenderManager.drawString(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.INTER_BOLD);
});
drawString(fontRendererObj, "Hello!", 0, 0, -1);
} // hi
diff --git a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java
index f45f9a5..b8d56bd 100644
--- a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java
+++ b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java
@@ -15,37 +15,40 @@ public class ColorUtils {
default:
case 0:
return OneConfigConfig.GRAY_400_80;
+ case 1:
+ return OneConfigConfig.BLUE_600_80;
}
}
switch (colorPalette) {
case -1:
- return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover);
+ return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover, 10f);
default:
case 0:
- return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_400), hover); // OK hopefully this works
+ return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_400), hover, 130f);
+ case 1:
+ return getColorComponents(color, splitColor(OneConfigConfig.BLUE_600), splitColor(OneConfigConfig.BLUE_500), hover, 150f);
}
}
private static float[] splitColor(int color) {
- Color c = new Color(color, true);
- return new float[] {c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f};
+ return new float[] { (color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) /255f };
}
- private static int getColorComponents(float[] currentColor, float[] initColor, float[] finalColor, boolean hover) {
- currentColor[0] = smooth(currentColor[0], initColor[0], finalColor[0], hover);
- currentColor[1] = smooth(currentColor[1], initColor[1], finalColor[1], hover);
- currentColor[2] = smooth(currentColor[2], initColor[2], finalColor[2], hover);
- currentColor[3] = smooth(currentColor[3], initColor[3], finalColor[3], hover);
+ private static int getColorComponents(float[] currentColor, float[] initColor, float[] finalColor, boolean hover, float speed) {
+ currentColor[0] = smooth(currentColor[0], initColor[0], finalColor[0], hover, speed);
+ currentColor[1] = smooth(currentColor[1], initColor[1], finalColor[1], hover, speed);
+ currentColor[2] = smooth(currentColor[2], initColor[2], finalColor[2], hover, speed);
+ currentColor[3] = smooth(currentColor[3], initColor[3], finalColor[3], hover, speed);
return new Color(currentColor[0], currentColor[1], currentColor[2], currentColor[3]).getRGB();
}
- private static float smooth(float current, float min, float max, boolean moveToFinal) {
- current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f);
+ private static float smooth(float current, float min, float max, boolean moveToFinal, float speed) {
+ current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f, speed);
if(current <= min) {
current = min;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java
index 7d64170..547e286 100644
--- a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java
+++ b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java
@@ -7,7 +7,14 @@ public class MathUtils {
public static float easeOut(float current, float goal) {
if (Math.floor(Math.abs(goal - current) / (float) 0.01) > 0) {
- return current + (goal - current) / (float) 100.0; // this number here controls the speed uh oh
+ return current + (goal - current) / (float) 100.0;
+ } else {
+ return goal;
+ }
+ }
+ public static float easeOut(float current, float goal, float speed) {
+ if (Math.floor(Math.abs(goal - current) / (float) 0.01) > 0) {
+ return current + (goal - current) / speed;
} else {
return goal;
}
diff --git a/src/main/resources/assets/oneconfig/textures/icon.png b/src/main/resources/assets/oneconfig/textures/icon.png
new file mode 100644
index 0000000..f0f6e68
--- /dev/null
+++ b/src/main/resources/assets/oneconfig/textures/icon.png
Binary files differ
diff --git a/src/main/resources/assets/oneconfig/textures/search.png b/src/main/resources/assets/oneconfig/textures/search.png
new file mode 100644
index 0000000..23a9e05
--- /dev/null
+++ b/src/main/resources/assets/oneconfig/textures/search.png
Binary files differ
diff --git a/src/main/resources/assets/oneconfig/textures/share.png b/src/main/resources/assets/oneconfig/textures/share.png
new file mode 100644
index 0000000..67930ef
--- /dev/null
+++ b/src/main/resources/assets/oneconfig/textures/share.png
Binary files differ
diff --git a/src/main/resources/assets/oneconfig/textures/share2.png b/src/main/resources/assets/oneconfig/textures/share2.png
new file mode 100644
index 0000000..5f1e1ac
--- /dev/null
+++ b/src/main/resources/assets/oneconfig/textures/share2.png
Binary files differ