diff --git a/src/main/java/org/saturnclient/config/AnimationConfig.java b/src/main/java/org/saturnclient/config/AnimationConfig.java index 180673b..32861de 100644 --- a/src/main/java/org/saturnclient/config/AnimationConfig.java +++ b/src/main/java/org/saturnclient/config/AnimationConfig.java @@ -1,5 +1,9 @@ package org.saturnclient.config; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + import org.saturnclient.config.property.IntProperty; import org.saturnclient.config.property.Property; import org.saturnclient.config.property.SelectProperty; @@ -25,6 +29,10 @@ public class AnimationConfig { // Emote wheel public static final AnimationConfig emoteWheel = new AnimationConfig(true, 700, 40); + /** Every menu's animation, in the order they're shown in the settings */ + public static final List ALL = List.of(logo, mainMenu, modMenu, shiftMenu, cosmeticsMenu, + emoteWheel); + public static void init(ConfigManager parent) { config = new ConfigManager(parent, "Animations"); @@ -47,7 +55,25 @@ public class AnimationConfig { this.curve = Property.select(1, "Ease In Out Cubic", "Ease Out Cubic", "Ease In Out Back"); } + /** The menu this animates, like "Mod Menu" */ + public String name; + + /** + * This animation's settings under short names ("Duration"), for showing + * them grouped under {@link #name}. They're saved under longer names + * ("Mod Menu Duration"), which stay as they are so saved settings keep + * loading. + */ + public Map getProperties() { + Map properties = new LinkedHashMap<>(); + properties.put("Duration", duration); + properties.put("Stagger", stagger); + properties.put("Curve", curve); + return properties; + } + public void init(String name) { + this.name = name; // config.property("Enable " + name + " Animations", this.enabled); config.property(name + " Duration", this.duration, "How long the animation takes"); config.property(name + " Stagger", this.stagger, "Delay between items appearing one after another"); diff --git a/src/main/java/org/saturnclient/ui/screens/ClientSettings.java b/src/main/java/org/saturnclient/ui/screens/ClientSettings.java index db3fd4e..e6cfbb3 100644 --- a/src/main/java/org/saturnclient/ui/screens/ClientSettings.java +++ b/src/main/java/org/saturnclient/ui/screens/ClientSettings.java @@ -92,7 +92,7 @@ public class ClientSettings extends PanelScreen { switch (section) { case GENERAL -> PropertyList.draw(scroll, getGeneralProperties(), Set.of(), listWidth, 0); case UI_STYLE -> drawUiStyle(scroll, listWidth); - case ANIMATIONS -> PropertyList.draw(scroll, AnimationConfig.config.getProperties(), Set.of(), listWidth, 0); + case ANIMATIONS -> drawAnimations(scroll, listWidth); } draw(scroll.dimensions(scrollWidth(width), contentHeight - LIST_Y).position(x, contentY + LIST_Y)); @@ -118,6 +118,18 @@ public class ClientSettings extends PanelScreen { PropertyList.draw(scroll, properties, getNames(properties, p -> p instanceof ColorProperty), width, y); } + /** + * Each menu's animation settings under the menu's name. + */ + private static void drawAnimations(Scroll scroll, int width) { + int y = 0; + + for (AnimationConfig animation : AnimationConfig.ALL) { + y = PropertyList.drawSection(scroll, animation.name, y) + 4; + y = PropertyList.draw(scroll, animation.getProperties(), Set.of(), width, y) + SECTION_GAP; + } + } + /** * The top-level settings. The namespaces have sections of their own. */