diff options
| author | shedaniel <daniel@shedaniel.me> | 2023-11-03 20:11:45 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2024-04-16 00:38:18 +0900 |
| commit | 7c65a6720851c93dd170d857c637d752a1c02574 (patch) | |
| tree | 66034a23f87e8be57bd09808e078aa5bc927b107 | |
| parent | 1be6fdd292cd5a96af8d9bc1e3432820f3737545 (diff) | |
| download | RoughlyEnoughItems-7c65a6720851c93dd170d857c637d752a1c02574.tar.gz RoughlyEnoughItems-7c65a6720851c93dd170d857c637d752a1c02574.tar.bz2 RoughlyEnoughItems-7c65a6720851c93dd170d857c637d752a1c02574.zip | |
Implement more missing config options
12 files changed, 202 insertions, 35 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java index b7ba99339..e961abaff 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java @@ -420,7 +420,7 @@ public class ConfigManagerImpl implements ConfigManager { collapsibleConfigObject.customGroups.addAll(CollectionUtils.map(CollapsibleConfigManager.getInstance().getConfig().customGroups, CollapsibleConfigManager.CustomGroup::copy)); builder.getOrCreateCategory(new TranslatableComponent("config.roughlyenoughitems.functionality")).getEntries().add(0, new ButtonsConfigEntry(220, Triple.of(new TranslatableComponent("text.rei.collapsible.entries"), $ -> {}, editedSink -> { - Minecraft.getInstance().setScreen(new CollapsibleEntriesScreen(Minecraft.getInstance().screen, collapsibleConfigObject, editedSink)); + // Minecraft.getInstance().setScreen(new CollapsibleEntriesScreen(Minecraft.getInstance().screen, collapsibleConfigObject, editedSink)); })) { @Override public boolean isEditable() { @@ -478,7 +478,8 @@ public class ConfigManagerImpl implements ConfigManager { }); builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.advanced")).getEntries().add(0, new ButtonsConfigEntry(220, Triple.of(new TranslatableComponent("text.rei.performance"), $ -> {}, $ -> { - Minecraft.getInstance().setScreen(new PerformanceScreen(Minecraft.getInstance().screen)); + Screen s = Minecraft.getInstance().screen; + Minecraft.getInstance().setScreen(new PerformanceScreen(() -> Minecraft.getInstance().setScreen(s))); }))); } ConfigAddonRegistryImpl addonRegistry = (ConfigAddonRegistryImpl) ConfigAddonRegistry.getInstance(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java index edd1b8917..3e24218f4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java @@ -31,22 +31,23 @@ import me.shedaniel.clothconfig2.api.Modifier; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; import me.shedaniel.rei.impl.client.config.ConfigObjectImpl; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.config.components.ConfigCategoriesListWidget; import me.shedaniel.rei.impl.client.gui.config.components.ConfigEntriesListWidget; -import me.shedaniel.rei.impl.client.gui.config.options.AllREIConfigCategories; -import me.shedaniel.rei.impl.client.gui.config.options.CompositeOption; -import me.shedaniel.rei.impl.client.gui.config.options.OptionCategory; -import me.shedaniel.rei.impl.client.gui.config.options.OptionGroup; +import me.shedaniel.rei.impl.client.gui.config.options.*; import me.shedaniel.rei.impl.client.gui.credits.CreditsScreen; import me.shedaniel.rei.impl.client.gui.modules.Menu; +import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import org.jetbrains.annotations.Nullable; @@ -55,6 +56,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static me.shedaniel.rei.impl.client.gui.config.options.ConfigUtils.translatable; + public class REIConfigScreen extends Screen implements ConfigAccess { private final Screen parent; private final List<OptionCategory> categories; @@ -75,13 +78,14 @@ public class REIConfigScreen extends Screen implements ConfigAccess { public REIConfigScreen(Screen parent, List<OptionCategory> categories) { super(new TranslatableComponent("config.roughlyenoughitems.title")); this.parent = parent; - this.categories = categories; - Preconditions.checkArgument(!categories.isEmpty(), "Categories cannot be empty!"); - this.activeCategory = categories.get(0); + this.categories = CollectionUtils.map(categories, OptionCategory::copy); + this.cleanRequiresLevel(); + Preconditions.checkArgument(!this.categories.isEmpty(), "Categories cannot be empty!"); + this.activeCategory = this.categories.get(0); ConfigObjectImpl defaultConfig = new ConfigObjectImpl(); ConfigObjectImpl config = ConfigManagerImpl.getInstance().getConfig(); - for (OptionCategory category : categories) { + for (OptionCategory category : this.categories) { for (OptionGroup group : category.getGroups()) { for (CompositeOption<?> option : group.getOptions()) { ((Map<CompositeOption<?>, Object>) this.defaultOptions).put(option, option.getBind().apply(defaultConfig)); @@ -91,6 +95,26 @@ public class REIConfigScreen extends Screen implements ConfigAccess { } } + private void cleanRequiresLevel() { + if (!(REIRuntime.getInstance().getPreviousContainerScreen() == null || Minecraft.getInstance().getConnection() == null || Minecraft.getInstance().getConnection().getRecipeManager() == null)) { + return; + } + + for (OptionCategory category : this.categories) { + for (OptionGroup group : category.getGroups()) { + group.getOptions().replaceAll(option -> { + if (option.isRequiresLevel()) { + return new CompositeOption<>(option.getName(), option.getDescription(), i -> 0, (i, v) -> new Object()) + .entry(value -> translatable("config.rei.texts.requires_level").withStyle(ChatFormatting.RED)) + .defaultValue(() -> 1); + } else { + return option; + } + }); + } + } + } + @Override public void init() { super.init(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java index 8db0b1bf1..a15e86f60 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java @@ -96,7 +96,8 @@ public interface AllREIConfigGroups { .add(TAG_SEARCH) .add(IDENTIFIER_SEARCH); OptionGroup SEARCH_ADVANCED = make("search.advanced"); - OptionGroup FILTERING_FILTERING = make("filtering.filtering"); + OptionGroup FILTERING_FILTERING = make("filtering.filtering") + .add(CUSTOMIZED_FILTERING); OptionGroup FILTERING_ADVANCED = make("filtering.advanced") .add(FILTER_DISPLAYS) .add(MERGE_DISPLAYS); @@ -105,10 +106,14 @@ public interface AllREIConfigGroups { .add(ORDERING) .add(ZOOM) .add(FOCUS_MODE); - OptionGroup LIST_COLLAPSIBLE_GROUPS = make("list.collapsible_groups"); + OptionGroup LIST_COLLAPSIBLE_GROUPS = make("list.collapsible_groups") + .add(COLLAPSIBLE_ENTRIES); OptionGroup DEBUG_PERFORMANCE = make("debug.performance") + .add(PLUGINS_PERFORMANCE) .add(SEARCH_PERFORMANCE) .add(ENTRY_LIST_PERFORMANCE); - OptionGroup RESET_RELOAD = make("reset.reload"); + OptionGroup RESET_RELOAD = make("reset.reload") + .add(RELOAD_PLUGINS) + .add(RELOAD_SEARCH); OptionGroup RESET_RESET = make("reset.reset"); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java index a39658806..c4a00b17d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java @@ -24,12 +24,28 @@ package me.shedaniel.rei.impl.client.gui.config.options; import me.shedaniel.clothconfig2.api.ModifierKeyCode; +import me.shedaniel.rei.RoughlyEnoughItemsCore; +import me.shedaniel.rei.RoughlyEnoughItemsCoreClient; import me.shedaniel.rei.api.client.gui.config.*; +import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry; +import me.shedaniel.rei.api.common.plugins.PluginManager; +import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.config.ConfigObjectImpl; +import me.shedaniel.rei.impl.client.config.collapsible.CollapsibleConfigManager; +import me.shedaniel.rei.impl.client.config.entries.ConfigureCategoriesScreen; import me.shedaniel.rei.impl.client.gui.config.REIConfigScreen; import me.shedaniel.rei.impl.client.gui.config.options.configure.PanelBoundariesConfiguration; +import me.shedaniel.rei.impl.client.gui.performance.PerformanceScreen; +import me.shedaniel.rei.impl.client.gui.screen.ConfigReloadingScreen; +import me.shedaniel.rei.impl.client.gui.screen.collapsible.CollapsibleEntriesScreen; +import me.shedaniel.rei.impl.client.search.argument.Argument; +import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistryImpl; import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.TranslatableComponent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.function.BiConsumer; import java.util.function.Function; @@ -132,6 +148,8 @@ public interface AllREIConfigOptions { .enabledDisabled(); CompositeOption<Boolean> STATUS_EFFECTS_LOCATION = make("accessibility.status_effects_location", i -> i.functionality.leftSideMobEffects, (i, v) -> i.functionality.leftSideMobEffects = v) .ofBoolean(translatable("config.rei.value.accessibility.status_effects_location.right"), translatable("config.rei.value.accessibility.status_effects_location.left")); + CompositeOption<Boolean> INVENTORY_SEARCH = make("accessibility.inventory_search", i -> i.functionality.allowInventoryHighlighting, (i, v) -> i.functionality.allowInventoryHighlighting = v) + .enabledDisabled(); CompositeOption<Boolean> FAVORITES_MODE = make("favorites.mode", i -> i.basics.favoritesEnabled, (i, v) -> i.basics.favoritesEnabled = v) .enabledDisabled(); CompositeOption<FavoriteAddWidgetMode> NEW_FAVORITES_BUTTON_VISIBILITY = make("favorites.new_favorites_button_visibility", i -> i.advanced.layout.favoriteAddWidgetMode, (i, v) -> i.advanced.layout.favoriteAddWidgetMode = v) @@ -158,7 +176,21 @@ public interface AllREIConfigOptions { CompositeOption<SearchMode> IDENTIFIER_SEARCH = make("search.identifier_search", i -> i.advanced.search.identifierSearch, (i, v) -> i.advanced.search.identifierSearch = v) .enumOptions(); // TODO: ASYNC_SEARCH - // TODO: CUSTOMIZED_FILTERING + CompositeOption<ConfigureCategoriesScreen> CUSTOMIZED_FILTERING = make("filtering.customized_filtering", i -> { + return new ConfigureCategoriesScreen( + new HashMap<>(i.getFilteringQuickCraftCategories()), + new HashSet<>(i.getHiddenCategories()), + new ArrayList<>(i.getCategoryOrdering()) + ); + }, (i, screen) -> { + i.setFilteringQuickCraftCategories(screen.getFilteringQuickCraftCategories()); + i.setHiddenCategories(screen.getHiddenCategories()); + i.setCategoryOrdering(screen.getCategoryOrdering()); + }).configure((access, option, onClose) -> { + ConfigureCategoriesScreen screen = access.get(option); + screen.parent = Minecraft.getInstance().screen; + Minecraft.getInstance().setScreen(screen); + }).requiresLevel(); CompositeOption<Boolean> FILTER_DISPLAYS = make("filtering.filter_displays", i -> i.advanced.filtering.shouldFilterDisplays, (i, v) -> i.advanced.filtering.shouldFilterDisplays = v) .enabledDisabled(); CompositeOption<Boolean> MERGE_DISPLAYS = make("filtering.merge_displays", i -> i.advanced.layout.mergeDisplayUnderOne, (i, v) -> i.advanced.layout.mergeDisplayUnderOne = v) @@ -170,11 +202,46 @@ public interface AllREIConfigOptions { CompositeOption<Double> ZOOM = make("list.zoom", i -> i.advanced.accessibility.entrySize, (i, v) -> i.advanced.accessibility.entrySize = v); CompositeOption<Boolean> FOCUS_MODE = make("list.focus_mode", i -> i.appearance.isFocusModeZoomed, (i, v) -> i.appearance.isFocusModeZoomed = v) .ofBoolean(translatable("config.rei.value.list.focus_mode.highlighted"), translatable("config.rei.value.list.focus_mode.zoomed")); - // TODO: PLUGINS_PERFORMANCE + CompositeOption<CollapsibleConfigManager.CollapsibleConfigObject> COLLAPSIBLE_ENTRIES = make("list.collapsible_entries", i -> { + CollapsibleConfigManager.CollapsibleConfigObject object = new CollapsibleConfigManager.CollapsibleConfigObject(); + object.disabledGroups.addAll(CollapsibleConfigManager.getInstance().getConfig().disabledGroups); + object.customGroups.addAll(CollectionUtils.map(CollapsibleConfigManager.getInstance().getConfig().customGroups, CollapsibleConfigManager.CustomGroup::copy)); + return object; + }, (i, object) -> { + CollapsibleConfigManager.CollapsibleConfigObject actualConfig = CollapsibleConfigManager.getInstance().getConfig(); + actualConfig.disabledGroups.clear(); + actualConfig.disabledGroups.addAll(object.disabledGroups); + actualConfig.customGroups.clear(); + actualConfig.customGroups.addAll(object.customGroups); + CollapsibleConfigManager.getInstance().saveConfig(); + ((CollapsibleEntryRegistryImpl) CollapsibleEntryRegistry.getInstance()).recollectCustomEntries(); + }).configure((access, option, onClose) -> { + Minecraft.getInstance().setScreen(new CollapsibleEntriesScreen(onClose, access.get(option))); + }).requiresLevel(); + CompositeOption<Object> PLUGINS_PERFORMANCE = make("debug.plugins_performance", i -> null, (i, v) -> new Object()) + .details((access, option, onClose) -> Minecraft.getInstance().setScreen(new PerformanceScreen(onClose))) + .requiresLevel(); CompositeOption<Boolean> SEARCH_PERFORMANCE = make("debug.search_performance", i -> i.advanced.search.debugSearchTimeRequired, (i, v) -> i.advanced.search.debugSearchTimeRequired = v) .enabledDisabled(); CompositeOption<Boolean> ENTRY_LIST_PERFORMANCE = make("debug.entry_list_performance", i -> i.advanced.layout.debugRenderTimeRequired, (i, v) -> i.advanced.layout.debugRenderTimeRequired = v) .enabledDisabled(); // TODO: RELOAD + CompositeOption<Object> RELOAD_PLUGINS = make("reset.reload_plugins", i -> null, (i, v) -> new Object()) + .reload((access, option, onClose) -> { + RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.clear(); + RoughlyEnoughItemsCoreClient.reloadPlugins(null, null); + while (!PluginManager.areAnyReloading()) { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + Minecraft.getInstance().setScreen(new ConfigReloadingScreen(new TranslatableComponent("text.rei.config.is.reloading"), PluginManager::areAnyReloading, onClose, null)); + }).requiresLevel(); + CompositeOption<Object> RELOAD_SEARCH = make("reset.reload_search", i -> null, (i, v) -> new Object()) + .reload((access, option, onClose) -> { + Argument.resetCache(true); + }).requiresLevel(); // TODO: RESET } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/CompositeOption.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/CompositeOption.java index 5a5d8190f..0057cadb0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/CompositeOption.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/CompositeOption.java @@ -42,6 +42,7 @@ public class CompositeOption<T> { @Nullable private Supplier<T> defaultValue = null; private OptionValueEntry<T> entry = OptionValueEntry.noOp(); + private boolean requiresLevel = false; public CompositeOption(Component name, Component description, Function<ConfigObjectImpl, T> bind, BiConsumer<ConfigObjectImpl, T> save) { this.name = name; @@ -83,6 +84,23 @@ public class CompositeOption<T> { return this.entry(OptionValueEntry.configure(configurator)); } + public CompositeOption<T> details(OptionValueEntry.Configurator<T> configurator) { + return this.entry(OptionValueEntry.details(configurator)); + } + + public CompositeOption<T> reload(OptionValueEntry.Configurator<T> configurator) { + return this.entry(OptionValueEntry.reload(configurator)); + } + + public CompositeOption<T> requiresLevel() { + this.requiresLevel = true; + return this; + } + + public boolean isRequiresLevel() { + return requiresLevel; + } + public CompositeOption<T> previewer(ConfigPreviewer<T> previewer) { this.previewer = previewer; return this; @@ -127,4 +145,13 @@ public class CompositeOption<T> { if (defaultValue == null) return null; return defaultValue.get(); } + + public CompositeOption<T> copy() { + CompositeOption<T> option = new CompositeOption<>(name, description, bind, save); + option.entry = entry; + option.previewer = previewer; + option.defaultValue = defaultValue; + option.requiresLevel = requiresLevel; + return option; + } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionCategory.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionCategory.java index 342525516..67dd5ef12 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionCategory.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionCategory.java @@ -59,4 +59,12 @@ public class OptionCategory { public List<OptionGroup> getGroups() { return groups; } + + public OptionCategory copy() { + OptionCategory category = new OptionCategory(icon, name); + for (OptionGroup group : groups) { + category.add(group.copy()); + } + return category; + } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionGroup.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionGroup.java index 36373ac1e..9e78c3a95 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionGroup.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionGroup.java @@ -48,4 +48,12 @@ public class OptionGroup { public List<CompositeOption<?>> getOptions() { return options; } + + public OptionGroup copy() { + OptionGroup group = new OptionGroup(groupName); + for (CompositeOption<?> option : options) { + group.add(option); + } + return group; + } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java index 48697d882..7102d6adc 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java @@ -110,6 +110,34 @@ public interface OptionValueEntry<T> { }; } + static <T> OptionValueEntry.Configure<T> details(Configurator<T> configurator) { + return new Configure<>() { + @Override + public void configure(ConfigAccess access, CompositeOption<T> option, Runnable onClose) { + configurator.configure(access, option, onClose); + } + + @Override + public Component getOption(T value) { + return translatable("config.rei.texts.details"); + } + }; + } + + static <T> OptionValueEntry.Configure<T> reload(Configurator<T> configurator) { + return new Configure<>() { + @Override + public void configure(ConfigAccess access, CompositeOption<T> option, Runnable onClose) { + configurator.configure(access, option, onClose); + } + + @Override + public Component getOption(T value) { + return translatable("config.rei.texts.reload"); + } + }; + } + static OptionValueEntry<ModifierKeyCode> keybind() { return ModifierKeyCode::getLocalizedName; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java index 2125e502a..239489a71 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java @@ -49,11 +49,11 @@ import static java.util.concurrent.TimeUnit.*; @Environment(EnvType.CLIENT) public class PerformanceScreen extends Screen { - private Screen parent; + private Runnable onClose; - public PerformanceScreen(Screen parent) { + public PerformanceScreen(Runnable onClose) { super(Component.translatable("text.rei.performance")); - this.parent = parent; + this.onClose = onClose; } private PerformanceEntryListWidget list; @@ -138,8 +138,8 @@ public class PerformanceScreen extends Screen { { Component backText = Component.literal("↩ ").append(Component.translatable("gui.back")); addRenderableWidget(new Button(4, 4, Minecraft.getInstance().font.width(backText) + 10, 20, backText, button -> { - minecraft.setScreen(parent); - this.parent = null; + this.onClose.run(); + this.onClose = null; })); } list = new PerformanceEntryListWidget(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java index 483f37dff..1c6d86062 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java @@ -62,18 +62,16 @@ import java.util.*; import java.util.function.Consumer; public class CollapsibleEntriesScreen extends Screen { - private final Screen parent; + private final Runnable onClose; private final CollapsibleConfigManager.CollapsibleConfigObject configObject; - private final Runnable editedSink; private final List<CollapsibleEntryWidget> widgets = new ArrayList<>(); private ListWidget listWidget; private boolean dirty = true; - public CollapsibleEntriesScreen(Screen parent, CollapsibleConfigManager.CollapsibleConfigObject configObject, Runnable editedSink) { + public CollapsibleEntriesScreen(Runnable onClose, CollapsibleConfigManager.CollapsibleConfigObject configObject) { super(new TranslatableComponent("text.rei.collapsible.entries.title")); - this.parent = parent; + this.onClose = onClose; this.configObject = configObject; - this.editedSink = editedSink; this.prepareWidgets(configObject); } @@ -82,11 +80,10 @@ public class CollapsibleEntriesScreen extends Screen { for (CollapsibleConfigManager.CustomGroup customEntry : configObject.customGroups) { this.widgets.add(new CollapsibleEntryWidget(true, customEntry.id, new TextComponent(customEntry.name), - CollectionUtils.filterAndMap(customEntry.stacks, EntryStackProvider::isValid, EntryStackProvider::provide), configObject, editedSink, + CollectionUtils.filterAndMap(customEntry.stacks, EntryStackProvider::isValid, EntryStackProvider::provide), configObject, () -> { this.prepareWidgets(configObject); this.dirty = true; - this.editedSink.run(); })); } @@ -101,11 +98,10 @@ public class CollapsibleEntriesScreen extends Screen { } for (CollapsibleEntryRegistryImpl.Entry entry : collapsibleRegistry.getEntries()) { - this.widgets.add(new CollapsibleEntryWidget(false, entry.getId(), entry.getName(), entries.get(entry.getId()), configObject, editedSink, + this.widgets.add(new CollapsibleEntryWidget(false, entry.getId(), entry.getName(), entries.get(entry.getId()), configObject, () -> { this.prepareWidgets(configObject); this.dirty = true; - this.editedSink.run(); })); } } @@ -124,7 +120,6 @@ public class CollapsibleEntriesScreen extends Screen { setupCustom(new ResourceLocation("custom:" + UUID.randomUUID()), "", new ArrayList<>(), this.configObject, () -> { this.prepareWidgets(configObject); this.dirty = true; - this.editedSink.run(); }); })); } @@ -202,7 +197,7 @@ public class CollapsibleEntriesScreen extends Screen { @Override public void onClose() { - this.minecraft.setScreen(this.parent); + this.onClose.run(); } private static class ListWidget extends Widget { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java index 1ade1dbeb..90f6a617a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java @@ -60,7 +60,6 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.UUID; @SuppressWarnings("UnstableApiUsage") public class CollapsibleEntryWidget extends WidgetWithBounds { @@ -94,7 +93,7 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { private int rowSize; public CollapsibleEntryWidget(boolean custom, ResourceLocation id, Component component, Collection<EntryStack<?>> stacks, - CollapsibleConfigManager.CollapsibleConfigObject configObject, Runnable editedSink, Runnable markDirty) { + CollapsibleConfigManager.CollapsibleConfigObject configObject, Runnable markDirty) { this.custom = custom; this.id = id; this.component = component; @@ -107,7 +106,6 @@ public class CollapsibleEntryWidget extends WidgetWithBounds { } else { this.configObject.disabledGroups.add(this.id); } - editedSink.run(); }); this.toggleButton.setWidth(this.font.width(toggleButton.getMessage()) + 8); if (this.custom) { diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index 2d602885a..25fb4d9c9 100755 --- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -349,6 +349,7 @@ "config.rei.options.accessibility.vanilla_recipe_book.desc": "Toggle the vanilla recipe book. This option is not designed for Modpack developers, as users should be the one to decide whether to use the vanilla recipe book.", "config.rei.options.accessibility.status_effects_location": "Status Effects Location", "config.rei.options.accessibility.status_effects_location.desc": "The location of the status effects. By vanilla, the status effects are placed on the right, but this can be changed to the left.", + "config.rei.options.accessibility.inventory_search": "Inventory Search", "config.rei.value.accessibility.status_effects_location.left": "Left", "config.rei.value.accessibility.status_effects_location.right": "Right", "config.rei.options.groups.favorites.favorites": "Favorites", @@ -431,6 +432,8 @@ "config.rei.value.list.focus_mode.highlighted": "Highlighted", "config.rei.value.list.focus_mode.zoomed": "Zoomed", "config.rei.options.groups.list.collapsible_groups": "Collapsible Groups", + "config.rei.options.list.collapsible_entries": "Collapsible Entries", + "config.rei.options.list.collapsible_entries.desc": "Collapsible Entries allows you to group entries together, and expand / collapse them. This is useful for organizing entries, and hiding entries you do not need.", "config.rei.options.groups.debug.performance": "Performance", "config.rei.options.debug.plugins_performance": "Plugins Performance", "config.rei.options.debug.plugins_performance.desc": "Detailed break-down of plugins' reload times. This is very useful in debugging the performance after loaded into a world.", @@ -452,5 +455,8 @@ "config.rei.value.enabledDisabled.false": "Disabled", "config.rei.value.enabledDisabled.true": "Enabled", "config.rei.texts.preview": "Preview...", - "config.rei.texts.configure": "Configure..." + "config.rei.texts.configure": "Configure...", + "config.rei.texts.details": "Details...", + "config.rei.texts.reload": "Reload...", + "config.rei.texts.requires_level": "Load Level First!" } |
