From 2cef7d69273197372edfeea4dda3fb02923ad920 Mon Sep 17 00:00:00 2001 From: JFronny <33260128+jfronny@users.noreply.github.com> Date: Sat, 1 May 2021 15:20:07 +0200 Subject: [PATCH 01/13] First attempt at rounding, not quite perfect --- .../gui/renderer/GuiRenderer.java | 10 ++++ .../gui/themes/meteor/MeteorGuiTheme.java | 11 ++++ .../gui/themes/meteor/MeteorWidget.java | 20 +++++--- .../themes/meteor/widgets/WMeteorQuad.java | 5 +- .../themes/meteor/widgets/WMeteorWindow.java | 4 +- .../widgets/pressable/WMeteorCheckbox.java | 2 +- .../meteorclient/rendering/MeshBuilder.java | 50 +++++++++++++++++++ 7 files changed, 90 insertions(+), 12 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java index 2a7eacc5cb..0517a96423 100644 --- a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java +++ b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java @@ -199,6 +199,16 @@ public void quad(double x, double y, double width, double height, GuiTexture tex mbTex.texQuad(x, y, width, height, texture.get(width, height), color); } + public void quadRounded(double x, double y, double width, double height, Color color, int round, boolean roundTop) { + mb.quadRounded(x, y, width, height, color, round, roundTop); + } + public void quadRounded(double x, double y, double width, double height, Color color, int round) { + quadRounded(x, y, width, height, color, round, true); + } + public void quadRounded(WWidget widget, Color color, int round) { + quadRounded(widget.x, widget.y, widget.width, widget.height, color, round); + } + public void rotatedQuad(double x, double y, double width, double height, double rotation, GuiTexture texture, Color color) { TextureRegion region = texture.get(width, height); diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java index 22354ac8d3..8f9cd61e09 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java @@ -80,6 +80,17 @@ public class MeteorGuiTheme extends GuiTheme { .build() ); + public final Setting round = sgGeneral.add(new IntSetting.Builder() + .name("round") + .description("How much windows should be rounded") + .defaultValue(0) + .min(0) + .max(20) + .sliderMin(0) + .sliderMax(15) + .build() + ); + // Colors public final Setting accentColor = color("accent", "Main color of the GUI.", new SettingColor(135, 0, 255)); diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java index db2d1dd6f5..ff53992604 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java @@ -17,14 +17,20 @@ default MeteorGuiTheme theme() { default void renderBackground(GuiRenderer renderer, WWidget widget, boolean pressed, boolean mouseOver) { MeteorGuiTheme theme = theme(); + int r = theme().round.get(); double s = theme.scale(2); - - renderer.quad(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver)); - Color outlineColor = theme.outlineColor.get(pressed, mouseOver); - renderer.quad(widget.x, widget.y, widget.width, s, outlineColor); - renderer.quad(widget.x, widget.y + widget.height - s, widget.width, s, outlineColor); - renderer.quad(widget.x, widget.y + s, s, widget.height - s * 2, outlineColor); - renderer.quad(widget.x + widget.width - s, widget.y + s, s, widget.height - s * 2, outlineColor); + if (r == 0) { + renderer.quad(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver)); + + renderer.quad(widget.x, widget.y, widget.width, s, outlineColor); + renderer.quad(widget.x, widget.y + widget.height - s, widget.width, s, outlineColor); + renderer.quad(widget.x, widget.y + s, s, widget.height - s * 2, outlineColor); + renderer.quad(widget.x + widget.width - s, widget.y + s, s, widget.height - s * 2, outlineColor); + } + else { + renderer.quadRounded(widget.x, widget.y, widget.width, widget.height, outlineColor, r); + renderer.quadRounded(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver), r); + } } } diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java index 1d2de1b6ec..5329ad09b2 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java @@ -6,16 +6,17 @@ package minegame159.meteorclient.gui.themes.meteor.widgets; import minegame159.meteorclient.gui.renderer.GuiRenderer; +import minegame159.meteorclient.gui.themes.meteor.MeteorWidget; import minegame159.meteorclient.gui.widgets.WQuad; import minegame159.meteorclient.utils.render.color.Color; -public class WMeteorQuad extends WQuad { +public class WMeteorQuad extends WQuad implements MeteorWidget { public WMeteorQuad(Color color) { super(color); } @Override protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) { - renderer.quad(x, y, width, height, color); + renderer.quadRounded(x, y, width, height, color, theme().round.get()); } } diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java index 99eaad4fea..f7f488528d 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java @@ -22,14 +22,14 @@ protected WHeader header() { @Override protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) { if (expanded || animProgress > 0) { - renderer.quad(x, y + header.height, width, height - header.height, theme().backgroundColor.get()); + renderer.quadRounded(x, y + header.height / 2, width, height - header.height / 2, theme().backgroundColor.get(), theme().round.get(), false); } } private class WMeteorHeader extends WHeader { @Override protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) { - renderer.quad(this, theme().accentColor.get()); + renderer.quadRounded(this, theme().accentColor.get(), theme().round.get()); } } } diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java index c1f60c5086..51a10eb011 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java @@ -30,7 +30,7 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub if (animProgress > 0) { double cs = (width - theme.scale(2)) / 1.75 * animProgress; - renderer.quad(x + (width - cs) / 2, y + (height - cs) / 2, cs, cs, theme.checkboxColor.get()); + renderer.quadRounded(x + (width - cs) / 2, y + (height - cs) / 2, cs, cs, theme.checkboxColor.get(), theme.round.get()); } } } diff --git a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java index 17bb70d887..2063d778b9 100644 --- a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java +++ b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java @@ -179,6 +179,56 @@ public void boxSides(double x1, double y1, double z1, double x2, double y2, doub if (Dir.is(excludeDir, Dir.EAST)) quad(x2, y1, z1, x2, y2, z1, x2, y2, z2, x2, y1, z2, color); // Right } + // Rounded quad + + public void quadRounded(double x, double y, double width, double height, Color color, int r, boolean roundTop) { + if (r == 0) + quad(x, y, width, height, color); + else { + if (r * 2 > height) { + r = (int)height / 2; + } + if (r * 2 > width) { + r = (int)width / 2; + } + int cirDepth = Math.max(r / 2, 1); + if (roundTop) { + //top + quarterCircle(x + r, y + r, r, 3, cirDepth, color); + quad(x + r, y, width - 2 * r, r, color); + quarterCircle(x + width - r, y + r, r, 0, cirDepth, color); + //middle + quad(x, y + r, width, height - 2 * r, color); + } + else { + //middle + quad(x, y, width, height - r, color); + } + //bottom + quarterCircle(x + width - r, y + height - r, r, 1, cirDepth, color); + quad(x + r, y + height - r, width - 2 * r, r, color); + quarterCircle(x + r, y + height - r, r, 2, cirDepth, color); + } + } + + private void quarterCircle(double x, double y, double r, double a, int cirDepth, Color color) { + a *= Math.PI / 2; + double cirPart = Math.PI / 2 / cirDepth; + vert2(x + Math.sin(a) * r, y - Math.cos(a) * r, color); + for (int i = 1; i < cirDepth + 1; i++) { + vert2(x, y, color); + double xV = x + Math.sin(a + cirPart * i) * r; + double yV = y - Math.cos(a + cirPart * i) * r; + vert2(xV, yV, color); + if (i != cirDepth) + vert2(xV, yV, color); + } + } + + public void vert2(double x, double y, Color c) { + pos(x, y, 0).color(c).endVertex(); + } + // LINES public void line(double x1, double y1, double z1, double x2, double y2, double z2, Color startColor, Color endColor) { From e8600bc9d5a865bb2ebebebec2c5b4125baa742a Mon Sep 17 00:00:00 2001 From: JFronny <33260128+jfronny@users.noreply.github.com> Date: Sat, 1 May 2021 18:51:12 +0200 Subject: [PATCH 02/13] Custom drawing for background outline (fix transparency) --- .../gui/renderer/GuiRenderer.java | 6 +++ .../gui/themes/meteor/MeteorWidget.java | 15 +----- .../meteorclient/rendering/MeshBuilder.java | 52 +++++++++++++++++++ 3 files changed, 60 insertions(+), 13 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java index 0517a96423..d226a64ef3 100644 --- a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java +++ b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java @@ -208,6 +208,12 @@ public void quadRounded(double x, double y, double width, double height, Color c public void quadRounded(WWidget widget, Color color, int round) { quadRounded(widget.x, widget.y, widget.width, widget.height, color, round); } + public void quadOutlineRounded(double x, double y, double width, double height, Color color, int round, double s) { + mb.quadRoundedOutline(x, y, width, height, color, round, s); + } + public void quadOutlineRounded(WWidget widget, Color color, int round, double s) { + quadOutlineRounded(widget.x, widget.y, widget.width, widget.height, color, round, s); + } public void rotatedQuad(double x, double y, double width, double height, double rotation, GuiTexture texture, Color color) { TextureRegion region = texture.get(width, height); diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java index ff53992604..995f0092ae 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java @@ -18,19 +18,8 @@ default MeteorGuiTheme theme() { default void renderBackground(GuiRenderer renderer, WWidget widget, boolean pressed, boolean mouseOver) { MeteorGuiTheme theme = theme(); int r = theme().round.get(); - double s = theme.scale(2); Color outlineColor = theme.outlineColor.get(pressed, mouseOver); - if (r == 0) { - renderer.quad(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver)); - - renderer.quad(widget.x, widget.y, widget.width, s, outlineColor); - renderer.quad(widget.x, widget.y + widget.height - s, widget.width, s, outlineColor); - renderer.quad(widget.x, widget.y + s, s, widget.height - s * 2, outlineColor); - renderer.quad(widget.x + widget.width - s, widget.y + s, s, widget.height - s * 2, outlineColor); - } - else { - renderer.quadRounded(widget.x, widget.y, widget.width, widget.height, outlineColor, r); - renderer.quadRounded(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver), r); - } + renderer.quadRounded(widget, theme.backgroundColor.get(pressed, mouseOver), r); + renderer.quadOutlineRounded(widget, outlineColor, r, theme.scale(2)); } } diff --git a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java index 2063d778b9..cf7259dae1 100644 --- a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java +++ b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java @@ -181,6 +181,35 @@ public void boxSides(double x1, double y1, double z1, double x2, double y2, doub // Rounded quad + public void quadRoundedOutline(double x, double y, double width, double height, Color color, int r, double s) { + if (r == 0) { + quad(x, y, width, s, color); + quad(x, y + height - s, width, s, color); + quad(x, y + s, s, height - s * 2, color); + quad(x + width - s, y + s, s, height - s * 2, color); + } + else { + if (r * 2 > height) { + r = (int)height / 2; + } + if (r * 2 > width) { + r = (int)width / 2; + } + int cirDepth = Math.max(r / 2, 1); + //top + quarterCircleOutline(x + r, y + r, r, 3, cirDepth, color, s); + quad(x + r, y, width - r * 2, s, color); + quarterCircleOutline(x + width - r, y + r, r, 0, cirDepth, color, s); + //middle + quad(x, y + r, s, height - r * 2, color); + quad(x + width - s, y + r, s, height - r * 2, color); + //bottom + quarterCircleOutline(x + width - r, y + height - r, r, 1, cirDepth, color, s); + quad(x + r, y + height - s, width - r * 2, s, color); + quarterCircleOutline(x + r, y + height - r, r, 2, cirDepth, color, s); + } + } + public void quadRounded(double x, double y, double width, double height, Color color, int r, boolean roundTop) { if (r == 0) quad(x, y, width, height, color); @@ -225,6 +254,29 @@ private void quarterCircle(double x, double y, double r, double a, int cirDepth, } } + private void quarterCircleOutline(double x, double y, double r, double a, int cirDepth, Color color, double s) { + a *= Math.PI / 2; + double cirPart = Math.PI / 2 / cirDepth; + for (int i = 0; i < cirDepth; i++) { + double xOC = x + Math.sin(a + cirPart * i) * r; + double yOC = y - Math.cos(a + cirPart * i) * r; + double xIC = x + Math.sin(a + cirPart * i) * (r - s); + double yIC = y - Math.cos(a + cirPart * i) * (r - s); + double xON = x + Math.sin(a + cirPart * (i + 1)) * r; + double yON = y - Math.cos(a + cirPart * (i + 1)) * r; + double xIN = x + Math.sin(a + cirPart * (i + 1)) * (r - s); + double yIN = y - Math.cos(a + cirPart * (i + 1)) * (r - s); + // + vert2(xOC, yOC, color); + vert2(xON, yON, color); + vert2(xIC, yIC, color); + // + vert2(xIC, yIC, color); + vert2(xON, yON, color); + vert2(xIN, yIN, color); + } + } + public void vert2(double x, double y, Color c) { pos(x, y, 0).color(c).endVertex(); } From 14eba342f5cfa8ceec047edb191331b2d6f79d61 Mon Sep 17 00:00:00 2001 From: JFronny <33260128+jfronny@users.noreply.github.com> Date: Sat, 1 May 2021 19:16:40 +0200 Subject: [PATCH 03/13] Round top bar --- .../gui/renderer/GuiRenderer.java | 6 +++++ .../themes/meteor/widgets/WMeteorTopBar.java | 5 ++++ .../meteorclient/gui/widgets/WTopBar.java | 27 ++++++++++++++++++- .../meteorclient/rendering/MeshBuilder.java | 26 ++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java index d226a64ef3..df22cd39c0 100644 --- a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java +++ b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java @@ -214,6 +214,12 @@ public void quadOutlineRounded(double x, double y, double width, double height, public void quadOutlineRounded(WWidget widget, Color color, int round, double s) { quadOutlineRounded(widget.x, widget.y, widget.width, widget.height, color, round, s); } + public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { + mb.quadRoundedSide(x, y, width, height, color, r, right); + } + public void quadRoundedSide(WWidget widget, Color color, int round, boolean right) { + quadRoundedSide(widget.x, widget.y, widget.width, widget.height, color, round, right); + } public void rotatedQuad(double x, double y, double width, double height, double rotation, GuiTexture texture, Color color) { TextureRegion region = texture.get(width, height); diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java index 671e0b6a5d..b888a8a838 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java @@ -19,4 +19,9 @@ protected Color getButtonColor(boolean pressed, boolean hovered) { protected Color getNameColor() { return theme().textColor.get(); } + + @Override + protected int getRoundingFactor() { + return theme().round.get(); + } } diff --git a/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java b/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java index 0aa9332f95..28ad6b38c4 100644 --- a/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java +++ b/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java @@ -9,6 +9,7 @@ import minegame159.meteorclient.gui.tabs.Tab; import minegame159.meteorclient.gui.tabs.TabScreen; import minegame159.meteorclient.gui.tabs.Tabs; +import minegame159.meteorclient.gui.themes.meteor.MeteorWidget; import minegame159.meteorclient.gui.widgets.containers.WHorizontalList; import minegame159.meteorclient.gui.widgets.pressable.WPressable; import minegame159.meteorclient.utils.render.color.Color; @@ -21,6 +22,7 @@ public abstract class WTopBar extends WHorizontalList { protected abstract Color getButtonColor(boolean pressed, boolean hovered); protected abstract Color getNameColor(); + protected abstract int getRoundingFactor(); public WTopBar() { spacing = 0; @@ -33,6 +35,15 @@ public void init() { } } + protected int getState(WTopBarButton btn) { + int a = 0; + if (btn.equals(cells.get(0).widget())) + a |= 1; + if (btn.equals(cells.get(cells.size() - 1).widget())) + a |= 2; + return a; + } + protected class WTopBarButton extends WPressable { private final Tab tab; @@ -66,7 +77,21 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub double pad = pad(); Color color = getButtonColor(pressed || (mc.currentScreen instanceof TabScreen && ((TabScreen) mc.currentScreen).tab == tab), mouseOver); - renderer.quad(x, y, width, height, color); + //renderer.quad(x, y, width, height, color); + switch (getState(this)) { + case 0: + renderer.quad(this, color); + break; + case 1: + renderer.quadRoundedSide(this, color, getRoundingFactor(), false); + break; + case 2: + renderer.quadRoundedSide(this, color, getRoundingFactor(), true); + break; + case 3: + renderer.quadRounded(this, color, getRoundingFactor()); + break; + } renderer.text(tab.name, x + pad, y + pad, getNameColor(), false); } } diff --git a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java index cf7259dae1..9b97a2e9e8 100644 --- a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java +++ b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java @@ -240,6 +240,32 @@ public void quadRounded(double x, double y, double width, double height, Color c } } + public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { + if (r == 0) + quad(x, y, width, height, color); + else { + if (r * 2 > height) { + r = (int)height / 2; + } + if (r * 2 > width) { + r = (int)width / 2; + } + int cirDepth = Math.max(r / 2, 1); + if (right) { + quarterCircle(x + width - r, y + r, r, 0, cirDepth, color); + quarterCircle(x + width - r, y + height - r, r, 1, cirDepth, color); + quad(x, y, width - r, height, color); + quad(x + width - r, y + r, r, height - r * 2, color); + } + else { + quarterCircle(x + r, y + r, r, 3, cirDepth, color); + quarterCircle(x + r, y + height - r, r, 2, cirDepth, color); + quad(x + r, y, width - r, height, color); + quad(x, y + r, r, height - r * 2, color); + } + } + } + private void quarterCircle(double x, double y, double r, double a, int cirDepth, Color color) { a *= Math.PI / 2; double cirPart = Math.PI / 2 / cirDepth; From 2aac4aa7517cff86fddbe651a686b17db7b30c8c Mon Sep 17 00:00:00 2001 From: JFronny <33260128+jfronny@users.noreply.github.com> Date: Sat, 1 May 2021 19:21:40 +0200 Subject: [PATCH 04/13] Make TopBarButton with edges default case --- .../java/minegame159/meteorclient/gui/widgets/WTopBar.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java b/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java index 28ad6b38c4..eb8f58e346 100644 --- a/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java +++ b/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java @@ -79,9 +79,6 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub //renderer.quad(x, y, width, height, color); switch (getState(this)) { - case 0: - renderer.quad(this, color); - break; case 1: renderer.quadRoundedSide(this, color, getRoundingFactor(), false); break; @@ -91,6 +88,9 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub case 3: renderer.quadRounded(this, color, getRoundingFactor()); break; + default: + renderer.quad(this, color); + break; } renderer.text(tab.name, x + pad, y + pad, getNameColor(), false); } From b74f5bb4da8a2914116ae0145c70064e79216461 Mon Sep 17 00:00:00 2001 From: JFronny <33260128+jfronny@users.noreply.github.com> Date: Sat, 1 May 2021 20:01:12 +0200 Subject: [PATCH 05/13] Round Combat and PlayerModel HUD element backgrounds --- src/main/java/minegame159/meteorclient/gui/GuiTheme.java | 2 ++ .../meteorclient/gui/themes/meteor/MeteorGuiTheme.java | 5 +++++ .../meteorclient/gui/themes/meteor/MeteorWidget.java | 2 +- .../gui/themes/meteor/widgets/WMeteorQuad.java | 4 ++-- .../gui/themes/meteor/widgets/WMeteorTopBar.java | 5 ----- .../gui/themes/meteor/widgets/WMeteorWindow.java | 4 ++-- .../themes/meteor/widgets/pressable/WMeteorCheckbox.java | 2 +- .../minegame159/meteorclient/gui/widgets/WTopBar.java | 8 +++----- .../systems/modules/render/hud/HudRenderer.java | 5 +++++ .../systems/modules/render/hud/modules/CombatHud.java | 2 +- .../modules/render/hud/modules/PlayerModelHud.java | 2 +- 11 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/gui/GuiTheme.java b/src/main/java/minegame159/meteorclient/gui/GuiTheme.java index 37c93186b2..25b902c5bb 100644 --- a/src/main/java/minegame159/meteorclient/gui/GuiTheme.java +++ b/src/main/java/minegame159/meteorclient/gui/GuiTheme.java @@ -213,6 +213,8 @@ public WidgetScreen proxiesScreen() { public abstract boolean categoryIcons(); public abstract boolean blur(); + + public abstract int roundAmount(); public double textWidth(String text, int length, boolean title) { return scale(textRenderer().getWidth(text, length) * (title ? TITLE_TEXT_SCALE : 1)); diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java index 8f9cd61e09..14a817589b 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorGuiTheme.java @@ -305,6 +305,11 @@ public boolean blur() { return blur.get(); } + @Override + public int roundAmount() { + return round.get(); + } + public class ThreeStateColorSetting { private final Setting normal, hovered, pressed; diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java index 995f0092ae..e4aa5a4aaf 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java @@ -17,7 +17,7 @@ default MeteorGuiTheme theme() { default void renderBackground(GuiRenderer renderer, WWidget widget, boolean pressed, boolean mouseOver) { MeteorGuiTheme theme = theme(); - int r = theme().round.get(); + int r = theme.roundAmount(); Color outlineColor = theme.outlineColor.get(pressed, mouseOver); renderer.quadRounded(widget, theme.backgroundColor.get(pressed, mouseOver), r); renderer.quadOutlineRounded(widget, outlineColor, r, theme.scale(2)); diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java index 5329ad09b2..0e509ddf1e 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java @@ -10,13 +10,13 @@ import minegame159.meteorclient.gui.widgets.WQuad; import minegame159.meteorclient.utils.render.color.Color; -public class WMeteorQuad extends WQuad implements MeteorWidget { +public class WMeteorQuad extends WQuad { public WMeteorQuad(Color color) { super(color); } @Override protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) { - renderer.quadRounded(x, y, width, height, color, theme().round.get()); + renderer.quadRounded(x, y, width, height, color, theme.roundAmount()); } } diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java index b888a8a838..671e0b6a5d 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorTopBar.java @@ -19,9 +19,4 @@ protected Color getButtonColor(boolean pressed, boolean hovered) { protected Color getNameColor() { return theme().textColor.get(); } - - @Override - protected int getRoundingFactor() { - return theme().round.get(); - } } diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java index f7f488528d..8ae380e0d8 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/WMeteorWindow.java @@ -22,14 +22,14 @@ protected WHeader header() { @Override protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) { if (expanded || animProgress > 0) { - renderer.quadRounded(x, y + header.height / 2, width, height - header.height / 2, theme().backgroundColor.get(), theme().round.get(), false); + renderer.quadRounded(x, y + header.height / 2, width, height - header.height / 2, theme().backgroundColor.get(), theme.roundAmount(), false); } } private class WMeteorHeader extends WHeader { @Override protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) { - renderer.quadRounded(this, theme().accentColor.get(), theme().round.get()); + renderer.quadRounded(this, theme().accentColor.get(), theme.roundAmount()); } } } diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java index 51a10eb011..a6afa04d76 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/widgets/pressable/WMeteorCheckbox.java @@ -30,7 +30,7 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub if (animProgress > 0) { double cs = (width - theme.scale(2)) / 1.75 * animProgress; - renderer.quadRounded(x + (width - cs) / 2, y + (height - cs) / 2, cs, cs, theme.checkboxColor.get(), theme.round.get()); + renderer.quadRounded(x + (width - cs) / 2, y + (height - cs) / 2, cs, cs, theme.checkboxColor.get(), theme.roundAmount()); } } } diff --git a/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java b/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java index eb8f58e346..4c061e37e7 100644 --- a/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java +++ b/src/main/java/minegame159/meteorclient/gui/widgets/WTopBar.java @@ -9,7 +9,6 @@ import minegame159.meteorclient.gui.tabs.Tab; import minegame159.meteorclient.gui.tabs.TabScreen; import minegame159.meteorclient.gui.tabs.Tabs; -import minegame159.meteorclient.gui.themes.meteor.MeteorWidget; import minegame159.meteorclient.gui.widgets.containers.WHorizontalList; import minegame159.meteorclient.gui.widgets.pressable.WPressable; import minegame159.meteorclient.utils.render.color.Color; @@ -22,7 +21,6 @@ public abstract class WTopBar extends WHorizontalList { protected abstract Color getButtonColor(boolean pressed, boolean hovered); protected abstract Color getNameColor(); - protected abstract int getRoundingFactor(); public WTopBar() { spacing = 0; @@ -80,13 +78,13 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub //renderer.quad(x, y, width, height, color); switch (getState(this)) { case 1: - renderer.quadRoundedSide(this, color, getRoundingFactor(), false); + renderer.quadRoundedSide(this, color, theme.roundAmount(), false); break; case 2: - renderer.quadRoundedSide(this, color, getRoundingFactor(), true); + renderer.quadRoundedSide(this, color, theme.roundAmount(), true); break; case 3: - renderer.quadRounded(this, color, getRoundingFactor()); + renderer.quadRounded(this, color, theme.roundAmount()); break; default: renderer.quad(this, color); diff --git a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/HudRenderer.java b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/HudRenderer.java index 2e220894e6..434e521c50 100644 --- a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/HudRenderer.java +++ b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/HudRenderer.java @@ -5,6 +5,7 @@ package minegame159.meteorclient.systems.modules.render.hud; +import minegame159.meteorclient.gui.GuiThemes; import minegame159.meteorclient.rendering.text.TextRenderer; import minegame159.meteorclient.utils.render.color.Color; @@ -46,4 +47,8 @@ public double textHeight() { public void addPostTask(Runnable runnable) { postTasks.add(runnable); } + + public int roundAmount() { + return GuiThemes.get().roundAmount(); + } } diff --git a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/CombatHud.java b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/CombatHud.java index a6fdb26531..9c830b413b 100644 --- a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/CombatHud.java +++ b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/CombatHud.java @@ -193,7 +193,7 @@ public void render(HudRenderer renderer) { // Background Renderer.NORMAL.begin(null, DrawMode.Triangles, VertexFormats.POSITION_COLOR); - Renderer.NORMAL.quad(x, y, box.width, box.height, backgroundColor.get()); + Renderer.NORMAL.quadRounded(x, y, box.width, box.height, backgroundColor.get(), renderer.roundAmount(), true); Renderer.NORMAL.end(); // Player Model diff --git a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/PlayerModelHud.java b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/PlayerModelHud.java index 5526640dee..3b77705311 100644 --- a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/PlayerModelHud.java +++ b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/PlayerModelHud.java @@ -96,7 +96,7 @@ public void render(HudRenderer renderer) { if (background.get()) { Renderer.NORMAL.begin(null, DrawMode.Triangles, VertexFormats.POSITION_COLOR); - Renderer.NORMAL.quad(x, y, box.width, box.height, backgroundColor.get()); + Renderer.NORMAL.quadRounded(x, y, box.width, box.height, backgroundColor.get(), renderer.roundAmount(), true); Renderer.NORMAL.end(); } From a218d200f88d4312fc935dcc01da1c61a52d6231 Mon Sep 17 00:00:00 2001 From: JFronny <33260128+jfronny@users.noreply.github.com> Date: Tue, 11 May 2021 14:01:21 +0200 Subject: [PATCH 06/13] Round flat inventory HUD --- .../meteorclient/rendering/MeshBuilder.java | 41 +++++++++---------- .../hud/modules/InventoryViewerHud.java | 3 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java index 9b97a2e9e8..3237183c8d 100644 --- a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java +++ b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java @@ -182,6 +182,7 @@ public void boxSides(double x1, double y1, double z1, double x2, double y2, doub // Rounded quad public void quadRoundedOutline(double x, double y, double width, double height, Color color, int r, double s) { + r = getR(r, width, height); if (r == 0) { quad(x, y, width, s, color); quad(x, y + height - s, width, s, color); @@ -189,13 +190,7 @@ public void quadRoundedOutline(double x, double y, double width, double height, quad(x + width - s, y + s, s, height - s * 2, color); } else { - if (r * 2 > height) { - r = (int)height / 2; - } - if (r * 2 > width) { - r = (int)width / 2; - } - int cirDepth = Math.max(r / 2, 1); + int cirDepth = getCir(r); //top quarterCircleOutline(x + r, y + r, r, 3, cirDepth, color, s); quad(x + r, y, width - r * 2, s, color); @@ -211,16 +206,11 @@ public void quadRoundedOutline(double x, double y, double width, double height, } public void quadRounded(double x, double y, double width, double height, Color color, int r, boolean roundTop) { + r = getR(r, width, height); if (r == 0) quad(x, y, width, height, color); else { - if (r * 2 > height) { - r = (int)height / 2; - } - if (r * 2 > width) { - r = (int)width / 2; - } - int cirDepth = Math.max(r / 2, 1); + int cirDepth = getCir(r); if (roundTop) { //top quarterCircle(x + r, y + r, r, 3, cirDepth, color); @@ -241,16 +231,11 @@ public void quadRounded(double x, double y, double width, double height, Color c } public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { + r = getR(r, width, height); if (r == 0) quad(x, y, width, height, color); else { - if (r * 2 > height) { - r = (int)height / 2; - } - if (r * 2 > width) { - r = (int)width / 2; - } - int cirDepth = Math.max(r / 2, 1); + int cirDepth = getCir(r); if (right) { quarterCircle(x + width - r, y + r, r, 0, cirDepth, color); quarterCircle(x + width - r, y + height - r, r, 1, cirDepth, color); @@ -266,6 +251,20 @@ public void quadRoundedSide(double x, double y, double width, double height, Col } } + private int getR(int r, double w, double h) { + if (r * 2 > h) { + r = (int)h / 2; + } + if (r * 2 > w) { + r = (int)w / 2; + } + return r; + } + + private int getCir(int r) { + return Math.max(r / 2, 1); + } + private void quarterCircle(double x, double y, double r, double a, int cirDepth, Color color) { a *= Math.PI / 2; double cirPart = Math.PI / 2 / cirDepth; diff --git a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java index abc730847e..72d017ad08 100644 --- a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java +++ b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java @@ -6,6 +6,7 @@ package minegame159.meteorclient.systems.modules.render.hud.modules; import com.mojang.blaze3d.systems.RenderSystem; +import minegame159.meteorclient.gui.GuiThemes; import minegame159.meteorclient.rendering.DrawMode; import minegame159.meteorclient.rendering.Matrices; import minegame159.meteorclient.rendering.Renderer; @@ -103,7 +104,7 @@ private void drawBackground(int x, int y) { break; case Flat: Renderer.NORMAL.begin(null, DrawMode.Triangles, VertexFormats.POSITION_COLOR); - Renderer.NORMAL.quad(x, y, w, h, color.get()); + Renderer.NORMAL.quadRounded(x, y, w, h, color.get(), GuiThemes.get().roundAmount(), true); Renderer.NORMAL.end(); break; } From 186a89d16bdfbe18c143f273411b082a052826e0 Mon Sep 17 00:00:00 2001 From: JFronny <6260391-JFronny@users.noreply.gitlab.com> Date: Thu, 20 May 2021 17:49:49 +0200 Subject: [PATCH 07/13] Expose logic for drawing partial circles --- .../gui/renderer/GuiRenderer.java | 6 ++ .../meteorclient/rendering/MeshBuilder.java | 70 ++++++++++--------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java index c7d1f4b5a0..6ce172ff5c 100644 --- a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java +++ b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java @@ -220,6 +220,12 @@ public void quadRoundedSide(double x, double y, double width, double height, Col public void quadRoundedSide(WWidget widget, Color color, int round, boolean right) { quadRoundedSide(widget.x, widget.y, widget.width, widget.height, color, round, right); } + public void circlePart(double x, double y, double r, double startAngle, double angle, Color color) { + mb.circlePart(x, y, r, startAngle, angle, color); + } + public void circlePartOutline(double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) { + mb.circlePartOutline(x, y, r, startAngle, angle, color, outlineWidth); + } public void rotatedQuad(double x, double y, double width, double height, double rotation, GuiTexture texture, Color color) { TextureRegion region = texture.get(width, height); diff --git a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java index 3237183c8d..cdd98e6e7c 100644 --- a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java +++ b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java @@ -180,6 +180,11 @@ public void boxSides(double x1, double y1, double z1, double x2, double y2, doub } // Rounded quad + + private final double circleNone = 0; + private final double circleQuarter = Math.PI / 2; + private final double circleHalf = circleQuarter * 2; + private final double circleThreeQuarter = circleQuarter * 3; public void quadRoundedOutline(double x, double y, double width, double height, Color color, int r, double s) { r = getR(r, width, height); @@ -190,18 +195,17 @@ public void quadRoundedOutline(double x, double y, double width, double height, quad(x + width - s, y + s, s, height - s * 2, color); } else { - int cirDepth = getCir(r); //top - quarterCircleOutline(x + r, y + r, r, 3, cirDepth, color, s); + circlePartOutline(x + r, y + r, r, circleThreeQuarter, circleQuarter, color, s); quad(x + r, y, width - r * 2, s, color); - quarterCircleOutline(x + width - r, y + r, r, 0, cirDepth, color, s); + circlePartOutline(x + width - r, y + r, r, circleNone, circleQuarter, color, s); //middle quad(x, y + r, s, height - r * 2, color); quad(x + width - s, y + r, s, height - r * 2, color); //bottom - quarterCircleOutline(x + width - r, y + height - r, r, 1, cirDepth, color, s); + circlePartOutline(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color, s); quad(x + r, y + height - s, width - r * 2, s, color); - quarterCircleOutline(x + r, y + height - r, r, 2, cirDepth, color, s); + circlePartOutline(x + r, y + height - r, r, circleHalf, circleQuarter, color, s); } } @@ -210,12 +214,11 @@ public void quadRounded(double x, double y, double width, double height, Color c if (r == 0) quad(x, y, width, height, color); else { - int cirDepth = getCir(r); if (roundTop) { //top - quarterCircle(x + r, y + r, r, 3, cirDepth, color); + circlePart(x + r, y + r, r, circleThreeQuarter, circleQuarter, color); quad(x + r, y, width - 2 * r, r, color); - quarterCircle(x + width - r, y + r, r, 0, cirDepth, color); + circlePart(x + width - r, y + r, r, circleNone, circleQuarter, color); //middle quad(x, y + r, width, height - 2 * r, color); } @@ -224,9 +227,9 @@ public void quadRounded(double x, double y, double width, double height, Color c quad(x, y, width, height - r, color); } //bottom - quarterCircle(x + width - r, y + height - r, r, 1, cirDepth, color); + circlePart(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color); quad(x + r, y + height - r, width - 2 * r, r, color); - quarterCircle(x + r, y + height - r, r, 2, cirDepth, color); + circlePart(x + r, y + height - r, r, circleHalf, circleQuarter, color); } } @@ -235,16 +238,15 @@ public void quadRoundedSide(double x, double y, double width, double height, Col if (r == 0) quad(x, y, width, height, color); else { - int cirDepth = getCir(r); if (right) { - quarterCircle(x + width - r, y + r, r, 0, cirDepth, color); - quarterCircle(x + width - r, y + height - r, r, 1, cirDepth, color); + circlePart(x + width - r, y + r, r, circleNone, circleQuarter, color); + circlePart(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color); quad(x, y, width - r, height, color); quad(x + width - r, y + r, r, height - r * 2, color); } else { - quarterCircle(x + r, y + r, r, 3, cirDepth, color); - quarterCircle(x + r, y + height - r, r, 2, cirDepth, color); + circlePart(x + r, y + r, r, circleThreeQuarter, circleQuarter, color); + circlePart(x + r, y + height - r, r, circleHalf, circleQuarter, color); quad(x + r, y, width - r, height, color); quad(x, y + r, r, height - r * 2, color); } @@ -261,36 +263,36 @@ private int getR(int r, double w, double h) { return r; } - private int getCir(int r) { - return Math.max(r / 2, 1); + private int getCirDepth(double r, double angle) { + return Math.max(1, (int)(angle * r / circleQuarter)); } - private void quarterCircle(double x, double y, double r, double a, int cirDepth, Color color) { - a *= Math.PI / 2; - double cirPart = Math.PI / 2 / cirDepth; - vert2(x + Math.sin(a) * r, y - Math.cos(a) * r, color); + public void circlePart(double x, double y, double r, double startAngle, double angle, Color color) { + int cirDepth = getCirDepth(r, angle); + double cirPart = angle / cirDepth; + vert2(x + Math.sin(startAngle) * r, y - Math.cos(startAngle) * r, color); for (int i = 1; i < cirDepth + 1; i++) { vert2(x, y, color); - double xV = x + Math.sin(a + cirPart * i) * r; - double yV = y - Math.cos(a + cirPart * i) * r; + double xV = x + Math.sin(startAngle + cirPart * i) * r; + double yV = y - Math.cos(startAngle + cirPart * i) * r; vert2(xV, yV, color); if (i != cirDepth) vert2(xV, yV, color); } } - private void quarterCircleOutline(double x, double y, double r, double a, int cirDepth, Color color, double s) { - a *= Math.PI / 2; - double cirPart = Math.PI / 2 / cirDepth; + public void circlePartOutline(double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) { + int cirDepth = getCirDepth(r, angle); + double cirPart = angle / cirDepth; for (int i = 0; i < cirDepth; i++) { - double xOC = x + Math.sin(a + cirPart * i) * r; - double yOC = y - Math.cos(a + cirPart * i) * r; - double xIC = x + Math.sin(a + cirPart * i) * (r - s); - double yIC = y - Math.cos(a + cirPart * i) * (r - s); - double xON = x + Math.sin(a + cirPart * (i + 1)) * r; - double yON = y - Math.cos(a + cirPart * (i + 1)) * r; - double xIN = x + Math.sin(a + cirPart * (i + 1)) * (r - s); - double yIN = y - Math.cos(a + cirPart * (i + 1)) * (r - s); + double xOC = x + Math.sin(startAngle + cirPart * i) * r; + double yOC = y - Math.cos(startAngle + cirPart * i) * r; + double xIC = x + Math.sin(startAngle + cirPart * i) * (r - outlineWidth); + double yIC = y - Math.cos(startAngle + cirPart * i) * (r - outlineWidth); + double xON = x + Math.sin(startAngle + cirPart * (i + 1)) * r; + double yON = y - Math.cos(startAngle + cirPart * (i + 1)) * r; + double xIN = x + Math.sin(startAngle + cirPart * (i + 1)) * (r - outlineWidth); + double yIN = y - Math.cos(startAngle + cirPart * (i + 1)) * (r - outlineWidth); // vert2(xOC, yOC, color); vert2(xON, yON, color); From d07e057d7a9537e3e8df851d8167bd23a559b210 Mon Sep 17 00:00:00 2001 From: JFronny Date: Thu, 10 Jun 2021 16:03:33 +0200 Subject: [PATCH 08/13] Fix --- .../gui/renderer/GuiRenderer.java | 10 +- .../gui/themes/meteor/MeteorWidget.java | 6 +- .../meteorclient/renderer/Mesh.java | 9 ++ .../meteorclient/renderer/Renderer2D.java | 124 +++++++++++++++++ .../meteorclient/rendering/MeshBuilder.java | 129 ------------------ .../hud/modules/InventoryViewerHud.java | 4 +- 6 files changed, 144 insertions(+), 138 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java index aa1532ebaa..dc0ed3a737 100644 --- a/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java +++ b/src/main/java/minegame159/meteorclient/gui/renderer/GuiRenderer.java @@ -206,7 +206,7 @@ public void quad(double x, double y, double width, double height, GuiTexture tex } public void quadRounded(double x, double y, double width, double height, Color color, int round, boolean roundTop) { - mb.quadRounded(x, y, width, height, color, round, roundTop); + r.quadRounded(x, y, width, height, color, round, roundTop); } public void quadRounded(double x, double y, double width, double height, Color color, int round) { quadRounded(x, y, width, height, color, round, true); @@ -215,22 +215,22 @@ public void quadRounded(WWidget widget, Color color, int round) { quadRounded(widget.x, widget.y, widget.width, widget.height, color, round); } public void quadOutlineRounded(double x, double y, double width, double height, Color color, int round, double s) { - mb.quadRoundedOutline(x, y, width, height, color, round, s); + r.quadRoundedOutline(x, y, width, height, color, round, s); } public void quadOutlineRounded(WWidget widget, Color color, int round, double s) { quadOutlineRounded(widget.x, widget.y, widget.width, widget.height, color, round, s); } public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { - mb.quadRoundedSide(x, y, width, height, color, r, right); + this.r.quadRoundedSide(x, y, width, height, color, r, right); } public void quadRoundedSide(WWidget widget, Color color, int round, boolean right) { quadRoundedSide(widget.x, widget.y, widget.width, widget.height, color, round, right); } public void circlePart(double x, double y, double r, double startAngle, double angle, Color color) { - mb.circlePart(x, y, r, startAngle, angle, color); + this.r.circlePart(x, y, r, startAngle, angle, color); } public void circlePartOutline(double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) { - mb.circlePartOutline(x, y, r, startAngle, angle, color, outlineWidth); + this.r.circlePartOutline(x, y, r, startAngle, angle, color, outlineWidth); } public void rotatedQuad(double x, double y, double width, double height, double rotation, GuiTexture texture, Color color) { diff --git a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java index e4aa5a4aaf..b3df86b2f8 100644 --- a/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java +++ b/src/main/java/minegame159/meteorclient/gui/themes/meteor/MeteorWidget.java @@ -17,9 +17,11 @@ default MeteorGuiTheme theme() { default void renderBackground(GuiRenderer renderer, WWidget widget, boolean pressed, boolean mouseOver) { MeteorGuiTheme theme = theme(); + double s = theme.scale(2); + int r = theme.roundAmount(); Color outlineColor = theme.outlineColor.get(pressed, mouseOver); - renderer.quadRounded(widget, theme.backgroundColor.get(pressed, mouseOver), r); - renderer.quadOutlineRounded(widget, outlineColor, r, theme.scale(2)); + renderer.quadRounded(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver), r); + renderer.quadOutlineRounded(widget, outlineColor, r, s); } } diff --git a/src/main/java/minegame159/meteorclient/renderer/Mesh.java b/src/main/java/minegame159/meteorclient/renderer/Mesh.java index 895dbb44fb..e999dcd864 100644 --- a/src/main/java/minegame159/meteorclient/renderer/Mesh.java +++ b/src/main/java/minegame159/meteorclient/renderer/Mesh.java @@ -141,6 +141,15 @@ public void quad(int i1, int i2, int i3, int i4) { growIfNeeded(); } + public void triangle(int i1, int i2, int i3) { + indices.put(i1); + indices.put(i2); + indices.put(i3); + + indicesCount += 3; + growIfNeeded(); + } + private void growIfNeeded() { // Vertices if ((vertexI + 1) * primitiveVerticesSize >= vertices.capacity()) { diff --git a/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java b/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java index e91983cf3c..3e30323696 100644 --- a/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java +++ b/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java @@ -136,4 +136,128 @@ public void texQuad(double x, double y, double width, double height, double rota public void texQuad(double x, double y, double width, double height, double rotation, TextureRegion region, Color color) { texQuad(x, y, width, height, rotation, region.x1, region.y1, region.x2, region.y2, color); } + + // Rounded quad + + private final double circleNone = 0; + private final double circleQuarter = Math.PI / 2; + private final double circleHalf = circleQuarter * 2; + private final double circleThreeQuarter = circleQuarter * 3; + + public void quadRoundedOutline(double x, double y, double width, double height, Color color, int r, double s) { + r = getR(r, width, height); + if (r == 0) { + quad(x, y, width, s, color); + quad(x, y + height - s, width, s, color); + quad(x, y + s, s, height - s * 2, color); + quad(x + width - s, y + s, s, height - s * 2, color); + } + else { + //top + circlePartOutline(x + r, y + r, r, circleThreeQuarter, circleQuarter, color, s); + quad(x + r, y, width - r * 2, s, color); + circlePartOutline(x + width - r, y + r, r, circleNone, circleQuarter, color, s); + //middle + quad(x, y + r, s, height - r * 2, color); + quad(x + width - s, y + r, s, height - r * 2, color); + //bottom + circlePartOutline(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color, s); + quad(x + r, y + height - s, width - r * 2, s, color); + circlePartOutline(x + r, y + height - r, r, circleHalf, circleQuarter, color, s); + } + } + + public void quadRounded(double x, double y, double width, double height, Color color, int r, boolean roundTop) { + r = getR(r, width, height); + if (r == 0) + quad(x, y, width, height, color); + else { + if (roundTop) { + //top + circlePart(x + r, y + r, r, circleThreeQuarter, circleQuarter, color); + quad(x + r, y, width - 2 * r, r, color); + circlePart(x + width - r, y + r, r, circleNone, circleQuarter, color); + //middle + quad(x, y + r, width, height - 2 * r, color); + } + else { + //middle + quad(x, y, width, height - r, color); + } + //bottom + circlePart(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color); + quad(x + r, y + height - r, width - 2 * r, r, color); + circlePart(x + r, y + height - r, r, circleHalf, circleQuarter, color); + } + } + + public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { + r = getR(r, width, height); + if (r == 0) + quad(x, y, width, height, color); + else { + if (right) { + circlePart(x + width - r, y + r, r, circleNone, circleQuarter, color); + circlePart(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color); + quad(x, y, width - r, height, color); + quad(x + width - r, y + r, r, height - r * 2, color); + } + else { + circlePart(x + r, y + r, r, circleThreeQuarter, circleQuarter, color); + circlePart(x + r, y + height - r, r, circleHalf, circleQuarter, color); + quad(x + r, y, width - r, height, color); + quad(x, y + r, r, height - r * 2, color); + } + } + } + + private int getR(int r, double w, double h) { + if (r * 2 > h) { + r = (int)h / 2; + } + if (r * 2 > w) { + r = (int)w / 2; + } + return r; + } + + private int getCirDepth(double r, double angle) { + return Math.max(1, (int)(angle * r / circleQuarter)); + } + + public void circlePart(double x, double y, double r, double startAngle, double angle, Color color) { + int cirDepth = getCirDepth(r, angle); + double cirPart = angle / cirDepth; + int center = triangles.vec2(x, y).color(color).next(); + int prev = triangles.vec2(x + Math.sin(startAngle) * r, y - Math.cos(startAngle) * r).color(color).next(); + for (int i = 1; i < cirDepth + 1; i++) { + double xV = x + Math.sin(startAngle + cirPart * i) * r; + double yV = y - Math.cos(startAngle + cirPart * i) * r; + int next = triangles.vec2(xV, yV).color(color).next(); + triangles.triangle(prev, center, next); + prev = next; + } + } + + public void circlePartOutline(double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) { + int cirDepth = getCirDepth(r, angle); + double cirPart = angle / cirDepth; + for (int i = 0; i < cirDepth; i++) { + double xOC = x + Math.sin(startAngle + cirPart * i) * r; + double yOC = y - Math.cos(startAngle + cirPart * i) * r; + double xIC = x + Math.sin(startAngle + cirPart * i) * (r - outlineWidth); + double yIC = y - Math.cos(startAngle + cirPart * i) * (r - outlineWidth); + double xON = x + Math.sin(startAngle + cirPart * (i + 1)) * r; + double yON = y - Math.cos(startAngle + cirPart * (i + 1)) * r; + double xIN = x + Math.sin(startAngle + cirPart * (i + 1)) * (r - outlineWidth); + double yIN = y - Math.cos(startAngle + cirPart * (i + 1)) * (r - outlineWidth); + + triangles.quad( + triangles.vec2(xOC, yOC).color(color).next(), + triangles.vec2(xON, yON).color(color).next(), + triangles.vec2(xIC, yIC).color(color).next(), + triangles.vec2(xIN, yIN).color(color).next() + ); + } + } } diff --git a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java index 0b136fafb5..5bac528f1a 100644 --- a/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java +++ b/src/main/java/minegame159/meteorclient/rendering/MeshBuilder.java @@ -180,135 +180,6 @@ public void boxSides(double x1, double y1, double z1, double x2, double y2, doub if (Dir.isNot(excludeDir, Dir.EAST)) quad(x2, y1, z1, x2, y2, z1, x2, y2, z2, x2, y1, z2, color); // Right } - // Rounded quad - - private final double circleNone = 0; - private final double circleQuarter = Math.PI / 2; - private final double circleHalf = circleQuarter * 2; - private final double circleThreeQuarter = circleQuarter * 3; - - public void quadRoundedOutline(double x, double y, double width, double height, Color color, int r, double s) { - r = getR(r, width, height); - if (r == 0) { - quad(x, y, width, s, color); - quad(x, y + height - s, width, s, color); - quad(x, y + s, s, height - s * 2, color); - quad(x + width - s, y + s, s, height - s * 2, color); - } - else { - //top - circlePartOutline(x + r, y + r, r, circleThreeQuarter, circleQuarter, color, s); - quad(x + r, y, width - r * 2, s, color); - circlePartOutline(x + width - r, y + r, r, circleNone, circleQuarter, color, s); - //middle - quad(x, y + r, s, height - r * 2, color); - quad(x + width - s, y + r, s, height - r * 2, color); - //bottom - circlePartOutline(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color, s); - quad(x + r, y + height - s, width - r * 2, s, color); - circlePartOutline(x + r, y + height - r, r, circleHalf, circleQuarter, color, s); - } - } - - public void quadRounded(double x, double y, double width, double height, Color color, int r, boolean roundTop) { - r = getR(r, width, height); - if (r == 0) - quad(x, y, width, height, color); - else { - if (roundTop) { - //top - circlePart(x + r, y + r, r, circleThreeQuarter, circleQuarter, color); - quad(x + r, y, width - 2 * r, r, color); - circlePart(x + width - r, y + r, r, circleNone, circleQuarter, color); - //middle - quad(x, y + r, width, height - 2 * r, color); - } - else { - //middle - quad(x, y, width, height - r, color); - } - //bottom - circlePart(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color); - quad(x + r, y + height - r, width - 2 * r, r, color); - circlePart(x + r, y + height - r, r, circleHalf, circleQuarter, color); - } - } - - public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { - r = getR(r, width, height); - if (r == 0) - quad(x, y, width, height, color); - else { - if (right) { - circlePart(x + width - r, y + r, r, circleNone, circleQuarter, color); - circlePart(x + width - r, y + height - r, r, circleQuarter, circleQuarter, color); - quad(x, y, width - r, height, color); - quad(x + width - r, y + r, r, height - r * 2, color); - } - else { - circlePart(x + r, y + r, r, circleThreeQuarter, circleQuarter, color); - circlePart(x + r, y + height - r, r, circleHalf, circleQuarter, color); - quad(x + r, y, width - r, height, color); - quad(x, y + r, r, height - r * 2, color); - } - } - } - - private int getR(int r, double w, double h) { - if (r * 2 > h) { - r = (int)h / 2; - } - if (r * 2 > w) { - r = (int)w / 2; - } - return r; - } - - private int getCirDepth(double r, double angle) { - return Math.max(1, (int)(angle * r / circleQuarter)); - } - - public void circlePart(double x, double y, double r, double startAngle, double angle, Color color) { - int cirDepth = getCirDepth(r, angle); - double cirPart = angle / cirDepth; - vert2(x + Math.sin(startAngle) * r, y - Math.cos(startAngle) * r, color); - for (int i = 1; i < cirDepth + 1; i++) { - vert2(x, y, color); - double xV = x + Math.sin(startAngle + cirPart * i) * r; - double yV = y - Math.cos(startAngle + cirPart * i) * r; - vert2(xV, yV, color); - if (i != cirDepth) - vert2(xV, yV, color); - } - } - - public void circlePartOutline(double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) { - int cirDepth = getCirDepth(r, angle); - double cirPart = angle / cirDepth; - for (int i = 0; i < cirDepth; i++) { - double xOC = x + Math.sin(startAngle + cirPart * i) * r; - double yOC = y - Math.cos(startAngle + cirPart * i) * r; - double xIC = x + Math.sin(startAngle + cirPart * i) * (r - outlineWidth); - double yIC = y - Math.cos(startAngle + cirPart * i) * (r - outlineWidth); - double xON = x + Math.sin(startAngle + cirPart * (i + 1)) * r; - double yON = y - Math.cos(startAngle + cirPart * (i + 1)) * r; - double xIN = x + Math.sin(startAngle + cirPart * (i + 1)) * (r - outlineWidth); - double yIN = y - Math.cos(startAngle + cirPart * (i + 1)) * (r - outlineWidth); - // - vert2(xOC, yOC, color); - vert2(xON, yON, color); - vert2(xIC, yIC, color); - // - vert2(xIC, yIC, color); - vert2(xON, yON, color); - vert2(xIN, yIN, color); - } - } - - public void vert2(double x, double y, Color c) { - pos(x, y, 0).color(c).endVertex(); - } - // LINES public void line(double x1, double y1, double z1, double x2, double y2, double z2, Color startColor, Color endColor) { diff --git a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java index 8bab9819b9..7a3cf5fc52 100644 --- a/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java +++ b/src/main/java/minegame159/meteorclient/systems/modules/render/hud/modules/InventoryViewerHud.java @@ -95,12 +95,12 @@ private void drawBackground(int x, int y) { mc.getTextureManager().bindTexture(background.get() == Background.Texture ? TEXTURE : TEXTURE_TRANSPARENT); Renderer2D.TEXTURE.begin(); - Renderer2D.TEXTURE.texQuad(x, y, box.width, box.height, color.get(), GuiThemes.get().roundAmount(), true); + Renderer2D.TEXTURE.texQuad(x, y, box.width, box.height, color.get()); Renderer2D.TEXTURE.render(null); } case Flat -> { Renderer2D.COLOR.begin(); - Renderer2D.COLOR.quad(x, y, w, h, color.get(), GuiThemes.get().roundAmount(), true); + Renderer2D.COLOR.quadRounded(x, y, w, h, color.get(), GuiThemes.get().roundAmount(), true); Renderer2D.COLOR.render(null); } } From c5f98a4cff3f4523be97566d660bc77a1d5759c1 Mon Sep 17 00:00:00 2001 From: JFronny Date: Fri, 11 Jun 2021 17:06:06 +0200 Subject: [PATCH 09/13] Optimize circlePartOutline --- .../meteorclient/renderer/Renderer2D.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java b/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java index c41c2513e5..98c2e76ee2 100644 --- a/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java +++ b/src/main/java/minegame159/meteorclient/renderer/Renderer2D.java @@ -229,35 +229,33 @@ public void circlePart(double x, double y, double r, double startAngle, double a int cirDepth = getCirDepth(r, angle); double cirPart = angle / cirDepth; int center = triangles.vec2(x, y).color(color).next(); - int prev = triangles.vec2(x + Math.sin(startAngle) * r, y - Math.cos(startAngle) * r).color(color).next(); + int prev = vecOnCircle(x, y, r, startAngle, color); for (int i = 1; i < cirDepth + 1; i++) { - double xV = x + Math.sin(startAngle + cirPart * i) * r; - double yV = y - Math.cos(startAngle + cirPart * i) * r; - int next = triangles.vec2(xV, yV).color(color).next(); + int next = vecOnCircle(x, y, r, startAngle + cirPart * i, color); triangles.triangle(prev, center, next); prev = next; } } public void circlePartOutline(double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) { + if (outlineWidth >= r) { + circlePart(x, y, r, startAngle, angle, color); + return; + } int cirDepth = getCirDepth(r, angle); double cirPart = angle / cirDepth; - for (int i = 0; i < cirDepth; i++) { - double xOC = x + Math.sin(startAngle + cirPart * i) * r; - double yOC = y - Math.cos(startAngle + cirPart * i) * r; - double xIC = x + Math.sin(startAngle + cirPart * i) * (r - outlineWidth); - double yIC = y - Math.cos(startAngle + cirPart * i) * (r - outlineWidth); - double xON = x + Math.sin(startAngle + cirPart * (i + 1)) * r; - double yON = y - Math.cos(startAngle + cirPart * (i + 1)) * r; - double xIN = x + Math.sin(startAngle + cirPart * (i + 1)) * (r - outlineWidth); - double yIN = y - Math.cos(startAngle + cirPart * (i + 1)) * (r - outlineWidth); - - triangles.quad( - triangles.vec2(xOC, yOC).color(color).next(), - triangles.vec2(xON, yON).color(color).next(), - triangles.vec2(xIC, yIC).color(color).next(), - triangles.vec2(xIN, yIN).color(color).next() - ); + int innerPrev = vecOnCircle(x, y, r - outlineWidth, startAngle, color); + int outerPrev = vecOnCircle(x, y, r, startAngle, color); + for (int i = 1; i < cirDepth + 1; i++) { + int inner = vecOnCircle(x, y, r - outlineWidth, startAngle + cirPart * i, color); + int outer = vecOnCircle(x, y, r, startAngle + cirPart * i, color); + triangles.quad(inner, innerPrev, outerPrev, outer); + innerPrev = inner; + outerPrev = outer; } } + + private int vecOnCircle(double x, double y, double r, double angle, Color color) { + return triangles.vec2(x + Math.sin(angle) * r, y - Math.cos(angle) * r).color(color).next(); + } } From cb0ca2dcec474a76cf37e0adf4ec6feec90eb3c8 Mon Sep 17 00:00:00 2001 From: JFronny Date: Mon, 14 Jun 2021 20:34:31 +0200 Subject: [PATCH 10/13] Fix --- .../meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java b/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java index 8a0a596f48..f540aaa8af 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/widgets/WMeteorQuad.java @@ -6,7 +6,6 @@ package meteordevelopment.meteorclient.gui.themes.meteor.widgets; import meteordevelopment.meteorclient.gui.renderer.GuiRenderer; -import minegame159.meteorclient.gui.themes.meteor.MeteorWidget; import meteordevelopment.meteorclient.gui.widgets.WQuad; import meteordevelopment.meteorclient.utils.render.color.Color; From 37cc259bf0d671297ed06af6a4645aafd7716ee2 Mon Sep 17 00:00:00 2001 From: JFronny Date: Mon, 19 Jul 2021 13:47:00 +0200 Subject: [PATCH 11/13] Fix Mesh addition --- .../java/meteordevelopment/meteorclient/renderer/Mesh.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java b/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java index 90be748df0..9fc468db4b 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java @@ -155,9 +155,9 @@ public void quad(int i1, int i2, int i3, int i4) { } public void triangle(int i1, int i2, int i3) { - indices.put(i1); - indices.put(i2); - indices.put(i3); + indices.putInt(i1); + indices.putInt(i2); + indices.putInt(i3); indicesCount += 3; growIfNeeded(); From f3fdb3722089da140827b15b5f953334321df82a Mon Sep 17 00:00:00 2001 From: JFronny Date: Sat, 24 Jul 2021 12:24:46 +0200 Subject: [PATCH 12/13] Remove seams in MeteorWidget.renderBackground --- .../meteorclient/gui/renderer/GuiRenderer.java | 14 +++++++------- .../gui/themes/meteor/MeteorWidget.java | 2 +- .../meteorclient/gui/widgets/WTopBar.java | 1 - .../meteorclient/renderer/Renderer2D.java | 14 +++++++------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java b/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java index 0a44c2d164..21ca769dc9 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java @@ -206,25 +206,25 @@ public void quad(double x, double y, double width, double height, GuiTexture tex rTex.texQuad(x, y, width, height, texture.get(width, height), color); } - public void quadRounded(double x, double y, double width, double height, Color color, int round, boolean roundTop) { + public void quadRounded(double x, double y, double width, double height, Color color, double round, boolean roundTop) { r.quadRounded(x, y, width, height, color, round, roundTop); } - public void quadRounded(double x, double y, double width, double height, Color color, int round) { + public void quadRounded(double x, double y, double width, double height, Color color, double round) { quadRounded(x, y, width, height, color, round, true); } - public void quadRounded(WWidget widget, Color color, int round) { + public void quadRounded(WWidget widget, Color color, double round) { quadRounded(widget.x, widget.y, widget.width, widget.height, color, round); } - public void quadOutlineRounded(double x, double y, double width, double height, Color color, int round, double s) { + public void quadOutlineRounded(double x, double y, double width, double height, Color color, double round, double s) { r.quadRoundedOutline(x, y, width, height, color, round, s); } - public void quadOutlineRounded(WWidget widget, Color color, int round, double s) { + public void quadOutlineRounded(WWidget widget, Color color, double round, double s) { quadOutlineRounded(widget.x, widget.y, widget.width, widget.height, color, round, s); } - public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { + public void quadRoundedSide(double x, double y, double width, double height, Color color, double r, boolean right) { this.r.quadRoundedSide(x, y, width, height, color, r, right); } - public void quadRoundedSide(WWidget widget, Color color, int round, boolean right) { + public void quadRoundedSide(WWidget widget, Color color, double round, boolean right) { quadRoundedSide(widget.x, widget.y, widget.width, widget.height, color, round, right); } public void circlePart(double x, double y, double r, double startAngle, double angle, Color color) { diff --git a/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorWidget.java b/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorWidget.java index d765a52da9..7b472a778a 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorWidget.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorWidget.java @@ -21,7 +21,7 @@ default void renderBackground(GuiRenderer renderer, WWidget widget, boolean pres int r = theme.roundAmount(); Color outlineColor = theme.outlineColor.get(pressed, mouseOver); - renderer.quadRounded(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver), r); + renderer.quadRounded(widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver), r - s); renderer.quadOutlineRounded(widget, outlineColor, r, s); } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WTopBar.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WTopBar.java index de1399f06e..b024c47c1b 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WTopBar.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WTopBar.java @@ -75,7 +75,6 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub double pad = pad(); Color color = getButtonColor(pressed || (mc.currentScreen instanceof TabScreen && ((TabScreen) mc.currentScreen).tab == tab), mouseOver); - //renderer.quad(x, y, width, height, color); switch (getState(this)) { case 1: renderer.quadRoundedSide(this, color, theme.roundAmount(), false); diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/Renderer2D.java b/src/main/java/meteordevelopment/meteorclient/renderer/Renderer2D.java index 64d34eb9bd..402c31dcf1 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/Renderer2D.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/Renderer2D.java @@ -144,9 +144,9 @@ public void texQuad(double x, double y, double width, double height, double rota private final double circleHalf = circleQuarter * 2; private final double circleThreeQuarter = circleQuarter * 3; - public void quadRoundedOutline(double x, double y, double width, double height, Color color, int r, double s) { + public void quadRoundedOutline(double x, double y, double width, double height, Color color, double r, double s) { r = getR(r, width, height); - if (r == 0) { + if (r <= 0) { quad(x, y, width, s, color); quad(x, y + height - s, width, s, color); quad(x, y + s, s, height - s * 2, color); @@ -167,9 +167,9 @@ public void quadRoundedOutline(double x, double y, double width, double height, } } - public void quadRounded(double x, double y, double width, double height, Color color, int r, boolean roundTop) { + public void quadRounded(double x, double y, double width, double height, Color color, double r, boolean roundTop) { r = getR(r, width, height); - if (r == 0) + if (r <= 0) quad(x, y, width, height, color); else { if (roundTop) { @@ -191,9 +191,9 @@ public void quadRounded(double x, double y, double width, double height, Color c } } - public void quadRoundedSide(double x, double y, double width, double height, Color color, int r, boolean right) { + public void quadRoundedSide(double x, double y, double width, double height, Color color, double r, boolean right) { r = getR(r, width, height); - if (r == 0) + if (r <= 0) quad(x, y, width, height, color); else { if (right) { @@ -211,7 +211,7 @@ public void quadRoundedSide(double x, double y, double width, double height, Col } } - private int getR(int r, double w, double h) { + private double getR(double r, double w, double h) { if (r * 2 > h) { r = (int)h / 2; } From 1c4207045f4c6240de572fe9dbb099d9c3a42789 Mon Sep 17 00:00:00 2001 From: JFronny Date: Sat, 21 Aug 2021 18:51:22 +0200 Subject: [PATCH 13/13] Update mesh patch for DMA --- .../meteordevelopment/meteorclient/renderer/Mesh.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java b/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java index 6e34b6337e..603f937fa7 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java @@ -175,9 +175,11 @@ public void quad(int i1, int i2, int i3, int i4) { } public void triangle(int i1, int i2, int i3) { - indices.putInt(i1); - indices.putInt(i2); - indices.putInt(i3); + long p = indicesPointer + indicesCount * 4L; + + memPutInt(p, i1); + memPutInt(p + 4, i2); + memPutInt(p + 8, i3); indicesCount += 3; growIfNeeded();