diff --git a/src/main/java/org/saturnclient/modules/Module.java b/src/main/java/org/saturnclient/modules/Module.java index 989cf33..95dcb03 100644 --- a/src/main/java/org/saturnclient/modules/Module.java +++ b/src/main/java/org/saturnclient/modules/Module.java @@ -2,7 +2,7 @@ package org.saturnclient.modules; import org.saturnclient.saturnclient.config.ConfigManager; import org.saturnclient.saturnclient.config.NamedProperty; -import org.saturnclient.ui.Textures; +import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.RenderScope; import net.minecraft.util.Identifier; diff --git a/src/main/java/org/saturnclient/saturnclient/SaturnClientConfig.java b/src/main/java/org/saturnclient/saturnclient/SaturnClientConfig.java index ebadff2..5d112ec 100644 --- a/src/main/java/org/saturnclient/saturnclient/SaturnClientConfig.java +++ b/src/main/java/org/saturnclient/saturnclient/SaturnClientConfig.java @@ -2,48 +2,20 @@ package org.saturnclient.saturnclient; import org.saturnclient.saturnclient.config.Property; import org.saturnclient.saturnclient.config.ConfigManager; -import org.saturnclient.ui.SaturnAnimation; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.Textures; -import org.saturnclient.ui.animations.FadeIn; +import org.saturnclient.ui2.resources.Textures; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; -import net.minecraft.util.math.ColorHelper; public class SaturnClientConfig { public static ConfigManager config; - public static Property color = - new Property<>( - ColorHelper.getArgb(255, 251, 60, 79), - Property.PropertyType.HEX); - - public static Property normal = - new Property<>( - ColorHelper.getArgb(255, 182, 182, 182), - Property.PropertyType.HEX); - public static Property realisticLogo = new Property<>(false); public static Property saturnTitleScreen = new Property<>(true); - public static int WHITE = ColorHelper.getArgb(255, 255, 255, 255); - - public static int getWhite(float alpha) { - return ((int) (alpha * 255) << 24) | (normal.value & 0x00FFFFFF); - } - - public static int getColor(boolean hovering, float alpha) { - return SaturnUi.getAlpha(hovering ? color.value : normal.value, alpha); - } - - public static SaturnAnimation[] getAnimations() { - return new SaturnAnimation[] { new FadeIn(1) }; - } - public static Identifier getLogo() { return realisticLogo.value ? Textures.REALISTIC_LOGO : Textures.LOGO; } @@ -71,9 +43,6 @@ public class SaturnClientConfig { public static void init() { config = new ConfigManager("Saturn Client"); - - config.property("Primary color", color); - config.property("Default color", normal); config.property("Realistic logo", realisticLogo); config.property("Saturn client title screen", saturnTitleScreen); } diff --git a/src/main/java/org/saturnclient/saturnclient/menus/HudEditor.java b/src/main/java/org/saturnclient/saturnclient/menus/HudEditor.java index 7fc3de2..2d9b92a 100644 --- a/src/main/java/org/saturnclient/saturnclient/menus/HudEditor.java +++ b/src/main/java/org/saturnclient/saturnclient/menus/HudEditor.java @@ -10,7 +10,7 @@ import org.saturnclient.modules.ModDimensions; import org.saturnclient.modules.ModManager; import org.saturnclient.modules.Module; import org.saturnclient.saturnclient.config.ConfigManager; -import org.saturnclient.ui.SaturnUi; +import org.saturnclient.ui2.SaturnScreen; import java.util.ArrayList; import java.util.List; @@ -90,7 +90,7 @@ public class HudEditor extends Screen { @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { if (client.world == null && client.getCurrentServerEntry() == null) { - SaturnUi.ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, 1.0F, delta); + SaturnScreen.ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, 1.0F, delta); } for (HudMod mod : hudMods) { diff --git a/src/main/java/org/saturnclient/ui/SaturnAnimation.java b/src/main/java/org/saturnclient/ui/SaturnAnimation.java deleted file mode 100644 index 61ea141..0000000 --- a/src/main/java/org/saturnclient/ui/SaturnAnimation.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.saturnclient.ui; - -public class SaturnAnimation { - - public int delay = 0; - public int lastTick = 0; - - public void init(SaturnWidget widget) {} - - public boolean run(SaturnWidget widget, int tick) { - return true; - } -} diff --git a/src/main/java/org/saturnclient/ui/SaturnUi.java b/src/main/java/org/saturnclient/ui/SaturnUi.java deleted file mode 100644 index 287b799..0000000 --- a/src/main/java/org/saturnclient/ui/SaturnUi.java +++ /dev/null @@ -1,322 +0,0 @@ -package org.saturnclient.ui; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gl.PostEffectProcessor; -import net.minecraft.client.gui.CubeMapRenderer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.RotatingCubeMapRenderer; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.render.DefaultFramebufferSet; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.util.Pool; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.MutableText; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; -import org.lwjgl.glfw.GLFW; - -public class SaturnUi extends Screen { - - private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); - - private final Pool pool = new Pool(3); - private float f = 0.0f; - public boolean blur = true; - public boolean titleBackground = false; - public List widgets = new ArrayList<>(); - private int tick = 0; - - protected static final CubeMapRenderer PANORAMA_RENDERER = new CubeMapRenderer( - Identifier.of("saturnclient", "textures/gui/title/background/panorama")); - - public static final RotatingCubeMapRenderer ROTATING_PANORAMA_RENDERER; - - static { - ROTATING_PANORAMA_RENDERER = new RotatingCubeMapRenderer(PANORAMA_RENDERER); - } - - public static MutableText text(String text) { - return Text.literal(text).setStyle( - Style.EMPTY.withFont(Identifier.of("saturnclient:inter"))); - } - - public static MutableText textBold(String text) { - return Text.literal(text).setStyle( - Style.EMPTY.withFont(Identifier.of("saturnclient:inter_bold"))); - } - - public static void drawHighResTexture(DrawContext context, Identifier t, int x, int y, int w, int h) { - MatrixStack matricies = context.getMatrices(); - matricies.push(); - matricies.translate(x, y, 0); - matricies.scale(.25f, .25f, 1.0f); - - context.drawTexture(RenderLayer::getGuiTextured, t, 0, 0, 0, 0, - w * 4, h * 4, w * 4, h * 4); - - matricies.pop(); - } - - public static void drawHighResTexture(DrawContext context, Identifier t, int x, int y, int w, int h, int c) { - MatrixStack matricies = context.getMatrices(); - matricies.push(); - matricies.translate(x, y, 0); - matricies.scale(.25f, .25f, 1.0f); - - context.drawTexture(RenderLayer::getGuiTextured, t, 0, 0, 0, 0, - w * 4, h * 4, w * 4, h * 4, c); - - matricies.pop(); - } - - public static void drawHighResGuiTexture(DrawContext context, Identifier t, int x, int y, int w, int h, int c) { - MatrixStack matricies = context.getMatrices(); - matricies.push(); - matricies.translate(x, y, 0); - matricies.scale(.25f, .25f, 1.0f); - - context.drawGuiTexture( - RenderLayer::getGuiTextured, - t, - 0, - 0, - w * 4, - h * 4, - c); - - matricies.pop(); - } - - public static int getAlpha(int color, float alpha) { - return ((int) (alpha * 255) << 24) | - (color & 0x00FFFFFF); - } - - public SaturnUi(Text title) { - super(title); - } - - @Override - protected void init() { - scheduler.scheduleAtFixedRate( - this::saturnTick, - 0, - 7, - TimeUnit.MILLISECONDS); - super.init(); - } - - public void draw(SaturnWidget widget) { - synchronized (widgets) { - widget.init(); - widgets.add(widget); - } - } - - public void refresh() { - synchronized (widgets) { - widgets.clear(); - - f = 0.0f; - tick = 0; - - init(); - } - } - - @SuppressWarnings("deprecation") - @Override - public void render( - DrawContext context, - int mouseX, - int mouseY, - float delta) { - - if (client.world == null && client.getCurrentServerEntry() == null) { - ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, 1.0F, delta); - } - - // Blur - if (!(f < 1.0F) && blur) { - PostEffectProcessor postEffectProcessor = this.client.getShaderLoader().loadPostEffect( - Identifier.ofVanilla("blur"), - DefaultFramebufferSet.MAIN_ONLY); - if (postEffectProcessor != null) { - postEffectProcessor.setUniforms("Radius", f); - postEffectProcessor.render(this.client.getFramebuffer(), this.pool); - } - - } - - for (SaturnWidget widget : new ArrayList<>(widgets)) { - if (!widget.visible) - continue; - - double adjustedMouseX = mouseX - widget.x; - double adjustedMouseY = mouseY - widget.y; - boolean isMouseInside = adjustedMouseX >= 0 && - adjustedMouseX <= (widget.width * widget.scale) && - adjustedMouseY >= 0 && - adjustedMouseY <= (widget.height * widget.scale); - - MatrixStack matrices = context.getMatrices(); - matrices.push(); - matrices.translate(widget.x, widget.y, 0); - matrices.scale(widget.scale, widget.scale, 1.0f); - widget.render( - context, - isMouseInside, - (int) (adjustedMouseX / widget.scale), - (int) (adjustedMouseY / widget.scale)); - matrices.pop(); - } - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (button == 0) { - for (SaturnWidget widget : new ArrayList<>(widgets)) { - widget.focused = false; - if (!widget.visible) - continue; - - double adjustedMouseX = mouseX - widget.x; - double adjustedMouseY = mouseY - widget.y; - boolean isMouseInside = adjustedMouseX >= 0 && - adjustedMouseX <= (widget.width * widget.scale) && - adjustedMouseY >= 0 && - adjustedMouseY <= (widget.height * widget.scale); - - if (isMouseInside) { - widget.focused = true; - widget.click( - (int) (adjustedMouseX / widget.scale), - (int) (adjustedMouseY / widget.scale)); - } - } - } - - return false; - } - - @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - for (SaturnWidget widget : new ArrayList<>(widgets)) { - if (!widget.visible && !widget.focused) - continue; - - widget.keyPressed(keyCode, scanCode, modifiers); - - char typedChar = getCharFromKey(keyCode, modifiers); - if (typedChar != '\0') { - widget.charTyped(typedChar); - } - } - return super.keyPressed(keyCode, scanCode, modifiers); - } - - @Override - public boolean mouseScrolled( - double mouseX, - double mouseY, - double horizontalAmount, - double verticalAmount) { - for (SaturnWidget widget : new ArrayList<>(widgets)) { - double adjustedMouseX = mouseX - widget.x; - double adjustedMouseY = mouseY - widget.y; - boolean isMouseInside = adjustedMouseX >= 0 && - adjustedMouseX <= (widget.width * widget.scale) && - adjustedMouseY >= 0 && - adjustedMouseY <= (widget.height * widget.scale); - - if (isMouseInside) { - widget.mouseScrolled( - (int) (adjustedMouseX / widget.scale), - (int) (adjustedMouseY / widget.scale), - horizontalAmount, - verticalAmount); - } - } - - return super.mouseScrolled( - mouseX, - mouseY, - horizontalAmount, - verticalAmount); - } - - private char getCharFromKey(int keyCode, int modifiers) { - boolean shift = (modifiers & GLFW.GLFW_MOD_SHIFT) != 0; - - // A-Z - if (keyCode >= GLFW.GLFW_KEY_A && keyCode <= GLFW.GLFW_KEY_Z) { - return (char) (shift - ? 'A' + (keyCode - GLFW.GLFW_KEY_A) - : 'a' + (keyCode - GLFW.GLFW_KEY_A)); - } - - // 0-9 - if (keyCode >= GLFW.GLFW_KEY_0 && keyCode <= GLFW.GLFW_KEY_9) { - return shift - ? ")!@#$%^&*(".charAt(keyCode - GLFW.GLFW_KEY_0) - : (char) ('0' + (keyCode - GLFW.GLFW_KEY_0)); - } - - // Special characters - return switch (keyCode) { - case GLFW.GLFW_KEY_SPACE -> ' '; - case GLFW.GLFW_KEY_PERIOD -> shift ? '>' : '.'; - case GLFW.GLFW_KEY_COMMA -> shift ? '<' : ','; - case GLFW.GLFW_KEY_MINUS -> shift ? '_' : '-'; - case GLFW.GLFW_KEY_EQUAL -> shift ? '+' : '='; - case GLFW.GLFW_KEY_SEMICOLON -> shift ? ':' : ';'; - case GLFW.GLFW_KEY_APOSTROPHE -> shift ? '"' : '\''; - case GLFW.GLFW_KEY_SLASH -> shift ? '?' : '/'; - case GLFW.GLFW_KEY_BACKSLASH -> shift ? '|' : '\\'; - case GLFW.GLFW_KEY_LEFT_BRACKET -> shift ? '{' : '['; - case GLFW.GLFW_KEY_RIGHT_BRACKET -> shift ? '}' : ']'; - case GLFW.GLFW_KEY_GRAVE_ACCENT -> shift ? '~' : '`'; - default -> '\0'; - }; - } - - public void saturnTick() { - synchronized (scheduler) { - if (f < 15.0f) { - f += 0.25f; - } - } - synchronized (widgets) { - for (SaturnWidget widget : widgets) { - if (widget.visible && widget.animations != null) { - for (SaturnAnimation animation : widget.animations) { - if (animation != null && - tick - animation.lastTick == animation.delay) { - if (animation.run(widget, tick)) { - animation = null; - } else { - animation.lastTick = tick; - } - } - } - } - - widget.tick(); - } - tick++; - } - } - - @Override - public void resize(MinecraftClient client, int width, int height) { - super.resize(client, width, height); - refresh(); - } -} diff --git a/src/main/java/org/saturnclient/ui/SaturnWidget.java b/src/main/java/org/saturnclient/ui/SaturnWidget.java deleted file mode 100644 index 1d248f9..0000000 --- a/src/main/java/org/saturnclient/ui/SaturnWidget.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.saturnclient.ui; - -import net.minecraft.client.gui.DrawContext; - -public class SaturnWidget { - - public int x = 0; - public int y = 0; - public int width = 0; - public int height = 0; - public float alpha = 1.0f; - public float scale = 1.0f; - public SaturnAnimation[] animations = null; - public boolean visible = true; - public boolean focused = false; - - public void init() { - } - - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - } - - public void click(int mouseX, int mouseY) { - } - - public void keyPressed(int keyCode, int scanCode, int modifiers) { - } - - public void charTyped(char typedChar) { - } - - public void tick() { - } - - public void mouseScrolled( - int mouseX, - int mouseY, - double horizontalAmount, - double verticalAmount) { - } - - public SaturnWidget setX(int x) { - this.x = x; - return this; - } - - public SaturnWidget setY(int y) { - this.y = y; - return this; - } - - public SaturnWidget setWidth(int width) { - this.width = width; - return this; - } - - public SaturnWidget setHeight(int height) { - this.height = height; - return this; - } - - public SaturnWidget setAlpha(float alpha) { - this.alpha = alpha; - return this; - } - - public SaturnWidget setAnimations(SaturnAnimation... animations) { - this.animations = animations; - for (SaturnAnimation anim : this.animations) { - anim.init(this); - } - return this; - } - - public SaturnWidget setVisible(boolean visible) { - this.visible = visible; - return this; - } - - public SaturnWidget setScale(float scale) { - this.scale = scale; - return this; - } -} diff --git a/src/main/java/org/saturnclient/ui/Textures.java b/src/main/java/org/saturnclient/ui/Textures.java deleted file mode 100644 index f8b90f9..0000000 --- a/src/main/java/org/saturnclient/ui/Textures.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.saturnclient.ui; - -import net.minecraft.util.Identifier; - -public class Textures { - public static final Identifier COSMETICS = Identifier.of("saturnclient", "textures/gui/components/cosmetics.png"); - public static final Identifier HUD_ICON = Identifier.of("saturnclient", "textures/gui/components/hud.png"); - public static final Identifier SEARCH = Identifier.of("saturnclient", "textures/gui/components/search.png"); - public static final Identifier CLOSE = Identifier.of("saturnclient", "textures/gui/components/close.png"); - public static final Identifier MODS_TAB = Identifier.of("saturnclient", "textures/gui/components/mods_tab.png"); - public static final Identifier SETTINGS = Identifier.of("saturnclient", "textures/gui/components/settings.png"); - public static final Identifier CLOAK = Identifier.of("saturnclient", "textures/gui/components/cloak.png"); - public static final Identifier HAT = Identifier.of("saturnclient", "textures/gui/components/hat.png"); - public static final Identifier RESET = Identifier.of("saturnclient", "textures/gui/components/reset.png"); - public static final Identifier TOGGLE_INDICATOR = Identifier.of("saturnclient", - "textures/gui/components/toggle_indicator.png"); - public static final Identifier TOGGLE_BG = Identifier.of("saturnclient", "textures/gui/components/toggle_bg.png"); - - public static final Identifier LOGO = Identifier.of("saturnclient", "textures/logo/logo.png"); - public static final Identifier REALISTIC_LOGO = Identifier.of("saturnclient", "textures/logo/realistic.png"); - public static final Identifier LOGO_TEXT = Identifier.of("saturnclient", "textures/logo/text.png"); - - // Widgets - public static final Identifier BUTTON_BORDER = Identifier.of("saturnclient", "button_border"); - public static final Identifier BUTTON = Identifier.of("saturnclient", "button"); - public static final Identifier BUTTON_OP = Identifier.of("saturnclient", "button_op"); - public static final Identifier SETTINGS_BG = Identifier.of("saturnclient", "settings_bg"); - public static final Identifier RECT = Identifier.of("saturnclient", "rect"); - public static final Identifier RECT_BORDER = Identifier.of("saturnclient", "rect_border"); - public static final Identifier MOD = Identifier.of("saturnclient", "textures/gui/components/mod.png"); - public static final Identifier MOD_BG = Identifier.of("saturnclient", "textures/gui/components/mod_bg.png"); - - public static Identifier getCloakPreview(String cloak) { - return Identifier.of("saturnclient", "textures/gui/cloak/" + (cloak.isEmpty() ? "none" : cloak) + ".png"); - } - - public static Identifier getHatPreview(String hat) { - return Identifier.of("saturnclient", "textures/gui/hat/" + (hat.isEmpty() ? "none" : hat) + ".png"); - } - - public static Identifier getModIcon(String modId) { - return Identifier.of("saturnclient", "textures/gui/mod/" + modId + ".png"); - } -} diff --git a/src/main/java/org/saturnclient/ui/animations/FadeIn.java b/src/main/java/org/saturnclient/ui/animations/FadeIn.java deleted file mode 100644 index a7c0b62..0000000 --- a/src/main/java/org/saturnclient/ui/animations/FadeIn.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.saturnclient.ui.animations; - -import org.saturnclient.ui.SaturnAnimation; -import org.saturnclient.ui.SaturnWidget; - -public class FadeIn extends SaturnAnimation { - public FadeIn(int delay) { - this.delay = delay; - } - - public void init(SaturnWidget widget) { - widget.alpha = 0.0f; - } - - public boolean run(SaturnWidget widget, int tick) { - widget.alpha += 0.05f; - - return widget.alpha > 0.9f; - } -} diff --git a/src/main/java/org/saturnclient/ui/animations/Slide.java b/src/main/java/org/saturnclient/ui/animations/Slide.java deleted file mode 100644 index ceb6b85..0000000 --- a/src/main/java/org/saturnclient/ui/animations/Slide.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.saturnclient.ui.animations; - -import org.saturnclient.ui.SaturnAnimation; -import org.saturnclient.ui.SaturnWidget; - -public class Slide extends SaturnAnimation { - private int offset; - - public Slide(int delay, int offset) { - this.delay = delay; - this.offset = offset; - } - - public void init(SaturnWidget widget) { - widget.y += offset; - } - - public boolean run(SaturnWidget widget, int tick) { - widget.y--; - offset--; - - return offset == 0; - } -} diff --git a/src/main/java/org/saturnclient/ui/components/SaturnFloat.java b/src/main/java/org/saturnclient/ui/components/SaturnFloat.java deleted file mode 100644 index 8348c5b..0000000 --- a/src/main/java/org/saturnclient/ui/components/SaturnFloat.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.saturnclient.ui.components; - -import org.saturnclient.saturnclient.SaturnClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; -import org.lwjgl.glfw.GLFW; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.saturnclient.config.ConfigManager; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; - -public class SaturnFloat extends SaturnWidget { - - String text = ""; - public Property prop; - public int cursorPosition = 0; - private TextRenderer textRenderer = SaturnClient.client.textRenderer; - - public SaturnFloat(Property prop, int x, int y, int width) { - this.x = x; - this.y = y; - this.width = width; - this.prop = prop; - this.text = String.valueOf(prop.value); - this.height = textRenderer.fontHeight + 4; - this.scale = 0.8f; - } - - @Override - public void click(int mouseX, int mouseY) { - int scrollOffset = getScrollOffset(); - String visibleText = text.substring(scrollOffset); - - int newCursorPos = scrollOffset; - int textWidth = 0; - - for (int i = 0; i < visibleText.length(); i++) { - textWidth = textRenderer.getWidth(visibleText.substring(0, i + 1)); - - if (textWidth > mouseX) { - break; - } - - newCursorPos++; - } - - cursorPosition = newCursorPos; - } - - @Override - public void charTyped(char chr) { - if ((Character.isDigit(chr) || chr == '.') && text.length() < 10) { - if (text.equals("0") && cursorPosition == 1) { - text = "" + chr; - } else { - text = text.substring(0, cursorPosition) + - chr + - text.substring(cursorPosition); - - prop.value = text.isEmpty() ? 0 : Float.parseFloat(text); - ConfigManager.save(); - - cursorPosition++; - } - } - } - - @Override - public void keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { - if (cursorPosition > 0) { - text = text.substring(0, cursorPosition - 1) + - text.substring(cursorPosition); - cursorPosition--; - if (text.length() == 0) { - text = "0"; - cursorPosition = 1; - } - prop.value = Float.parseFloat(text); - ConfigManager.save(); - } - } else if (keyCode == GLFW.GLFW_KEY_LEFT) { - if (cursorPosition > 0) { - cursorPosition--; - } - } else if (keyCode == GLFW.GLFW_KEY_RIGHT) { - if (cursorPosition < text.length()) { - cursorPosition++; - } - } - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - if (prop.isReset) { - this.text = String.valueOf(prop.value); - this.cursorPosition = 0; - prop.isReset = false; - } - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON_BORDER, - 0, - 0, - this.width, - this.height, - focused - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha)); - - int scrollOffset = getScrollOffset(); - String visibleText = getVisibleText(scrollOffset); - - int textColor = focused ? 0xFFFFFF : 0xAAAAAA; - context.drawText( - textRenderer, - SaturnUi.text(visibleText), - 2, - 2, - textColor, - false); - - if (focused) { - int cursorX = 2 + - textRenderer.getWidth( - SaturnUi.text( - visibleText.substring(0, cursorPosition - scrollOffset))); - context.fill( - cursorX, - 2, - cursorX + 1, - textRenderer.fontHeight + 4, - 0xFFFFFFFF); - } - } - - public void clearText() { - text = "0"; - cursorPosition = 1; - prop.value = 0.0f; - } - - private int getScrollOffset() { - if (text.isEmpty()) { - return 0; - } - - int offset = 0; - int maxWidth = width - 4; // Available width for text - while (offset < cursorPosition) { // Ensure cursor remains visible - String visibleText = text.substring(offset, cursorPosition); - if (textRenderer.getWidth(SaturnUi.text(visibleText)) > maxWidth) { - offset++; - } else { - break; - } - } - return offset; - } - - private String getVisibleText(int scrollOffset) { - String visibleText = text.substring(scrollOffset); - - // Ensure text does not overflow past the available width - for (int i = 1; i <= visibleText.length(); i++) { - if (textRenderer.getWidth( - SaturnUi.text(visibleText.substring(0, i))) > width - 4) { - return visibleText.substring(0, i - 1); // Trim overflow - } - } - return visibleText; - } -} diff --git a/src/main/java/org/saturnclient/ui/components/SaturnHex.java b/src/main/java/org/saturnclient/ui/components/SaturnHex.java deleted file mode 100644 index bf66ddd..0000000 --- a/src/main/java/org/saturnclient/ui/components/SaturnHex.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.saturnclient.ui.components; - -import org.saturnclient.saturnclient.SaturnClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; -import org.lwjgl.glfw.GLFW; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.saturnclient.config.ConfigManager; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; - -public class SaturnHex extends SaturnWidget { - - private String text = "#"; // Always starts with '#' - public Property prop; - public int cursorPosition = 1; // After '#' - private final TextRenderer textRenderer = SaturnClient.client.textRenderer; - - public SaturnHex(Property prop, int x, int y, int width) { - this.x = x; - this.y = y; - this.width = width; - this.prop = prop; - this.text = intToHex(prop.value); - this.height = textRenderer.fontHeight + 4; - this.scale = 0.8f; - } - - @Override - public void click(int mouseX, int mouseY) { - cursorPosition = Math.min(7, text.length()); // Keep cursor inside hex length - } - - @Override - public void charTyped(char chr) { - if (isHexChar(chr) && text.length() < 7) { // Limit to 6 hex digits + '#' - text = text.substring(0, cursorPosition) + - chr + - text.substring(cursorPosition); - cursorPosition++; - - if (text.length() == 7) { // Only update value when full hex is entered - prop.value = hexToInt(text); - ConfigManager.save(); - } - } - } - - @Override - public void keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode == GLFW.GLFW_KEY_BACKSPACE && cursorPosition > 1) { // Prevent deleting '#' - text = text.substring(0, cursorPosition - 1) + - text.substring(cursorPosition); - cursorPosition--; - } else if (keyCode == GLFW.GLFW_KEY_LEFT && cursorPosition > 1) { - cursorPosition--; - } else if (keyCode == GLFW.GLFW_KEY_RIGHT && cursorPosition < text.length()) { - cursorPosition++; - } - - if (text.length() == 1) { // Reset if empty (keep '#') - text = "#"; - cursorPosition = 1; - } - - if (text.length() == 7) { // Update only when valid hex - prop.value = hexToInt(text); - ConfigManager.save(); - } - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - if (prop.isReset) { - this.text = intToHex(prop.value); - this.cursorPosition = 0; - prop.isReset = false; - } - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON_BORDER, - 0, - 0, - this.width, - this.height, - focused - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha)); - - int textColor = focused ? 0xFFFFFF : 0xAAAAAA; - context.drawText( - textRenderer, - SaturnUi.text(text), - 2, - 2, - textColor, - false); - - if (focused) { - int cursorX = 2 + - textRenderer.getWidth( - SaturnUi.text(text.substring(0, cursorPosition))); - context.fill( - cursorX, - 2, - cursorX + 1, - textRenderer.fontHeight + 4, - 0xFFFFFFFF); - } - } - - public void clearText() { - text = "#"; - cursorPosition = 1; - prop.value = 0xFFFFFFFF; // Default white - } - - private boolean isHexChar(char chr) { - return ((chr >= '0' && chr <= '9') || - (chr >= 'A' && chr <= 'F') || - (chr >= 'a' && chr <= 'f')); - } - - public static int hexToInt(String hex) { - hex = hex.replace("#", ""); - int rgb = Integer.parseInt(hex, 16); - return (0xFF << 24) | rgb; - } - - public static String intToHex(int color) { - int rgb = color & 0xFFFFFF; - return String.format("#%06X", rgb).toLowerCase(); - } -} diff --git a/src/main/java/org/saturnclient/ui/components/SaturnInteger.java b/src/main/java/org/saturnclient/ui/components/SaturnInteger.java deleted file mode 100644 index b97da9d..0000000 --- a/src/main/java/org/saturnclient/ui/components/SaturnInteger.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.saturnclient.ui.components; - -import net.minecraft.client.gui.DrawContext; -import org.lwjgl.glfw.GLFW; -import org.saturnclient.saturnclient.SaturnClient; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.saturnclient.config.ConfigManager; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; - -public class SaturnInteger extends SaturnWidget { - - String text = ""; - public Property prop; - public int cursorPosition = 0; - - public SaturnInteger(Property prop, int x, int y, int width) { - this.x = x; - this.y = y; - this.width = width; - this.prop = prop; - this.text = String.valueOf(prop.value); - this.height = SaturnClient.client.textRenderer.fontHeight + 4; - this.scale = 0.8f; - } - - @Override - public void click(int mouseX, int mouseY) { - int scrollOffset = getScrollOffset(); - String visibleText = text.substring(scrollOffset); - - int newCursorPos = scrollOffset; - int textWidth = 0; - - for (int i = 0; i < visibleText.length(); i++) { - textWidth = SaturnClient.client.textRenderer.getWidth(visibleText.substring(0, i + 1)); - - if (textWidth > mouseX) { - break; - } - - newCursorPos++; - } - - cursorPosition = newCursorPos; - } - - @Override - public void charTyped(char chr) { - if (Character.isDigit(chr) && text.length() < 10) { - if (text.equals("0") && cursorPosition == 1) { - text = "" + chr; - } else { - text = text.substring(0, cursorPosition) + - chr + - text.substring(cursorPosition); - - prop.value = text.isEmpty() ? 0 : Integer.parseInt(text); - ConfigManager.save(); - - cursorPosition++; - } - } - } - - @Override - public void keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { - if (cursorPosition > 0) { - text = text.substring(0, cursorPosition - 1) + - text.substring(cursorPosition); - cursorPosition--; - if (text.length() == 0) { - text = "0"; - cursorPosition = 1; - } - prop.value = Integer.parseInt(text); - ConfigManager.save(); - } - } else if (keyCode == GLFW.GLFW_KEY_LEFT) { - if (cursorPosition > 0) { - cursorPosition--; - } - } else if (keyCode == GLFW.GLFW_KEY_RIGHT) { - if (cursorPosition < text.length()) { - cursorPosition++; - } - } - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - if (prop.isReset) { - this.text = String.valueOf(prop.value); - this.cursorPosition = 0; - prop.isReset = false; - } - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON_BORDER, - 0, - 0, - this.width, - this.height, - focused - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha)); - - int scrollOffset = getScrollOffset(); - String visibleText = getVisibleText(scrollOffset); - - int textColor = focused ? 0xFFFFFF : 0xAAAAAA; - context.drawText( - SaturnClient.client.textRenderer, - SaturnUi.text(visibleText), - 2, - 2, - textColor, - false); - - if (focused) { - int cursorX = 2 + - SaturnClient.client.textRenderer.getWidth( - SaturnUi.text( - visibleText.substring(0, cursorPosition - scrollOffset))); - context.fill( - cursorX, - 2, - cursorX + 1, - SaturnClient.client.textRenderer.fontHeight + 4, - 0xFFFFFFFF); - } - } - - public void clearText() { - text = "0"; - cursorPosition = 1; - prop.value = 0; - } - - private int getScrollOffset() { - if (text.isEmpty()) { - return 0; - } - - int offset = 0; - int maxWidth = width - 4; // Available width for text - while (offset < cursorPosition) { // Ensure cursor remains visible - String visibleText = text.substring(offset, cursorPosition); - if (SaturnClient.client.textRenderer.getWidth(SaturnUi.text(visibleText)) > maxWidth) { - offset++; - } else { - break; - } - } - return offset; - } - - private String getVisibleText(int scrollOffset) { - String visibleText = text.substring(scrollOffset); - - // Ensure text does not overflow past the available width - for (int i = 1; i <= visibleText.length(); i++) { - if (SaturnClient.client.textRenderer.getWidth( - SaturnUi.text(visibleText.substring(0, i))) > width - 4) { - return visibleText.substring(0, i - 1); // Trim overflow - } - } - return visibleText; - } -} diff --git a/src/main/java/org/saturnclient/ui/components/SaturnModComp.java b/src/main/java/org/saturnclient/ui/components/SaturnModComp.java deleted file mode 100644 index b9dff4f..0000000 --- a/src/main/java/org/saturnclient/ui/components/SaturnModComp.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.saturnclient.ui.components; - -import net.minecraft.client.gui.DrawContext; - -import org.saturnclient.modules.Module; -import org.saturnclient.saturnclient.SaturnClient; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; -import org.saturnclient.ui2.screens.ConfigEditor; - -public class SaturnModComp extends SaturnWidget { - - Module mod; - - public SaturnModComp(Module mod) { - this.mod = mod; - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - boolean enabled = mod.isEnabled(); - - boolean hovering_settings = settingsHovering(mouseX, mouseY); - - int color = !hovering_settings && (enabled || hovering) - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(alpha); - - int size = 12; - - if (enabled) { - SaturnUi.drawHighResTexture( - context, - Textures.MOD_BG, - 0, - 0, - 86, - 20, - SaturnClientConfig.color.value); - } - - SaturnUi.drawHighResTexture( - context, - Textures.MOD, - 0, - 0, - 86, - 20, - color); - - SaturnUi.drawHighResTexture( - context, - mod.getIconTexture(), - 4, - 4, - size, - size, - color); - - context.drawText( - SaturnClient.client.textRenderer, - SaturnUi.text(mod.getName()), - 20, - (21 - SaturnClient.client.textRenderer.fontHeight) / 2, - color, - false); - - SaturnUi.drawHighResTexture( - context, - Textures.SETTINGS, - 77, - 11, - 7, - 7, - hovering_settings - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(alpha)); - } - - @Override - public void click(int mouseX, int mouseY) { - if (settingsHovering(mouseX, mouseY)) { - SaturnClient.client - .setScreen(new ConfigEditor(mod.getConfig())); - } else { - mod.setEnabled(!mod.isEnabled()); - } - } - - public boolean settingsHovering(int mouseX, int mouseY) { - int sX = 77; - int sY = 11; - int size = 7; - - return (sX < mouseX && - sX + size > mouseX && - sY < mouseY && - sY + size > mouseY); - } -} diff --git a/src/main/java/org/saturnclient/ui/components/SaturnString.java b/src/main/java/org/saturnclient/ui/components/SaturnString.java deleted file mode 100644 index c7908b9..0000000 --- a/src/main/java/org/saturnclient/ui/components/SaturnString.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.saturnclient.ui.components; - -import org.saturnclient.saturnclient.SaturnClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; -import org.lwjgl.glfw.GLFW; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; - -public class SaturnString extends SaturnWidget { - - public Property prop; - public int cursorPosition = 0; - private TextRenderer textRenderer = SaturnClient.client.textRenderer; - - public SaturnString(Property prop, int x, int y, int width) { - this.x = x; - this.y = y; - this.width = width; - this.prop = prop; - this.height = textRenderer.fontHeight + 4; - this.scale = 0.8f; - } - - @Override - public void click(int mouseX, int mouseY) { - int scrollOffset = getScrollOffset(); - String visibleText = prop.value.substring(scrollOffset); - - int newCursorPos = scrollOffset; - int textWidth = 0; - - for (int i = 0; i < visibleText.length(); i++) { - textWidth = textRenderer.getWidth(visibleText.substring(0, i + 1)); - - if (textWidth > mouseX) { - break; - } - - newCursorPos++; - } - - cursorPosition = newCursorPos; - } - - @Override - public void charTyped(char chr) { - prop.value = prop.value.substring(0, cursorPosition) + - chr + - prop.value.substring(cursorPosition); - - cursorPosition++; - } - - @Override - public void keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { - if (cursorPosition > 0) { - prop.value = prop.value.substring(0, cursorPosition - 1) + - prop.value.substring(cursorPosition); - cursorPosition--; - } - } else if (keyCode == GLFW.GLFW_KEY_LEFT) { - if (cursorPosition > 0) { - cursorPosition--; - } - } else if (keyCode == GLFW.GLFW_KEY_RIGHT) { - if (cursorPosition < prop.value.length()) { - cursorPosition++; - } - } - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON_BORDER, - 0, - 0, - this.width, - this.height, - focused - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha)); - - int scrollOffset = getScrollOffset(); - String visibleText = getVisibleText(scrollOffset); - - int textColor = focused ? 0xFFFFFF : 0xAAAAAA; - context.drawText( - textRenderer, - SaturnUi.text(visibleText), - 2, - 2, - textColor, - false); - - if (focused) { - int cursorX = 2 + - textRenderer.getWidth( - SaturnUi.text( - visibleText.substring(0, cursorPosition - scrollOffset))); - context.fill( - cursorX, - 2, - cursorX + 1, - textRenderer.fontHeight + 3, - 0xFFFFFFFF); - } - } - - public void clearText() { - prop.value = ""; - cursorPosition = 1; - } - - private int getScrollOffset() { - if (prop.value.isEmpty()) { - return 0; - } - - int offset = 0; - int maxWidth = width - 4; // Available width for prop.value - while (offset < cursorPosition) { // Ensure cursor remains visible - String visibleText = prop.value.substring(offset, cursorPosition); - if (textRenderer.getWidth(SaturnUi.text(visibleText)) > maxWidth) { - offset++; - } else { - break; - } - } - return offset; - } - - private String getVisibleText(int scrollOffset) { - String visibleText = prop.value.substring(scrollOffset); - - // Ensure prop.value does not overflow past the available width - for (int i = 1; i <= visibleText.length(); i++) { - if (textRenderer.getWidth( - SaturnUi.text(visibleText.substring(0, i))) > width - 4) { - return visibleText.substring(0, i - 1); // Trim overflow - } - } - return visibleText; - } -} diff --git a/src/main/java/org/saturnclient/ui/components/SaturnToggle.java b/src/main/java/org/saturnclient/ui/components/SaturnToggle.java deleted file mode 100644 index 3bf248d..0000000 --- a/src/main/java/org/saturnclient/ui/components/SaturnToggle.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.saturnclient.ui.components; - -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.RenderLayer; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.saturnclient.config.ConfigManager; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; - -public class SaturnToggle extends SaturnWidget { - - Property prop; - - public SaturnToggle(Property prop) { - this.prop = prop; - width = 16; - height = 8; - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - int color = prop.value - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(alpha); - int w = 13; - int h = 6; - int s = 8; - - context.drawTexture( - RenderLayer::getGuiTextured, - Textures.TOGGLE_BG, - 0, - 1, - 0, - 0, - w, - h, - w, - h, - color); - - context.drawTexture( - RenderLayer::getGuiTextured, - Textures.TOGGLE_INDICATOR, - prop.value ? 5 : 0, - 0, - 0, - 0, - s, - s, - s, - s, - color); - } - - @Override - public void click(int mouseX, int mouseY) { - prop.value = !prop.value; - ConfigManager.save(); - } -} diff --git a/src/main/java/org/saturnclient/ui/components/SkinPreview.java b/src/main/java/org/saturnclient/ui/components/SkinPreview.java deleted file mode 100644 index a71d26a..0000000 --- a/src/main/java/org/saturnclient/ui/components/SkinPreview.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.saturnclient.ui.components; - -import org.jetbrains.annotations.Nullable; -import org.joml.Quaternionf; -import org.joml.Vector3f; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.saturnclient.SaturnClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.DiffuseLighting; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.entity.LivingEntity; - -// If you think this code is bad, it's because it's written by Mojang - -public class SkinPreview extends SaturnWidget { - private boolean negativeAngle = false; - private float angle = 0.0f; - - public SkinPreview(float angle, boolean negativeAngle) { - this.angle = angle; - this.negativeAngle = negativeAngle; - } - - public static void drawEntity(DrawContext context, int x1, int y1, int x2, int y2, int size, float f, float mouseX, - float mouseY, LivingEntity entity, float angle, boolean negativeAngle) { - float g = (float) (x1 + x2) / 2.0F; - float h = (float) (y1 + y2) / 2.0F; - context.enableScissor(0, 6, x2, y2); - float i = (float) Math.atan((double) ((g - mouseX) / 40.0F)); - float j = (float) Math.atan((double) ((h - mouseY) / 40.0F)); - Quaternionf quaternionf = (new Quaternionf()).rotateZ(3.1415927F); - float k = entity.bodyYaw; - float l = entity.getYaw(); - float m = entity.getPitch(); - float n = entity.prevHeadYaw; - float o = entity.headYaw; - entity.setYaw(angle); - entity.bodyYaw = angle; - entity.setPitch(negativeAngle ? -(j * 20.0F) : j * 20.0F); - entity.headYaw = negativeAngle ? (i * 40.0F) + 180f : -(i * 40.0F); - entity.prevHeadYaw = entity.getHeadYaw(); - entity.setCustomNameVisible(false); - - float p = entity.getScale(); - Vector3f vector3f = new Vector3f(0.0F, entity.getHeight() / 2.0F + f * p, 0.0F); - float q = (float) size / p; - drawEntity(context, g, h, q, vector3f, quaternionf, null, entity); - - entity.setCustomNameVisible(true); - entity.bodyYaw = k; - entity.setYaw(l); - entity.setPitch(m); - entity.prevHeadYaw = n; - entity.headYaw = o; - context.disableScissor(); - } - - public static void drawEntity(DrawContext context, float x, float y, float size, Vector3f vector3f, - Quaternionf quaternionf, @Nullable Quaternionf quaternionf2, LivingEntity entity) { - context.getMatrices().push(); - context.getMatrices().translate((double) x, (double) y, 50.0); - context.getMatrices().scale(size, size, -size); - context.getMatrices().translate(vector3f.x, vector3f.y, vector3f.z); - context.getMatrices().multiply(quaternionf); - context.draw(); - DiffuseLighting.method_34742(); - EntityRenderDispatcher entityRenderDispatcher = SaturnClient.client.getEntityRenderDispatcher(); - - entityRenderDispatcher.setRenderShadows(false); - context.draw((vertexConsumers) -> { - entityRenderDispatcher.render(entity, 0.0, 0.0, 0.0, 1.0F, context.getMatrices(), vertexConsumers, - 15728880); - }); - context.draw(); - entityRenderDispatcher.setRenderShadows(true); - context.getMatrices().pop(); - DiffuseLighting.enableGuiDepthLighting(); - } - - @Override - public void render(DrawContext context, boolean hovering, int mouseX, int mouseY) { - LivingEntity entity = SaturnClient.client.player; - if (entity != null) { - drawEntity(context, 0, 0, 75, 78, 30, 0.0625F, mouseX, mouseY, entity, angle, negativeAngle); - } - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnButton.java b/src/main/java/org/saturnclient/ui/widgets/SaturnButton.java deleted file mode 100644 index 7e26284..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnButton.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.saturnclient.ui.widgets; - -import com.mojang.blaze3d.systems.RenderSystem; -import java.util.function.Consumer; -import org.saturnclient.saturnclient.SaturnClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; - -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; -import net.minecraft.client.MinecraftClient; - - -public class SaturnButton extends SaturnWidget { - - public boolean active = true; - public String text; - public Consumer onPress; - public boolean background = true; - public boolean bold = false; - private float hoverAlpha = 0.0f; - - public SaturnButton(String text, Consumer onPress) { - this.text = text; - this.onPress = onPress; - } - - public SaturnButton(String text, Runnable onPress) { - this(text, b -> { - onPress.run(); - }); - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - MinecraftClient minecraftClient = SaturnClient.client; - - if (background) { - RenderSystem.setShaderTexture(0, Textures.BUTTON); - - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON, - 0, - 0, - this.width, - this.height, - SaturnClientConfig.getColor(hovering, alpha)); - - if (hovering) { - if (hoverAlpha == 0.0f) - hoverAlpha = 0.1f; - - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON_BORDER, - 0, - 0, - this.width, - this.height, - SaturnClientConfig.getColor(hovering, alpha)); - } else { - hoverAlpha = 0.0f; - } - } - - if (alpha != 0.0f) { - Text t = bold ? SaturnUi.textBold(text) : SaturnUi.text(text); - context.drawText( - minecraftClient.textRenderer, - t, - ((this.width - - minecraftClient.textRenderer.getWidth(t)) - / - 2), - ((this.height - minecraftClient.textRenderer.fontHeight + 1) / - 2), - SaturnClientConfig.getColor(hovering, alpha), - false); - } - } - - @Override - public void click(int mouseX, int mouseY) { - this.onPress.accept(this); - } - - @Override - public void tick() { - if (hoverAlpha > 0.0f && hoverAlpha < 0.9f) - hoverAlpha += 0.03f; - else if (hoverAlpha > 0.9f && hoverAlpha < 1.0f) - hoverAlpha = 1.0f; - } - - public SaturnWidget setBold(boolean bold) { - this.bold = bold; - return this; - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnClickableImage.java b/src/main/java/org/saturnclient/ui/widgets/SaturnClickableImage.java deleted file mode 100644 index 7c59bc3..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnClickableImage.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.saturnclient.ui.widgets; - -import java.util.function.Consumer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.util.Identifier; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; - -public class SaturnClickableImage extends SaturnWidget { - - public Identifier texture; - public boolean selected = false; - public Consumer onPress; - private float hoverAlpha = 0.0f; - - public SaturnClickableImage( - Identifier texture, - Consumer onPress) { - this.texture = texture; - this.onPress = onPress; - } - - public SaturnClickableImage(Identifier texture, Runnable onPress) { - this(texture, _o -> { - onPress.run(); - }); - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - if (hovering) { - if (hoverAlpha == 0.0f) - hoverAlpha = 0.1f; - } - - SaturnUi.drawHighResTexture( - context, - texture, - 0, - 0, - width, - height, - SaturnClientConfig.getColor(hovering || selected, alpha)); - } - - @Override - public void click(int mouseX, int mouseY) { - this.onPress.accept(this); - } - - public SaturnClickableImage setSelected(boolean selected) { - this.selected = selected; - return this; - } - - @Override - public void tick() { - if (hoverAlpha > 0.0f && hoverAlpha < 0.9f) - hoverAlpha += 0.03f; - else if (hoverAlpha > 0.9f && hoverAlpha < 1.0f) - hoverAlpha = 1.0f; - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnClickableSprite.java b/src/main/java/org/saturnclient/ui/widgets/SaturnClickableSprite.java deleted file mode 100644 index 8541cca..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnClickableSprite.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.saturnclient.ui.widgets; - -import java.util.function.Consumer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.util.Identifier; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; - -public class SaturnClickableSprite extends SaturnWidget { - - public Identifier sprite; - public boolean selected = false; - public Consumer onPress; - - public SaturnClickableSprite( - Identifier sprite, - Consumer onPress) { - this.sprite = sprite; - this.onPress = onPress; - } - - public SaturnClickableSprite(Identifier sprite, Runnable onPress) { - this(sprite, _o -> { - onPress.run(); - }); - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - SaturnUi.drawHighResGuiTexture( - context, - sprite, - 0, - 0, - this.width, - this.height, - SaturnClientConfig.getColor(hovering, alpha)); - } - - @Override - public void click(int mouseX, int mouseY) { - this.onPress.accept(this); - } - - public SaturnClickableSprite setSelected(boolean selected) { - this.selected = selected; - return this; - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnImage.java b/src/main/java/org/saturnclient/ui/widgets/SaturnImage.java deleted file mode 100644 index b86eafe..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnImage.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.saturnclient.ui.widgets; - -import net.minecraft.client.gui.DrawContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.ColorHelper; - -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; - -public class SaturnImage extends SaturnWidget { - - private final Identifier sprite; - - public SaturnImage(Identifier sprite) { - this.sprite = sprite; - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - SaturnUi.drawHighResTexture( - context, - sprite, - 0, - 0, - width, - height, - ColorHelper.getWhite(alpha)); - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnImageButton.java b/src/main/java/org/saturnclient/ui/widgets/SaturnImageButton.java deleted file mode 100644 index 7fb60a5..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnImageButton.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.saturnclient.ui.widgets; - -import java.util.function.Consumer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.util.Identifier; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.ui.Textures; - -import com.mojang.blaze3d.systems.RenderSystem; - -public class SaturnImageButton extends SaturnWidget { - - public Identifier sprite; - public int imageWidth; - public int imageHeight; - public Consumer onPress; - private float hoverAlpha = 0.0f; - - public SaturnImageButton( - Identifier sprite, - int imageWidth, - int imageHeight, - Consumer onPress) { - this.sprite = sprite; - this.imageWidth = imageWidth; - this.imageHeight = imageHeight; - this.onPress = onPress; - } - - public SaturnImageButton( - Identifier sprite, - int imageWidth, - int imageHeight, - Runnable onPress) { - this(sprite, imageWidth, imageHeight, _o -> { - onPress.run(); - }); - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - if (hovering) { - if (hoverAlpha == 0.0f) - hoverAlpha = 0.1f; - } - RenderSystem.setShaderTexture(0, Textures.BUTTON); - - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON, - 0, - 0, - this.width, - this.height, - SaturnClientConfig.getColor(hovering, alpha)); - - if (hovering) { - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON_BORDER, - 0, - 0, - this.width, - this.height, - SaturnClientConfig.getColor(hovering, alpha)); - } - - context.drawTexture( - RenderLayer::getGuiTextured, - sprite, - ((width - imageWidth) / 2), - ((height - imageHeight) / 2), - 0, - 0, - imageWidth, - imageHeight, - imageWidth, - imageHeight, - SaturnClientConfig.getColor(hovering, alpha)); - } - - @Override - public void click(int mouseX, int mouseY) { - this.onPress.accept(this); - } - - @Override - public void tick() { - if (hoverAlpha > 0.0f && hoverAlpha < 0.9f) - hoverAlpha += 0.03f; - else if (hoverAlpha > 0.9f && hoverAlpha < 1.0f) - hoverAlpha = 1.0f; - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnInputBox.java b/src/main/java/org/saturnclient/ui/widgets/SaturnInputBox.java deleted file mode 100644 index d428977..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnInputBox.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.saturnclient.ui.widgets; - -import org.saturnclient.ui.SaturnWidget; -import org.saturnclient.saturnclient.SaturnClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.util.math.MatrixStack; - -import org.lwjgl.glfw.GLFW; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.Textures; - -public class SaturnInputBox extends SaturnWidget { - - private TextRenderer textRenderer = SaturnClient.client.textRenderer; - private int tick = 0; - private boolean cursorVisible = true; - - public Property prop; - public int cursorPosition = 0; - public Runnable onUpdate; - - public SaturnInputBox(Property prop, int x, int y, int width) { - this.x = x; - this.y = y; - this.width = width; - this.prop = prop; - this.height = textRenderer.fontHeight + 4; - this.scale = 1.0f; - } - - @Override - public void click(int mouseX, int mouseY) { - int scrollOffset = getScrollOffset(); - String visibleText = prop.value.substring(scrollOffset); - - int newCursorPos = scrollOffset; - int textWidth = 0; - - for (int i = 0; i < visibleText.length(); i++) { - textWidth = textRenderer.getWidth(visibleText.substring(0, i + 1)); - - if (textWidth > mouseX) { - break; - } - - newCursorPos++; - } - - cursorPosition = newCursorPos; - } - - @Override - public void charTyped(char chr) { - prop.value = prop.value.substring(0, cursorPosition) + - chr + - prop.value.substring(cursorPosition); - - cursorPosition++; - - onUpdate.run(); - } - - @Override - public void keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { - if (cursorPosition > 0) { - prop.value = prop.value.substring(0, cursorPosition - 1) + - prop.value.substring(cursorPosition); - cursorPosition--; - } - onUpdate.run(); - } else if (keyCode == GLFW.GLFW_KEY_LEFT) { - if (cursorPosition > 0) { - cursorPosition--; - } - } else if (keyCode == GLFW.GLFW_KEY_RIGHT) { - if (cursorPosition < prop.value.length()) { - cursorPosition++; - } - } - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON, - 0, - 0, - this.width, - this.height, - focused - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha)); - - if (hovering || focused) { - SaturnUi.drawHighResGuiTexture( - context, - Textures.BUTTON_BORDER, - 0, - 0, - this.width, - this.height, - hovering - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha)); - } - - MatrixStack matrices = context.getMatrices(); - matrices.push(); - - if (prop.value.isEmpty() && !focused) { - SaturnUi.drawHighResTexture( - context, - Textures.SEARCH, - 3, - 3, - 9, - 9, - hovering - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha)); - - matrices.scale(0.9f, 0.9f, 1.0f); - - context.drawText( - textRenderer, - SaturnUi.text("Search"), - 14, - textRenderer.fontHeight / 2 + 1, - hovering - ? SaturnClientConfig.color.value - : SaturnClientConfig.getWhite(this.alpha), - false); - } - - matrices.pop(); - - matrices.push(); - - matrices.scale(0.9f, 0.9f, 1.0f); - - int scrollOffset = getScrollOffset(); - String visibleText = getVisibleText(scrollOffset); - int textColor = focused ? 0xFFFFFF : 0xAAAAAA; - context.drawText( - textRenderer, - SaturnUi.text(visibleText), - 3, - textRenderer.fontHeight / 2, - textColor, - false); - - if (focused && cursorVisible) { - int cursorX = 2 + - textRenderer.getWidth( - SaturnUi.text( - visibleText.substring(0, cursorPosition - scrollOffset))); - matrices.translate(cursorX, 0, 0); - context.fill( - 1, - 2, - 2, - textRenderer.fontHeight + 3, - 0xFFFFFFFF); - } - - matrices.pop(); - } - - public void clearText() { - prop.value = ""; - cursorPosition = 1; - } - - private int getScrollOffset() { - if (prop.value.isEmpty()) { - return 0; - } - - int offset = 0; - int maxWidth = width - 4; // Available width for prop.value - while (offset < cursorPosition) { // Ensure cursor remains visible - String visibleText = prop.value.substring(offset, cursorPosition); - if (textRenderer.getWidth(SaturnUi.text(visibleText)) > maxWidth) { - offset++; - } else { - break; - } - } - return offset; - } - - private String getVisibleText(int scrollOffset) { - String visibleText = prop.value.substring(scrollOffset); - - // Ensure prop.value does not overflow past the available width - for (int i = 1; i <= visibleText.length(); i++) { - if (textRenderer.getWidth( - SaturnUi.text(visibleText.substring(0, i))) > width - 4) { - return visibleText.substring(0, i - 1); // Trim overflow - } - } - return visibleText; - } - - public SaturnInputBox onUpdate(Runnable onUpdate) { - this.onUpdate = onUpdate; - return this; - } - - @Override - public void tick() { - if (focused) { - if (tick < 45 || tick < 60 && cursorVisible) { - tick++; - } else { - tick = 0; - cursorVisible = !cursorVisible; - } - } - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnScroll.java b/src/main/java/org/saturnclient/ui/widgets/SaturnScroll.java deleted file mode 100644 index 3fdc8e5..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnScroll.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.saturnclient.ui.widgets; - -import java.util.ArrayList; -import java.util.List; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.util.math.MatrixStack; -import org.saturnclient.ui.SaturnWidget; - -public class SaturnScroll extends SaturnWidget { - - private int scroll = 0; - private int maxScroll = 0; - private List children = new ArrayList<>(); - - @Override - public void mouseScrolled( - int mouseX, - int mouseY, - double horizontalAmount, - double verticalAmount - ) { - verticalAmount *= 2; - - if (scroll - verticalAmount <= 0) { - scroll = 0; - } else if (scroll - verticalAmount >= maxScroll) { - scroll = maxScroll; - } else { - scroll -= verticalAmount; - } - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY - ) { - context.enableScissor(0, 0, width, height); - - for (SaturnWidget widget : children) { - if (!widget.visible) continue; - - double adjustedMouseX = (mouseX - widget.x); - double adjustedMouseY = (mouseY - widget.y + scroll); - boolean isMouseInside = - adjustedMouseX >= 0 && - adjustedMouseX <= (widget.width * widget.scale) && - adjustedMouseY >= 0 && - adjustedMouseY <= (widget.height * widget.scale); - - if ( - widget.y - scroll < height && widget.y + widget.height > scroll - ) { - MatrixStack matrices = context.getMatrices(); - matrices.push(); - matrices.translate(widget.x, widget.y - scroll, 0); - matrices.scale(widget.scale, widget.scale, 1.0f); - - widget.render( - context, - isMouseInside, - (int) (adjustedMouseX / widget.scale), - (int) (adjustedMouseY / widget.scale) - ); - matrices.pop(); - } - } - context.disableScissor(); - } - - @Override - public void init() { - maxScroll = 0; - for (SaturnWidget child : children) { - maxScroll = Math.max(maxScroll, child.y + child.height - height); - } - } - - public void draw(SaturnWidget widget) { - synchronized (children) { - widget.init(); - children.add(widget); - } - } - - public boolean isScrollable() { - for (SaturnWidget widget : children) { - if (widget.y + widget.height > height) { - return true; - } - } - return false; - } - - @Override - public void keyPressed(int keyCode, int scanCode, int modifiers) { - for (SaturnWidget widget : children) { - if (!widget.visible || !widget.focused) { - continue; - } - - widget.keyPressed(keyCode, scanCode, modifiers); - break; - } - } - - @Override - public void charTyped(char typedChar) { - for (SaturnWidget widget : children) { - if (!widget.visible || !widget.focused) { - continue; - } - - widget.charTyped(typedChar); - break; - } - } - - @Override - public void click(int mouseX, int mouseY) { - for (SaturnWidget widget : children) { - widget.focused = false; - if (!widget.visible) { - continue; - } - - double adjustedMouseX = (mouseX - widget.x); - double adjustedMouseY = (mouseY - (widget.y - scroll)); - boolean isMouseInside = - adjustedMouseX >= 0 && - adjustedMouseX <= (widget.width * widget.scale) && - adjustedMouseY >= 0 && - adjustedMouseY <= (widget.height * widget.scale); - - if (isMouseInside) { - widget.focused = true; - widget.click( - (int) (adjustedMouseX / widget.scale), - (int) (adjustedMouseY / widget.scale) - ); - } - } - } - - public void clear() { - children.clear(); - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnSprite.java b/src/main/java/org/saturnclient/ui/widgets/SaturnSprite.java deleted file mode 100644 index a5eebdc..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnSprite.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.saturnclient.ui.widgets; - -import net.minecraft.client.gui.DrawContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.ColorHelper; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; - -public class SaturnSprite extends SaturnWidget { - - private final Identifier sprite; - - public SaturnSprite(Identifier sprite) { - this.sprite = sprite; - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - SaturnUi.drawHighResGuiTexture( - context, - sprite, - 0, - 0, - this.width, - this.height, - ColorHelper.getWhite(this.alpha)); - } -} diff --git a/src/main/java/org/saturnclient/ui/widgets/SaturnText.java b/src/main/java/org/saturnclient/ui/widgets/SaturnText.java deleted file mode 100644 index 3b5a387..0000000 --- a/src/main/java/org/saturnclient/ui/widgets/SaturnText.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.saturnclient.ui.widgets; - -import net.minecraft.client.gui.DrawContext; - -import org.saturnclient.saturnclient.SaturnClient; -import org.saturnclient.saturnclient.SaturnClientConfig; -import org.saturnclient.ui.SaturnUi; -import org.saturnclient.ui.SaturnWidget; - -public class SaturnText extends SaturnWidget { - - private String text; - - public SaturnText(String text) { - this.text = text; - this.width = SaturnClient.client.textRenderer.getWidth(SaturnUi.text(text)); - this.height = SaturnClient.client.textRenderer.fontHeight; - } - - public SaturnText(String text, int color) { - this(text); - } - - @Override - public void render( - DrawContext context, - boolean hovering, - int mouseX, - int mouseY) { - context.drawText( - SaturnClient.client.textRenderer, - SaturnUi.text(text), - 0, - 0, - SaturnClientConfig.getColor(hovering, alpha), - false); - } -} diff --git a/src/main/java/org/saturnclient/ui2/components/SaturnModule.java b/src/main/java/org/saturnclient/ui2/components/SaturnModule.java index 6bc159f..5a02a44 100644 --- a/src/main/java/org/saturnclient/ui2/components/SaturnModule.java +++ b/src/main/java/org/saturnclient/ui2/components/SaturnModule.java @@ -4,7 +4,7 @@ import org.saturnclient.modules.Module; import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.config.Property; import org.saturnclient.saturnclient.config.ThemeManager; -import org.saturnclient.ui.Textures; +import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.ElementContext; import org.saturnclient.ui2.RenderScope; diff --git a/src/main/java/org/saturnclient/ui2/components/Sidebar.java b/src/main/java/org/saturnclient/ui2/components/Sidebar.java index 325893b..69a5d9f 100644 --- a/src/main/java/org/saturnclient/ui2/components/Sidebar.java +++ b/src/main/java/org/saturnclient/ui2/components/Sidebar.java @@ -3,7 +3,7 @@ package org.saturnclient.ui2.components; import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.config.Property; import org.saturnclient.saturnclient.config.ThemeManager; -import org.saturnclient.ui.Textures; +import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.ElementContext; import org.saturnclient.ui2.RenderScope; diff --git a/src/main/java/org/saturnclient/ui2/components/inputs/Input.java b/src/main/java/org/saturnclient/ui2/components/inputs/Input.java index 09405c6..0236249 100644 --- a/src/main/java/org/saturnclient/ui2/components/inputs/Input.java +++ b/src/main/java/org/saturnclient/ui2/components/inputs/Input.java @@ -2,10 +2,10 @@ package org.saturnclient.ui2.components.inputs; import org.lwjgl.glfw.GLFW; import org.saturnclient.saturnclient.SaturnClient; -import org.saturnclient.ui.SaturnUi; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.ElementContext; import org.saturnclient.ui2.RenderScope; +import org.saturnclient.ui2.resources.Fonts; public abstract class Input extends Element { String text = ""; @@ -71,7 +71,7 @@ public abstract class Input extends Element { if (focused) { int cursorX = 2 + SaturnClient.client.textRenderer.getWidth( - SaturnUi.text(visibleText.substring(0, cursorPosition - scrollOffset))); + Fonts.setFont(visibleText.substring(0, cursorPosition - scrollOffset))); renderScope.drawRect(cursorX, 2, 1, height - 1, 0xFFFFFFFF); } @@ -86,7 +86,7 @@ public abstract class Input extends Element { int maxWidth = width - 4; // Available width for text while (offset < cursorPosition) { // Ensure cursor remains visible String visibleText = text.substring(offset, cursorPosition); - if (SaturnClient.client.textRenderer.getWidth(SaturnUi.text(visibleText)) > maxWidth) { + if (SaturnClient.client.textRenderer.getWidth(Fonts.setFont(visibleText)) > maxWidth) { offset++; } else { break; @@ -101,7 +101,7 @@ public abstract class Input extends Element { // Ensure text does not overflow past the available width for (int i = 1; i <= visibleText.length(); i++) { if (SaturnClient.client.textRenderer.getWidth( - SaturnUi.text(visibleText.substring(0, i))) > width - 4) { + Fonts.setFont(visibleText.substring(0, i))) > width - 4) { return visibleText.substring(0, i - 1); // Trim overflow } } diff --git a/src/main/java/org/saturnclient/ui2/resources/Fonts.java b/src/main/java/org/saturnclient/ui2/resources/Fonts.java index 6851193..b1697f1 100644 --- a/src/main/java/org/saturnclient/ui2/resources/Fonts.java +++ b/src/main/java/org/saturnclient/ui2/resources/Fonts.java @@ -22,6 +22,16 @@ public class Fonts { Style.EMPTY.withFont(font)); } + public static Text setFont(String text, boolean bold) { + return Text.literal(text).setStyle( + Style.EMPTY.withFont(bold ? INTER_BOLD : INTER)); + } + + public static Text setFont(String text) { + return Text.literal(text).setStyle( + Style.EMPTY.withFont(INTER)); + } + // public static int getWidth(String text, Identifier font) { // return SaturnClient.client.textRenderer.getWidth(Text.literal(text).setStyle( // Style.EMPTY.withFont(font))); diff --git a/src/main/java/org/saturnclient/ui2/resources/Textures.java b/src/main/java/org/saturnclient/ui2/resources/Textures.java index ff26eff..cfdf79f 100644 --- a/src/main/java/org/saturnclient/ui2/resources/Textures.java +++ b/src/main/java/org/saturnclient/ui2/resources/Textures.java @@ -4,4 +4,42 @@ import net.minecraft.util.Identifier; public class Textures { public static final Identifier CROSSHAIR_RANGE = Identifier.of("saturnclient", "textures/gui/hud/crosshair_range.png"); -} \ No newline at end of file + public static final Identifier COSMETICS = Identifier.of("saturnclient", "textures/gui/components/cosmetics.png"); + public static final Identifier HUD_ICON = Identifier.of("saturnclient", "textures/gui/components/hud.png"); + public static final Identifier SEARCH = Identifier.of("saturnclient", "textures/gui/components/search.png"); + public static final Identifier CLOSE = Identifier.of("saturnclient", "textures/gui/components/close.png"); + public static final Identifier MODS_TAB = Identifier.of("saturnclient", "textures/gui/components/mods_tab.png"); + public static final Identifier SETTINGS = Identifier.of("saturnclient", "textures/gui/components/settings.png"); + public static final Identifier CLOAK = Identifier.of("saturnclient", "textures/gui/components/cloak.png"); + public static final Identifier HAT = Identifier.of("saturnclient", "textures/gui/components/hat.png"); + public static final Identifier RESET = Identifier.of("saturnclient", "textures/gui/components/reset.png"); + public static final Identifier TOGGLE_INDICATOR = Identifier.of("saturnclient", + "textures/gui/components/toggle_indicator.png"); + public static final Identifier TOGGLE_BG = Identifier.of("saturnclient", "textures/gui/components/toggle_bg.png"); + + public static final Identifier LOGO = Identifier.of("saturnclient", "textures/logo/logo.png"); + public static final Identifier REALISTIC_LOGO = Identifier.of("saturnclient", "textures/logo/realistic.png"); + public static final Identifier LOGO_TEXT = Identifier.of("saturnclient", "textures/logo/text.png"); + + // Widgets + public static final Identifier BUTTON_BORDER = Identifier.of("saturnclient", "button_border"); + public static final Identifier BUTTON = Identifier.of("saturnclient", "button"); + public static final Identifier BUTTON_OP = Identifier.of("saturnclient", "button_op"); + public static final Identifier SETTINGS_BG = Identifier.of("saturnclient", "settings_bg"); + public static final Identifier RECT = Identifier.of("saturnclient", "rect"); + public static final Identifier RECT_BORDER = Identifier.of("saturnclient", "rect_border"); + public static final Identifier MOD = Identifier.of("saturnclient", "textures/gui/components/mod.png"); + public static final Identifier MOD_BG = Identifier.of("saturnclient", "textures/gui/components/mod_bg.png"); + + public static Identifier getCloakPreview(String cloak) { + return Identifier.of("saturnclient", "textures/gui/cloak/" + (cloak.isEmpty() ? "none" : cloak) + ".png"); + } + + public static Identifier getHatPreview(String hat) { + return Identifier.of("saturnclient", "textures/gui/hat/" + (hat.isEmpty() ? "none" : hat) + ".png"); + } + + public static Identifier getModIcon(String modId) { + return Identifier.of("saturnclient", "textures/gui/mod/" + modId + ".png"); + } +} diff --git a/src/main/java/org/saturnclient/ui2/screens/CloakMenu.java b/src/main/java/org/saturnclient/ui2/screens/CloakMenu.java index 30d6d07..15cb79a 100644 --- a/src/main/java/org/saturnclient/ui2/screens/CloakMenu.java +++ b/src/main/java/org/saturnclient/ui2/screens/CloakMenu.java @@ -3,7 +3,7 @@ package org.saturnclient.ui2.screens; import org.saturnclient.saturnclient.auth.Auth; import org.saturnclient.saturnclient.auth.SaturnPlayer; import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks; -import org.saturnclient.ui.Textures; +import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.SaturnScreen; import org.saturnclient.ui2.components.CosmeticPreview; import org.saturnclient.ui2.components.Sidebar; diff --git a/src/main/java/org/saturnclient/ui2/screens/HatMenu.java b/src/main/java/org/saturnclient/ui2/screens/HatMenu.java index d47182b..a75b7a0 100644 --- a/src/main/java/org/saturnclient/ui2/screens/HatMenu.java +++ b/src/main/java/org/saturnclient/ui2/screens/HatMenu.java @@ -3,7 +3,7 @@ package org.saturnclient.ui2.screens; import org.saturnclient.saturnclient.auth.Auth; import org.saturnclient.saturnclient.auth.SaturnPlayer; import org.saturnclient.saturnclient.cosmetics.Hats; -import org.saturnclient.ui.Textures; +import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.SaturnScreen; import org.saturnclient.ui2.components.CosmeticPreview; import org.saturnclient.ui2.components.Sidebar; diff --git a/src/main/java/org/saturnclient/ui2/screens/ShiftMenu.java b/src/main/java/org/saturnclient/ui2/screens/ShiftMenu.java index 3657f8f..51e38b5 100644 --- a/src/main/java/org/saturnclient/ui2/screens/ShiftMenu.java +++ b/src/main/java/org/saturnclient/ui2/screens/ShiftMenu.java @@ -3,7 +3,7 @@ package org.saturnclient.ui2.screens; import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.SaturnClientConfig; import org.saturnclient.saturnclient.menus.HudEditor; -import org.saturnclient.ui.Textures; +import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.SaturnScreen; import org.saturnclient.ui2.elements.Button; diff --git a/src/main/java/org/saturnclient/ui2/screens/TitleMenu.java b/src/main/java/org/saturnclient/ui2/screens/TitleMenu.java index 48c9164..194cc8f 100644 --- a/src/main/java/org/saturnclient/ui2/screens/TitleMenu.java +++ b/src/main/java/org/saturnclient/ui2/screens/TitleMenu.java @@ -3,7 +3,7 @@ package org.saturnclient.ui2.screens; import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.SaturnClientConfig; import org.saturnclient.saturnclient.menus.HudEditor; -import org.saturnclient.ui.Textures; +import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.SaturnScreen; import org.saturnclient.ui2.anim.Fade; import org.saturnclient.ui2.anim.SlideY;