diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-03-25 03:55:36 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-03-25 03:55:36 +0800 |
| commit | 995b8b58aa8c890c9181ae479e12a4facfa05a25 (patch) | |
| tree | a16149371fc4b69a73e2ab13e2d96cd2c324b43a /runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java | |
| parent | a34a748d2b6cdb1f70f176f1ec1bd27cbc2a98cf (diff) | |
| download | RoughlyEnoughItems-995b8b58aa8c890c9181ae479e12a4facfa05a25.tar.gz RoughlyEnoughItems-995b8b58aa8c890c9181ae479e12a4facfa05a25.tar.bz2 RoughlyEnoughItems-995b8b58aa8c890c9181ae479e12a4facfa05a25.zip | |
Relocate most of the internal classes to match the api
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java')
| -rw-r--r-- | runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java deleted file mode 100644 index bddc13d03..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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; - -import com.google.common.collect.Lists; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.gui.widgets.Slot; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.registry.display.DisplayCategory; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.display.Display; -import me.shedaniel.rei.api.common.ingredient.EntryStack; -import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.gui.widget.EntryWidget; -import me.shedaniel.rei.impl.registry.ClientHelperImpl; -import net.minecraft.client.gui.chat.NarratorChatListener; -import net.minecraft.client.gui.components.events.ContainerEventHandler; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.screens.Screen; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Map; - -public abstract class AbstractDisplayViewingScreen extends Screen implements RecipeScreen { - protected final Map<DisplayCategory<?>, List<Display>> categoryMap; - protected final List<DisplayCategory<?>> categories; - protected EntryStack<?> ingredientStackToNotice = EntryStack.empty(); - protected EntryStack<?> resultStackToNotice = EntryStack.empty(); - protected int selectedCategoryIndex = 0; - protected int tabsPerPage; - protected Rectangle bounds; - - protected AbstractDisplayViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable CategoryIdentifier<?> category, int tabsPerPage) { - super(NarratorChatListener.NO_TITLE); - this.categoryMap = categoryMap; - this.categories = Lists.newArrayList(categoryMap.keySet()); - this.tabsPerPage = tabsPerPage; - if (category != null) { - for (int i = 0; i < categories.size(); i++) { - if (categories.get(i).getCategoryIdentifier().equals(category)) { - this.selectedCategoryIndex = i; - break; - } - } - } - } - - @Override - public Rectangle getBounds() { - return bounds; - } - - @Override - public void addIngredientStackToNotice(EntryStack<?> stack) { - this.ingredientStackToNotice = stack; - } - - @Override - public void addResultStackToNotice(EntryStack<?> stack) { - this.resultStackToNotice = stack; - } - - @Override - public boolean isPauseScreen() { - return false; - } - - @Override - public CategoryIdentifier<?> getCurrentCategory() { - return getSelectedCategory().getCategoryIdentifier(); - } - - public DisplayCategory<Display> getSelectedCategory() { - return (DisplayCategory<Display>) categories.get(selectedCategoryIndex); - } - - protected void previousCategory() { - int currentCategoryIndex = selectedCategoryIndex; - currentCategoryIndex--; - if (currentCategoryIndex < 0) - currentCategoryIndex = categories.size() - 1; - ClientHelperImpl.getInstance().openRecipeViewingScreen(categoryMap, categories.get(currentCategoryIndex).getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice); - } - - protected void nextCategory() { - int currentCategoryIndex = selectedCategoryIndex; - currentCategoryIndex++; - if (currentCategoryIndex >= categories.size()) - currentCategoryIndex = 0; - ClientHelperImpl.getInstance().openRecipeViewingScreen(categoryMap, categories.get(currentCategoryIndex).getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice); - } - - protected void transformIngredientNotice(List<Widget> setupDisplay, EntryStack<?> noticeStack) { - transformNotice(Slot.INPUT, setupDisplay, noticeStack); - } - - protected void transformResultNotice(List<Widget> setupDisplay, EntryStack<?> noticeStack) { - transformNotice(Slot.OUTPUT, setupDisplay, noticeStack); - } - - private static void transformNotice(int marker, List<? extends GuiEventListener> setupDisplay, EntryStack<?> noticeStack) { - if (noticeStack.isEmpty()) - return; - for (GuiEventListener widget : setupDisplay) { - if (widget instanceof EntryWidget) { - EntryWidget entry = (EntryWidget) widget; - if (entry.getNoticeMark() == marker && entry.getEntries().size() > 1) { - EntryStack<?> stack = CollectionUtils.findFirstOrNullEqualsExact(entry.getEntries(), noticeStack); - if (stack != null) { - entry.clearStacks(); - entry.entry(stack); - } - } - } else if (widget instanceof ContainerEventHandler) { - transformNotice(marker, ((ContainerEventHandler) widget).children(), noticeStack); - } - } - } -} |
