aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-05-19 20:09:53 +0800
committershedaniel <daniel@shedaniel.me>2020-05-19 20:09:53 +0800
commitc7ad61fe96028eed16c16f580b78ca06a4d6b772 (patch)
treeeafad18802a4b3c122aa758f48ad59d8e77a1244 /src/main/java
parent1337b0214b5917ea7eab028b5d3dcbe02a7bfa1a (diff)
downloadRoughlyEnoughItems-c7ad61fe96028eed16c16f580b78ca06a4d6b772.tar.gz
RoughlyEnoughItems-c7ad61fe96028eed16c16f580b78ca06a4d6b772.tar.bz2
RoughlyEnoughItems-c7ad61fe96028eed16c16f580b78ca06a4d6b772.zip
Support new Cloth Config
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java14
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/entry/RecipeScreenTypeEntry.java8
2 files changed, 18 insertions, 4 deletions
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<List<EntryStack>> {
private ButtonWidget hideButton;
private ButtonWidget showButton;
+ private boolean edited = false;
+
private List<SearchArgument.SearchArguments> lastSearchArguments = Collections.emptyList();
public FilteringEntry(List<EntryStack> configFiltered, List<EntryStack> defaultValue, Consumer<List<EntryStack>> saveConsumer) {
@@ -133,7 +135,7 @@ public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack>> {
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<List<EntryStack>> {
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<List<EntryStack>> {
@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<RecipeScreenType> {
private int width;
+ private final RecipeScreenType original;
private RecipeScreenType type;
private RecipeScreenType defaultValue;
private Consumer<RecipeScreenType> save;
@@ -52,7 +53,6 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
MinecraftClient.getInstance().openScreen(new PreRecipeViewingScreen(getScreen(), type, false, original -> {
MinecraftClient.getInstance().openScreen(getScreen());
type = original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER;
- getScreen().setEdited(true, isRequiresRestart());
}));
}
@@ -67,6 +67,7 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
@SuppressWarnings("deprecation")
public RecipeScreenTypeEntry(int width, Text fieldName, RecipeScreenType type, RecipeScreenType defaultValue, Consumer<RecipeScreenType> save) {
super(fieldName, null);
+ this.original = type;
this.width = width;
this.type = type;
this.defaultValue = defaultValue;
@@ -74,6 +75,11 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
}
@Override
+ public boolean isEdited() {
+ return super.isEdited() || getValue() != original;
+ }
+
+ @Override
public RecipeScreenType getValue() {
return type;
}