aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/polyfrost')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java53
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/SideBar.java14
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java28
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java18
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java37
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java14
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java21
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java38
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java19
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java18
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java12
-rw-r--r--src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java18
12 files changed, 244 insertions, 46 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
index 0879bd4..bc30257 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -1,15 +1,18 @@
package io.polyfrost.oneconfig.gui;
import io.polyfrost.oneconfig.config.OneConfigConfig;
-import io.polyfrost.oneconfig.gui.elements.BasicButton;
import io.polyfrost.oneconfig.gui.elements.BasicElement;
import io.polyfrost.oneconfig.gui.elements.TextInputField;
+import io.polyfrost.oneconfig.gui.pages.HomePage;
+import io.polyfrost.oneconfig.gui.pages.Page;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import io.polyfrost.oneconfig.utils.MathUtils;
import net.minecraft.client.gui.GuiScreen;
+import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Keyboard;
-import org.lwjgl.nanovg.NVGColor;
-import org.lwjgl.nanovg.NanoVG;
+
+import static org.lwjgl.nanovg.NanoVG.*;
public class OneConfigGui extends GuiScreen {
public static OneConfigGui INSTANCE;
@@ -20,8 +23,12 @@ public class OneConfigGui extends GuiScreen {
private final SideBar sideBar = new SideBar();
+ protected Page currentPage;
+ protected Page prevPage;
+ private float pageProgress = -224f;
+
private final TextInputField textInputField = new TextInputField(776, 32, "Search all of OneConfig...", false, false);
- private final BasicButton btn = new BasicButton(184, 36, "Socials", "/assets/oneconfig/textures/share.png", "/assets/oneconfig/textures/share2.png", 1, BasicButton.ALIGNMENT_CENTER);
+
public OneConfigGui() {
INSTANCE = this;
@@ -30,6 +37,8 @@ public class OneConfigGui extends GuiScreen {
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
RenderManager.setupAndDraw((vg) -> {
+ if(currentPage == null) currentPage = new HomePage();
+ //nvgScale(vg, 0.5f, 0.5f);
if(OneConfigConfig.ROUNDED_CORNERS) {
RenderManager.drawRoundedRect(vg, 544, 140, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN);
RenderManager.drawRoundedRect(vg, 320, 140, 244, 800, OneConfigConfig.GRAY_900_80, OneConfigConfig.CORNER_RADIUS_WIN);
@@ -43,17 +52,28 @@ public class OneConfigGui extends GuiScreen {
RenderManager.drawLine(vg, 544, 140, 544, 940, 1, OneConfigConfig.GRAY_700);
RenderManager.drawImage(vg, "/assets/oneconfig/textures/icon.png", x + 19, y + 19, 42, 42);
- RenderManager.drawString(vg, "OneConfig", x + 69, y + 23, OneConfigConfig.WHITE, 18f, Fonts.INTER_BOLD);
- RenderManager.drawString(vg, "By Polyfrost", 389, 183, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR);
+ RenderManager.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.INTER_BOLD); // added half line height to center text
+ RenderManager.drawString(vg, "By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR);
//element.setColorPalette(0);
- try {
- sideBar.draw(vg, x, y);
- //element.draw(vg, 0, 0);
- textInputField.draw(vg, 792, 548);
- btn.draw(vg, 976, 870);
- } catch (Exception e) {
- e.printStackTrace();
+ sideBar.draw(vg, x, y);
+ nvgScissor(vg, x + 224, y + 72, 1056, 728);
+ if(prevPage != null) {
+ pageProgress = MathUtils.easeInOutCirc(50, pageProgress, 832 - pageProgress, 220);
+ prevPage.draw(vg, (int) (x - pageProgress), y + 72);
+ RenderManager.drawLine(vg, (int) (x - pageProgress + 1055), y + 72, (int) (x - pageProgress + 1057), y + 800, 2, OneConfigConfig.GRAY_700); // TODO might remove this
+ currentPage.draw(vg, (int) (x - pageProgress + 1056), y + 72);
+ if(pageProgress > 828f) {
+ prevPage = null;
+ pageProgress = -224f;
+ }
+ } else {
+ currentPage.draw(vg, (int) (x - pageProgress), y + 72);
}
+ nvgResetScissor(vg);
+ RenderManager.drawString(vg, currentPage.getTitle(), x + 336, y + 36, OneConfigConfig.WHITE_90, 32f, Fonts.INTER_SEMIBOLD);
+
+ //textInputField.draw(vg, 792, 548);
+ //btn.draw(vg, 976, 870);
//RenderManager.drawGradientRoundedRect(vg, 100, 100, 500, 100, OneConfigConfig.BLUE_600, OneConfigConfig.BLUE_500, OneConfigConfig.CORNER_RADIUS_WIN);
@@ -70,6 +90,13 @@ public class OneConfigGui extends GuiScreen {
}
}
+ public void openPage(@NotNull Page page) {
+ if(prevPage == null) {
+ prevPage = currentPage;
+ }
+ currentPage = page;
+ }
+
@Override
public boolean doesGuiPauseGame() {
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
index 0b8659f..7f84049 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
@@ -2,6 +2,8 @@ package io.polyfrost.oneconfig.gui;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.gui.elements.BasicButton;
+import io.polyfrost.oneconfig.gui.pages.HomePage;
+import io.polyfrost.oneconfig.gui.pages.ModsPage;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.MathUtils;
@@ -15,17 +17,17 @@ public class SideBar {
private float targetY = 0, currentY = 0;
public SideBar() {
- btnList.add(new BasicButton(192, 36, "Dashboard", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Dashboard", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage()));
btnList.add(new BasicButton(192, 36, "Global Search", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Mods", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Mods", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage()));
btnList.add(new BasicButton(192, 36, "Performance", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Profiles", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Updates", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Screenshots", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "HUD Settings", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "General", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Close", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Minimize", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Close", "/assets/oneconfig/textures/share.png", null, -1, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Minimize", "/assets/oneconfig/textures/share.png", null, -1, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Edit HUD", "/assets/oneconfig/textures/share.png", null, 0, BasicButton.ALIGNMENT_LEFT));
}
@@ -36,7 +38,7 @@ public class SideBar {
RenderManager.drawRoundedRect(vg, x + 16, currentY, 192, 36, OneConfigConfig.BLUE_600, OneConfigConfig.CORNER_RADIUS);
int i = 0;
if (targetY == 0) {
- targetY = x + 16;
+ targetY = y + 96;
currentY = targetY;
}
for (BasicButton btn : btnList) {
@@ -55,7 +57,7 @@ public class SideBar {
}
if (btn.isClicked()) {
- targetY = btn.y;
+ if(i < 520) targetY = btn.y;
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
index 39d5e9c..1de952e 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -1,14 +1,14 @@
package io.polyfrost.oneconfig.gui.elements;
import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.gui.OneConfigGui;
+import io.polyfrost.oneconfig.gui.pages.Page;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.ColorUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import static org.lwjgl.nanovg.NanoVG.nvgTextBounds;
-
public class BasicButton extends BasicElement {
protected String text;
@@ -21,6 +21,10 @@ public class BasicButton extends BasicElement {
public static final int ALIGNMENT_LEFT = 0;
public static final int ALIGNMENT_CENTER = 1;
+ private boolean toggleable;
+
+ private Page page;
+
/**
* Create a new basic button. Used mostly on the homepage and the sidebar. Note: The button will not be drawn until you call {@link #draw(long, int, int)}.
* The button's content is centered on its total length, so the text is not always in the middle.
@@ -45,6 +49,17 @@ public class BasicButton extends BasicElement {
}
}
+ public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, Page page) {
+ this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment);
+ this.page = page;
+ }
+
+ public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, boolean toggleable) {
+ this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment);
+ this.toggleable = toggleable;
+ }
+
+
@Override
public void draw(long vg, int x, int y) {
@@ -94,9 +109,18 @@ public class BasicButton extends BasicElement {
return;
}
currentColor = ColorUtils.getColor(currentColor, colorPalette, hovered, clicked);
+ if(toggleable && toggled) {
+ currentColor = OneConfigConfig.BLUE_600;
+ }
}
}
+ @Override
+ public void onClick() {
+ if(this.page != null) {
+ OneConfigGui.INSTANCE.openPage(page);
+ }
+ }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java
index 765a271..68e25f6 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java
@@ -3,8 +3,13 @@ package io.polyfrost.oneconfig.gui.elements;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.utils.ColorUtils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.util.ChatComponentText;
import org.lwjgl.input.Mouse;
+import java.lang.reflect.Method;
+import java.util.function.Consumer;
+
public class BasicElement {
protected int width, height;
protected int colorPalette;
@@ -46,13 +51,20 @@ public class BasicElement {
int buttonBottom = y + height;
hovered = mouseX > x - hitBoxX && mouseY > y - hitBoxY && mouseX < buttonRight + hitBoxX && mouseY < buttonBottom + hitBoxY;
- if (Mouse.isButtonDown(0) && clicked) {
- toggled = !toggled;
+ if (hovered) {
+ if (Mouse.isButtonDown(0) && !clicked) {
+ toggled = !toggled;
+ onClick();
+ }
+ clicked = Mouse.isButtonDown(0);
}
- clicked = Mouse.isButtonDown(0) && hovered;
}
+ public void onClick() {
+
+ }
+
public void setCustomHitbox(int x, int y) {
hitBoxX = x;
hitBoxY = y;
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
new file mode 100644
index 0000000..dd4fe87
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -0,0 +1,37 @@
+package io.polyfrost.oneconfig.gui.elements;
+
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class ModCard extends BasicElement {
+ private final String modName, iconPath;
+ private boolean active, disabled, favorite;
+
+ public ModCard(@NotNull String modName, @Nullable String iconPath, boolean active, boolean disabled, boolean favorite) {
+ super(224, 119, true);
+ this.modName = modName;
+ this.iconPath = iconPath;
+ this.active = active;
+ this.disabled = disabled;
+ this.favorite = favorite;
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ RenderManager.drawRoundedRect(vg, x, y, width, 100, OneConfigConfig.GRAY_600, 12f);
+ RenderManager.drawRoundedRect(vg, x, y + 75, width, 32, OneConfigConfig.BLUE_600, 12f);
+ RenderManager.drawRect(vg, x, y + 75, width, 12, OneConfigConfig.BLUE_600);
+ if(iconPath != null) {
+ RenderManager.drawImage(vg, iconPath, x, y, width, 87);
+ } else {
+ RenderManager.drawImage(vg, "assets/oneconfig/textures/box.png", x + 98, y + 19, 40, 40);
+ }
+ RenderManager.drawString(vg, modName, x + 12, y + 92, OneConfigConfig.WHITE, 14f, Fonts.INTER_MEDIUM);
+ if(favorite) {
+ // TODO
+ }
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java
new file mode 100644
index 0000000..93df1b4
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java
@@ -0,0 +1,14 @@
+package io.polyfrost.oneconfig.gui.elements;
+
+public class SearchField extends TextInputField{
+
+ public SearchField(int width, int height, String defaultText, boolean multiLine, boolean password) {
+ super(width, height, defaultText, multiLine, password);
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ super.draw(vg, x, y);
+ // TODO
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
new file mode 100644
index 0000000..d38f565
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -0,0 +1,21 @@
+package io.polyfrost.oneconfig.gui.pages;
+
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.gui.elements.BasicButton;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+public class HomePage extends Page {
+ private final BasicButton btn = new BasicButton(184, 36, "Socials", "/assets/oneconfig/textures/share.png", "/assets/oneconfig/textures/share2.png", 1, BasicButton.ALIGNMENT_CENTER);
+ public HomePage() {
+ super("Home Dashboard");
+ }
+
+ 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.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/io/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
new file mode 100644
index 0000000..97751d6
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -0,0 +1,38 @@
+package io.polyfrost.oneconfig.gui.pages;
+
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.gui.elements.BasicButton;
+import io.polyfrost.oneconfig.gui.elements.ModCard;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+public class ModsPage extends Page {
+ private final BasicButton allBtn = new BasicButton(49, 40, "All", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+ private final BasicButton newBtn = new BasicButton(64, 40, "New", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+ private final BasicButton combatBtn = new BasicButton(104, 40, "Combat", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+ private final BasicButton hudBtn = new BasicButton(104, 40, "HUD & QoL", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+ private final BasicButton hypixelBtn = new BasicButton(104, 40, "Hypixel", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+ private final BasicButton skyblockBtn = new BasicButton(104, 40, "Skyblock", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+ private final BasicButton utilBtn = new BasicButton(104, 40, "Utility", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+ private final BasicButton customBtn = new BasicButton(104, 40, "Custom", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
+
+ private final ModCard exCard = new ModCard("Placeholder Mod Name", null, true, false, false);
+
+ public ModsPage() {
+ super("Mods");
+ }
+
+ public void draw(long vg, int x, int y) {
+ allBtn.draw(vg, x + 16, y + 16);
+ newBtn.draw(vg, x + 92, y + 16);
+ combatBtn.draw(vg, x + 168, y + 16);
+ hudBtn.draw(vg, x + 284, y + 16);
+ hypixelBtn.draw(vg, x + 400, y + 16);
+ skyblockBtn.draw(vg, x + 516, y + 16);
+ utilBtn.draw(vg, x + 632, y + 16);
+ customBtn.draw(vg, x + 748, y + 16);
+
+ exCard.draw(vg, x + 16, y + 72);
+
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
index 72fa3a3..492a1f9 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
@@ -1,4 +1,23 @@
package io.polyfrost.oneconfig.gui.pages;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+/**
+ * A page is a 1056x728 rectangle of the GUI. It is the main content of the gui, and can be switched back and forwards easily. All the content of OneConfig is in a page.
+ */
public class Page {
+ protected final String title;
+
+ Page(String title) {
+ this.title = title;
+ }
+
+ public void draw(long vg, int x, int y) {
+ RenderManager.drawString(vg, "If you are seeing this, something went quite wrong.", x + 12, y + 12, -1, 24f, Fonts.INTER_BOLD);
+ }
+
+ public String getTitle() {
+ return title;
+ }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
index e0a85c7..dcfd513 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -192,9 +192,9 @@ public final class RenderManager {
NSVGPath path;
int i;
for (shape = image.shapes(); shape != null; shape.next()) {
- //if ((shape.flags() == NSVG_FLAGS_VISIBLE)) {
- // continue;
- //}
+ if ((shape.flags() == NSVG_FLAGS_VISIBLE)) {
+ continue;
+ }
nvgFillColor(vg, color(vg, shape.fill().color()));
nvgStrokeColor(vg, color(vg, shape.stroke().color()));
@@ -204,21 +204,15 @@ public final class RenderManager {
nvgBeginPath(vg);
FloatBuffer points = path.pts();
nvgMoveTo(vg, points.get(0), points.get(1));
- for (i = 0; i < path.npts() - 1; i += 3) {
- float[] p = new float[10];
- for (int j = 0; j < i * 2 + 3; j++) { // THIS WONT WORK WHy why why why
- p[j] = points.get(j);
- System.out.println(j + " " + p[j]);
- }
- nvgBezierTo(vg, p[2], p[3], p[4], p[5], p[6], p[7]);
+ for (i = 1; i < path.npts() - 1; i += 3) {
+ int b = i * 2;
+ nvgBezierTo(vg, points.get(b), points.get(b + 1), points.get(b + 2), points.get(b + 3), points.get(b + 4), points.get(b + 5));
}
if (path.closed() == 1) {
nvgLineTo(vg, points.get(0), points.get(1));
}
nvgStroke(vg);
}
-
-
}
} catch (Exception e) {
//e.printStackTrace();
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
index 6fbd27f..4a35959 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
@@ -10,6 +10,7 @@ import org.lwjgl.stb.STBImage;
import org.lwjgl.system.MemoryStack;
import java.io.BufferedReader;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
@@ -46,7 +47,16 @@ public class ImageLoader {
public boolean loadSVGImage(String fileName) {
if(!NSVGImageHashMap.containsKey(fileName)) {
try {
- CharSequence s = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("oneconfig", fileName)).getInputStream())).readLine();
+ InputStream inputStream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("oneconfig", fileName)).getInputStream();
+ StringBuilder resultStringBuilder = new StringBuilder();
+ try (BufferedReader br
+ = new BufferedReader(new InputStreamReader(inputStream))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ resultStringBuilder.append(line);
+ }
+ }
+ CharSequence s = resultStringBuilder.toString();
System.out.println(s);
NSVGImage image = NanoSVG.nsvgParse(s, "px", 96f);
NSVGImageHashMap.put(fileName, image);
diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
index 313da70..88ec1ee 100644
--- a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java
@@ -14,15 +14,15 @@ public class TestNanoVGGui extends GuiScreen {
drawRect(0, 0, width, height, Color.BLACK.getRGB());
long startTime = System.nanoTime();
RenderManager.setupAndDraw((vg) -> {
- RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB());
- RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8);
- RenderManager.drawString(vg, "Hello!", 80, 20, Color.WHITE.getRGB(), 50, Fonts.MC_REGULAR);
- RenderManager.drawString(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.INTER_BOLD);
- RenderManager.drawImage(vg, "/assets/oneconfig/textures/hudsettings.png", 10, 10, 400, 400);
- RenderManager.drawSVGImage(vg, "textures/pc.svg", 1000, 1000, 500, 500);
- RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB());
- RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB());
- RenderManager.drawString(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.INTER_BOLD);
+ //RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB());
+ //RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8);
+ //RenderManager.drawString(vg, "Hello!", 80, 20, Color.WHITE.getRGB(), 50, Fonts.MC_REGULAR);
+ //RenderManager.drawString(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.INTER_BOLD);
+ //RenderManager.drawImage(vg, "/assets/oneconfig/textures/hudsettings.png", 10, 10, 400, 400);
+ RenderManager.drawSVGImage(vg, "icons/TestIcon.svg", 10, 10, 100, 100);
+ //RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB());
+ //RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB());
+ //RenderManager.drawString(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.INTER_BOLD);
});
drawString(fontRendererObj, "Hello!", 0, 0, -1);
} // hi