Fixed crash when exit
This commit is contained in:
@@ -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)y2, 0.0F).texture(u2, v2).color(color);
|
||||||
vertexConsumer.vertex(matrix4f, (float)x2, (float)y1, 0.0F).texture(u2, v1).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
|
@Override
|
||||||
public void render(RenderScope renderScope, RenderContext ctx) {
|
public void render(RenderScope renderScope, RenderContext ctx) {
|
||||||
if (ctx.isHovering()) {
|
renderScope.drawRoundedBorderCorner(50, 50, 30, fgColor.value);
|
||||||
theme.setState("hovering");
|
renderScope.drawRect(30, 0, width, 3, -1);
|
||||||
} 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);
|
// 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
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.saturnclient.ui2.screens;
|
package org.saturnclient.ui2.screens;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
import org.saturnclient.saturnclient.menus.ModMenu;
|
||||||
import org.saturnclient.ui2.SaturnScreen;
|
import org.saturnclient.ui2.SaturnScreen;
|
||||||
import org.saturnclient.ui2.elements.Button;
|
import org.saturnclient.ui2.elements.Button;
|
||||||
|
|
||||||
@@ -11,8 +12,8 @@ public class ShiftMenu extends SaturnScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ui() {
|
public void ui() {
|
||||||
draw(new Button("Click Me!", () -> {
|
draw(new Button("Settings", () -> {
|
||||||
SaturnClient.LOGGER.info("Clicked!");
|
SaturnClient.client.setScreen(new ModMenu());
|
||||||
}).center(width, height));
|
}).center(width, height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user