Fixed config
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.saturnclient.config;
|
||||
|
||||
import org.saturnclient.config.property.IntProperty;
|
||||
import org.saturnclient.config.property.Property;
|
||||
import org.saturnclient.config.property.SelectProperty;
|
||||
|
||||
public class AnimationConfig {
|
||||
public static ConfigManager config;
|
||||
@@ -35,9 +37,9 @@ public class AnimationConfig {
|
||||
}
|
||||
|
||||
// Animation properties
|
||||
public final Property<Integer> duration;
|
||||
public final Property<Integer> stagger;
|
||||
public final Property<Integer> curve;
|
||||
public final IntProperty duration;
|
||||
public final IntProperty stagger;
|
||||
public final SelectProperty curve;
|
||||
|
||||
public AnimationConfig(boolean enabled, int delay, int stagger) {
|
||||
this.duration = Property.integer(delay);
|
||||
|
||||
@@ -5,17 +5,19 @@ 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.property.BoolProperty;
|
||||
import org.saturnclient.config.property.KeybindingProperty;
|
||||
import org.saturnclient.config.property.Property;
|
||||
import org.saturnclient.ui.resources.Textures;
|
||||
|
||||
public class Config {
|
||||
public static ConfigManager 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(GLFWProvider.GLFW_KEY_B);
|
||||
public static Property<Boolean> stagger = Property.bool(true);
|
||||
public static BoolProperty realisticLogo = Property.bool(false);
|
||||
public static BoolProperty saturnTitleScreen = Property.bool(true);
|
||||
public static BoolProperty cloakPhysics = Property.bool(true);
|
||||
public static BoolProperty stagger = Property.bool(true);
|
||||
public static KeybindingProperty openEmoteWheel = Property.keybinding(GLFWProvider.GLFW_KEY_B);
|
||||
|
||||
public static IdentifierRef getLogo() {
|
||||
return realisticLogo.value ? Textures.REALISTIC_LOGO : Textures.LOGO;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.nio.file.Files;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.saturnclient.config.property.NamespaceProperty;
|
||||
import org.saturnclient.config.property.Property;
|
||||
|
||||
public class ConfigManager {
|
||||
@@ -18,11 +19,11 @@ public class ConfigManager {
|
||||
private static File configFile;
|
||||
|
||||
// SINGLE ROOT TREE
|
||||
private static final Map<String, Property<?>> ROOT = new LinkedHashMap<>();
|
||||
private static final Map<String, Property> ROOT = new LinkedHashMap<>();
|
||||
|
||||
private static JsonNode cachedJson = null;
|
||||
|
||||
private final Map<String, Property<?>> currentMap;
|
||||
private final Map<String, Property> currentMap;
|
||||
|
||||
private final String[] path;
|
||||
|
||||
@@ -63,7 +64,7 @@ public class ConfigManager {
|
||||
/**
|
||||
* Add a property
|
||||
*/
|
||||
public <T> Property<T> property(String name, Property<T> value) {
|
||||
public Property property(String name, Property value) {
|
||||
currentMap.put(name, value);
|
||||
loadSingleProperty(name, value);
|
||||
return value;
|
||||
@@ -105,13 +106,11 @@ public class ConfigManager {
|
||||
/**
|
||||
* Recursive save
|
||||
*/
|
||||
private static void saveRecursive(ObjectNode json, Map<String, Property<?>> map) {
|
||||
private static void saveRecursive(ObjectNode json, Map<String, Property> map) {
|
||||
map.forEach((name, prop) -> {
|
||||
if (prop.isNamespace()) {
|
||||
|
||||
if (prop instanceof NamespaceProperty n) {
|
||||
ObjectNode child = json.objectNode();
|
||||
saveRecursive(child, prop.getNamespaceMap());
|
||||
|
||||
saveRecursive(child, n.value);
|
||||
json.set(name, child);
|
||||
|
||||
} else {
|
||||
@@ -125,7 +124,7 @@ public class ConfigManager {
|
||||
/**
|
||||
* Recursive load
|
||||
*/
|
||||
private static void loadRecursive(ObjectNode json, Map<String, Property<?>> map) {
|
||||
private static void loadRecursive(ObjectNode json, Map<String, Property> map) {
|
||||
|
||||
map.forEach((name, prop) -> {
|
||||
|
||||
@@ -133,9 +132,8 @@ public class ConfigManager {
|
||||
if (element == null)
|
||||
return;
|
||||
|
||||
if (prop.isNamespace() && element.isObject()) {
|
||||
|
||||
loadRecursive((ObjectNode) element, prop.getNamespaceMap());
|
||||
if (prop instanceof NamespaceProperty n) {
|
||||
loadRecursive((ObjectNode) element, n.value);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -149,7 +147,7 @@ public class ConfigManager {
|
||||
/**
|
||||
* Load only a single property immediately after creation
|
||||
*/
|
||||
private void loadSingleProperty(String name, Property<?> prop) {
|
||||
private void loadSingleProperty(String name, Property prop) {
|
||||
|
||||
JsonNode source = cachedJson != null ? cachedJson : loadAndCache();
|
||||
if (source == null || !source.isObject())
|
||||
@@ -201,7 +199,7 @@ public class ConfigManager {
|
||||
|
||||
}
|
||||
|
||||
public Map<String, Property<?>> getProperties() {
|
||||
public Map<String, Property> getProperties() {
|
||||
return currentMap;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,38 @@
|
||||
package org.saturnclient.config;
|
||||
|
||||
import org.saturnclient.config.property.ColorProperty;
|
||||
import org.saturnclient.config.property.IntProperty;
|
||||
import org.saturnclient.config.property.Property;
|
||||
import org.saturnclient.config.property.SelectProperty;
|
||||
|
||||
public class Theme {
|
||||
// Main UI background (slightly warm dark to match Saturn tone)
|
||||
public static final Property<Integer> BACKGROUND = Property.color(0xFF12100D);
|
||||
public static final ColorProperty BACKGROUND = Property.color(0xFF12100D);
|
||||
|
||||
// Default text color
|
||||
public static final Property<Integer> FOREGROUND = Property.color(0xFFF2E6D2);
|
||||
public static final ColorProperty FOREGROUND = Property.color(0xFFF2E6D2);
|
||||
|
||||
// Widget default background (normal state)
|
||||
public static final Property<Integer> PRIMARY = Property.color(0xFF1C1915);
|
||||
public static final ColorProperty PRIMARY = Property.color(0xFF1C1915);
|
||||
|
||||
// Widget text color
|
||||
public static final Property<Integer> PRIMARY_FG = Property.color(0xFFEAD9B8);
|
||||
public static final ColorProperty PRIMARY_FG = Property.color(0xFFEAD9B8);
|
||||
|
||||
// Saturn brand color (hovered / enabled / selected)
|
||||
public static final Property<Integer> ACCENT = Property.color(0xFFE2BF7D);
|
||||
public static final ColorProperty ACCENT = Property.color(0xFFE2BF7D);
|
||||
|
||||
// Text/icons shown on accent background
|
||||
public static final Property<Integer> ACCENT_FG = Property.color(0xFF1A140A);
|
||||
public static final ColorProperty ACCENT_FG = Property.color(0xFF1A140A);
|
||||
|
||||
// Misc colors
|
||||
public static final Property<Integer> SCROLL = Property.color(0xFFE2BF7D);
|
||||
public static final ColorProperty SCROLL = Property.color(0xFFE2BF7D);
|
||||
|
||||
// UI metrics
|
||||
public static final Property<Integer> BG_RADIUS = Property.integer(12);
|
||||
public static final Property<Integer> WIDGET_RADIUS = Property.integer(10);
|
||||
public static final IntProperty BG_RADIUS = Property.integer(12);
|
||||
public static final IntProperty WIDGET_RADIUS = Property.integer(10);
|
||||
|
||||
// Font
|
||||
public static final Property<Integer> FONT = Property.font(2);
|
||||
public static final SelectProperty FONT = Property.font(2);
|
||||
|
||||
public static void init(ConfigManager parent) {
|
||||
ConfigManager config = new ConfigManager(parent, "UI Style");
|
||||
|
||||
Reference in New Issue
Block a user