This commit is contained in:
2025-05-06 08:00:09 -05:00
parent d37d4e49f9
commit 9a7b93ccbe
12 changed files with 52 additions and 38 deletions
@@ -44,12 +44,12 @@ public class SaturnUi extends Screen {
public static MutableText text(String text) {
return Text.literal(text).setStyle(
Style.EMPTY.withFont(Identifier.of("saturnclient:panton")));
Style.EMPTY.withFont(Identifier.of("saturnclient:inter")));
}
public static MutableText textBold(String text) {
return Text.literal(text).setStyle(
Style.EMPTY.withFont(Identifier.of("saturnclient:panton_bold")));
Style.EMPTY.withFont(Identifier.of("saturnclient:inter_bold")));
}
public static void drawHighResTexture(DrawContext context, Identifier t, int x, int y, int w, int h) {
@@ -14,6 +14,10 @@ public class RenderContext {
}
public boolean isHovering() {
return Utils.isHovering(mouseX , mouseY, elementWidth, elementHeight, elementScale);
return Utils.isHovering(mouseX, mouseY, elementWidth, elementHeight, elementScale);
}
public boolean isHovering(int x, int y, int width, int height) {
return Utils.isHovering(mouseX - x, mouseY - y, width, height, elementScale);
}
}
@@ -82,7 +82,7 @@ public class RenderScope {
public void drawText(String text, int x, int y, boolean bold, int color) {
color = getColor(color);
Identifier font = bold ? Fonts.PANTON_BOLD : Fonts.PANTON;
Identifier font = bold ? Fonts.INTER_BOLD : Fonts.INTER;
matrices.push();
matrices.translate(x, y, 0);
@@ -1,9 +1,13 @@
package org.saturnclient.ui2.components;
import org.saturnclient.modules.Module;
import org.saturnclient.ui.Textures;
import org.saturnclient.ui2.Element;
import org.saturnclient.ui2.RenderContext;
import org.saturnclient.ui2.RenderScope;
import org.saturnclient.ui2.resources.Fonts;
import net.minecraft.client.render.RenderLayer;
public class SaturnModule extends Element {
private Module mod;
@@ -31,7 +35,39 @@ public class SaturnModule extends Element {
renderScope.matrices.push();
renderScope.matrices.translate(10 + 7, 30, 0);
renderScope.matrices.scale(0.7f, 0.7f, 1.0f);
renderScope.drawText(mod.getDescription(), 0, 0, false, 0xFFAAAAAA);
renderScope.drawText(formatText(mod.getDescription(), width - 7 - 10), 0, 0, false, 0xFFAAAAAA);
renderScope.matrices.pop();
if (ctx.isHovering(10 + 7, height - 10 - 10, 10, 10)) {
}
renderScope.setRenderLayer(RenderLayer::getGuiTextured);
renderScope.drawTexture(Textures.SETTINGS, 10 + 7, height - 10 - 10, 0, 0, 10, 10);
}
@Override
public void click(int mouseX, int mouseY) {
mod.setEnabled(!mod.isEnabled());
}
private static String formatText(String text, int width) {
width -= Fonts.getWidth("..", Fonts.INTER);
StringBuilder trimmedText = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
String current = trimmedText.toString() + text.charAt(i);
double currentWidth = Fonts.getWidth(current, Fonts.INTER) * 0.7;
if (currentWidth > width) {
trimmedText.append("..");
break;
}
trimmedText.append(text.charAt(i));
}
return trimmedText.toString();
}
}
@@ -6,14 +6,14 @@ import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class Fonts {
public static final Identifier PANTON = Identifier.of("saturnclient", "panton");
public static final Identifier PANTON_BOLD = Identifier.of("saturnclient", "panton_bold");
public static final Identifier INTER = Identifier.of("saturnclient", "inter");
public static final Identifier INTER_BOLD = Identifier.of("saturnclient", "inter_bold");
public static Identifier getFont(boolean bold) {
if (bold) {
return PANTON_BOLD;
return INTER_BOLD;
} else {
return PANTON;
return INTER;
}
}
@@ -2,11 +2,11 @@
"providers": [
{
"type": "reference",
"id": "saturnclient:panton"
"id": "saturnclient:inter"
},
{
"type": "reference",
"id": "saturnclient:panton_bold"
"id": "saturnclient:inter_bold"
}
]
}
@@ -1,3 +1 @@
This font was designed by Ivan Petrov and published by Fontfabric.
The panton font is the regular version of: https://www.dafont.com/panton.font
Here is the font download: https://fonts.google.com/specimen/Inter
@@ -1,12 +0,0 @@
{
"providers": [
{
"type": "ttf",
"file": "saturnclient:panton.ttf",
"shift": [0, 0],
"size": 9,
"oversample": 5.0,
"skip_missing": true
}
]
}
@@ -1,12 +0,0 @@
{
"providers": [
{
"type": "ttf",
"file": "saturnclient:panton_bold.ttf",
"shift": [0, 0],
"size": 9,
"oversample": 5.0,
"skip_missing": true
}
]
}