aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/OneConfig.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java11
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java2
-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/ConfigDropdown.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java2
-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/config/ConfigUniSelector.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java18
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java20
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java10
21 files changed, 85 insertions, 63 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
index 2dcb8fe..eced81e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
@@ -54,7 +54,7 @@ public class OneConfig {
MinecraftForge.EVENT_BUS.register(new HudCore());
RenderManager.setupAndDraw((vg) -> {
RenderManager.drawRoundedRect(vg, -100, -100, 50, 50, -1, 12f);
- RenderManager.drawString(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.MEDIUM);
RenderManager.drawImage(vg, Images.LOGO, -100, -100, 50, 50);
});
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 380f89a..88bf59b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -3,7 +3,6 @@ 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.text.NumberInputField;
import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.gui.pages.HomePage;
import cc.polyfrost.oneconfig.gui.pages.Page;
@@ -69,8 +68,8 @@ public class OneConfigGui extends GuiScreen {
RenderManager.drawLine(vg, 544, 140, 544, 940, 1, OneConfigConfig.GRAY_700);
RenderManager.drawImage(vg, Images.LOGO, x + 19, y + 19, 42, 42);
- 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.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.BOLD); // added half line height to center text
+ RenderManager.drawString(vg, "ALPHA - By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.REGULAR);
//RenderManager.drawRect(vg, x + 300, y + 500, 400, 12, OneConfigConfig.ERROR_700);
@@ -140,12 +139,12 @@ public class OneConfigGui extends GuiScreen {
float breadcrumbX = x + 336;
for (int i = 0; i < parents.size(); i++) {
String title = parents.get(i).getTitle();
- float width = RenderManager.getTextWidth(vg, title, 24f, Fonts.INTER_SEMIBOLD);
+ float width = RenderManager.getTextWidth(vg, title, 24f, Fonts.SEMIBOLD);
boolean hovered = InputUtils.isAreaHovered((int) breadcrumbX, y + 24, (int) width, 36);
int color = OneConfigConfig.WHITE_60;
if (i == parents.size() - 1) color = OneConfigConfig.WHITE_95;
else if (hovered && !Mouse.isButtonDown(0)) color = OneConfigConfig.WHITE_80;
- RenderManager.drawString(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.INTER_SEMIBOLD);
+ RenderManager.drawString(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.SEMIBOLD);
if (i != 0)
RenderManager.drawImage(vg, Images.CHEVRON_ARROW, breadcrumbX - 22, y + 26, 13, 22, color);
if (hovered && i != parents.size() - 1)
@@ -156,7 +155,7 @@ public class OneConfigGui extends GuiScreen {
long end = System.nanoTime() - start;
String s = (" draw: " + end / 1000000f + "ms");
- RenderManager.drawString(vg, s, x + 1170, y + 790, OneConfigConfig.GRAY_300, 10f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, s, x + 1170, y + 790, OneConfigConfig.GRAY_300, 10f, Fonts.MEDIUM);
});
mouseDown = Mouse.isButtonDown(0);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index 73f46f7..4d506ba 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -48,11 +48,11 @@ public class SideBar {
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.INTER_SEMIBOLD);
+ RenderManager.drawString(vg, "MOD CONFIG", x + 16, y + 200, OneConfigConfig.WHITE_90, 12f, Fonts.SEMIBOLD);
i = 122;
}
if (i == 298) {
- RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 420, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_SEMIBOLD);
+ RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 420, OneConfigConfig.WHITE_90, 12f, Fonts.SEMIBOLD);
i = 342;
}
if (i == 518) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
index faf0b07..c76e029 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -75,7 +75,7 @@ public class BasicButton extends BasicElement {
this.y = y;
int textColor = -1;
RenderManager.drawRectangle(vg, x, y, this.width, this.height, this.currentColor);
- float contentWidth = RenderManager.getTextWidth(vg, text, fontSize, Fonts.INTER_MEDIUM);
+ float contentWidth = RenderManager.getTextWidth(vg, text, fontSize, Fonts.MEDIUM);
if (fileNameLeftIco != null) {
contentWidth += 28;
}
@@ -92,7 +92,7 @@ public class BasicButton extends BasicElement {
if (thisAlignment == ALIGNMENT_CENTER) {
int middle = x + this.width / 2;
- RenderManager.drawString(vg, text, middle - contentWidth / 2 + (fileNameLeftIco != null ? 28 : 0), y + ((float) height / 2) + 1, textColor, fontSize, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, text, middle - contentWidth / 2 + (fileNameLeftIco != null ? 28 : 0), y + ((float) height / 2) + 1, textColor, fontSize, Fonts.MEDIUM);
if (fileNameLeftIco != null) {
RenderManager.drawImage(vg, fileNameLeftIco, middle - contentWidth / 2, y + 8, 20, 20);
}
@@ -103,9 +103,9 @@ public class BasicButton extends BasicElement {
if (thisAlignment == ALIGNMENT_LEFT) {
if (fileNameLeftIco != null) {
RenderManager.drawImage(vg, fileNameLeftIco, x + 12, y + 8, 20, 20, textColor);
- RenderManager.drawString(vg, text, x + 40, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, text, x + 40, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.MEDIUM);
} else {
- RenderManager.drawString(vg, text, x + 12, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, text, x + 12, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.MEDIUM);
}
if (fileNameRightIco != null) {
RenderManager.drawImage(vg, fileNameRightIco, x + width - 28, y + 8, 20, 20);
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 4fe1524..fb9f40a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -55,7 +55,7 @@ public class ModCard extends BasicElement {
favoriteHitbox.currentColor = ColorUtils.getColor(favoriteHitbox.currentColor, favoriteHitbox.colorPalette, favoriteHitbox.hovered, favoriteHitbox.clicked);
RenderManager.drawRoundedRectVaried(vg, x + 212, y + 87, 32, 32, favoriteHitbox.currentColor, 0f, 0f, 12f, 0f);
favorite = favoriteHitbox.isToggled();
- RenderManager.drawString(vg, modData.name, x + 12, y + 103, OneConfigConfig.WHITE, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, modData.name, x + 12, y + 103, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM);
if (favorite) {
RenderManager.drawImage(vg, Images.FAVORITE, x + 220, y + 95, 16, 16);
} else {
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 990ce07..4dc4d72 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
@@ -44,7 +44,7 @@ public class ConfigCheckbox extends BasicOption {
RenderManager.drawHollowRoundRect(vg, x, y + 4, 23.5f, 23.5f, OneConfigConfig.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok
}
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.INTER_MEDIUM);
+ 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) {
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 a5c82e2..ce683bf 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
@@ -39,7 +39,7 @@ public class ConfigColorElement extends BasicOption {
@Override
public void draw(long vg, int x, int y) {
- RenderManager.drawString(vg, name, x, y + 15, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x, y + 15, OneConfigConfig.WHITE_90, 18f, Fonts.MEDIUM);
hexField.draw(vg, x + 240, y);
if (!alphaField.isToggled()) alphaField.setInput(String.format("%.01f", alpha * 100f) + "%");
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 c867409..b46d2eb 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,7 +28,7 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers
@Override
public void draw(long vg, int x, int y) {
- RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM);
+ 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);
@@ -50,13 +50,13 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers
if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f);
if (size == 1) {
RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor, 12);
- RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM);
RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8);
RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 459, y + 8, 10, 6);
NanoVG.nvgTranslate(vg, x + 469, y + 24);
} else {
RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor, 12);
- RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM);
RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8);
RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 971, y + 8, 10, 6);
NanoVG.nvgTranslate(vg, x + 981, y + 24);
@@ -85,7 +85,7 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers
if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f);
if (size == 1) {
RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor, 12);
- RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM);
NanoVG.nvgGlobalAlpha(vg, 1f);
RenderManager.drawRoundedRect(vg, x + 224, y + 40, 256, options.length * 32 + 4, OneConfigConfig.GRAY_700, 12);
@@ -108,7 +108,7 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers
opened = false;
}
- RenderManager.drawString(vg, option, x + 240, optionY + 4, color, 14, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, option, x + 240, optionY + 4, color, 14, Fonts.MEDIUM);
if (!options[options.length - 1].equals(option))
RenderManager.drawLine(vg, x + 232, optionY + 18, x + 472, optionY + 18, 1, new Color(204, 204, 204, 77).getRGB());
optionY += 32;
@@ -120,7 +120,7 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers
NanoVG.nvgTranslate(vg, x + 469, y + 24);
} else {
RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor, 12);
- RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM);
RenderManager.drawRoundedRect(vg, x + 352, y + 40, 640, options.length * 32 + 4, OneConfigConfig.GRAY_700, 12);
RenderManager.drawHollowRoundRect(vg, x + 352, y + 40, 640, options.length * 32 + 4, new Color(204, 204, 204, 77).getRGB(), 8, 1);
@@ -135,7 +135,7 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers
color = OneConfigConfig.WHITE;
}
- RenderManager.drawString(vg, option, x + 368, optionY + 4, color, 14, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, option, x + 368, optionY + 4, color, 14, Fonts.MEDIUM);
if (!options[options.length - 1].equals(option))
RenderManager.drawLine(vg, x + 360, optionY + 18, x + 984, optionY + 18, 1, new Color(204, 204, 204, 77).getRGB());
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 ed908b6..30bd9b7 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
@@ -32,12 +32,12 @@ public class ConfigDualOption extends BasicOption {
toggled = (boolean) get();
} catch (IllegalAccessException ignored) {
}
- RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM);
+ 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));
RenderManager.drawRoundedRect(vg, x1, y + 2, 124, 28, OneConfigConfig.BLUE_600, 10f);
- RenderManager.drawString(vg, left, x + 290 - RenderManager.getTextWidth(vg, left, 12f, Fonts.INTER_MEDIUM) / 2, y + 17, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM);
- RenderManager.drawString(vg, right, x + 418 - RenderManager.getTextWidth(vg, right, 12f, Fonts.INTER_MEDIUM) / 2, y + 17, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM);
+ 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)) {
toggled = !toggled;
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 81e1dd0..bb95ab5 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
@@ -36,9 +36,9 @@ public class ConfigPageButton extends BasicOption {
if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f);
RenderManager.drawRoundedRect(vg, x - 16, y, 1024, height, backgroundColor, 20);
- RenderManager.drawString(vg, name, x + 10, y + 32, OneConfigConfig.WHITE_90, 24, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x + 10, y + 32, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM);
if (!description.equals(""))
- RenderManager.drawString(vg, name, x + 10, y + 70, OneConfigConfig.WHITE_90, 14, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x + 10, y + 70, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM);
RenderManager.drawImage(vg, Images.CHEVRON_ARROW, x + 981f, y + (description.equals("") ? 20f : 36f), 13, 22);
if (clicked) OneConfigGui.INSTANCE.openPage(new ModConfigPage(page));
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 adbfb8d..531f18a 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
@@ -61,7 +61,7 @@ public class ConfigSlider extends BasicOption {
}
if (!inputField.isToggled()) inputField.setCurrentValue(value);
- RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM);
RenderManager.drawRoundedRect(vg, x + 352, y + 13, 512, 6, OneConfigConfig.GRAY_300, 4f);
RenderManager.drawRoundedRect(vg, x + 352, y + 13, xCoordinate - x - 352, 6, OneConfigConfig.BLUE_500, 4f);
if (step > 0) {
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 01e2f14..cb57121 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
@@ -33,7 +33,7 @@ public class ConfigSwitch extends BasicOption {
}
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.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x + 50, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM);
if (InputUtils.isAreaClicked(x, y, 42, 32)) {
toggled = !toggled;
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 66dece5..45048c7 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
@@ -25,7 +25,7 @@ public class ConfigTextBox extends BasicOption {
@Override
public void draw(long vg, int x, int y) {
- RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM);
try {
String value = (String) get();
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 5fad0a4..77a68ad 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
@@ -36,15 +36,15 @@ public class ConfigUniSelector extends BasicOption {
} catch (IllegalAccessException ignored) {
}
String option = options[selected] + " " + (selected + 1) + "/" + options.length;
- RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM);
Scissor scissor = ScissorManager.scissor(vg, x + 256, y, 192, 32);
if (previous == -1) {
- RenderManager.drawString(vg, option, x + 352 - RenderManager.getTextWidth(vg, option, 12f, Fonts.INTER_MEDIUM) / 2f, y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, option, x + 352 - RenderManager.getTextWidth(vg, option, 12f, Fonts.MEDIUM) / 2f, y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.MEDIUM);
} else {
String prevOption = options[previous] + " " + (previous + 1) + "/" + options.length;
- RenderManager.drawString(vg, selected < previous ? prevOption : option, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? prevOption : option, 12f, Fonts.INTER_MEDIUM) / 2f + 192 * percentMove, y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM);
- RenderManager.drawString(vg, selected < previous ? option : prevOption, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? option : prevOption, 12f, Fonts.INTER_MEDIUM) / 2f - 192 * (1 - percentMove), y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, selected < previous ? prevOption : option, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? prevOption : option, 12f, Fonts.MEDIUM) / 2f + 192 * percentMove, y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.MEDIUM);
+ RenderManager.drawString(vg, selected < previous ? option : prevOption, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? option : prevOption, 12f, Fonts.MEDIUM) / 2f - 192 * (1 - percentMove), y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.MEDIUM);
}
ScissorManager.resetScissor(vg, scissor);
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 2ad851b..02ebe86 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
@@ -100,12 +100,12 @@ public class TextInputField extends BasicElement {
float width;
StringBuilder s = new StringBuilder();
if (!password) {
- width = RenderManager.getTextWidth(vg, input.substring(0, caretPos), 14f, Fonts.INTER_REGULAR);
+ width = RenderManager.getTextWidth(vg, input.substring(0, caretPos), 14f, Fonts.REGULAR);
} else {
for (int i = 0; i < input.length(); i++) {
s.append("*");
}
- width = RenderManager.getTextWidth(vg, s.substring(0, caretPos), 14f, Fonts.INTER_REGULAR);
+ width = RenderManager.getTextWidth(vg, s.substring(0, caretPos), 14f, Fonts.REGULAR);
}
if (hovered) {
while (Mouse.next()) {
@@ -169,20 +169,20 @@ public class TextInputField extends BasicElement {
if (input.equals("")) {
if (!centered) {
- RenderManager.drawString(vg, defaultText, x + 12, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
+ RenderManager.drawString(vg, defaultText, x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR);
} else {
- RenderManager.drawString(vg, defaultText, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
+ RenderManager.drawString(vg, defaultText, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.REGULAR);
}
}
if (!password) {
if (!centered) {
- RenderManager.drawString(vg, input, x + 12, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
+ RenderManager.drawString(vg, input, x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR);
} else {
- RenderManager.drawString(vg, input, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
+ RenderManager.drawString(vg, input, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.REGULAR);
}
} else {
- RenderManager.drawString(vg, s.toString(), x + 12, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR);
+ RenderManager.drawString(vg, s.toString(), x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR);
}
ScissorManager.resetScissor(vg, scissor);
} catch (Exception e) {
@@ -418,9 +418,9 @@ public class TextInputField extends BasicElement {
while (s1.length() < s.length()) {
s1.append('*');
}
- return RenderManager.getTextWidth(vg, s1.toString(), 14.0f, Fonts.INTER_REGULAR);
+ return RenderManager.getTextWidth(vg, s1.toString(), 14.0f, Fonts.REGULAR);
} else {
- return RenderManager.getTextWidth(vg, s, 14.0f, Fonts.INTER_REGULAR);
+ return RenderManager.getTextWidth(vg, s, 14.0f, Fonts.REGULAR);
}
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
index 83e095c..d07f515 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -15,7 +15,7 @@ public class HomePage extends Page {
public void draw(long vg, int x, int y) {
RenderManager.drawRoundedRect(vg, x, y, 184, 36, -1, 12f);
- RenderManager.drawString(vg, "This is a cool string to test pages", x + 32, y + 72, -1, 36f, Fonts.INTER_BOLD);
+ RenderManager.drawString(vg, "This is a cool string to test pages", x + 32, y + 72, -1, 36f, Fonts.BOLD);
RenderManager.drawRoundedRect(vg, x + 350, y + 310, 300, 200, OneConfigConfig.BLUE_600, 14f);
//RenderManager.drawRoundedRect(vg);
btn.draw(vg, x + 432, y + 658);
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 acd01a1..b529778 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -9,7 +9,6 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import java.util.ArrayList;
-import java.util.HashMap;
public class ModConfigPage extends Page {
private final OptionPage page;
@@ -71,7 +70,7 @@ public class ModConfigPage extends Page {
if (page.categories.get(selectedCategory).subcategories.keySet().size() > 0) {
optionY += 16;
for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) {
- RenderManager.drawString(vg, subCategory, optionX, optionY + 16, OneConfigConfig.WHITE_90, 24f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, subCategory, optionX, optionY + 16, OneConfigConfig.WHITE_90, 24f, Fonts.MEDIUM);
optionY += 48;
for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) {
BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i);
@@ -127,7 +126,7 @@ public class ModConfigPage extends Page {
int buttonX = x + 16;
for (BasicButton button : categories) {
if (button.getWidth() == 0)
- button.setWidth((int) (Math.ceil(RenderManager.getTextWidth(vg, button.getText(), 14f, Fonts.INTER_MEDIUM) / 8f) * 8 + 16));
+ button.setWidth((int) (Math.ceil(RenderManager.getTextWidth(vg, button.getText(), 14f, Fonts.MEDIUM) / 8f) * 8 + 16));
button.draw(vg, buttonX, y + 16);
buttonX += button.getWidth() + 16;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
index bb9cbd6..fc20d35 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -58,7 +58,7 @@ public class ModsPage extends Page {
}
}
if (iX == x + 16 && iY == y + 72) {
- RenderManager.drawString(vg, "Looks like there is nothing here. Try another category?", x + 16, y + 72, OneConfigConfig.WHITE_60, 14f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, "Looks like there is nothing here. Try another category?", x + 16, y + 72, OneConfigConfig.WHITE_60, 14f, Fonts.MEDIUM);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
index 94a2650..4d5df83 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.lwjgl;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.lwjgl.font.Font;
import cc.polyfrost.oneconfig.lwjgl.font.FontManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Image;
@@ -14,8 +15,14 @@ import org.lwjgl.nanovg.NVGColor;
import org.lwjgl.nanovg.NVGPaint;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
+import sun.font.Font2D;
+import sun.font.FontManagerFactory;
+import sun.font.StrikeMetrics;
+import sun.font.TrueTypeFont;
import java.awt.*;
+import java.io.File;
+import java.util.Arrays;
import java.util.function.LongConsumer;
import static org.lwjgl.nanovg.NanoVG.*;
@@ -145,16 +152,15 @@ public final class RenderManager {
nvgColor.free();
}
- public static float fontSizeToNVGFontSize(float fontSize) {
- int dpi = 72;
- float pixelsPerFUnit = (fontSize * dpi) / (72f * 2816f);
- return 2728f * pixelsPerFUnit - (-680 * pixelsPerFUnit);
+ public static float fontSizeToNVGFontSize(float fontSize, Font font) {
+ float pixelsPerFUnit = (fontSize * 72f) / (72f * font.getUnitsPerEm());
+ return font.getAscender() * pixelsPerFUnit - (font.getDescender() * pixelsPerFUnit);
}
public static void drawString(long vg, String text, float x, float y, int color, float size, Fonts font) {
nvgBeginPath(vg);
- nvgFontSize(vg, fontSizeToNVGFontSize(size));
+ nvgFontSize(vg, fontSizeToNVGFontSize(size, font.font));
nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
NVGColor nvgColor = color(vg, color);
@@ -165,7 +171,7 @@ public final class RenderManager {
public static void drawString(long vg, String text, float x, float y, int color, float size, int lineHeight, Fonts font) {
nvgBeginPath(vg);
- nvgFontSize(vg, fontSizeToNVGFontSize(size));
+ nvgFontSize(vg, fontSizeToNVGFontSize(size, font.font));
nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
nvgTextMetrics(vg, new float[]{10f}, new float[]{10f}, new float[]{lineHeight});
@@ -177,7 +183,7 @@ public final class RenderManager {
public static void drawWrappedString(long vg, String text, float x, float y, float width, int color, float size, Fonts font) {
nvgBeginPath(vg);
- nvgFontSize(vg, fontSizeToNVGFontSize(size));
+ nvgFontSize(vg, fontSizeToNVGFontSize(size, font.font));
nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
NVGColor nvgColor = color(vg, color);
@@ -224,7 +230,7 @@ public final class RenderManager {
public static float getTextWidth(long vg, String text, float fontSize, Fonts font) {
float[] bounds = new float[4];
- nvgFontSize(vg, fontSizeToNVGFontSize(fontSize));
+ nvgFontSize(vg, fontSizeToNVGFontSize(fontSize, font.font));
nvgFontFace(vg, font.font.getName());
return nvgTextBounds(vg, 0, 0, text, bounds);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java
index 970c073..649252b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java
@@ -7,10 +7,16 @@ public class Font {
private final String name;
private boolean loaded = false;
private ByteBuffer buffer = null;
+ private final int unitsPerEm;
+ private final int ascender;
+ private final int descender;
- public Font(String name, String fileName) {
+ public Font(String name, String fileName, int unitsPerEm, int ascender, int descender) {
this.name = name;
this.fileName = fileName;
+ this.unitsPerEm = unitsPerEm;
+ this.ascender = ascender;
+ this.descender = descender;
}
public String getName() {
@@ -36,4 +42,16 @@ public class Font {
void setBuffer(ByteBuffer buffer) {
this.buffer = buffer;
}
+
+ public int getUnitsPerEm() {
+ return unitsPerEm;
+ }
+
+ public int getAscender() {
+ return ascender;
+ }
+
+ public int getDescender() {
+ return descender;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java
index aef639c..d2b94f0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java
@@ -1,11 +1,11 @@
package cc.polyfrost.oneconfig.lwjgl.font;
public enum Fonts {
- INTER_BOLD(new Font("inter-bold", "/assets/oneconfig/font/Inter-Bold.otf")),
- 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"));
+ // https://opentype.js.org/font-inspector.html
+ BOLD(new Font("inter-bold", "/assets/oneconfig/font/Bold.otf", 2816, 2728, -680)),
+ SEMIBOLD(new Font("inter-semibold", "/assets/oneconfig/font/SemiBold.otf", 2816, 2728, -68)),
+ MEDIUM(new Font("inter-medium", "/assets/oneconfig/font/Medium.otf", 2816, 2728, -680)),
+ REGULAR(new Font("inter-regular", "/assets/oneconfig/font/Regular.otf", 2816, 2728, -680));
public final Font font;