diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-02-26 00:35:20 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-02-26 00:35:20 +0800 |
| commit | 69a855f33483c3a5273f6f337c95fb51aad5d2b4 (patch) | |
| tree | 8cec3c7967d95ec386bcf4aabe59b323b23f1103 /src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java | |
| parent | 6a943e21ed3c2610ade20c3ba0646da87db65501 (diff) | |
| download | RoughlyEnoughItems-69a855f33483c3a5273f6f337c95fb51aad5d2b4.tar.gz RoughlyEnoughItems-69a855f33483c3a5273f6f337c95fb51aad5d2b4.tar.bz2 RoughlyEnoughItems-69a855f33483c3a5273f6f337c95fb51aad5d2b4.zip | |
improved notice filtering
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 8b73d7603..45757a4cd 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -39,7 +39,7 @@ import java.util.*; import java.util.function.Supplier; @ApiStatus.Internal -public class RecipeViewingScreen extends Screen { +public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); private final List<Widget> preWidgets; @@ -59,7 +59,8 @@ public class RecipeViewingScreen extends Screen { @Nullable private CategoryBaseWidget workingStationsBaseWidget; private RecipeCategory<RecipeDisplay> selectedCategory; private ButtonWidget recipeBack, recipeNext, categoryBack, categoryNext; - private EntryStack mainStackToNotice = EntryStack.empty(); + private EntryStack ingredientStackToNotice = EntryStack.empty(); + private EntryStack resultStackToNotice = EntryStack.empty(); public RecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap) { super(new LiteralText("")); @@ -80,14 +81,24 @@ public class RecipeViewingScreen extends Screen { this.choosePageActivated = false; } - static void transformNotice(List<Widget> setupDisplay, EntryStack mainStackToNotice) { - if (mainStackToNotice.isEmpty()) + @ApiStatus.Internal + static void transformIngredientNotice(List<Widget> setupDisplay, EntryStack noticeStack) { + transformNotice(1, setupDisplay, noticeStack); + } + + @ApiStatus.Internal + static void transformResultNotice(List<Widget> setupDisplay, EntryStack noticeStack) { + transformNotice(2, setupDisplay, noticeStack); + } + + private static void transformNotice(int marker, List<Widget> setupDisplay, EntryStack noticeStack) { + if (noticeStack.isEmpty()) return; for (Widget widget : setupDisplay) { if (widget instanceof EntryWidget) { EntryWidget entry = (EntryWidget) widget; - if (entry.entries().size() > 1) { - EntryStack stack = CollectionUtils.findFirstOrNullEqualsEntryIgnoreAmount(entry.entries(), mainStackToNotice); + if (entry.getNoticeMark() == marker && entry.entries().size() > 1) { + EntryStack stack = CollectionUtils.findFirstOrNullEqualsEntryIgnoreAmount(entry.entries(), noticeStack); if (stack != null) { entry.clearStacks(); entry.entry(stack); @@ -97,8 +108,16 @@ public class RecipeViewingScreen extends Screen { } } - public void addMainStackToNotice(EntryStack stack) { - this.mainStackToNotice = stack; + @ApiStatus.Internal + @Override + public void addIngredientStackToNotice(EntryStack stack) { + this.ingredientStackToNotice = stack; + } + + @ApiStatus.Internal + @Override + public void addResultStackToNotice(EntryStack stack) { + this.resultStackToNotice = stack; } @Nullable @@ -271,7 +290,8 @@ public class RecipeViewingScreen extends Screen { int displayWidth = selectedCategory.getDisplayWidth(displaySupplier.get()); final Rectangle displayBounds = new Rectangle(getBounds().getCenterX() - displayWidth / 2, getBounds().y - 2 + 36 + recipeHeight * i + 4 * i, displayWidth, recipeHeight); List<Widget> setupDisplay = selectedCategory.setupDisplay(displaySupplier, displayBounds); - transformNotice(setupDisplay, mainStackToNotice); + transformIngredientNotice(setupDisplay, ingredientStackToNotice); + transformResultNotice(setupDisplay, resultStackToNotice); recipeBounds.put(displayBounds, setupDisplay); this.widgets.addAll(setupDisplay); if (supplier.isPresent() && supplier.get().get(displayBounds) != null) |
