aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-10 20:19:07 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-10 20:19:07 +0100
commitcefe13f6c232ed5ca2d458b896a76df2ee25a8a3 (patch)
treed64f34e2ee55124ce9c3469fea9333d94ccfb23f /src/main/java/cc/polyfrost
parentb5a1aea2239b0beace4d4407d2ab75294c6eab12 (diff)
parent3872c0ae8746e69671ac9b44ff94dc3c7b194817 (diff)
downloadOneConfig-cefe13f6c232ed5ca2d458b896a76df2ee25a8a3.tar.gz
OneConfig-cefe13f6c232ed5ca2d458b896a76df2ee25a8a3.tar.bz2
OneConfig-cefe13f6c232ed5ca2d458b896a76df2ee25a8a3.zip
reduce dependency on minecraft + stuff
Diffstat (limited to 'src/main/java/cc/polyfrost')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/OneConfig.java19
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/ConfigPage.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java7
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java118
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java24
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java29
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java36
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java30
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java7
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java109
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java7
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java21
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java91
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java6
20 files changed, 380 insertions, 166 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
index 25866e8..e8121d6 100644
--- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
@@ -5,14 +5,14 @@ import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
-import cc.polyfrost.oneconfig.lwjgl.BlurHandler;
-import cc.polyfrost.oneconfig.lwjgl.OneColor;
-import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.hud.HudCore;
+import cc.polyfrost.oneconfig.lwjgl.BlurHandler;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.test.TestConfig;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ScaledResolution;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader;
@@ -78,4 +78,17 @@ public class OneConfig {
if (modData.add(newMod)) loadedMods.add(newMod); // anti duplicate fix
}
}
+
+ public static int[] getScaledResolution() {
+ ScaledResolution resolution = new ScaledResolution(mc);
+ return new int[]{resolution.getScaledWidth(), resolution.getScaledHeight()};
+ }
+
+ public static int getDisplayWidth() {
+ return mc.displayWidth;
+ }
+
+ public static int getDisplayHeight() {
+ return mc.displayHeight;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
index e6a91d9..eccaf01 100644
--- a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
+++ b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
@@ -2,9 +2,9 @@ package cc.polyfrost.oneconfig.command;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.HudGui;
+import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.test.TestNanoVGGui;
import cc.polyfrost.oneconfig.utils.TickDelay;
-import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
@@ -13,8 +13,6 @@ import java.util.List;
public class OneConfigCommand extends CommandBase {
- private static final Minecraft mc = Minecraft.getMinecraft();
-
@Override
public String getCommandName() {
return "oneconfig";
@@ -35,14 +33,14 @@ public class OneConfigCommand extends CommandBase {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if (args.length == 0) new TickDelay(() -> mc.displayGuiScreen(OneConfigGui.create()), 1);
+ if (args.length == 0) new TickDelay(() -> RenderManager.displayGuiScreen(OneConfigGui.create()), 1);
else {
switch (args[0]) {
case "hud":
- new TickDelay(() -> mc.displayGuiScreen(new HudGui()), 1);
+ new TickDelay(() -> RenderManager.displayGuiScreen(new HudGui()), 1);
break;
case "lwjgl":
- new TickDelay(() -> mc.displayGuiScreen(new TestNanoVGGui()), 1);
+ new TickDelay(() -> RenderManager.displayGuiScreen(new TestNanoVGGui()), 1);
break;
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/ConfigPage.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/ConfigPage.java
index f9d7c19..432d65c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/ConfigPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/ConfigPage.java
@@ -29,4 +29,9 @@ public @interface ConfigPage {
* The category of the page
*/
String category() default "General";
+
+ /**
+ * The subcategory of the page
+ */
+ String subcategory() default "";
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java
index d5e9fc7..efcadc8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java
@@ -29,7 +29,7 @@ public @interface Option {
/**
* The subcategory of the component (displayed as header)
*/
- String subcategory();
+ String subcategory() default "";
/**
* The width of the option (1 = half width, 2 = full width)
@@ -82,4 +82,9 @@ public @interface Option {
* Option for info option type
*/
InfoType infoType() default InfoType.INFO;
+
+ /**
+ * Text displayed inside button
+ */
+ String buttonText() default "Activate";
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java
index 14111f4..363cfda 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java
@@ -7,7 +7,5 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
public class OptionCategory {
- public final LinkedHashMap<String, ArrayList<BasicOption>> subcategories = new LinkedHashMap<>();
- public final ArrayList<ConfigPageButton> topPages = new ArrayList<>();
- public final ArrayList<ConfigPageButton> bottomPages = new ArrayList<>();
+ public final ArrayList<OptionSubcategory> subcategories = new ArrayList<>();
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java
new file mode 100644
index 0000000..cdd9c51
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java
@@ -0,0 +1,118 @@
+package cc.polyfrost.oneconfig.config.data;
+
+import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
+import cc.polyfrost.oneconfig.gui.OneConfigGui;
+import cc.polyfrost.oneconfig.gui.elements.config.ConfigPageButton;
+import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+import java.util.ArrayList;
+
+public class OptionSubcategory {
+ private final String name;
+ public ArrayList<BasicOption> options = new ArrayList<>();
+ public ArrayList<ConfigPageButton> topButtons = new ArrayList<>();
+ public ArrayList<ConfigPageButton> bottomButtons = new ArrayList<>();
+
+ public OptionSubcategory(String name) {
+ this.name = name;
+ }
+
+ public int draw(long vg, int x, int y) {
+ String filter = OneConfigGui.INSTANCE == null ? "" : OneConfigGui.INSTANCE.getSearchValue().toLowerCase().trim();
+ ArrayList<BasicOption> filteredOptions = new ArrayList<>(options);
+ ArrayList<ConfigPageButton> filteredTop = new ArrayList<>(topButtons);
+ ArrayList<ConfigPageButton> filteredBottom = new ArrayList<>(bottomButtons);
+ if (!filter.equals("") && !name.toLowerCase().contains(filter)) {
+ filteredOptions.clear();
+ filteredTop.clear();
+ filteredBottom.clear();
+ for (BasicOption option : options) {
+ if (option.getName().toLowerCase().contains(filter)) filteredOptions.add(option);
+ }
+ for (ConfigPageButton page : topButtons) {
+ if (page.getName().toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
+ filteredTop.add(page);
+ }
+ for (ConfigPageButton page : bottomButtons) {
+ if (page.getName().toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
+ filteredBottom.add(page);
+ }
+ }
+ if (filteredOptions.size() == 0 && filteredTop.size() == 0 && filteredBottom.size() == 0) return 0;
+ int optionY = y;
+ if (!name.equals("")) {
+ RenderManager.drawString(vg, name, x, y + 12, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM);
+ optionY += 36;
+ }
+
+ for (ConfigPageButton page : filteredTop) {
+ page.draw(vg, x, optionY);
+ optionY += page.getHeight() + 16;
+ }
+
+ if (filteredOptions.size() > 0) {
+ int backgroundSize = 16;
+ for (int i = 0; i < filteredOptions.size(); i++) {
+ BasicOption option = filteredOptions.get(i);
+ if (i + 1 < filteredOptions.size()) {
+ BasicOption nextOption = filteredOptions.get(i + 1);
+ if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
+ backgroundSize += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
+ i++;
+ continue;
+ }
+ }
+ backgroundSize += option.getHeight() + 16;
+ }
+ RenderManager.drawRoundedRect(vg, x - 16, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20);
+ optionY += 16;
+ }
+
+ int drawLastY = optionY;
+ if (filteredOptions.size() > 0) {
+ for (int i = 0; i < filteredOptions.size(); i++) {
+ BasicOption option = filteredOptions.get(i);
+ option.draw(vg, x, optionY);
+ if (i + 1 < filteredOptions.size()) {
+ BasicOption nextOption = filteredOptions.get(i + 1);
+ if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
+ nextOption.draw(vg, x + 512, optionY);
+ optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
+ i++;
+ continue;
+ }
+ }
+ optionY += option.getHeight() + 16;
+ }
+ optionY += 16;
+ }
+
+ for (ConfigPageButton page : filteredBottom) {
+ page.draw(vg, x, optionY);
+ optionY += page.getHeight() + 16;
+ }
+
+ for (int i = 0; i < filteredOptions.size(); i++) {
+ BasicOption option = filteredOptions.get(i);
+ option.drawLast(vg, x, drawLastY);
+ if (i + 1 < filteredOptions.size()) {
+ BasicOption nextOption = filteredOptions.get(i + 1);
+ if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
+ nextOption.drawLast(vg, x + 512, drawLastY);
+ drawLastY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
+ i++;
+ continue;
+ }
+ }
+ drawLastY += option.getHeight() + 16;
+ }
+
+ return optionY - y;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java
index a9b9a6a..6fe5733 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java
@@ -36,11 +36,15 @@ public enum OptionType {
DROPDOWN,
//MULTI_DROPDOWN,
/**
- * Type: String
+ * Type: doesn't matter
*/
INFO,
/**
- * Type: class that extends BasicHud
+ * Type: doesn't matter
+ */
+ HEADER,
+ /**
+ * Type: runnable
*/
- HUD
+ BUTTON
}
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 756d3c3..9eecc52 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
@@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.OptionCategory;
import cc.polyfrost.oneconfig.config.data.OptionPage;
+import cc.polyfrost.oneconfig.config.data.OptionSubcategory;
import cc.polyfrost.oneconfig.config.profiles.Profiles;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.config.*;
@@ -84,6 +85,10 @@ public class Config {
ConfigPage option = field.getAnnotation(ConfigPage.class);
if (!page.categories.containsKey(option.category()))
page.categories.put(option.category(), new OptionCategory());
+ OptionCategory category = page.categories.get(option.category());
+ if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(option.subcategory()))
+ category.subcategories.add(new OptionSubcategory(option.subcategory()));
+ OptionSubcategory subcategory = category.subcategories.get(category.subcategories.size() - 1);
OptionPage newPage = new OptionPage(option.name(), mod);
try {
field.setAccessible(true);
@@ -91,10 +96,10 @@ public class Config {
generateOptionList(object.getClass(), newPage, mod);
switch (option.location()) {
case TOP:
- page.categories.get(option.category()).topPages.add(new ConfigPageButton(field, option.name(), option.description(), newPage));
+ subcategory.topButtons.add(new ConfigPageButton(field, option.name(), option.description(), newPage));
break;
case BOTTOM:
- page.categories.get(option.category()).bottomPages.add(new ConfigPageButton(field, option.name(), option.description(), newPage));
+ subcategory.bottomButtons.add(new ConfigPageButton(field, option.name(), option.description(), newPage));
break;
}
} catch (IllegalAccessException e) {
@@ -105,9 +110,10 @@ public class Config {
Option option = field.getAnnotation(Option.class);
if (!page.categories.containsKey(option.category()))
page.categories.put(option.category(), new OptionCategory());
- if (!page.categories.get(option.category()).subcategories.containsKey(option.subcategory()))
- page.categories.get(option.category()).subcategories.put(option.subcategory(), new ArrayList<>());
- ArrayList<BasicOption> options = page.categories.get(option.category()).subcategories.get(option.subcategory());
+ OptionCategory category = page.categories.get(option.category());
+ if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(option.subcategory()))
+ category.subcategories.add(new OptionSubcategory(option.subcategory()));
+ ArrayList<BasicOption> options = category.subcategories.get(category.subcategories.size() - 1).options;
switch (option.type()) {
case SWITCH:
options.add(new ConfigSwitch(field, option.name(), option.size()));
@@ -136,6 +142,12 @@ public class Config {
case COLOR:
options.add(new ConfigColorElement(field, option.name(), option.size()));
break;
+ case HEADER:
+ options.add(new ConfigHeader(field, option.name(), option.size()));
+ break;
+ case BUTTON:
+ options.add(new ConfigButton(field, option.name(), option.size(), option.buttonText()));
+ break;
}
}
}
@@ -172,7 +184,7 @@ public class Config {
Object object = adapter.fromJsonTree(value);
field.setAccessible(true);
field.set(this, object);
- } catch (NoSuchFieldException | IllegalAccessException ignored) {
+ } catch (Exception ignored) {
}
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
index a67c1d1..5465652 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
@@ -3,7 +3,6 @@ package cc.polyfrost.oneconfig.gui;
import cc.polyfrost.oneconfig.hud.HudCore;
import cc.polyfrost.oneconfig.hud.BasicHud;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
-import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Keyboard;
@@ -26,7 +25,7 @@ public class HudGui extends GuiScreen {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- Gui.drawRect(0, 0, this.width, this.height, new Color(80, 80, 80, 50).getRGB());
+ RenderManager.drawGlRect(0, 0, this.width, this.height, new Color(80, 80, 80, 50).getRGB());
if (isDragging) {
setPosition(mouseX - xOffset, mouseY - yOffset, true);
@@ -67,7 +66,7 @@ public class HudGui extends GuiScreen {
if (editingHud == hud) {
color = new Color(43, 159, 235).getRGB();
if (isDragging)
- Gui.drawRect(x, y, x + width, y + height, new Color(108, 176, 255, 60).getRGB());
+ RenderManager.drawGlRect(x, y, width, height, new Color(108, 176, 255, 60).getRGB());
}
int finalColor = color;
RenderManager.setupAndDraw(true, (vg) -> {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 45d92b7..ae70758 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -1,5 +1,6 @@
package cc.polyfrost.oneconfig.gui;
+import cc.polyfrost.oneconfig.OneConfig;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
@@ -14,14 +15,12 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.MathUtils;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
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.util.ArrayList;
public class OneConfigGui extends GuiScreen {
@@ -71,7 +70,7 @@ public class OneConfigGui extends GuiScreen {
currentPage = new HomePage();
parents.add(currentPage);
}
- scale = Minecraft.getMinecraft().displayWidth / 1920f;
+ scale = OneConfig.getDisplayWidth() / 1920f;
NanoVG.nvgScale(vg, scale, scale);
if (OneConfigConfig.ROUNDED_CORNERS) {
RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index 1850367..bec14b1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -20,14 +20,16 @@ public class SideBar {
public SideBar() {
btnList.add(new BasicButton(192, 36, "Dashboard", Images.DASHBOARD, null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage()));
btnList.add(new BasicButton(192, 36, "Global Search", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Screenshots", Images.SCREENSHOT, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Preferences", Images.PREFERENCES, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Mods", Images.MODS, null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage()));
btnList.add(new BasicButton(192, 36, "Performance", Images.PERFORMANCE, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Profiles", Images.PROFILES, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Updates", Images.UPDATES, null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Theme", Images.THEMES, null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Screenshots", Images.SCREENSHOT, null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "HUD Settings", Images.HUD_SETTINGS, null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Preferences", Images.PREFERENCES, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Themes Library", Images.THEMES, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Themes Browser", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Packs Library", Images.MOD_BOX, null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Packs Browser", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Close", Images.CLOSE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> RenderManager.displayGuiScreen(null)));
btnList.add(new BasicButton(192, 36, "Minimize", Images.MINIMIZE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> {
OneConfigGui.instanceToRestore = OneConfigGui.INSTANCE;
@@ -37,8 +39,6 @@ public class SideBar {
}
public void draw(long vg, int x, int y) {
- //percentMove = 36f;
-
currentY = MathUtils.easeInOutCirc(50, currentY, targetY - currentY, 120);
RenderManager.drawRoundedRect(vg, x + 16, currentY, 192, 36, OneConfigConfig.BLUE_600, OneConfigConfig.CORNER_RADIUS);
int i = 0;
@@ -48,16 +48,17 @@ public class SideBar {
}
for (BasicButton btn : btnList) {
btn.draw(vg, x + 16, y + 96 + i);
- i += 44;
- if (i == 88) { // +88
- RenderManager.drawString(vg, "MOD CONFIG", x + 16, y + 200, OneConfigConfig.WHITE_90, 12f, Fonts.SEMIBOLD);
- i = 122;
+ if (i >= 562) i += 44;
+ else i += 36;
+ if (i == 144) {
+ RenderManager.drawString(vg, "MOD CONFIG", x + 16, y + 266, OneConfigConfig.WHITE_90, 12f, Fonts.SEMIBOLD);
+ i = 180;
}
- if (i == 298) {
- RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 420, OneConfigConfig.WHITE_90, 12f, Fonts.SEMIBOLD);
- i = 342;
+ if (i == 324) {
+ RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 446, OneConfigConfig.WHITE_90, 12f, Fonts.SEMIBOLD);
+ i = 360;
}
- if (i == 518) {
+ if (i == 504) {
i = 562;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
index 48a6218..8d2ad16 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -12,7 +12,6 @@ import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.utils.ColorUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
import net.minecraft.client.Minecraft;
-import net.minecraft.command.CommandException;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.ModMetadata;
import org.jetbrains.annotations.NotNull;
@@ -109,7 +108,7 @@ public class ModCard extends BasicElement {
if (possibleCommands.contains(command)) {
try {
ClientCommandHandler.instance.getCommands().get(command).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{});
- } catch (CommandException e) {
+ } catch (Exception e) {
throw new RuntimeException(e);
}
break;
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
new file mode 100644
index 0000000..fdb0157
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
@@ -0,0 +1,36 @@
+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.BasicButton;
+import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+import java.lang.reflect.Field;
+
+public class ConfigButton extends BasicOption {
+ private final BasicButton button;
+
+ public ConfigButton(Field field, String name, int size, String text) {
+ super(field, name, size);
+ Runnable runnable = () -> {
+ };
+ try {
+ runnable = (Runnable) get();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, null, null, 1, BasicButton.ALIGNMENT_CENTER, runnable);
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM);
+ button.draw(vg, x + (size == 1 ? 352 : 736), y);
+ }
+
+ @Override
+ public int getHeight() {
+ return 32;
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
new file mode 100644
index 0000000..3ef3d06
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
@@ -0,0 +1,30 @@
+package cc.polyfrost.oneconfig.gui.elements.config;
+
+import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
+import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
+
+import java.lang.reflect.Field;
+
+public class ConfigHeader extends BasicOption {
+
+ public ConfigHeader(Field field, String name, int size) {
+ super(field, name, size);
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 480 : 992, 32);
+ RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM);
+ ScissorManager.resetScissor(vg, scissor);
+ }
+
+
+ @Override
+ public int getHeight() {
+ return 32;
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
index dbca002..349e7af 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
@@ -8,7 +8,6 @@ import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.utils.InputUtils;
import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.util.ChatAllowedCharacters;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -344,7 +343,7 @@ public class TextInputField extends BasicElement {
if (!Character.isDefined(key)) return;
if (!Character.isDefined(c)) return;
if (GuiScreen.isCtrlKeyDown()) return;
- if (ChatAllowedCharacters.isAllowedCharacter(c)) {
+ if (isAllowedCharacter(c)) {
if (selectedText != null) {
if (caretPos > prevCaret) {
input = input.substring(0, prevCaret) + input.substring(prevCaret, caretPos);
@@ -426,4 +425,8 @@ public class TextInputField extends BasicElement {
return RenderManager.getTextWidth(vg, s, 14.0f, Fonts.REGULAR);
}
}
+
+ public static boolean isAllowedCharacter(char character) {
+ return character != 167 && character >= ' ' && character != 127;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
index 790d0e4..797f573 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -2,6 +2,7 @@ package cc.polyfrost.oneconfig.gui.pages;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.config.data.OptionPage;
+import cc.polyfrost.oneconfig.config.data.OptionSubcategory;
import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
@@ -39,109 +40,11 @@ public class ModConfigPage extends Page {
@Override
public void draw(long vg, int x, int y) {
if (page.categories.size() == 0) return;
- String filter = OneConfigGui.INSTANCE == null ? "" : OneConfigGui.INSTANCE.getSearchValue().toLowerCase().trim();
- LinkedHashMap<String, ArrayList<BasicOption>> filteredSubcategories = new LinkedHashMap<>(page.categories.get(selectedCategory).subcategories);
- if (!filter.equals("")) {
- filteredSubcategories.clear();
- for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) {
- if (subCategory.toLowerCase().contains(filter)) {
- filteredSubcategories.put(subCategory, page.categories.get(selectedCategory).subcategories.get(subCategory));
- continue;
- }
- for (BasicOption option : page.categories.get(selectedCategory).subcategories.get(subCategory)) {
- if (!option.getName().toLowerCase().contains(filter)) continue;
- if (!filteredSubcategories.containsKey(subCategory))
- filteredSubcategories.put(subCategory, new ArrayList<>());
- filteredSubcategories.get(subCategory).add(option);
- }
- }
- }
- int optionX = x + 30;
int optionY = y + (page.categories.size() == 1 ? 16 : 64);
-
- // Top page buttons
- for (ConfigPageButton page : page.categories.get(selectedCategory).topPages) {
- if (!page.getName().toLowerCase().contains(filter) && !page.description.toLowerCase().contains(filter))
- continue;
- page.draw(vg, optionX, optionY);
- optionY += page.getHeight() + 16;
- }
-
- // Background
- if (filteredSubcategories.keySet().size() > 0) {
- int backgroundSize = 16;
- for (String subCategory : filteredSubcategories.keySet()) {
- backgroundSize += 48;
- for (int i = 0; i < filteredSubcategories.get(subCategory).size(); i++) {
- BasicOption option = filteredSubcategories.get(subCategory).get(i);
- if (i + 1 < filteredSubcategories.get(subCategory).size()) {
- BasicOption nextOption = filteredSubcategories.get(subCategory).get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
- backgroundSize += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
- i++;
- continue;
- }
- }
- backgroundSize += option.getHeight() + 16;
- }
- }
- RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20);
- }
-
- // draw options
- int optionLastY = optionY + 16;
- if (filteredSubcategories.keySet().size() > 0) {
- optionY += 16;
- for (String subCategory : filteredSubcategories.keySet()) {
- RenderManager.drawString(vg, subCategory, optionX, optionY + 16, OneConfigConfig.WHITE_90, 24f, Fonts.MEDIUM);
- optionY += 48;
- for (int i = 0; i < filteredSubcategories.get(subCategory).size(); i++) {
- BasicOption option = filteredSubcategories.get(subCategory).get(i);
- option.draw(vg, optionX, optionY);
- if (i + 1 < filteredSubcategories.get(subCategory).size()) {
- BasicOption nextOption = filteredSubcategories.get(subCategory).get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
- nextOption.draw(vg, optionX + 512, optionY);
- optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
- i++;
- continue;
- }
- }
- optionY += option.getHeight() + 16;
- }
- }
- optionY += 16;
- }
-
- // Bottom page buttons
- for (ConfigPageButton page : page.categories.get(selectedCategory).bottomPages) {
- if (!page.getName().toLowerCase().contains(filter) && !page.description.toLowerCase().contains(filter))
- continue;
- page.draw(vg, optionX, optionY);
- optionY += page.getHeight() + 16;
+ for (OptionSubcategory subCategory : page.categories.get(selectedCategory).subcategories) {
+ optionY += subCategory.draw(vg, x + 30, optionY);
}
totalSize = optionY - y;
-
- // Draw last options
- if (filteredSubcategories.keySet().size() > 0) {
- for (String subCategory : filteredSubcategories.keySet()) {
- optionLastY += 48;
- for (int i = 0; i < filteredSubcategories.get(subCategory).size(); i++) {
- BasicOption option = filteredSubcategories.get(subCategory).get(i);
- option.drawLast(vg, optionX, optionLastY);
- if (i + 1 < filteredSubcategories.get(subCategory).size()) {
- BasicOption nextOption = filteredSubcategories.get(subCategory).get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
- nextOption.drawLast(vg, optionX + 512, optionLastY);
- optionLastY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
- i++;
- continue;
- }
- }
- optionLastY += option.getHeight() + 16;
- }
- }
- }
}
@Override
@@ -166,9 +69,9 @@ public class ModConfigPage extends Page {
@Override
public void keyTyped(char key, int keyCode) {
if (page.categories.size() == 0) return;
- for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) {
- for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) {
- page.categories.get(selectedCategory).subcategories.get(subCategory).get(i).keyTyped(key, keyCode);
+ for (OptionSubcategory subCategory : page.categories.get(selectedCategory).subcategories) {
+ for (BasicOption option : subCategory.options) {
+ option.keyTyped(key, keyCode);
}
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java b/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java
index 60ade17..50303be 100644
--- a/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java
+++ b/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java
@@ -1,7 +1,6 @@
package cc.polyfrost.oneconfig.hud;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.ScaledResolution;
+import cc.polyfrost.oneconfig.OneConfig;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -14,9 +13,9 @@ public class HudCore {
@SubscribeEvent
public void onRender(RenderGameOverlayEvent.Post event) {
if (event.type != RenderGameOverlayEvent.ElementType.ALL || editing) return;
- ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ int[] sr = OneConfig.getScaledResolution();
for (BasicHud hud : huds) {
- hud.drawAll(hud.getXScaled(sr.getScaledWidth()), hud.getYScaled(sr.getScaledHeight()), hud.scale, true);
+ hud.drawAll(hud.getXScaled(sr[0]), hud.getYScaled(sr[1]), hud.scale, true);
}
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
index 297fcfc..2600075 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -7,14 +7,15 @@ import cc.polyfrost.oneconfig.lwjgl.image.Image;
import cc.polyfrost.oneconfig.lwjgl.image.ImageLoader;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import org.lwjgl.nanovg.NVGColor;
import org.lwjgl.nanovg.NVGPaint;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL14;
import java.awt.*;
import java.util.function.LongConsumer;
@@ -74,7 +75,7 @@ public final class RenderManager {
}
}
-
+ // Can be removed or atleast marked out since it is no longer used - MoonTidez
public static void drawGradientRoundedRect(long vg, float x, float y, float width, float height, int color, int color2, float radius) {
NVGPaint bg = NVGPaint.create();
nvgBeginPath(vg);
@@ -88,13 +89,12 @@ public final class RenderManager {
}
public static void drawHSBBox(long vg, float x, float y, float width, float height, int colorTarget) {
-
drawRoundedRect(vg, x, y, width, height, colorTarget, 8f);
NVGPaint bg = NVGPaint.create();
nvgBeginPath(vg);
nvgRoundedRect(vg, x, y, width, height, 8f);
- NVGColor nvgColor = color(vg, OneConfigConfig.WHITE);
+ NVGColor nvgColor = color(vg, OneConfigConfig.WHITE); // Do not use OneConfigConfig colors for this, use rgba code - MoonTidez
NVGColor nvgColor2 = color(vg, OneConfigConfig.TRANSPARENT_25);
nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x + width, y, nvgColor, nvgColor2, bg));
nvgFill(vg);
@@ -105,16 +105,14 @@ public final class RenderManager {
nvgBeginPath(vg);
nvgRoundedRect(vg, x, y, width, height, 8f);
NVGColor nvgColor3 = color(vg, OneConfigConfig.TRANSPARENT_25);
- NVGColor nvgColor4 = color(vg, OneConfigConfig.BLACK);
+ NVGColor nvgColor4 = color(vg, OneConfigConfig.BLACK); // Do not use OneConfigConfig colors for this, use rgba code - MoonTidez
nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x, y + height, nvgColor3, nvgColor4, bg2));
nvgFill(vg);
nvgColor3.free();
nvgColor4.free();
-
- //drawHollowRoundRect(vg, x - 0.5f, y - 0.5f, width, height, new Color(77,77,77,255).getRGB(), 8f, 1f);
-
}
+ /*
public static void drawGradientRect(long vg, float x, float y, float width, float height, int color, int color2) {
NVGPaint bg = NVGPaint.create();
nvgBeginPath(vg);
@@ -127,6 +125,7 @@ public final class RenderManager {
nvgColor.free();
nvgColor2.free();
}
+ */
public static void drawRect(long vg, float x, float y, float width, float height, int color) {
nvgBeginPath(vg);
@@ -336,7 +335,7 @@ public final class RenderManager {
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA);
- OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+ GL14.glBlendFuncSeparate(770, 771, 1, 0); // this should never fail because it's a GL14 call, and we import GL31
glColor(color);
GL11.glLineWidth(width);
GL11.glBegin(GL11.GL_LINES);
@@ -351,6 +350,10 @@ public final class RenderManager {
GL11.glPopMatrix();
}
+ public static void drawGlRect(int x, int y, int width, int height, int color) {
+ Gui.drawRect(x, y, x + width, y + height, color);
+ }
+
// other minecraft functions
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
index a741865..d314354 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
@@ -5,6 +5,7 @@ import cc.polyfrost.oneconfig.config.annotations.Option;
import cc.polyfrost.oneconfig.config.data.*;
import cc.polyfrost.oneconfig.config.interfaces.Config;
import cc.polyfrost.oneconfig.lwjgl.OneColor;
+import net.minecraftforge.fml.common.FMLCommonHandler;
public class TestConfig extends Config {
@@ -18,6 +19,23 @@ public class TestConfig extends Config {
public static boolean ignored;
@Option(
+ name = "Crash game",
+ subcategory = "Test",
+ type = OptionType.BUTTON,
+ buttonText = "Crash!"
+ )
+ public static Runnable runnable = () -> FMLCommonHandler.instance().exitJava(69, false);
+
+ @Option(
+ name = "Crash game",
+ subcategory = "Test",
+ type = OptionType.BUTTON,
+ size = 2,
+ buttonText = "Crash!"
+ )
+ public static Runnable runnable2 = () -> FMLCommonHandler.instance().exitJava(69, false);
+
+ @Option(
name = "Test color selector",
subcategory = "Test",
type = OptionType.COLOR,
@@ -195,6 +213,7 @@ public class TestConfig extends Config {
max = 25
)
public static int slider1;
+
@Option(
name = "Stepped Slider",
subcategory = "Sliders",
@@ -207,8 +226,78 @@ public class TestConfig extends Config {
)
public static float slider2;
+ @Option(
+ name = "Slider",
+ type = OptionType.SLIDER,
+ category = "subcategory test",
+ min = 5,
+ max = 3287
+ )
+ public static float slider = 26;
+
+ @Option(
+ name = "Slider",
+ type = OptionType.SLIDER,
+ category = "subcategory test",
+ min = 5,
+ max = 3287
+ )
+ public static float slider10 = 26;
+
+ @Option(
+ name = "Slider",
+ type = OptionType.SLIDER,
+ category = "subcategory test",
+ min = 5,
+ max = 3287,
+ subcategory = "Second subcategory"
+ )
+ public static float slider11 = 26;
+
+ @Option(
+ name = "Header Test",
+ type = OptionType.HEADER,
+ category = "subcategory test",
+ subcategory = "Second subcategory",
+ size = 2
+ )
+ public static boolean somethingHere;
+
+
+ @Option(
+ name = "Slider",
+ type = OptionType.SLIDER,
+ category = "subcategory test",
+ min = 5,
+ max = 3287,
+ subcategory = "Second subcategory"
+ )
+ public static float slider12 = 26;
+
+ @ConfigPage(
+ name = "Test page",
+ location = PageLocation.TOP,
+ category = "subcategory test",
+ subcategory = "Second subcategory"
+ )
+ public static TestPage testPage23 = new TestPage();
- TestHud testHud = new TestHud();
+ @ConfigPage(
+ name = "Test page",
+ location = PageLocation.BOTTOM,
+ category = "subcategory test",
+ subcategory = "Second subcategory"
+ )
+ public static TestPage testPage24 = new TestPage();
+
+ @Option(
+ name = "Slider",
+ type = OptionType.SLIDER,
+ category = "subcategory test",
+ min = 5,
+ max = 3287
+ )
+ public static float slider13 = 26;
public TestConfig() {
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
index 7f2e5d2..80f5175 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
@@ -1,7 +1,7 @@
package cc.polyfrost.oneconfig.utils;
+import cc.polyfrost.oneconfig.OneConfig;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
-import net.minecraft.client.Minecraft;
import org.lwjgl.input.Mouse;
public class InputUtils {
@@ -30,7 +30,7 @@ public class InputUtils {
}
public static int mouseY() {
- if (OneConfigGui.INSTANCE == null) return Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY());
- return (int) ((Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY())) / OneConfigGui.INSTANCE.getScaleFactor());
+ if (OneConfigGui.INSTANCE == null) return OneConfig.getDisplayHeight() - Math.abs(Mouse.getY());
+ return (int) ((OneConfig.getDisplayHeight() - Math.abs(Mouse.getY())) / OneConfigGui.INSTANCE.getScaleFactor());
}
}