aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java7
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModUpdateCard.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java39
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java119
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/SearchField.java (renamed from src/main/java/cc/polyfrost/oneconfig/gui/elements/SearchField.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java (renamed from src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java)13
8 files changed, 147 insertions, 45 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 44e019e..380f89a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -3,7 +3,8 @@ package cc.polyfrost.oneconfig.gui;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
-import cc.polyfrost.oneconfig.gui.elements.TextInputField;
+import cc.polyfrost.oneconfig.gui.elements.text.NumberInputField;
+import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.gui.pages.HomePage;
import cc.polyfrost.oneconfig.gui.pages.Page;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
@@ -30,7 +31,6 @@ public class OneConfigGui extends GuiScreen {
protected Page currentPage;
protected Page prevPage;
private float pageProgress = -224f;
- private float scissorExclusionHeight = 0f;
private final TextInputField textInputField = new TextInputField(248, 40, "Search all of OneConfig...", false, false);
private final ArrayList<Page> previousPages = new ArrayList<>();
private final ArrayList<Page> nextPages = new ArrayList<>();
@@ -65,7 +65,6 @@ public class OneConfigGui extends GuiScreen {
RenderManager.drawRect(vg, 544, 140, 20, 800, OneConfigConfig.GRAY_800);
//RenderManager.drawDropShadow(vg, 544, 140, 1056, 800, 20f, 32f, OneConfigConfig.GRAY_800);
}
-
RenderManager.drawLine(vg, 544, 212, 1600, 212, 1, OneConfigConfig.GRAY_700);
RenderManager.drawLine(vg, 544, 140, 544, 940, 1, OneConfigConfig.GRAY_700);
@@ -73,10 +72,10 @@ public class OneConfigGui extends GuiScreen {
RenderManager.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.INTER_BOLD); // added half line height to center text
RenderManager.drawString(vg, "ALPHA - By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR);
+
//RenderManager.drawRect(vg, x + 300, y + 500, 400, 12, OneConfigConfig.ERROR_700);
//RenderManager.drawString(vg, "MoonTidez is Annoyinhg here is an f |||", x + 300, y + 500, OneConfigConfig.WHITE, 14f, 14,Fonts.INTER_REGULAR);
-
textInputField.draw(vg, x + 1020, y + 16);
sideBar.draw(vg, x, y);
backArrow.draw(vg, x + 240, y + 16);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModUpdateCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModUpdateCard.java
new file mode 100644
index 0000000..3baf001
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModUpdateCard.java
@@ -0,0 +1,8 @@
+package cc.polyfrost.oneconfig.gui.elements;
+
+public class ModUpdateCard extends BasicElement{
+
+ public ModUpdateCard(int width, int height) { // TODO
+ super(width, height, true);
+ }
+}
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 2c89133..a5c82e2 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
@@ -5,7 +5,7 @@ import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
-import cc.polyfrost.oneconfig.gui.elements.TextInputField;
+import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
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 69cb887..856fbf3 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
@@ -2,27 +2,21 @@ 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.elements.BasicElement;
+import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
-import cc.polyfrost.oneconfig.lwjgl.image.Images;
-import cc.polyfrost.oneconfig.utils.ColorUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.MathUtils;
-import cc.polyfrost.oneconfig.gui.elements.BasicElement;
-import cc.polyfrost.oneconfig.gui.elements.TextInputField;
import org.lwjgl.input.Mouse;
-import org.lwjgl.nanovg.NanoVG;
import java.lang.reflect.Field;
public class ConfigSlider extends BasicOption {
private final BasicElement slideYBoi = new BasicElement(24, 24, false);
private final TextInputField inputField = new TextInputField(84, 24, "", false, false);
- private final BasicElement upArrow = new BasicElement(12, 14, false);
- private final BasicElement downArrow = new BasicElement(12, 14, false);
private final float min, max;
private int steps = 0;
- private int colorTop, colorBottom;
private boolean isFloat = true;
private Float prevAsNum = null;
private final int step;
@@ -112,33 +106,6 @@ public class ConfigSlider extends BasicOption {
}
currentAsNum = current * (max - min) + min;
- RenderManager.drawRoundedRect(vg, x + 980, y, 12, 28, OneConfigConfig.GRAY_500, 6f);
- upArrow.update(x + 980, y);
- downArrow.update(x + 980, y + 14);
- if (current == 1f) colorTop = OneConfigConfig.GRAY_500_80;
- if (current == 0f) colorBottom = OneConfigConfig.GRAY_500_80;
- colorTop = ColorUtils.getColor(colorTop, 2, upArrow.isHovered(), upArrow.isClicked());
- colorBottom = ColorUtils.getColor(colorBottom, 2, downArrow.isHovered(), downArrow.isClicked());
- if (upArrow.isClicked()) {
- currentAsNum += step == 0 ? 1 : step;
- current = MathUtils.clamp((currentAsNum - min) / (max - min));
- }
- if (downArrow.isClicked()) {
- currentAsNum -= step == 0 ? 1 : step;
- current = MathUtils.clamp((currentAsNum - min) / (max - min));
- }
- if (current == 1f) NanoVG.nvgGlobalAlpha(vg, 0.3f);
- RenderManager.drawRoundedRectVaried(vg, x + 980, y, 12, 14, colorTop, 6f, 6f, 0f, 0f);
- RenderManager.drawImage(vg, Images.UP_ARROW, x + 981, y + 2, 10, 10);
- if (current == 1f) NanoVG.nvgGlobalAlpha(vg, 1f);
-
- if (current == 0f) NanoVG.nvgGlobalAlpha(vg, 0.3f);
- RenderManager.drawRoundedRectVaried(vg, x + 980, y + 14, 12, 14, colorBottom, 0f, 0f, 6f, 6f);
- NanoVG.nvgTranslate(vg, x + 991, y + 25);
- NanoVG.nvgRotate(vg, (float) Math.toRadians(180));
- RenderManager.drawImage(vg, Images.UP_ARROW, 0, 0, 10, 10);
- NanoVG.nvgResetTransform(vg);
- NanoVG.nvgGlobalAlpha(vg, 1f);
if (currentAsNum != prevAsNum) {
try {
@@ -172,6 +139,8 @@ public class ConfigSlider extends BasicOption {
}
}
+
+
@Override
public boolean hasHalfSize() {
return false;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
index 94ed127..66dece5 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
@@ -6,7 +6,7 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.utils.InputUtils;
-import cc.polyfrost.oneconfig.gui.elements.TextInputField;
+import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import java.awt.*;
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
new file mode 100644
index 0000000..0e28a90
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java
@@ -0,0 +1,119 @@
+package cc.polyfrost.oneconfig.gui.elements.text;
+
+import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.gui.elements.BasicElement;
+import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.lwjgl.image.Images;
+import cc.polyfrost.oneconfig.utils.ColorUtils;
+import org.lwjgl.nanovg.NanoVG;
+
+public class NumberInputField extends TextInputField {
+ private final BasicElement upArrow = new BasicElement(12, 14, false);
+ private final BasicElement downArrow = new BasicElement(12, 14, false);
+ private float min;
+ private float max;
+ private float step;
+ private int colorTop, colorBottom;
+ private float current;
+
+ public NumberInputField(int width, int height, float defaultValue, float min, float max, float step) {
+ super(width - 16, height, true, "");
+ super.onlyNums = true;
+ this.min = min;
+ this.max = max;
+ this.step = step;
+ this.input = String.format("%.01f", defaultValue);
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ super.errored = false;
+ RenderManager.drawRoundedRect(vg, x + width + 4, y, 12, 28, OneConfigConfig.GRAY_500, 6f);
+ upArrow.update(x + width + 4, y);
+ downArrow.update(x + width + 4, y + 14);
+ try {
+ current = Float.parseFloat(input);
+ if (current < min || current > max) {
+ super.errored = true;
+ } else {
+ upArrow.disable(false);
+ downArrow.disable(false);
+ }
+ if (current == max) colorTop = OneConfigConfig.GRAY_500_80;
+ if (current == min) colorBottom = OneConfigConfig.GRAY_500_80;
+
+ colorTop = ColorUtils.getColor(colorTop, 2, upArrow.isHovered(), upArrow.isClicked());
+ colorBottom = ColorUtils.getColor(colorBottom, 2, downArrow.isHovered(), downArrow.isClicked());
+ if (upArrow.isClicked()) {
+ current += step;
+ if (current > max) current = max;
+ setCurrentValue(current);
+ }
+ if (downArrow.isClicked()) {
+ current -= step;
+ if(current < min) current = min;
+ setCurrentValue(current);
+ }
+ if (current >= max) {
+ NanoVG.nvgGlobalAlpha(vg, 0.3f);
+ upArrow.disable(true);
+ }
+ RenderManager.drawRoundedRectVaried(vg, x + width + 4, y, 12, 14, colorTop, 6f, 6f, 0f, 0f);
+ RenderManager.drawImage(vg, Images.UP_ARROW, x + width + 5, y + 2, 10, 10);
+ if (current >= max) NanoVG.nvgGlobalAlpha(vg, 1f);
+
+ if (current <= min) {
+ NanoVG.nvgGlobalAlpha(vg, 0.3f);
+ downArrow.disable(true);
+ }
+ RenderManager.drawRoundedRectVaried(vg, x + width + 4, y + 14, 12, 14, colorBottom, 0f, 0f, 6f, 6f);
+ NanoVG.nvgTranslate(vg, x + width + 15, y + 25);
+ NanoVG.nvgRotate(vg, (float) Math.toRadians(180));
+ RenderManager.drawImage(vg, Images.UP_ARROW, 0, 0, 10, 10);
+ NanoVG.nvgResetTransform(vg);
+ NanoVG.nvgGlobalAlpha(vg, 1f);
+
+ } catch (Exception e) {
+ super.errored = true;
+ }
+ try {
+ super.draw(vg, x, y - 2);
+ } catch (Exception e) {
+ setCurrentValue(current);
+ super.caretPos = 0;
+ super.prevCaret = 0;
+ }
+ }
+
+
+ public float getCurrentValue() {
+ return current;
+ }
+
+ public void setCurrentValue(float value) {
+ input = String.format("%.01f", value);
+ }
+
+ @Override
+ public void onClose() {
+ try {
+ if (current < min) current = min;
+ if (current > max) current = max;
+ setCurrentValue(current);
+ } catch (Exception ignored) {
+
+ }
+ }
+
+ public void setStep(float step) {
+ this.step = step;
+ }
+
+ public void setMax(float max) {
+ this.max = max;
+ }
+
+ public void setMin(float min) {
+ this.min = min;
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/SearchField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/SearchField.java
index 6f460d6..af7b6e1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/SearchField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/SearchField.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.gui.elements;
+package cc.polyfrost.oneconfig.gui.elements.text;
public class SearchField extends TextInputField {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
index 196c447..6983ae8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
@@ -1,6 +1,7 @@
-package cc.polyfrost.oneconfig.gui.elements;
+package cc.polyfrost.oneconfig.gui.elements.text;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
@@ -42,10 +43,9 @@ public class TextInputField extends BasicElement {
this.input = "";
}
- public TextInputField(int width, int height, boolean centered, boolean onlyNums, String defaultText) {
+ public TextInputField(int width, int height, boolean centered, String defaultText) {
this(width, height, defaultText, false, false);
this.centered = centered;
- this.onlyNums = onlyNums;
}
public void onlyAcceptNumbers(boolean state) {
@@ -91,6 +91,7 @@ public class TextInputField extends BasicElement {
RenderManager.drawHollowRoundRect(vg, x, y, width, height, colorOutline, 12f, 2f);
super.update(x, y);
if (Mouse.isButtonDown(0) && !InputUtils.isAreaHovered(x - 40, y - 20, width + 90, height + 20)) {
+ onClose();
toggled = false;
}
int color = toggled ? OneConfigConfig.WHITE : OneConfigConfig.WHITE_60;
@@ -317,6 +318,7 @@ public class TextInputField extends BasicElement {
if (key == Keyboard.KEY_RETURN) {
+ onClose();
toggled = false;
if (start != 0f && end != 0f) {
start = 0f;
@@ -324,6 +326,7 @@ public class TextInputField extends BasicElement {
}
}
if (key == Keyboard.KEY_END) {
+ onClose();
toggled = false;
}
@@ -404,6 +407,10 @@ public class TextInputField extends BasicElement {
return 0;
}
+ public void onClose() {
+
+ }
+
private float getTextWidth(long vg, String s) {
if (password) {
StringBuilder s1 = new StringBuilder();