From 2cd3f0737b2008e37f8eaadf479312c60d36e7bc Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 20 Mar 2021 16:40:39 +0800 Subject: Allow customizing what part of REI should animate, disable config screen animation by default Signed-off-by: shedaniel --- .../me/shedaniel/rei/impl/ConfigManagerImpl.java | 6 +++--- .../me/shedaniel/rei/impl/ConfigObjectImpl.java | 23 +++++++++++++++++++--- .../me/shedaniel/rei/impl/InternalWidgets.java | 1 + 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'runtime/src/main/java/me/shedaniel/rei/impl') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java index b8edc6b5c..e69c5f3aa 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java @@ -245,7 +245,7 @@ public class ConfigManagerImpl implements ConfigManager { MutableLong current = new MutableLong(0); parentTranslated = new TransformingScreen(true, parent, null, - () -> current.setValue(current.getValue() == 0 ? Util.getMillis() + (getConfig().isReducedMotion() ? -3000 : 0) : current.getValue()), + () -> current.setValue(current.getValue() == 0 ? Util.getMillis() + (!getConfig().isConfigScreenAnimated() ? -3000 : 0) : current.getValue()), () -> 0, () -> (EasingMethod.EasingMethodImpl.EXPO.apply(Mth.clamp((Util.getMillis() - current.getValue()) / 750.0, 0, 1))) * Minecraft.getInstance().getWindow().getGuiScaledHeight(), () -> Util.getMillis() - current.getValue() > 800); parentTranslated.setInitAfter(true); @@ -266,7 +266,7 @@ public class ConfigManagerImpl implements ConfigManager { CreditsScreen creditsScreen = new CreditsScreen(screen); Minecraft.getInstance().setScreen(new TransformingScreen(false, creditsScreen, screen, - () -> current.setValue(current.getValue() == 0 ? Util.getMillis() + (getConfig().isReducedMotion() ? -3000 : 0) : current.getValue()), + () -> current.setValue(current.getValue() == 0 ? Util.getMillis() + (!getConfig().isCreditsScreenAnimated() ? -3000 : 0) : current.getValue()), () -> (1 - EasingMethod.EasingMethodImpl.EXPO.apply(Mth.clamp((Util.getMillis() - current.getValue()) / 750.0, 0, 1))) * Minecraft.getInstance().getWindow().getGuiScaledWidth() * 1.3, () -> 0, @@ -284,7 +284,7 @@ public class ConfigManagerImpl implements ConfigManager { MutableLong current = new MutableLong(0); return new TransformingScreen(false, configScreen, parent, - () -> current.setValue(current.getValue() == 0 ? Util.getMillis() + (getConfig().isReducedMotion() ? -3000 : 0) : current.getValue()), + () -> current.setValue(current.getValue() == 0 ? Util.getMillis() + (!getConfig().isConfigScreenAnimated() ? -3000 : 0) : current.getValue()), () -> 0, () -> (1 - EasingMethod.EasingMethodImpl.EXPO.apply(Mth.clamp((Util.getMillis() - current.getValue()) / 750.0, 0, 1))) * Minecraft.getInstance().getWindow().getGuiScaledHeight() * 1.3, () -> Util.getMillis() - current.getValue() > 800); } catch (Exception e) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index ad1ea29b3..9c019f19a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -101,8 +101,18 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override - public boolean isReducedMotion() { - return basics.reducedMotion; + public boolean isConfigScreenAnimated() { + return basics.motion.configScreenAnimation; + } + + @Override + public boolean isCreditsScreenAnimated() { + return basics.motion.creditsScreenAnimation; + } + + @Override + public boolean isFavoritesAnimated() { + return basics.motion.favoritesAnimation; } @Override @@ -400,7 +410,14 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Comment("Declares whether REI is visible.") @ConfigEntry.Gui.Excluded private boolean overlayVisible = true; @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private ItemCheatingStyle cheatingStyle = ItemCheatingStyle.GRAB; - private boolean reducedMotion = false; + @ConfigEntry.Gui.CollapsibleObject + private Motion motion = new Motion(); + } + + public static class Motion { + private boolean configScreenAnimation = false; + private boolean creditsScreenAnimation = true; + private boolean favoritesAnimation = true; } public static class KeyBindings { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java b/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java index dea02b9c2..9e7831d23 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java @@ -48,6 +48,7 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Objects; -- cgit