diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-08-28 18:50:24 +0900 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-08-28 18:50:24 +0900 |
| commit | 94e323f75c17e297c33fba1d3afb5c47ae66a8ad (patch) | |
| tree | 3c6cb6c1721fbda792050b96707fad50d1db64e9 /runtime-engine | |
| parent | f5061d043cac7f0217bbe9d4c041b77f9ef911a1 (diff) | |
| download | RoughlyEnoughItems-94e323f75c17e297c33fba1d3afb5c47ae66a8ad.tar.gz RoughlyEnoughItems-94e323f75c17e297c33fba1d3afb5c47ae66a8ad.tar.bz2 RoughlyEnoughItems-94e323f75c17e297c33fba1d3afb5c47ae66a8ad.zip | |
Separate EntryListWidget and FavoritesListWidget more
Diffstat (limited to 'runtime-engine')
3 files changed, 19 insertions, 145 deletions
diff --git a/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/LegacyWrapperViewSearchBuilder.java b/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/LegacyWrapperViewSearchBuilder.java deleted file mode 100644 index 406787e9f..000000000 --- a/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/LegacyWrapperViewSearchBuilder.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.impl.client.view; - -import me.shedaniel.rei.api.client.registry.display.DisplayCategory; -import me.shedaniel.rei.api.client.view.ViewSearchBuilder; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.impl.display.DisplaySpec; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -public final class LegacyWrapperViewSearchBuilder extends AbstractViewSearchBuilder { - private final Map<DisplayCategory<?>, List<DisplaySpec>> map; - @Nullable - private EntryStack<?> inputNotice; - @Nullable - private EntryStack<?> outputNotice; - @Nullable - private CategoryIdentifier<?> preferredOpenedCategory = null; - - public LegacyWrapperViewSearchBuilder(Map<DisplayCategory<?>, List<DisplaySpec>> map) { - this.map = map; - } - - @Override - public ViewSearchBuilder addCategory(CategoryIdentifier<?> category) { - return this; - } - - @Override - public ViewSearchBuilder addCategories(Collection<CategoryIdentifier<?>> categories) { - return this; - } - - @Override - public Set<CategoryIdentifier<?>> getCategories() { - return Collections.emptySet(); - } - - @Override - public ViewSearchBuilder filterCategory(CategoryIdentifier<?> category) { - return this; - } - - @Override - public ViewSearchBuilder filterCategories(Collection<CategoryIdentifier<?>> categories) { - return this; - } - - @Override - public Set<CategoryIdentifier<?>> getFilteringCategories() { - return Collections.emptySet(); - } - - @Override - public <T> ViewSearchBuilder addRecipesFor(EntryStack<T> stack) { - return this; - } - - @Override - public List<EntryStack<?>> getRecipesFor() { - return inputNotice == null ? Collections.emptyList() : Collections.singletonList(outputNotice); - } - - @Override - public <T> ViewSearchBuilder addUsagesFor(EntryStack<T> stack) { - return this; - } - - @Override - public List<EntryStack<?>> getUsagesFor() { - return inputNotice == null ? Collections.emptyList() : Collections.singletonList(inputNotice); - } - - @Override - public ViewSearchBuilder setPreferredOpenedCategory(@Nullable CategoryIdentifier<?> category) { - this.preferredOpenedCategory = category; - return this; - } - - @Override - @Nullable - public CategoryIdentifier<?> getPreferredOpenedCategory() { - return this.preferredOpenedCategory; - } - - public <T> LegacyWrapperViewSearchBuilder addInputNotice(@Nullable EntryStack<T> stack) { - this.inputNotice = stack; - return this; - } - - public <T> LegacyWrapperViewSearchBuilder addOutputNotice(@Nullable EntryStack<T> stack) { - this.outputNotice = stack; - return this; - } - - @Override - public Map<DisplayCategory<?>, List<DisplaySpec>> buildMapInternal() { - fillPreferredOpenedCategory(); - return this.map; - } - - @Override - public boolean isMergingDisplays() { - return true; - } - - @Override - public ViewSearchBuilder mergingDisplays(boolean mergingDisplays) { - return this; - } - - @Override - public boolean isProcessingVisibilityHandlers() { - return false; - } - - @Override - public ViewSearchBuilder processingVisibilityHandlers(boolean processingVisibilityHandlers) { - return this; - } -} diff --git a/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewSearchBuilderImpl.java b/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewSearchBuilderImpl.java index 354ac7e47..0d8640ac5 100644 --- a/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewSearchBuilderImpl.java +++ b/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewSearchBuilderImpl.java @@ -27,6 +27,7 @@ import com.google.common.base.Suppliers; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.display.DisplaySpec; import org.jetbrains.annotations.Nullable; @@ -39,6 +40,7 @@ public final class ViewSearchBuilderImpl extends AbstractViewSearchBuilder { private final Set<CategoryIdentifier<?>> categories = new HashSet<>(); private final List<EntryStack<?>> recipesFor = new ArrayList<>(); private final List<EntryStack<?>> usagesFor = new ArrayList<>(); + private final List<Display> additionalDisplays = new ArrayList<>(); @Nullable private CategoryIdentifier<?> preferredOpenedCategory = null; private boolean mergeDisplays = true; @@ -140,4 +142,15 @@ public final class ViewSearchBuilderImpl extends AbstractViewSearchBuilder { this.processVisibilityHandlers = processingVisibilityHandlers; return this; } + + @Override + public ViewSearchBuilder addDisplays(Collection<Display> displays) { + this.additionalDisplays.addAll(displays); + return this; + } + + @Override + public List<Display> getAdditionalDisplays() { + return Collections.unmodifiableList(additionalDisplays); + } } diff --git a/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java b/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java index 3483b1ee3..a2400eb32 100644 --- a/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java +++ b/runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java @@ -211,6 +211,12 @@ public class ViewsImpl implements Views { generateLiveDisplays(displayRegistry, wrapForError(generator), builder, displayConsumer); } + for (Display display : builder.getAdditionalDisplays()) { + if (!processingVisibilityHandlers || displayRegistry.isDisplayVisible(display)) { + displayConsumer.accept(display); + } + } + Map<DisplayCategory<?>, List<DisplaySpec>> resultSpeced = (Map<DisplayCategory<?>, List<DisplaySpec>>) (Map) new LinkedHashMap<>(result); // optimize displays if (builder.isMergingDisplays() && ConfigObject.getInstance().doMergeDisplayUnderOne()) { |
