Skip to content

Commit 3367c39

Browse files
committed
Round widgets
1 parent 4a1d24c commit 3367c39

File tree

9 files changed

+144
-21
lines changed

9 files changed

+144
-21
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ org.gradle.jvmargs=-Xmx2G
33
org.gradle.parallel=true
44

55
# SimpleClient
6-
simpleclient_version=0.2.5
6+
simpleclient_version=0.2.6
77
discord_game_sdk_version=v0.5.5

simpleclient-1.19.4/src/main/java/simpleclient/gui/EditFeaturesScreen.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import simpleclient.adapter.TextRendererAdapterImpl;
1919
import simpleclient.feature.*;
2020
import simpleclient.text.Text;
21+
import simpleclient.util.DrawUtil;
2122

2223
import java.io.IOException;
2324
import java.util.List;
@@ -66,14 +67,26 @@ public void render(PoseStack poseStack, int mouseX, int mouseY, float delta) {
6667
int wX2 = (2 + wSize) * x + wSize;
6768
int wY2 = 2 + (2 + wSize) * y + wSize;
6869
// Background
69-
GuiComponent.fill(poseStack, wX1, scroll + wY1, wX2, scroll + wY2, 0xff555555);
70+
int corners = (wY2 - wY1) / 8;
71+
DrawUtil.drawCircle(poseStack, wX1 + corners, scroll + wY1 + corners, corners, 90.0F, -90.0F, 0xFF555555);
72+
DrawUtil.drawCircle(poseStack, wX2 - corners, scroll + wY1 + corners, corners, 90.0F, 0.0F, 0xFF555555);
73+
DrawUtil.drawCircle(poseStack, wX1 + corners, scroll + wY2 - corners, corners, 90.0F, 180.0F, 0xFF555555);
74+
DrawUtil.drawCircle(poseStack, wX2 - corners, scroll + wY2 - corners, corners, 90.0F, 90.0F, 0xFF555555);
75+
Gui.fill(poseStack, wX1 + corners, scroll + wY1, wX2 - corners, scroll + wY1 + corners, 0xFF555555);
76+
Gui.fill(poseStack, wX1 + corners, scroll + wY2 - corners, wX2 - corners, scroll + wY2, 0xFF555555);
77+
Gui.fill(poseStack, wX1, scroll + wY1 + corners, wX1 + corners, scroll + wY2 - corners, 0xFF555555);
78+
Gui.fill(poseStack, wX2 - corners, scroll + wY1 + corners, wX2, scroll + wY2 - corners, 0xFF555555);
79+
Gui.fill(poseStack, wX1 + corners, scroll + wY1 + corners, wX2 - corners, scroll + wY2 - corners, 0xFF555555);
7080
// Enable Button
7181
if (feature instanceof EnableableFeature ef) {
72-
GuiComponent.fill(poseStack, wX1 + wSize / 10, scroll + wY2 - wSize / 10 - wSize / 3 / 2, wX1 + wSize / 10 + wSize / 3, scroll + wY2 - wSize / 10, ef.isEnabled() ? 0xff00ff00 : 0xffff0000);
82+
int height = wSize / 6;
83+
DrawUtil.drawCircle(poseStack, wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - height / 2, height / 2, 180.0F, 180.0F, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
84+
DrawUtil.drawCircle(poseStack, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10 - height / 2, height / 2, 180.0F, 0.0F, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
85+
Gui.fill(poseStack, wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - height, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
7386
if (ef.isEnabled()) {
74-
GuiComponent.fill(poseStack, wX1 + wSize / 10 + wSize / 3 / 2 + wSize / 20, scroll + wY2 - wSize / 10 - wSize / 3 / 2 + wSize / 20, wX1 + wSize / 10 + wSize / 3 - wSize / 20, scroll + wY2 - wSize / 10 - wSize / 20, 0xff000000);
87+
DrawUtil.drawCircle(poseStack, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10 - height / 2, height * 2 / 5, 360.0F, 0.0F, 0xFF000000);
7588
} else {
76-
GuiComponent.fill(poseStack, wX1 + wSize / 10 + wSize / 20, scroll + wY2 - wSize / 10 - wSize / 3 / 2 + wSize / 20, wX1 + wSize / 10 + wSize / 3 / 2 - wSize / 20, scroll + wY2 - wSize / 10 - wSize / 20, 0xff000000);
89+
DrawUtil.drawCircle(poseStack, wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - height / 2, height * 2 / 5, 360.0F, 0.0F, 0xFF000000);
7790
}
7891
}
7992
// Config Button
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package simpleclient.util;
2+
3+
import com.mojang.blaze3d.vertex.PoseStack;
4+
import com.mojang.math.Axis;
5+
import net.minecraft.client.gui.Gui;
6+
import net.minecraft.client.gui.GuiComponent;
7+
8+
public class DrawUtil {
9+
public static void drawCircle(PoseStack poseStack, int x, int y, int radius, float degrees, float rotation, int color) {
10+
float detail = 1.1F;
11+
int i = (int) (2 * Math.PI * radius * detail);
12+
for (int j = 0; j < i; j++) {
13+
poseStack.pushPose();
14+
poseStack.translate(x, y, 0);
15+
poseStack.pushPose();
16+
poseStack.rotateAround(Axis.ZP.rotationDegrees(rotation + degrees / i * j), 0, 0, 0);
17+
GuiComponent.vLine(poseStack, 0, -radius - 1, 0, color);
18+
poseStack.popPose();
19+
poseStack.popPose();
20+
}
21+
}
22+
23+
public static void drawCircle(PoseStack poseStack, int x, int y, int radius, float degrees, int color) {
24+
drawCircle(poseStack, x, y, radius, degrees, 0.0F, color);
25+
}
26+
27+
public static void drawCircle(PoseStack poseStack, int x, int y, int radius, int color) {
28+
drawCircle(poseStack, x, y, radius, 360.0F, color);
29+
}
30+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
accessWidener v1 named
22
extendable class net/minecraft/client/OptionInstance
3-
mutable field net/minecraft/client/Options gamma Lnet/minecraft/client/OptionInstance;
3+
mutable field net/minecraft/client/Options gamma Lnet/minecraft/client/OptionInstance;
4+
accessible method net/minecraft/client/gui/GuiComponent vLine (Lcom/mojang/blaze3d/vertex/PoseStack;IIII)V

simpleclient-1.20.1/src/main/java/simpleclient/gui/EditFeaturesScreen.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package simpleclient.gui;
22

3-
import com.mojang.blaze3d.systems.RenderSystem;
4-
import com.mojang.blaze3d.vertex.PoseStack;
53
import com.mojang.math.Axis;
64
import net.minecraft.client.gui.GuiGraphics;
75
import net.minecraft.client.gui.screens.Screen;
8-
import net.minecraft.client.renderer.GameRenderer;
96
import net.minecraft.network.chat.Component;
107
import net.minecraft.resources.ResourceLocation;
118
import simpleclient.adapter.ItemRendererAdapter;
@@ -14,6 +11,7 @@
1411
import simpleclient.adapter.TextRendererAdapterImpl;
1512
import simpleclient.feature.*;
1613
import simpleclient.text.Text;
14+
import simpleclient.util.DrawUtil;
1715

1816
import java.util.List;
1917

@@ -56,19 +54,31 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
5654
int x = i % count;
5755
int y = i / count;
5856
int wSize = (width / 4 - 2 - count * 2) / count;
59-
int wX1 = 2 + (2 + wSize) * x;
57+
int wX1 = 3 + (2 + wSize) * x;
6058
int wY1 = 2 + 2 + (2 + wSize) * y;
61-
int wX2 = (2 + wSize) * x + wSize;
59+
int wX2 = (2 + wSize) * x + wSize + 1;
6260
int wY2 = 2 + (2 + wSize) * y + wSize;
6361
// Background
64-
guiGraphics.fill(wX1, scroll + wY1, wX2, scroll + wY2, 0xff555555);
62+
int corners = (wY2 - wY1) / 8;
63+
DrawUtil.drawCircle(guiGraphics, wX1 + corners, scroll + wY1 + corners, corners, 90.0F, -90.0F, 0xFF555555);
64+
DrawUtil.drawCircle(guiGraphics, wX2 - corners, scroll + wY1 + corners, corners, 90.0F, 0.0F, 0xFF555555);
65+
DrawUtil.drawCircle(guiGraphics, wX1 + corners, scroll + wY2 - corners, corners, 90.0F, 180.0F, 0xFF555555);
66+
DrawUtil.drawCircle(guiGraphics, wX2 - corners, scroll + wY2 - corners, corners, 90.0F, 90.0F, 0xFF555555);
67+
guiGraphics.fill(wX1 + corners, scroll + wY1, wX2 - corners, scroll + wY1 + corners, 0xFF555555);
68+
guiGraphics.fill(wX1 + corners, scroll + wY2 - corners, wX2 - corners, scroll + wY2, 0xFF555555);
69+
guiGraphics.fill(wX1, scroll + wY1 + corners, wX1 + corners, scroll + wY2 - corners, 0xFF555555);
70+
guiGraphics.fill(wX2 - corners, scroll + wY1 + corners, wX2, scroll + wY2 - corners, 0xFF555555);
71+
guiGraphics.fill(wX1 + corners, scroll + wY1 + corners, wX2 - corners, scroll + wY2 - corners, 0xFF555555);
6572
// Enable Button
6673
if (feature instanceof EnableableFeature ef) {
67-
guiGraphics.fill(wX1 + wSize / 10, scroll + wY2 - wSize / 10 - wSize / 3 / 2, wX1 + wSize / 10 + wSize / 3, scroll + wY2 - wSize / 10, ef.isEnabled() ? 0xff00ff00 : 0xffff0000);
74+
int height = wSize / 6;
75+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - height / 2, height / 2, 180.0F, 180.0F, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
76+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10 - height / 2, height / 2, 180.0F, 0.0F, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
77+
guiGraphics.fill(wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - wSize / 3 / 2, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
6878
if (ef.isEnabled()) {
69-
guiGraphics.fill(wX1 + wSize / 10 + wSize / 3 / 2 + wSize / 20, scroll + wY2 - wSize / 10 - wSize / 3 / 2 + wSize / 20, wX1 + wSize / 10 + wSize / 3 - wSize / 20, scroll + wY2 - wSize / 10 - wSize / 20, 0xff000000);
79+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10 - height / 2, height * 2 / 5, 360.0F, 0.0F, 0xFF000000);
7080
} else {
71-
guiGraphics.fill(wX1 + wSize / 10 + wSize / 20, scroll + wY2 - wSize / 10 - wSize / 3 / 2 + wSize / 20, wX1 + wSize / 10 + wSize / 3 / 2 - wSize / 20, scroll + wY2 - wSize / 10 - wSize / 20, 0xff000000);
81+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - height / 2, height * 2 / 5, 360.0F, 0.0F, 0xFF000000);
7282
}
7383
}
7484
// Config Button
@@ -78,7 +88,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
7888
int cogwheelX = wX1 + wSize / 10 * 4 + wSize / 3;
7989
int cogwheelY = scroll + wY2 - wSize / 10 - wSize / 3 / 2;
8090
if (cogwheelX <= mouseX && mouseX <= cogwheelX + h &&
81-
cogwheelY <= mouseY && mouseY <= cogwheelY + h) {
91+
cogwheelY <= mouseY && mouseY <= cogwheelY + h) {
8292
guiGraphics.pose().rotateAround(Axis.ZP.rotation((float) (System.currentTimeMillis() % 4000) / 400), cogwheelX + h / 2, cogwheelY + h / 2, 0.0F);
8393
}
8494
guiGraphics.blit(new ResourceLocation("simpleclient", "textures/settings.png"), cogwheelX, cogwheelY, 0, 0, h, h, h, h);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package simpleclient.util;
2+
3+
import com.mojang.math.Axis;
4+
import net.minecraft.client.gui.GuiGraphics;
5+
6+
public class DrawUtil {
7+
public static void drawCircle(GuiGraphics guiGraphics, int x, int y, int radius, float degrees, float rotation, int color) {
8+
float detail = 1.1F;
9+
int i = (int) (2 * Math.PI * radius * detail);
10+
for (int j = 0; j < i; j++) {
11+
guiGraphics.pose().pushPose();
12+
guiGraphics.pose().translate(x, y, 0);
13+
guiGraphics.pose().pushPose();
14+
guiGraphics.pose().rotateAround(Axis.ZP.rotationDegrees(rotation + degrees / i * j), 0, 0, 0);
15+
guiGraphics.vLine(0, -radius - 1, 0, color);
16+
guiGraphics.pose().popPose();
17+
guiGraphics.pose().popPose();
18+
}
19+
}
20+
21+
public static void drawCircle(GuiGraphics guiGraphics, int x, int y, int radius, float degrees, int color) {
22+
drawCircle(guiGraphics, x, y, radius, degrees, 0.0F, color);
23+
}
24+
25+
public static void drawCircle(GuiGraphics guiGraphics, int x, int y, int radius, int color) {
26+
drawCircle(guiGraphics, x, y, radius, 360.0F, color);
27+
}
28+
}

simpleclient-1.20/src/main/java/simpleclient/gui/EditFeaturesScreen.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import simpleclient.adapter.TextRendererAdapterImpl;
1515
import simpleclient.feature.*;
1616
import simpleclient.text.Text;
17+
import simpleclient.util.DrawUtil;
1718

1819
import java.util.List;
1920

@@ -61,14 +62,26 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
6162
int wX2 = (2 + wSize) * x + wSize;
6263
int wY2 = 2 + (2 + wSize) * y + wSize;
6364
// Background
64-
guiGraphics.fill(wX1, scroll + wY1, wX2, scroll + wY2, 0xff555555);
65+
int corners = (wY2 - wY1) / 8;
66+
DrawUtil.drawCircle(guiGraphics, wX1 + corners, scroll + wY1 + corners, corners, 90.0F, -90.0F, 0xFF555555);
67+
DrawUtil.drawCircle(guiGraphics, wX2 - corners, scroll + wY1 + corners, corners, 90.0F, 0.0F, 0xFF555555);
68+
DrawUtil.drawCircle(guiGraphics, wX1 + corners, scroll + wY2 - corners, corners, 90.0F, 180.0F, 0xFF555555);
69+
DrawUtil.drawCircle(guiGraphics, wX2 - corners, scroll + wY2 - corners, corners, 90.0F, 90.0F, 0xFF555555);
70+
guiGraphics.fill(wX1 + corners, scroll + wY1, wX2 - corners, scroll + wY1 + corners, 0xFF555555);
71+
guiGraphics.fill(wX1 + corners, scroll + wY2 - corners, wX2 - corners, scroll + wY2, 0xFF555555);
72+
guiGraphics.fill(wX1, scroll + wY1 + corners, wX1 + corners, scroll + wY2 - corners, 0xFF555555);
73+
guiGraphics.fill(wX2 - corners, scroll + wY1 + corners, wX2, scroll + wY2 - corners, 0xFF555555);
74+
guiGraphics.fill(wX1 + corners, scroll + wY1 + corners, wX2 - corners, scroll + wY2 - corners, 0xFF555555);
6575
// Enable Button
6676
if (feature instanceof EnableableFeature ef) {
67-
guiGraphics.fill(wX1 + wSize / 10, scroll + wY2 - wSize / 10 - wSize / 3 / 2, wX1 + wSize / 10 + wSize / 3, scroll + wY2 - wSize / 10, ef.isEnabled() ? 0xff00ff00 : 0xffff0000);
77+
int height = wSize / 6;
78+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - height / 2, height / 2, 180.0F, 180.0F, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
79+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10 - height / 2, height / 2, 180.0F, 0.0F, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
80+
guiGraphics.fill(wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - wSize / 3 / 2, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10, ef.isEnabled() ? 0xFF00FF00 : 0xFFFF0000);
6881
if (ef.isEnabled()) {
69-
guiGraphics.fill(wX1 + wSize / 10 + wSize / 3 / 2 + wSize / 20, scroll + wY2 - wSize / 10 - wSize / 3 / 2 + wSize / 20, wX1 + wSize / 10 + wSize / 3 - wSize / 20, scroll + wY2 - wSize / 10 - wSize / 20, 0xff000000);
82+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + wSize / 3 - height / 2, scroll + wY2 - wSize / 10 - height / 2, height * 2 / 5, 360.0F, 0.0F, 0xFF000000);
7083
} else {
71-
guiGraphics.fill(wX1 + wSize / 10 + wSize / 20, scroll + wY2 - wSize / 10 - wSize / 3 / 2 + wSize / 20, wX1 + wSize / 10 + wSize / 3 / 2 - wSize / 20, scroll + wY2 - wSize / 10 - wSize / 20, 0xff000000);
84+
DrawUtil.drawCircle(guiGraphics, wX1 + wSize / 10 + height / 2, scroll + wY2 - wSize / 10 - height / 2, height * 2 / 5, 360.0F, 0.0F, 0xFF000000);
7285
}
7386
}
7487
// Config Button
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package simpleclient.util;
2+
3+
import com.mojang.math.Axis;
4+
import net.minecraft.client.gui.GuiGraphics;
5+
6+
public class DrawUtil {
7+
public static void drawCircle(GuiGraphics guiGraphics, int x, int y, int radius, float degrees, float rotation, int color) {
8+
float detail = 1.1F;
9+
int i = (int) (2 * Math.PI * radius * detail);
10+
for (int j = 0; j < i; j++) {
11+
guiGraphics.pose().pushPose();
12+
guiGraphics.pose().translate(x, y, 0);
13+
guiGraphics.pose().pushPose();
14+
guiGraphics.pose().rotateAround(Axis.ZP.rotationDegrees(rotation + degrees / i * j), 0, 0, 0);
15+
guiGraphics.vLine(0, -radius - 1, 0, color);
16+
guiGraphics.pose().popPose();
17+
guiGraphics.pose().popPose();
18+
}
19+
}
20+
21+
public static void drawCircle(GuiGraphics guiGraphics, int x, int y, int radius, float degrees, int color) {
22+
drawCircle(guiGraphics, x, y, radius, degrees, 0.0F, color);
23+
}
24+
25+
public static void drawCircle(GuiGraphics guiGraphics, int x, int y, int radius, int color) {
26+
drawCircle(guiGraphics, x, y, radius, 360.0F, color);
27+
}
28+
}

simpleclient-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ dependencies {
1515
}
1616

1717
tasks.withType(JavaCompile).configureEach {
18-
it.options.release = 8
18+
it.options.release = 17
1919
}

0 commit comments

Comments
 (0)