aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-11 20:11:42 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-11 20:11:42 +0200
commit174dcbf96f4715fe52a21ca8592d5d71b6fa4a8b (patch)
tree514d5bfbf20de70822d577e5a47ec47850d6d8e7 /src/main/java/cc/polyfrost/oneconfig
parent671a9bbad56f7760536058d2c364c0b9ff2f9e52 (diff)
downloadOneConfig-174dcbf96f4715fe52a21ca8592d5d71b6fa4a8b.tar.gz
OneConfig-174dcbf96f4715fe52a21ca8592d5d71b6fa4a8b.tar.bz2
OneConfig-174dcbf96f4715fe52a21ca8592d5d71b6fa4a8b.zip
disabling
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java29
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java4
13 files changed, 76 insertions, 21 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
index 38e0366..c036408 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
@@ -1,12 +1,14 @@
package cc.polyfrost.oneconfig.config.interfaces;
import java.lang.reflect.Field;
+import java.util.function.Supplier;
@SuppressWarnings({"unused"})
public abstract class BasicOption {
protected final Field field;
protected final String name;
public final int size;
+ private Supplier<Boolean> dependency;
/**
* Initialize option
@@ -82,4 +84,12 @@ public abstract class BasicOption {
public String getName() {
return name;
}
+
+ public void setDependency(Supplier<Boolean> supplier) {
+ this.dependency = supplier;
+ }
+
+ protected boolean isEnabled() {
+ return dependency == null || dependency.get();
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
index 32853f8..9524723 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
@@ -19,15 +19,14 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
+import java.util.function.Supplier;
public class Config {
transient protected final String configFile;
transient protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().create();
transient private Mod mod;
+ final transient private HashMap<String, BasicOption> optionNames = new HashMap<>();
public boolean enabled = true;
/**
@@ -78,6 +77,7 @@ public class Config {
*/
protected void generateOptionList(Class<?> clazz, OptionPage page, Mod mod) {
for (Field field : clazz.getDeclaredFields()) {
+ String pagePrefix = page.equals(mod.defaultPage) ? "" : page.name + ".";
if (!field.isAnnotationPresent(Option.class) && !field.isAnnotationPresent(ConfigPage.class)) {
processCustomOption(field, page);
continue;
@@ -94,16 +94,17 @@ public class Config {
field.setAccessible(true);
Object object = field.get(clazz);
generateOptionList(object.getClass(), newPage, mod);
+ ConfigPageButton configPageButton = new ConfigPageButton(field, option.name(), option.description(), newPage);
switch (option.location()) {
case TOP:
- subcategory.topButtons.add(new ConfigPageButton(field, option.name(), option.description(), newPage));
+ subcategory.topButtons.add(configPageButton);
break;
case BOTTOM:
- subcategory.bottomButtons.add(new ConfigPageButton(field, option.name(), option.description(), newPage));
+ subcategory.bottomButtons.add(configPageButton);
break;
}
- } catch (IllegalAccessException e) {
- continue;
+ optionNames.put(pagePrefix + field.getName(), configPageButton);
+ } catch (IllegalAccessException ignored) {
}
continue;
}
@@ -152,6 +153,7 @@ public class Config {
options.add(new ConfigKeyBind(field, option.name(), option.size()));
break;
}
+ optionNames.put(pagePrefix + field.getName(), options.get(options.size() - 1));
}
}
@@ -199,4 +201,15 @@ public class Config {
if (mod == null) return;
RenderManager.displayGuiScreen(new OneConfigGui(new ModConfigPage(mod.defaultPage)));
}
+
+ /**
+ * Disable an option if a certain condition is not met
+ *
+ * @param option The name of the field, or if the field is in a page "pageName.fieldName"
+ * @param condition The condition that has to be met for the option to be enabled
+ */
+ protected void addDependency(String option, Supplier<Boolean> condition) {
+ if (!optionNames.containsKey(option)) return;
+ optionNames.get(option).setDependency(condition);
+ }
}
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 fdb0157..643bc90 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
@@ -5,6 +5,7 @@ import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
+import org.lwjgl.nanovg.NanoVG;
import java.lang.reflect.Field;
@@ -25,8 +26,11 @@ public class ConfigButton extends BasicOption {
@Override
public void draw(long vg, int x, int y) {
+ button.disable(!isEnabled());
+ NanoVG.nvgGlobalAlpha(vg, 0.5f);
RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM);
button.draw(vg, x + (size == 1 ? 352 : 736), y);
+ NanoVG.nvgGlobalAlpha(vg, 1f);
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
index 4dc4d72..a1c8b9c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
@@ -8,6 +8,7 @@ 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 org.lwjgl.nanovg.NanoVG;
import java.awt.*;
import java.lang.reflect.Field;
@@ -22,6 +23,7 @@ public class ConfigCheckbox extends BasicOption {
@Override
public void draw(long vg, int x, int y) {
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
boolean toggled = false;
try {
toggled = (boolean) get();
@@ -30,7 +32,7 @@ public class ConfigCheckbox extends BasicOption {
boolean hover = InputUtils.isAreaHovered(x, y + 4, 24, 24);
boolean clicked = InputUtils.isClicked() && hover;
- if (clicked) {
+ if (clicked && isEnabled()) {
toggled = !toggled;
try {
set(toggled);
@@ -46,12 +48,12 @@ public class ConfigCheckbox extends BasicOption {
color = ColorUtils.smoothColor(color, OneConfigConfig.GRAY_600, OneConfigConfig.GRAY_400, hover, 40f);
RenderManager.drawString(vg, name, x + 32, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM);
percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 5f));
- if (percentOn == 0f) return;
- if (percentOn != 1f) {
+ if (percentOn != 0 && percentOn != 1f) {
RenderManager.drawImage(vg, Images.CHECKMARK, x, y + 4, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB());
- } else { // performance, that color could cause havoc am I right definitely
+ } else if (percentOn != 0) {
RenderManager.drawImage(vg, Images.CHECKMARK, x, y + 4, 24, 24);
}
+ NanoVG.nvgGlobalAlpha(vg, 1f);
}
@Override
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 64753d2..2805fd4 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
@@ -28,11 +28,12 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers
@Override
public void draw(long vg, int x, int y) {
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM);
boolean hovered;
- if (size == 1) hovered = InputUtils.isAreaHovered(x + 224, y, 256, 32);
- else hovered = InputUtils.isAreaHovered(x + 352, y, 640, 32);
+ if (size == 1) hovered = InputUtils.isAreaHovered(x + 224, y, 256, 32) && isEnabled();
+ else hovered = InputUtils.isAreaHovered(x + 352, y, 640, 32) && isEnabled();
if (hovered && InputUtils.isClicked() || opened && InputUtils.isClicked() &&
(size == 1 && !InputUtils.isAreaHovered(x + 224, y + 40, 256, options.length * 32 + 4) ||
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 30bd9b7..c05a370 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
@@ -6,6 +6,7 @@ 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 org.lwjgl.nanovg.NanoVG;
import java.lang.reflect.Field;
@@ -32,6 +33,7 @@ public class ConfigDualOption extends BasicOption {
toggled = (boolean) get();
} catch (IllegalAccessException ignored) {
}
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM);
RenderManager.drawRoundedRect(vg, x + 226, y, 256, 32, OneConfigConfig.GRAY_500, 12f);
int x1 = (int) (x + 228 + (percentMove * 128));
@@ -39,7 +41,8 @@ public class ConfigDualOption extends BasicOption {
RenderManager.drawString(vg, left, x + 290 - RenderManager.getTextWidth(vg, left, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE_90, 12f, Fonts.MEDIUM);
RenderManager.drawString(vg, right, x + 418 - RenderManager.getTextWidth(vg, right, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE_90, 12f, Fonts.MEDIUM);
- if (InputUtils.isAreaClicked(x + 226, y, 256, 32)) {
+ NanoVG.nvgGlobalAlpha(vg, 1);
+ if (InputUtils.isAreaClicked(x + 226, y, 256, 32) && isEnabled()) {
toggled = !toggled;
try {
set(toggled);
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 809143f..476e58d 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
@@ -9,6 +9,7 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import org.lwjgl.input.Keyboard;
+import org.lwjgl.nanovg.NanoVG;
import java.lang.reflect.Field;
@@ -24,9 +25,11 @@ public class ConfigKeyBind extends BasicOption {
@Override
public void draw(long vg, int x, int y) {
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM);
OneKeyBind keyBind = getKeyBind();
String text = keyBind.getDisplay();
+ button.disable(!isEnabled());
if (button.isToggled()) {
if (text.equals("")) text = "Recording... (ESC to clear)";
if (!clicked) {
@@ -43,6 +46,7 @@ public class ConfigKeyBind extends BasicOption {
} else if (text.equals("")) text = "None";
button.setText(text);
button.draw(vg, x + (size == 1 ? 224 : 736), y);
+ NanoVG.nvgGlobalAlpha(vg, 1f);
}
@Override
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 bb95ab5..42f7568 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
@@ -29,11 +29,12 @@ public class ConfigPageButton extends BasicOption {
@Override
public void draw(long vg, int x, int y) {
int height = description.equals("") ? 64 : 96;
- boolean hovered = InputUtils.isAreaHovered(x - 2, y, 1024, height);
- boolean clicked = InputUtils.isAreaClicked(x - 2, y, 1024, height);
+ boolean hovered = InputUtils.isAreaHovered(x - 2, y, 1024, height) && isEnabled();
+ boolean clicked = hovered && InputUtils.isClicked();
backgroundColor = ColorUtils.smoothColor(backgroundColor, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, hovered, 100);
if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f);
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
RenderManager.drawRoundedRect(vg, x - 16, y, 1024, height, backgroundColor, 20);
RenderManager.drawString(vg, name, x + 10, y + 32, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM);
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 d44c33f..3a4253c 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
@@ -8,6 +8,7 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.MathUtils;
import org.lwjgl.input.Mouse;
+import org.lwjgl.nanovg.NanoVG;
import java.lang.reflect.Field;
@@ -30,7 +31,8 @@ public class ConfigSlider extends BasicOption {
public void draw(long vg, int x, int y) {
int xCoordinate = 0;
float value = 0;
- boolean hovered = InputUtils.isAreaHovered(x + 352, y, 512, 32);
+ boolean hovered = InputUtils.isAreaHovered(x + 352, y, 512, 32) && isEnabled();
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
if (hovered && Mouse.isButtonDown(0)) dragging = true;
if (dragging) {
xCoordinate = (int) MathUtils.clamp(InputUtils.mouseX(), x + 352, x + 864);
@@ -73,6 +75,7 @@ public class ConfigSlider extends BasicOption {
if (step == 0) RenderManager.drawRoundedRect(vg, xCoordinate - 12, y + 4, 24, 24, OneConfigConfig.WHITE, 12f);
else RenderManager.drawRoundedRect(vg, xCoordinate - 4, y + 4, 8, 24, OneConfigConfig.WHITE, 4f);
inputField.draw(vg, x + 892, y);
+ NanoVG.nvgGlobalAlpha(vg, 1f);
}
private int getStepCoordinate(int xCoordinate, int x) {
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 cb57121..3ce4693 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
@@ -7,6 +7,7 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.utils.ColorUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.MathUtils;
+import org.lwjgl.nanovg.NanoVG;
import java.lang.reflect.Field;
@@ -31,11 +32,12 @@ public class ConfigSwitch extends BasicOption {
if (color == -15123643) {
color = OneConfigConfig.GRAY_400;
}
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, color, 12f);
RenderManager.drawRoundedRect(vg, x2, y + 7, 18, 18, OneConfigConfig.WHITE, 9f);
RenderManager.drawString(vg, name, x + 50, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM);
- if (InputUtils.isAreaClicked(x, y, 42, 32)) {
+ if (InputUtils.isAreaClicked(x, y, 42, 32) && isEnabled()) {
toggled = !toggled;
try {
set(toggled);
@@ -45,6 +47,7 @@ public class ConfigSwitch extends BasicOption {
}
}
percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 10));
+ NanoVG.nvgGlobalAlpha(vg, 1f);
}
@Override
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 45048c7..1fb7c84 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
@@ -7,6 +7,7 @@ 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.text.TextInputField;
+import org.lwjgl.nanovg.NanoVG;
import java.awt.*;
import java.lang.reflect.Field;
@@ -25,6 +26,8 @@ public class ConfigTextBox extends BasicOption {
@Override
public void draw(long vg, int x, int y) {
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
+ textField.disable(!isEnabled());
RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM);
try {
@@ -38,10 +41,12 @@ public class ConfigTextBox extends BasicOption {
if (secure)
RenderManager.drawImage(vg, Images.HIDE_EYE, x + 967, y + 7, 18, 18, new Color(196, 196, 196).getRGB());
if (secure && InputUtils.isAreaClicked(x + 967, y + 7, 18, 18)) textField.setPassword(!textField.getPassword());
+ NanoVG.nvgGlobalAlpha(vg, 1f);
}
@Override
public void keyTyped(char key, int keyCode) {
+ if (!isEnabled()) return;
textField.keyTyped(key, keyCode);
try {
set(textField.getInput());
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
index d6acf52..e77357f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
@@ -35,6 +35,7 @@ public class ConfigUniSelector extends BasicOption {
selected = (int) get();
} catch (IllegalAccessException ignored) {
}
+ if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f);
String option = options[selected] + " " + (selected + 1) + "/" + options.length;
RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM);
@@ -51,7 +52,7 @@ public class ConfigUniSelector extends BasicOption {
RenderManager.drawImage(vg, Images.CHEVRON_ARROW, x + 248, y + 7, -8, 14, OneConfigConfig.BLUE_400);
RenderManager.drawImage(vg, Images.CHEVRON_ARROW, x + 456, y + 7, 8, 14, OneConfigConfig.BLUE_400);
- if (InputUtils.isAreaClicked(x + 235, y + 5, 18, 18) && selected > 0) {
+ if (InputUtils.isAreaClicked(x + 235, y + 5, 18, 18) && selected > 0 && isEnabled()) {
previous = selected;
selected -= 1;
try {
@@ -59,7 +60,7 @@ public class ConfigUniSelector extends BasicOption {
} catch (IllegalAccessException ignored) {
}
percentMove = selected < previous ? 0f : 1f;
- } else if (InputUtils.isAreaClicked(x + 451, y + 5, 18, 18) && selected < options.length - 1) {
+ } else if (InputUtils.isAreaClicked(x + 451, y + 5, 18, 18) && selected < options.length - 1 && isEnabled()) {
previous = selected;
selected += 1;
try {
@@ -70,5 +71,6 @@ public class ConfigUniSelector extends BasicOption {
}
if (previous != -1) percentMove = MathUtils.easeOut(percentMove, selected < previous ? 1f : 0f, 10);
if ((selected < previous ? 1f : 0f) == percentMove) previous = -1;
+ NanoVG.nvgGlobalAlpha(vg, 1f);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
index 439c51d..8dc2889 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
@@ -8,6 +8,8 @@ import cc.polyfrost.oneconfig.config.interfaces.Config;
import cc.polyfrost.oneconfig.lwjgl.OneColor;
import net.minecraftforge.fml.common.FMLCommonHandler;
+import java.lang.reflect.Field;
+
public class TestConfig extends Config {
@Option(
@@ -318,6 +320,8 @@ public class TestConfig extends Config {
public TestConfig() {
super(new Mod("hacks", ModType.UTIL_QOL, "ShadyDev", "1.0"), "hacksConfig.json");
+ addDependency("switchTest5", () -> switchTest4);
+ addDependency("Test page.testDescription", () -> false);
}
}