aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/renderer
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-21 04:04:48 +0900
committerGitHub <noreply@github.com>2022-07-20 20:04:48 +0100
commitf06946c01b2c8f210b398a16610c260eca093a8b (patch)
tree22bda7a5e9b0a1e7370ff2b1e74fc7c9e4035379 /src/main/java/cc/polyfrost/oneconfig/renderer
parentff2ead62333e90b61e05c8cb6a91f692fcf30805 (diff)
downloadOneConfig-f06946c01b2c8f210b398a16610c260eca093a8b.tar.gz
OneConfig-f06946c01b2c8f210b398a16610c260eca093a8b.tar.bz2
OneConfig-f06946c01b2c8f210b398a16610c260eca093a8b.zip
HUD Improvements, 1.16 port, fix NanoVG with ARM (#52)
* egg 1 * separate Hud from background stuff * 1984 This reverts commit 9ae517d57bbd495d30d35cb1cbfe81a03556e6bd. * hitboxes woo!!!!! * Revert "hitboxes woo!!!!!" This reverts commit 405d32d17df3c83f2e79eddf0de853f7279767a6. * padding * allow position to go slightly off the screen * stop using ints for ABSOLUTELY EVERYTHING, DIAMOND ... fix vigilance compat not setting color * start on new pos system * some stuff * finish new position system * api momento * 1.16.2 fabric port * start on hud gui * temp remove 1.16.2 fabric since it doesn't compile * fix fabric build * hud gui stuff * apiDump * fix fabric build 2 * so true * selecting stuff * scaling + other small things * More protecting * fix nanovg not working with macOS ARM move OneConfig.preLaunch to OneConfigInit * clean up OneUIScreen make kotlin version of TestNanoVGGui * make keybinds have runnable by default * rollback keybind things * merge master into hud-improvements (#55) * Release workflow (#53) * release workflow * update normal version to hash * fix * fix naming * fix some stuff * fix version thing * switch to number from hash * Release workflow (#54) * release workflow * update normal version to hash * fix * fix naming * fix some stuff * fix version thing * switch to number from hash * Maybe epic fixo * gotta love those Java principles * Revert "gotta love those Java principles", wrong branch This reverts commit 333d8b2ad8941790c13c4bfe0777fbd203d463e5. * start on snapping * Finish snapping * stop including mixin by default on legacy versions this breaks builds if the mod itself does not use mixin * merge draw and drawExample * fix gradle publish * Some fixes * Api DUmpidy * Help subcommand impovments (#59) * Made the overall look of the "help" subcommand better + added the ability to change the colour for the command overall + each individual SubCommand * Made the alliases show batter + added support for to show subcommand aliasses * mr deliverer didnt reply but whatever, added a space between command/subcommand and alliasses Co-authored-by: pinkulu <pinkulumc@gmail.com> * fix file not overwriting toJavaColor * Fix full shadow not scaling correctly Co-authored-by: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Co-authored-by: nxtdaydelivery <12willettsh@gmail.com> Co-authored-by: pinkulu <56201697+pinkulu@users.noreply.github.com> Co-authored-by: pinkulu <pinkulumc@gmail.com>
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/renderer')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java28
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java2
3 files changed, 8 insertions, 26 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
index 93c3c94..5f8ea11 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
@@ -7,6 +7,7 @@ import cc.polyfrost.oneconfig.internal.assets.Images;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.libs.universal.UGraphics;
import cc.polyfrost.oneconfig.libs.universal.UResolution;
+import cc.polyfrost.oneconfig.platform.NanoVGPlatform;
import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.font.Font;
import cc.polyfrost.oneconfig.renderer.font.FontManager;
@@ -14,7 +15,6 @@ import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.NetworkUtils;
import org.lwjgl.nanovg.NVGColor;
import org.lwjgl.nanovg.NVGPaint;
-import org.lwjgl.nanovg.NanoVGGL2;
import org.lwjgl.opengl.GL11;
import java.util.function.LongConsumer;
@@ -52,7 +52,7 @@ public final class RenderManager {
*/
public static void setupAndDraw(boolean mcScaling, LongConsumer consumer) {
if (vg == -1) {
- vg = NanoVGGL2.nvgCreate(NanoVGGL2.NVG_ANTIALIAS);
+ vg = Platform.getNanoVGPlatform().nvgCreate(NanoVGPlatform.NVG_ANTIALIAS);
if (vg == -1) {
throw new RuntimeException("Failed to create nvg context");
}
@@ -86,24 +86,6 @@ public final class RenderManager {
* @param height The height.
* @param color The color.
*/
- public static void drawRectangle(long vg, float x, float y, float width, float height, int color) { // TODO make everything use this one day
- if (Colors.ROUNDED_CORNERS) {
- drawRoundedRect(vg, x, y, width, height, color, Colors.CORNER_RADIUS);
- } else {
- drawRect(vg, x, y, width, height, color);
- }
- }
-
- /**
- * Draws a rectangle with the given parameters.
- *
- * @param vg The NanoVG context.
- * @param x The x position.
- * @param y The y position.
- * @param width The width.
- * @param height The height.
- * @param color The color.
- */
public static void drawRect(long vg, float x, float y, float width, float height, int color) {
nvgBeginPath(vg);
nvgRect(vg, x, y, width, height);
@@ -330,12 +312,12 @@ public final class RenderManager {
* <p><b>This does NOT scale to Minecraft's GUI scale!</b></p>
*
* @see RenderManager#drawText(long, String, float, float, int, float, Font)
- * @see InputUtils#isAreaClicked(int, int, int, int)
+ * @see InputUtils#isAreaClicked(float, float, float, float)
*/
public static void drawURL(long vg, String url, float x, float y, float size, Font font) {
drawText(vg, url, x, y, Colors.PRIMARY_500, size, font);
float length = getTextWidth(vg, url, size, font);
- drawRectangle(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500);
+ drawRect(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500);
if (InputUtils.isAreaClicked((int) (x - 2), (int) (y - 1), (int) (length + 4), (int) (size / 2 + 3))) {
NetworkUtils.browseLink(url);
}
@@ -723,7 +705,7 @@ public final class RenderManager {
Platform.getGLPlatform().drawText(text, x * (1 / scale), y * (1 / scale), color, true);
break;
case FULL:
- drawBorderedText(text, x, y, color, 100);
+ drawBorderedText(text, x * (1 / scale), y * (1 / scale), color, 100);
break;
}
UGraphics.GL.popMatrix();
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java b/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java
index 95071d1..ed77942 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java
@@ -122,12 +122,12 @@ public class TextRenderer {
* <p><b>This does NOT scale to Minecraft's GUI scale!</b></p>
*
* @see RenderManager#drawText(long, String, float, float, int, float, Font)
- * @see InputUtils#isAreaClicked(int, int, int, int)
+ * @see InputUtils#isAreaClicked(float, float, float, float)
*/
public static void drawURL(long vg, String url, float x, float y, float size, Font font) {
drawText(vg, url, x, y, Colors.PRIMARY_500, size, font);
float length = getTextWidth(vg, url, size, font);
- RenderManager.drawRectangle(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500);
+ RenderManager.drawRect(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500);
if (InputUtils.isAreaClicked((int) (x - 2), (int) (y - 1), (int) (length + 4), (int) (size / 2 + 3))) {
NetworkUtils.browseLink(url);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java b/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java
index 62854ef..7ced323 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java
@@ -25,7 +25,7 @@ public class Scissor {
this.height = scissor.height;
}
- public boolean isInScissor(int x, int y) {
+ public boolean isInScissor(float x, float y) {
return x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height;
}
}