aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-06-11 19:15:16 +0800
committershedaniel <daniel@shedaniel.me>2020-06-11 19:15:16 +0800
commit4755b58cc468d8711f21c42fb2f51357da5ca851 (patch)
tree32437a186542a6b0db9e9876cfaace080e8e0d68 /src/main/java/me
parent14802dfe0c02bd5b9c442672de62f4f113524954 (diff)
downloadRoughlyEnoughItems-4755b58cc468d8711f21c42fb2f51357da5ca851.tar.gz
RoughlyEnoughItems-4755b58cc468d8711f21c42fb2f51357da5ca851.tar.bz2
RoughlyEnoughItems-4755b58cc468d8711f21c42fb2f51357da5ca851.zip
Rewritten Config Screen
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me')
-rw-r--r--src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java8
-rw-r--r--src/main/java/me/shedaniel/rei/api/ConfigObject.java8
-rw-r--r--src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java5
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java5
-rw-r--r--src/main/java/me/shedaniel/rei/gui/WarningAndErrorScreen.java20
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java40
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java40
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java40
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java (renamed from src/main/java/me/shedaniel/rei/gui/config/ItemListOrdering.java)10
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrderingConfig.java (renamed from src/main/java/me/shedaniel/rei/gui/config/ItemListOrderingConfig.java)22
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java2
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java420
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java510
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/entry/NoFilteringEntry.java29
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/entry/RecipeScreenTypeEntry.java8
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/entry/ReloadPluginsEntry.java94
-rw-r--r--src/main/java/me/shedaniel/rei/gui/credits/CreditsEntryListWidget.java6
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java9
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java14
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java29
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java271
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ScreenHelper.java2
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java10
23 files changed, 986 insertions, 616 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index c9a5a45ba..85e8bd694 100644
--- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -25,7 +25,7 @@ package me.shedaniel.rei;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import me.shedaniel.cloth.hooks.ClothClientHooks;
+import me.shedaniel.cloth.api.client.events.v0.ClothClientHooks;
import me.shedaniel.math.api.Executor;
import me.shedaniel.rei.api.*;
import me.shedaniel.rei.api.plugins.REIPluginV0;
@@ -321,14 +321,14 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
if (screen instanceof ContainerScreen)
ScreenHelper.setPreviousContainerScreen((ContainerScreen<?>) screen);
boolean alreadyAdded = false;
- for (Element element : Lists.newArrayList(screenHooks.cloth_getChildren()))
+ for (Element element : Lists.newArrayList(screenHooks.cloth$getChildren()))
if (ContainerScreenOverlay.class.isAssignableFrom(element.getClass()))
if (alreadyAdded)
- screenHooks.cloth_getChildren().remove(element);
+ screenHooks.cloth$getChildren().remove(element);
else
alreadyAdded = true;
if (!alreadyAdded)
- screenHooks.cloth_getChildren().add(ScreenHelper.getLastOverlay(true, false));
+ screenHooks.cloth$getChildren().add(ScreenHelper.getLastOverlay(true, false));
});
ClothClientHooks.SCREEN_RENDER_POST.register((matrices, minecraftClient, screen, i, i1, v) -> {
if (shouldReturn(screen))
diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java
index 52b7fe664..448c3ccb8 100644
--- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java
+++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java
@@ -24,12 +24,11 @@
package me.shedaniel.rei.api;
import me.shedaniel.clothconfig2.api.ModifierKeyCode;
-import me.shedaniel.rei.gui.config.ItemListOrdering;
+import me.shedaniel.rei.gui.config.EntryPanelOrdering;
import me.shedaniel.rei.gui.config.RecipeBorderType;
import me.shedaniel.rei.gui.config.RecipeScreenType;
import me.shedaniel.rei.gui.config.SearchFieldLocation;
import me.shedaniel.rei.impl.ConfigManagerImpl;
-import me.shedaniel.rei.impl.ConfigObjectImpl;
import org.jetbrains.annotations.ApiStatus;
import java.util.List;
@@ -51,7 +50,7 @@ public interface ConfigObject {
void setCheating(boolean cheating);
- ItemListOrdering getItemListOrdering();
+ EntryPanelOrdering getItemListOrdering();
boolean isItemListAscending();
@@ -137,9 +136,6 @@ public interface ConfigObject {
double getEntrySize();
- @ApiStatus.Internal
- ConfigObjectImpl.General getGeneral();
-
boolean isUsingCompactTabs();
boolean isLowerConfigButton();
diff --git a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
index d57a9bbfd..28faa8b37 100644
--- a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
@@ -34,14 +34,13 @@ import me.shedaniel.rei.gui.config.RecipeScreenType;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.gui.widget.WidgetWithBounds;
import me.shedaniel.rei.impl.ScreenHelper;
-import net.minecraft.class_5348;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
import net.minecraft.client.util.NarratorManager;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
+import net.minecraft.text.StringRenderable;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
@@ -128,7 +127,7 @@ public class PreRecipeViewingScreen extends Screen {
this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 20, 16777215);
if (showTips) {
int i = 30;
- for (class_5348 s : this.textRenderer.wrapStringToWidthAsList(new TranslatableText("text.rei.recipe_screen_type.selection.sub").formatted(Formatting.GRAY), width - 30)) {
+ for (StringRenderable s : this.textRenderer.wrapStringToWidthAsList(new TranslatableText("text.rei.recipe_screen_type.selection.sub").formatted(Formatting.GRAY), width - 30)) {
this.drawCenteredText(matrices, this.textRenderer, s, width / 2, i, -1);
i += 10;
}
diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java b/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java
index 3d9b98081..fe6007d1b 100644
--- a/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java
+++ b/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java
@@ -23,7 +23,6 @@
package me.shedaniel.rei.gui;
-import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.gui.toast.ExportRecipeIdentifierToast;
@@ -36,7 +35,7 @@ import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.resource.ResourceImpl;
+import net.minecraft.util.Util;
import org.jetbrains.annotations.ApiStatus;
import java.io.File;
@@ -105,7 +104,7 @@ public final class RecipeDisplayExporter extends Widget {
strippedImage.setPixelRgba(x, y, nativeImage.getPixelRgba(x + (int) (rectangle.x * window.getScaleFactor()), y + (int) (rectangle.y * window.getScaleFactor())));
}
}
- ResourceImpl.RESOURCE_IO_EXECUTOR.execute(() -> {
+ Util.method_27958().execute(() -> {
try {
File export = new File(minecraft.runDirectory, "rei_exports");
export.mkdirs();
diff --git a/src/main/java/me/shedaniel/rei/gui/WarningAndErrorScreen.java b/src/main/java/me/shedaniel/rei/gui/WarningAndErrorScreen.java
index 4f0fadedc..a9baafcea 100644
--- a/src/main/java/me/shedaniel/rei/gui/WarningAndErrorScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/WarningAndErrorScreen.java
@@ -25,7 +25,6 @@ package me.shedaniel.rei.gui;
import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget;
import me.shedaniel.rei.RoughlyEnoughItemsState;
-import net.minecraft.class_5348;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen;
@@ -37,6 +36,7 @@ import net.minecraft.client.util.TextCollector;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
+import net.minecraft.text.StringRenderable;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -70,13 +70,13 @@ public class WarningAndErrorScreen extends Screen {
}
private void addText(Text string) {
- for (class_5348 s : textRenderer.wrapStringToWidthAsList(string, width - 80)) {
+ for (StringRenderable s : textRenderer.wrapStringToWidthAsList(string, width - 80)) {
listWidget.creditsAddEntry(new TextItem(s));
}
}
private void addLink(Text string, String link) {
- for (class_5348 s : textRenderer.wrapStringToWidthAsList(string, width - 80)) {
+ for (StringRenderable s : textRenderer.wrapStringToWidthAsList(string, width - 80)) {
listWidget.creditsAddEntry(new LinkItem(s, link));
}
}
@@ -214,9 +214,9 @@ public class WarningAndErrorScreen extends Screen {
}
private static class TextItem extends StringItem {
- private class_5348 text;
+ private StringRenderable text;
- public TextItem(class_5348 text) {
+ public TextItem(StringRenderable text) {
this.text = text;
}
@@ -242,11 +242,11 @@ public class WarningAndErrorScreen extends Screen {
}
private class LinkItem extends StringItem {
- private class_5348 text;
+ private StringRenderable text;
private String link;
private boolean contains;
- public LinkItem(class_5348 text, String link) {
+ public LinkItem(StringRenderable text, String link) {
this.text = text;
this.link = link;
}
@@ -256,12 +256,12 @@ public class WarningAndErrorScreen extends Screen {
contains = mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight;
if (contains) {
WarningAndErrorScreen.this.renderTooltip(matrices, new LiteralText("Click to open link."), mouseX, mouseY);
- class_5348 underlined = text.visit(new class_5348.StyledVisitor<class_5348>() {
+ StringRenderable underlined = text.visit(new StringRenderable.StyledVisitor<StringRenderable>() {
TextCollector collector = new TextCollector();
@Override
- public Optional<class_5348> accept(Style style, String asString) {
- collector.add(class_5348.method_29431(asString, style));
+ public Optional<StringRenderable> accept(Style style, String asString) {
+ collector.add(StringRenderable.styled(asString, style));
return Optional.of(collector.getCombined());
}
}, Style.EMPTY.withFormatting(Formatting.UNDERLINE)).orElse(text);
diff --git a/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java b/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java
new file mode 100644
index 000000000..43bf52eeb
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java
@@ -0,0 +1,40 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.gui.config;
+
+import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry;
+import net.minecraft.client.resource.language.I18n;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Locale;
+
+public enum AppearanceTheme implements SelectionListEntry.Translatable {
+ LIGHT,
+ DARK;
+
+ @Override
+ public @NotNull String getKey() {
+ return I18n.translate("config.roughlyenoughitems.theme." + name().toLowerCase(Locale.ROOT));
+ }
+}
diff --git a/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java b/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java
new file mode 100644
index 000000000..b07238fc9
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java
@@ -0,0 +1,40 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.gui.config;
+
+import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry;
+import net.minecraft.client.resource.language.I18n;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Locale;
+
+public enum ConfigButtonPosition implements SelectionListEntry.Translatable {
+ UPPER,
+ LOWER;
+
+ @Override
+ public @NotNull String getKey() {
+ return I18n.translate("config.roughlyenoughitems.layout.configButtonLocation." + name().toLowerCase(Locale.ROOT));
+ }
+}
diff --git a/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java b/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java
new file mode 100644
index 000000000..a9022ff09
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java
@@ -0,0 +1,40 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.gui.config;
+
+import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry;
+import net.minecraft.client.resource.language.I18n;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Locale;
+
+public enum DisplayPanelLocation implements SelectionListEntry.Translatable {
+ LEFT,
+ RIGHT;
+
+ @Override
+ public @NotNull String getKey() {
+ return I18n.translate("config.roughlyenoughitems.accessibility.displayPanelLocation." + name().toLowerCase(Locale.ROOT));
+ }
+}
diff --git a/src/main/java/me/shedaniel/rei/gui/config/ItemListOrdering.java b/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java
index 9ef4c366e..fb11df19a 100644
--- a/src/main/java/me/shedaniel/rei/gui/config/ItemListOrdering.java
+++ b/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java
@@ -26,15 +26,15 @@ package me.shedaniel.rei.gui.config;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
-public enum ItemListOrdering {
+public enum EntryPanelOrdering {
- registry("ordering.rei.registry"),
- name("ordering.rei.name"),
- item_groups("ordering.rei.item_groups");
+ REGISTRY("ordering.rei.registry"),
+ NAME("ordering.rei.name"),
+ GROUPS("ordering.rei.item_groups");
private String nameTranslationKey;
- ItemListOrdering(String nameTranslationKey) {
+ EntryPanelOrdering(String nameTranslationKey) {
this.nameTranslationKey = nameTranslationKey;
}
diff --git a/src/main/java/me/shedaniel/rei/gui/config/ItemListOrderingConfig.java b/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrderingConfig.java
index 1b1f0a89b..d64e0cb08 100644
--- a/src/main/java/me/shedaniel/rei/gui/config/ItemListOrderingConfig.java
+++ b/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrderingConfig.java
@@ -27,28 +27,28 @@ import net.minecraft.client.resource.language.I18n;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
-public enum ItemListOrderingConfig {
- REGISTRY_ASCENDING(ItemListOrdering.registry, true),
- NAME_ASCENDING(ItemListOrdering.name, true),
- GROUPS_ASCENDING(ItemListOrdering.item_groups, true),
- REGISTRY_DESCENDING(ItemListOrdering.registry, false),
- NAME_DESCENDING(ItemListOrdering.name, false),
- GROUPS_DESCENDING(ItemListOrdering.item_groups, false);
+public enum EntryPanelOrderingConfig {
+ REGISTRY_ASCENDING(EntryPanelOrdering.REGISTRY, true),
+ NAME_ASCENDING(EntryPanelOrdering.NAME, true),
+ GROUPS_ASCENDING(EntryPanelOrdering.GROUPS, true),
+ REGISTRY_DESCENDING(EntryPanelOrdering.REGISTRY, false),
+ NAME_DESCENDING(EntryPanelOrdering.NAME, false),
+ GROUPS_DESCENDING(EntryPanelOrdering.GROUPS, false);
- private ItemListOrdering ordering;
+ private EntryPanelOrdering ordering;
private boolean isAscending;
- ItemListOrderingConfig(ItemListOrdering ordering, boolean isAscending) {
+ EntryPanelOrderingConfig(EntryPanelOrdering ordering, boolean isAscending) {
this.ordering = ordering;
this.isAscending = isAscending;
}
- public static ItemListOrderingConfig from(ItemListOrdering ordering, boolean isAscending) {
+ public static EntryPanelOrderingConfig from(EntryPanelOrdering ordering, boolean isAscending) {
int index = ordering.ordinal() + (isAscending ? 0 : 3);
return values()[index];
}
- public ItemListOrdering getOrdering() {
+ public EntryPanelOrdering getOrdering() {
return ordering;
}
diff --git a/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java b/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java
index 5b39e2150..6dd19316a 100644
--- a/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java
+++ b/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java
@@ -36,6 +36,6 @@ public enum SearchFieldLocation {
@Override
public String toString() {
- return I18n.translate("config.roughlyenoughitems.searchFieldLocation.%s", name().toLowerCase(Locale.ROOT));
+ return I18n.translate("config.roughlyenoughitems.layout.searchFieldLocation.%s", name().toLowerCase(Locale.ROOT));
}
}
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 5b8306c3f..4aecdef6f 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
@@ -23,148 +23,43 @@
package me.shedaniel.rei.gui.config.entry;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.mojang.blaze3d.systems.RenderSystem;
-import me.shedaniel.clothconfig2.ClothConfigInitializer;
+import com.google.common.collect.ImmutableList;
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
-import me.shedaniel.clothconfig2.api.ScrollingContainer;
-import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget;
-import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget;
-import me.shedaniel.math.Point;
-import me.shedaniel.math.Rectangle;
-import me.shedaniel.math.impl.PointHelper;
-import me.shedaniel.rei.api.ConfigObject;
-import me.shedaniel.rei.api.EntryRegistry;
import me.shedaniel.rei.api.EntryStack;
-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.rei.impl.ScreenHelper;
-import me.shedaniel.rei.impl.SearchArgument;
-import me.shedaniel.rei.utils.CollectionUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.NarratorManager;
+import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
-import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.ApiStatus;
-import org.jetbrains.annotations.Nullable;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
import java.util.function.Consumer;
-import static me.shedaniel.rei.gui.widget.EntryListWidget.entrySize;
-
@ApiStatus.Internal
public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack>> {
- protected List<EntryStack> selected = Lists.newArrayList();
- protected final ScrollingContainer scrolling = new ScrollingContainer() {
- @Override
- public int getMaxScrollHeight() {
- return MathHelper.ceil(entryStacks.size() / (innerBounds.width / (float) entrySize())) * entrySize() + 28;
- }
-
- @Override
- public Rectangle getBounds() {
- return FilteringEntry.this.getBounds();
- }
-
- @Override
- public int getScrollBarX() {
- return getParent().right - 7;
- }
- };
- private Consumer<List<EntryStack>> saveConsumer;
- private List<EntryStack> defaultValue;
- private List<EntryStack> configFiltered;
- private Tooltip tooltip = null;
- @SuppressWarnings("rawtypes") private DynamicEntryListWidget lastList = null;
- private List<EntryStack> entryStacks = null;
- private Rectangle innerBounds;
- private List<EntryListEntry> entries = Collections.emptyList();
- private List<Element> elements = Collections.emptyList();
-
- private Point selectionPoint = null;
- private Point secondPoint = null;
-
- private OverlaySearchField searchField;
- private ButtonWidget selectAllButton;
- private ButtonWidget selectNoneButton;
- 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) {
+ private int width;
+ Consumer<List<EntryStack>> saveConsumer;
+ List<EntryStack> defaultValue;
+ List<EntryStack> configFiltered;
+ boolean edited = false;
+ private final FilteringScreen filteringScreen = new FilteringScreen(this);
+ private final AbstractButtonWidget buttonWidget = new ButtonWidget(0, 0, 0, 20, new TranslatableText("config.roughlyenoughitems.filteringScreen"), button -> {
+ filteringScreen.parent = MinecraftClient.getInstance().currentScreen;
+ MinecraftClient.getInstance().openScreen(filteringScreen);
+ });
+ private final List<Element> children = ImmutableList.of(buttonWidget);
+
+ public FilteringEntry(int width, List<EntryStack> configFiltered, List<EntryStack> defaultValue, Consumer<List<EntryStack>> saveConsumer) {
super(NarratorManager.EMPTY, false);
+ this.width = width;
this.configFiltered = configFiltered;
this.defaultValue = defaultValue;
this.saveConsumer = saveConsumer;
- this.searchField = new OverlaySearchField(0, 0, 0, 0);
- {
- Text selectAllText = new TranslatableText("config.roughlyenoughitems.filteredEntries.selectAll");
- this.selectAllButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(selectAllText) + 10, 20, selectAllText, button -> {
- this.selectionPoint = new Point(-Integer.MAX_VALUE / 2, -Integer.MAX_VALUE / 2);
- this.secondPoint = new Point(Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 2);
- });
- }
- {
- Text selectNoneText = new TranslatableText("config.roughlyenoughitems.filteredEntries.selectNone");
- this.selectNoneButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(selectNoneText) + 10, 20, selectNoneText, button -> {
- this.selectionPoint = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
- this.secondPoint = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
- });
- }
- {
- Text hideText = new TranslatableText("config.roughlyenoughitems.filteredEntries.hide");
- this.hideButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(hideText) + 10, 20, hideText, button -> {
- for (int i = 0; i < entryStacks.size(); i++) {
- EntryStack stack = entryStacks.get(i);
- EntryListEntry entry = entries.get(i);
- entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount);
- if (entry.isSelected() && !entry.isFiltered()) {
- configFiltered.add(stack);
- edited = true;
- }
- }
- });
- }
- {
- Text showText = new TranslatableText("config.roughlyenoughitems.filteredEntries.show");
- this.showButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(showText) + 10, 20, showText, button -> {
- for (int i = 0; i < entryStacks.size(); i++) {
- EntryStack stack = entryStacks.get(i);
- EntryListEntry entry = entries.get(i);
- entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount);
- if (entry.isSelected() && configFiltered.remove(stack)) {
- edited = true;
- }
- }
- });
- }
- this.searchField.isMain = false;
- }
-
- private static Rectangle updateInnerBounds(Rectangle bounds) {
- int width = Math.max(MathHelper.floor((bounds.width - 2