From a385fdd18a06f85adc28a4fd555447fcbf8dbb4d Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 15 Jan 2020 11:59:12 +0800 Subject: 3.3.10 --- .../shedaniel/rei/gui/VillagerRecipeViewingScreen.java | 15 +++------------ .../me/shedaniel/rei/gui/widget/EntryListWidget.java | 14 ++++---------- .../shedaniel/rei/gui/widget/FavoritesListWidget.java | 15 ++++----------- .../plugin/information/DefaultInformationCategory.java | 18 +++++------------- 4 files changed, 16 insertions(+), 46 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index 8dbbe8837..b49b1f50b 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -10,8 +10,6 @@ import com.google.common.collect.Maps; import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; -import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget.Interpolation; -import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget.Precision; import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; import me.shedaniel.math.impl.PointHelper; @@ -421,16 +419,9 @@ public class VillagerRecipeViewingScreen extends Screen { } private void updatePosition(float delta) { - target = clamp(target); - if (target < 0) { - target -= target * (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3; - } else if (target > getMaxScroll()) { - target = (target - getMaxScroll()) * (1 - (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3) + getMaxScroll(); - } - if (!Precision.almostEquals(scroll, target, Precision.FLOAT_EPSILON)) - scroll = (float) Interpolation.expoEase(scroll, target, Math.min((System.currentTimeMillis() - start) / ((double) duration), 1)); - else - scroll = target; + double[] target = new double[]{this.target}; + this.scroll = ClothConfigInitializer.handleScrollingPosition(target, this.scroll, this.getMaxScroll(), delta, this.start, this.duration); + this.target = target[0]; } @Override diff --git a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java index 5804f021b..5e1e9cf94 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -427,22 +427,16 @@ public class EntryListWidget extends WidgetWithBounds { } private void updatePosition(float delta) { - target = clamp(target); - if (target < 0) { - target -= target * (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3; - } else if (target > getMaxScroll()) { - target = (target - getMaxScroll()) * (1 - (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3) + getMaxScroll(); - } else if (ConfigObject.getInstance().doesSnapToRows()) { + if (ConfigObject.getInstance().doesSnapToRows() && target >= 0 && target <= getMaxScroll()) { double nearestRow = Math.round(target / (double) entrySize()) * (double) entrySize(); if (!DynamicNewSmoothScrollingEntryListWidget.Precision.almostEquals(target, nearestRow, DynamicNewSmoothScrollingEntryListWidget.Precision.FLOAT_EPSILON)) target += (nearestRow - target) * Math.min(delta / 2.0, 1.0); else target = nearestRow; } - if (!DynamicNewSmoothScrollingEntryListWidget.Precision.almostEquals(scroll, target, DynamicNewSmoothScrollingEntryListWidget.Precision.FLOAT_EPSILON)) - scroll = (float) DynamicNewSmoothScrollingEntryListWidget.Interpolation.expoEase(scroll, target, Math.min((System.currentTimeMillis() - start) / ((double) duration), 1)); - else - scroll = target; + double[] targetD = new double[]{this.target}; + this.scroll = ClothConfigInitializer.handleScrollingPosition(targetD, this.scroll, this.getMaxScroll(), delta, this.start, this.duration); + this.target = targetD[0]; } @Override diff --git a/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java index cefeb8789..19faf9d04 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java @@ -198,22 +198,16 @@ public class FavoritesListWidget extends WidgetWithBounds { } private void updatePosition(float delta) { - target = clamp(target); - if (target < 0) { - target -= target * (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3; - } else if (target > getMaxScroll()) { - target = (target - getMaxScroll()) * (1 - (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3) + getMaxScroll(); - } else if (ConfigObject.getInstance().doesSnapToRows()) { + if (ConfigObject.getInstance().doesSnapToRows() && target >= 0 && target <= getMaxScroll()) { double nearestRow = Math.round(target / (double) entrySize()) * (double) entrySize(); if (!DynamicNewSmoothScrollingEntryListWidget.Precision.almostEquals(target, nearestRow, DynamicNewSmoothScrollingEntryListWidget.Precision.FLOAT_EPSILON)) target += (nearestRow - target) * Math.min(delta / 2.0, 1.0); else target = nearestRow; } - if (!DynamicNewSmoothScrollingEntryListWidget.Precision.almostEquals(scroll, target, DynamicNewSmoothScrollingEntryListWidget.Precision.FLOAT_EPSILON)) - scroll = (float) DynamicNewSmoothScrollingEntryListWidget.Interpolation.expoEase(scroll, target, Math.min((System.currentTimeMillis() - start) / ((double) duration), 1)); - else - scroll = target; + double[] targetD = new double[]{this.target}; + this.scroll = ClothConfigInitializer.handleScrollingPosition(targetD, this.scroll, this.getMaxScroll(), delta, this.start, this.duration); + this.target = targetD[0]; } @Override @@ -230,7 +224,6 @@ public class FavoritesListWidget extends WidgetWithBounds { this.bounds = boundsHandler.getFavoritesListArea(!ConfigObject.getInstance().isLeftHandSidePanel() ? boundsHandler.getLeftBounds(MinecraftClient.getInstance().currentScreen) : boundsHandler.getRightBounds(MinecraftClient.getInstance().currentScreen)); } - @SuppressWarnings("deprecation") public void updateSearch(EntryListWidget listWidget, String searchTerm) { if (ConfigObject.getInstance().isFavoritesEnabled() && ConfigObject.getInstance().doDisplayFavoritesOnTheLeft()) { if (ConfigObject.getInstance().doSearchFavorites()) { diff --git a/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java b/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java index 6735571f9..12cf78071 100644 --- a/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java +++ b/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java @@ -10,7 +10,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget; -import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget; import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; import me.shedaniel.math.impl.PointHelper; @@ -227,8 +226,8 @@ public class DefaultInformationCategory implements RecipeCategory maxScroll ? (int) scroll - maxScroll : 0), height * .95); height = Math.max(10, height); - int minY = Math.min(Math.max((int) scroll * (this.getBounds().height - 2 - height) / maxScroll + getBounds().y + 1, getBounds().y + 1), getBounds().getMaxY() -1 - height); - + int minY = Math.min(Math.max((int) scroll * (this.getBounds().height - 2 - height) / maxScroll + getBounds().y + 1, getBounds().y + 1), getBounds().getMaxY() - 1 - height); + boolean hovered = new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height).contains(PointHelper.fromMouse()); int bottomC = hovered ? 168 : 128; int topC = hovered ? 222 : 172; @@ -260,16 +259,9 @@ public class DefaultInformationCategory implements RecipeCategory getMaxScroll()) { - target = (target - getMaxScroll()) * (1 - (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3) + getMaxScroll(); - } - if (!DynamicNewSmoothScrollingEntryListWidget.Precision.almostEquals(scroll, target, DynamicNewSmoothScrollingEntryListWidget.Precision.FLOAT_EPSILON)) - scroll = (float) DynamicNewSmoothScrollingEntryListWidget.Interpolation.expoEase(scroll, target, Math.min((System.currentTimeMillis() - start) / ((double) duration), 1)); - else - scroll = target; + double[] target = new double[]{this.target}; + this.scroll = ClothConfigInitializer.handleScrollingPosition(target, this.scroll, this.getMaxScroll(), delta, this.start, this.duration); + this.target = target[0]; } @Override -- cgit