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