Fixed crash when exit

This commit is contained in:
2025-04-26 00:10:39 +02:00
parent 32c1391336
commit ece5a16d34
3 changed files with 34 additions and 9 deletions
@@ -172,4 +172,25 @@ public class RenderScope {
vertexConsumer.vertex(matrix4f, (float)x2, (float)y2, 0.0F).texture(u2, v2).color(color);
vertexConsumer.vertex(matrix4f, (float)x2, (float)y1, 0.0F).texture(u2, v1).color(color);
}
public void drawRoundedBorderCorner(int width, int height, int radius, int color) {
int h = height;
int s = 3;
for (int y = 0; y < h; y+=s) {
int startX = 0;
if (y < radius) {
double dy = radius - y - 0.5;
double dx = Math.sqrt(Math.max(0, radius * radius - dy * dy));
startX = radius - (int) dx;
}
this.drawRect(startX, y, s, s, color);
}
}
public void drawRoundedBorder(int x, int y, int width, int height, int borderSize, int radius, int color) {
}
}
@@ -32,14 +32,17 @@ public class Button extends Element {
@Override
public void render(RenderScope renderScope, RenderContext ctx) {
if (ctx.isHovering()) {
theme.setState("hovering");
} else {
theme.setState(null);
}
renderScope.drawRoundedRectangle(0, 0, width, height, 10, bgColor.value);
renderScope.drawRoundedBorderCorner(50, 50, 30, fgColor.value);
renderScope.drawRect(30, 0, width, 3, -1);
renderScope.drawText(text, width / 2 - Fonts.getWidth(text, font) / 2, height / 2 - Fonts.getHeight() / 2, bold.value, fgColor.value);
// if (ctx.isHovering()) {
// theme.setState("hovering");
// } else {
// theme.setState(null);
// }
// renderScope.drawRoundedRectangle(0, 0, width, height, 10, bgColor.value);
// renderScope.drawText(text, width / 2 - Fonts.getWidth(text, font) / 2, height / 2 - Fonts.getHeight() / 2, bold.value, fgColor.value);
}
@Override
@@ -1,6 +1,7 @@
package org.saturnclient.ui2.screens;
import org.saturnclient.saturnclient.SaturnClient;
import org.saturnclient.saturnclient.menus.ModMenu;
import org.saturnclient.ui2.SaturnScreen;
import org.saturnclient.ui2.elements.Button;
@@ -11,8 +12,8 @@ public class ShiftMenu extends SaturnScreen {
@Override
public void ui() {
draw(new Button("Click Me!", () -> {
SaturnClient.LOGGER.info("Clicked!");
draw(new Button("Settings", () -> {
SaturnClient.client.setScreen(new ModMenu());
}).center(width, height));
}
}