From c7ad61fe96028eed16c16f580b78ca06a4d6b772 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 19 May 2020 20:09:53 +0800 Subject: Support new Cloth Config Signed-off-by: shedaniel --- .../me/shedaniel/rei/gui/config/entry/FilteringEntry.java | 14 +++++++++++--- .../rei/gui/config/entry/RecipeScreenTypeEntry.java | 8 +++++++- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src/main/java/me') diff --git a/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java b/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java index 96176953c..8b56fb1a2 100644 --- a/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java +++ b/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java @@ -28,6 +28,7 @@ import com.google.common.collect.Sets; import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; +import me.shedaniel.clothconfig2.api.ScrollingContainer; import me.shedaniel.clothconfig2.gui.ClothConfigScreen; import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget; import me.shedaniel.math.Point; @@ -40,7 +41,6 @@ import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.widgets.Tooltip; import me.shedaniel.rei.gui.OverlaySearchField; import me.shedaniel.rei.gui.widget.EntryWidget; -import me.shedaniel.clothconfig2.api.ScrollingContainer; import me.shedaniel.rei.impl.ScreenHelper; import me.shedaniel.rei.impl.SearchArgument; import me.shedaniel.rei.utils.CollectionUtils; @@ -102,6 +102,8 @@ public class FilteringEntry extends AbstractConfigListEntry> { private ButtonWidget hideButton; private ButtonWidget showButton; + private boolean edited = false; + private List lastSearchArguments = Collections.emptyList(); public FilteringEntry(List configFiltered, List defaultValue, Consumer> saveConsumer) { @@ -133,7 +135,7 @@ public class FilteringEntry extends AbstractConfigListEntry> { entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount); if (entry.isSelected() && !entry.isFiltered()) { configFiltered.add(stack); - getScreen().setEdited(true, false); + edited = true; } } }); @@ -146,7 +148,7 @@ public class FilteringEntry extends AbstractConfigListEntry> { EntryListEntry entry = entries.get(i); entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount); if (entry.isSelected() && configFiltered.remove(stack)) { - getScreen().setEdited(true, false); + edited = true; } } }); @@ -178,6 +180,12 @@ public class FilteringEntry extends AbstractConfigListEntry> { @Override public void save() { saveConsumer.accept(getValue()); + this.edited = false; + } + + @Override + public boolean isEdited() { + return super.isEdited() || edited; } @SuppressWarnings("rawtypes") diff --git a/src/main/java/me/shedaniel/rei/gui/config/entry/RecipeScreenTypeEntry.java b/src/main/java/me/shedaniel/rei/gui/config/entry/RecipeScreenTypeEntry.java index 620fbcf45..364c1c0fb 100644 --- a/src/main/java/me/shedaniel/rei/gui/config/entry/RecipeScreenTypeEntry.java +++ b/src/main/java/me/shedaniel/rei/gui/config/entry/RecipeScreenTypeEntry.java @@ -43,6 +43,7 @@ import java.util.function.Consumer; public class RecipeScreenTypeEntry extends TooltipListEntry { private int width; + private final RecipeScreenType original; private RecipeScreenType type; private RecipeScreenType defaultValue; private Consumer save; @@ -52,7 +53,6 @@ public class RecipeScreenTypeEntry extends TooltipListEntry { MinecraftClient.getInstance().openScreen(new PreRecipeViewingScreen(getScreen(), type, false, original -> { MinecraftClient.getInstance().openScreen(getScreen()); type = original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER; - getScreen().setEdited(true, isRequiresRestart()); })); } @@ -67,12 +67,18 @@ public class RecipeScreenTypeEntry extends TooltipListEntry { @SuppressWarnings("deprecation") public RecipeScreenTypeEntry(int width, Text fieldName, RecipeScreenType type, RecipeScreenType defaultValue, Consumer save) { super(fieldName, null); + this.original = type; this.width = width; this.type = type; this.defaultValue = defaultValue; this.save = save; } + @Override + public boolean isEdited() { + return super.isEdited() || getValue() != original; + } + @Override public RecipeScreenType getValue() { return type; -- cgit