This commit is contained in:
2026-03-08 02:40:15 +01:00
parent 48494cd857
commit b2f381a0d6
10 changed files with 49 additions and 47 deletions
@@ -1,6 +1,10 @@
package org.saturnclient.config.manager;
package org.saturnclient.common.provider;
public interface GLFWProvider {
public abstract boolean isKeyPressed(int key);
public abstract String getKeyName(int key);
public class Key {
/** Printable keys. */
public static final int GLFW_KEY_SPACE = 32,
GLFW_KEY_APOSTROPHE = 39,
@@ -3,4 +3,5 @@ package org.saturnclient.common.provider;
public class Providers {
public static RefConstructorProvider refConstructor;
public static SaturnProvider saturn;
public static GLFWProvider GLFW;
}
@@ -8,11 +8,7 @@ import java.awt.image.BufferedImage;
public interface SaturnProvider {
public abstract MinecraftClientRef getClient();
public abstract boolean isKeyPressed(int key);
public abstract void registerBufferedImageTexture(IdentifierRef i, BufferedImage bi);
public abstract String getKeyName(int key);
public abstract void stop();
}
@@ -2,10 +2,10 @@ package org.saturnclient.config;
import java.io.File;
import org.saturnclient.common.provider.GLFWProvider;
import org.saturnclient.common.provider.Providers;
import org.saturnclient.common.ref.asset.IdentifierRef;
import org.saturnclient.config.manager.ConfigManager;
import org.saturnclient.config.manager.Key;
import org.saturnclient.config.manager.Property;
import org.saturnclient.ui.resources.Textures;
@@ -15,7 +15,7 @@ public class Config {
public static Property<Boolean> realisticLogo = Property.bool(false);
public static Property<Boolean> saturnTitleScreen = Property.bool(true);
public static Property<Boolean> cloakPhysics = Property.bool(true);
public static Property<Integer> openEmoteWheel = Property.keybinding(Key.GLFW_KEY_B);
public static Property<Integer> openEmoteWheel = Property.keybinding(GLFWProvider.GLFW_KEY_B);
public static Property<Boolean> stagger = Property.bool(true);
public static IdentifierRef getLogo() {
@@ -275,7 +275,7 @@ public class Property<T> {
public boolean isKeyPressed() {
return (Integer) value != -1 &&
Providers.saturn.isKeyPressed((Integer) value);
Providers.GLFW.isKeyPressed((Integer) value);
}
public boolean wasKeyPressed() {
@@ -3,7 +3,7 @@ package org.saturnclient.modules.mods;
import org.saturnclient.modules.Module;
import org.saturnclient.modules.ModuleDetails;
import org.saturnclient.modules.interfaces.FreelookInterface;
import org.saturnclient.config.manager.Key;
import org.saturnclient.common.provider.GLFWProvider;
import org.saturnclient.config.manager.Property;
public class Freelook extends Module {
@@ -11,7 +11,7 @@ public class Freelook extends Module {
private static Property<Boolean> enabled = Property.bool(false);
private static Property<Boolean> toggle = Property.bool(true);
public static Property<Integer> freelookKey = Property.keybinding(Key.GLFW_KEY_H);
public static Property<Integer> freelookKey = Property.keybinding(GLFWProvider.GLFW_KEY_H);
public static boolean isFreeLooking = false;
private static boolean was1stPerson = false;
@@ -2,13 +2,13 @@ package org.saturnclient.modules.mods;
import org.saturnclient.modules.Module;
import org.saturnclient.modules.ModuleDetails;
import org.saturnclient.config.manager.Key;
import org.saturnclient.common.provider.GLFWProvider;
import org.saturnclient.config.manager.Property;
public class Zoom extends Module {
private static Property<Boolean> enabled = Property.bool(false);
private static Property<Boolean> toggle = Property.bool(false);
public static Property<Integer> zoomKey = Property.keybinding(Key.GLFW_KEY_C);
public static Property<Integer> zoomKey = Property.keybinding(GLFWProvider.GLFW_KEY_C);
public static Property<Float> zoomLevel = Property.floatProp(3.0f);
public static boolean isZooming = false;
+28 -27
View File
@@ -2,7 +2,7 @@ package org.saturnclient.ui;
import java.util.List;
import org.saturnclient.config.manager.Key;
import org.saturnclient.common.provider.GLFWProvider;
public class Utils {
public static boolean isHovering(int mouseX, int mouseY, int elementWidth, int elementHeight, float elementScale) {
@@ -13,36 +13,36 @@ public class Utils {
}
public static char getCharFromKey(int keyCode, int modifiers) {
boolean shift = (modifiers & Key.GLFW_MOD_SHIFT) != 0;
boolean shift = (modifiers & GLFWProvider.GLFW_MOD_SHIFT) != 0;
// A-Z
if (keyCode >= Key.GLFW_KEY_A && keyCode <= Key.GLFW_KEY_Z) {
if (keyCode >= GLFWProvider.GLFW_KEY_A && keyCode <= GLFWProvider.GLFW_KEY_Z) {
return (char) (shift
? 'A' + (keyCode - Key.GLFW_KEY_A)
: 'a' + (keyCode - Key.GLFW_KEY_A));
? 'A' + (keyCode - GLFWProvider.GLFW_KEY_A)
: 'a' + (keyCode - GLFWProvider.GLFW_KEY_A));
}
// 0-9
if (keyCode >= Key.GLFW_KEY_0 && keyCode <= Key.GLFW_KEY_9) {
if (keyCode >= GLFWProvider.GLFW_KEY_0 && keyCode <= GLFWProvider.GLFW_KEY_9) {
return shift
? ")!@#$%^&*(".charAt(keyCode - Key.GLFW_KEY_0)
: (char) ('0' + (keyCode - Key.GLFW_KEY_0));
? ")!@#$%^&*(".charAt(keyCode - GLFWProvider.GLFW_KEY_0)
: (char) ('0' + (keyCode - GLFWProvider.GLFW_KEY_0));
}
// Special characters
return switch (keyCode) {
case Key.GLFW_KEY_SPACE -> ' ';
case Key.GLFW_KEY_PERIOD -> shift ? '>' : '.';
case Key.GLFW_KEY_COMMA -> shift ? '<' : ',';
case Key.GLFW_KEY_MINUS -> shift ? '_' : '-';
case Key.GLFW_KEY_EQUAL -> shift ? '+' : '=';
case Key.GLFW_KEY_SEMICOLON -> shift ? ':' : ';';
case Key.GLFW_KEY_APOSTROPHE -> shift ? '"' : '\'';
case Key.GLFW_KEY_SLASH -> shift ? '?' : '/';
case Key.GLFW_KEY_BACKSLASH -> shift ? '|' : '\\';
case Key.GLFW_KEY_LEFT_BRACKET -> shift ? '{' : '[';
case Key.GLFW_KEY_RIGHT_BRACKET -> shift ? '}' : ']';
case Key.GLFW_KEY_GRAVE_ACCENT -> shift ? '~' : '`';
case GLFWProvider.GLFW_KEY_SPACE -> ' ';
case GLFWProvider.GLFW_KEY_PERIOD -> shift ? '>' : '.';
case GLFWProvider.GLFW_KEY_COMMA -> shift ? '<' : ',';
case GLFWProvider.GLFW_KEY_MINUS -> shift ? '_' : '-';
case GLFWProvider.GLFW_KEY_EQUAL -> shift ? '+' : '=';
case GLFWProvider.GLFW_KEY_SEMICOLON -> shift ? ':' : ';';
case GLFWProvider.GLFW_KEY_APOSTROPHE -> shift ? '"' : '\'';
case GLFWProvider.GLFW_KEY_SLASH -> shift ? '?' : '/';
case GLFWProvider.GLFW_KEY_BACKSLASH -> shift ? '|' : '\\';
case GLFWProvider.GLFW_KEY_LEFT_BRACKET -> shift ? '{' : '[';
case GLFWProvider.GLFW_KEY_RIGHT_BRACKET -> shift ? '}' : ']';
case GLFWProvider.GLFW_KEY_GRAVE_ACCENT -> shift ? '~' : '`';
default -> '\0';
};
}
@@ -51,12 +51,13 @@ public class Utils {
return (index >= 0 && index < list.size()) ? list.get(index) : null;
}
// public static void notify(NotificationKind kind, String title, String toast) {
// if (SaturnClient.client.currentScreen instanceof SaturnScreen) {
// ((SaturnScreen) SaturnClient.client.currentScreen)
// .draw(new Notification(SaturnClient.client.currentScreen.width,
// SaturnClient.client.currentScreen.height, kind,
// title, toast));
// }
// public static void notify(NotificationKind kind, String title, String toast)
// {
// if (SaturnClient.client.currentScreen instanceof SaturnScreen) {
// ((SaturnScreen) SaturnClient.client.currentScreen)
// .draw(new Notification(SaturnClient.client.currentScreen.width,
// SaturnClient.client.currentScreen.height, kind,
// title, toast));
// }
// }
}
@@ -1,7 +1,7 @@
package org.saturnclient.ui.components.inputs;
import org.saturnclient.common.provider.GLFWProvider;
import org.saturnclient.config.Theme;
import org.saturnclient.config.manager.Key;
import org.saturnclient.ui.Element;
import org.saturnclient.ui.ElementContext;
import org.saturnclient.ui.RenderScope;
@@ -21,18 +21,18 @@ public abstract class Input extends Element {
@Override
public void keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == Key.GLFW_KEY_BACKSPACE) {
if (keyCode == GLFWProvider.GLFW_KEY_BACKSPACE) {
if (cursorPosition > 0 && validateBackspace()) {
text = text.substring(0, cursorPosition - 1) +
text.substring(cursorPosition);
cursorPosition--;
backspace();
}
} else if (keyCode == Key.GLFW_KEY_LEFT) {
} else if (keyCode == GLFWProvider.GLFW_KEY_LEFT) {
if (cursorPosition > 0) {
cursorPosition--;
}
} else if (keyCode == Key.GLFW_KEY_RIGHT) {
} else if (keyCode == GLFWProvider.GLFW_KEY_RIGHT) {
if (cursorPosition < text.length()) {
cursorPosition++;
}
@@ -1,8 +1,8 @@
package org.saturnclient.ui.components.inputs;
import org.saturnclient.common.provider.GLFWProvider;
import org.saturnclient.common.provider.Providers;
import org.saturnclient.config.Theme;
import org.saturnclient.config.manager.Key;
import org.saturnclient.config.manager.Property;
import org.saturnclient.ui.Element;
import org.saturnclient.ui.ElementContext;
@@ -22,7 +22,7 @@ public class KeybindingSelector extends Element {
public void render(RenderScope renderScope, ElementContext ctx) {
int textColor = focused ? 0xFFFFFF : 0xAAAAAA;
renderScope.drawRoundedRectangle(0, 0, width, height, 10, 0xFF000000);
String name = Providers.saturn.getKeyName(prop.value);
String name = Providers.GLFW.getKeyName(prop.value);
renderScope.drawText(0.6f,
prop.value == -1 ? "<NONE>"
@@ -32,7 +32,7 @@ public class KeybindingSelector extends Element {
@Override
public void keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == Key.GLFW_KEY_BACKSPACE) {
if (keyCode == GLFWProvider.GLFW_KEY_BACKSPACE) {
prop.value = -1;
} else {
prop.value = keyCode;