diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-05-21 20:29:08 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-05-21 20:29:08 +0800 |
| commit | a4884f1e31083a05b48ea238ce8792842e691444 (patch) | |
| tree | 5284d9cc68d5d21f74a6dc84f8004d42061c8831 /runtime/src/main/java/me/shedaniel/rei/impl | |
| parent | e48b5b7a9eec72fcaf202d1ffe53765da6aad503 (diff) | |
| parent | 8589dfa9b7e382c2eff22bb1c5bea5d7759007d5 (diff) | |
| download | RoughlyEnoughItems-a4884f1e31083a05b48ea238ce8792842e691444.tar.gz RoughlyEnoughItems-a4884f1e31083a05b48ea238ce8792842e691444.tar.bz2 RoughlyEnoughItems-a4884f1e31083a05b48ea238ce8792842e691444.zip | |
Merge remote-tracking branch 'origin/8.x-1.18.2' into 9.x-1.19
# Conflicts:
# gradle.properties
# runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/impl')
52 files changed, 3242 insertions, 1422 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java index 2e476749c..fd13d30fb 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java @@ -269,7 +269,7 @@ public class ClientHelperImpl implements ClientHelper { } @ApiStatus.Internal - public void openRecipeViewingScreen(Map<DisplayCategory<?>, List<DisplaySpec>> map, @Nullable CategoryIdentifier<?> category, List<EntryStack<?>> ingredientNotice, List<EntryStack<?>> resultNotice) { + public void openDisplayViewingScreen(Map<DisplayCategory<?>, List<DisplaySpec>> map, @Nullable CategoryIdentifier<?> category, List<EntryStack<?>> ingredientNotice, List<EntryStack<?>> resultNotice) { LegacyWrapperViewSearchBuilder builder = new LegacyWrapperViewSearchBuilder(map); for (EntryStack<?> stack : ingredientNotice) { builder.addInputNotice(stack); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java index 792c66586..8791301b0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java @@ -58,7 +58,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -import static me.shedaniel.rei.impl.client.gui.widget.EntryListWidget.entrySize; +import static me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget.entrySize; @ApiStatus.Internal @Environment(EnvType.CLIENT) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java index 0f273b7e8..28f45277b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java @@ -167,11 +167,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Override public boolean isCraftableFilterEnabled() { - return appearance.layout.enableCraftableOnlyButton; + return appearance.layout.showCraftableOnlyButton; } public void setCraftableFilterEnabled(boolean enabled) { - appearance.layout.enableCraftableOnlyButton = enabled; + appearance.layout.showCraftableOnlyButton = enabled; } @Override @@ -249,7 +249,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Override public boolean doesSnapToRows() { - return advanced.accessibility.snapToRows; + return false; } @Override @@ -570,7 +570,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { private SearchFieldLocation searchFieldLocation = SearchFieldLocation.CENTER; @Comment("Declares the position of the config button.") @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private ConfigButtonPosition configButtonLocation = ConfigButtonPosition.LOWER; - @Comment("Declares whether the craftable filter button is enabled.") private boolean enableCraftableOnlyButton = true; + @Comment("Declares whether the craftable filter button is enabled.") private boolean showCraftableOnlyButton = true; } @UsePercentage(min = 0.1, max = 1.0, prefix = "Limit: ") private double horizontalEntriesBoundaries = 1.0; @@ -633,7 +633,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @UsePercentage(min = 0.25, max = 4.0) private double entrySize = 1.0; @Comment("Declares the position of the entry panel.") @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private DisplayPanelLocation displayPanelLocation = DisplayPanelLocation.RIGHT; - @Comment("Declares whether scrolled entry panel should snap to rows.") private boolean snapToRows = false; @Comment("Declares how the scrollbar in composite screen should act.") private boolean compositeScrollBarPermanent = false; private boolean toastDisplayedOnCopyIdentifier = true; @Comment("Declares whether REI should use compact tabs for categories.") private boolean useCompactTabs = true; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java index 4abc68318..2106e0e36 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java @@ -35,7 +35,6 @@ import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.client.search.SearchFilter; @@ -46,6 +45,7 @@ import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; +import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; @@ -56,11 +56,13 @@ import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; +import java.util.function.Predicate; -import static me.shedaniel.rei.impl.client.gui.widget.EntryListWidget.entrySize; +import static me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget.entrySize; @ApiStatus.Internal public class FilteringScreen extends Screen { @@ -87,11 +89,12 @@ public class FilteringScreen extends Screen { private Tooltip tooltip = null; private List<EntryStack<?>> entryStacks = null; private Rectangle innerBounds; - private List<EntryListEntry> entries = Collections.emptyList(); + private List<FilteringListEntry> entries = Collections.emptyList(); private List<GuiEventListener> elements = Collections.emptyList(); - private Point selectionPoint = null; - private Point secondPoint = null; + private record PointPair(Point firstPoint, @Nullable Point secondPoint) {} + + private List<PointPair> points = new ArrayList<>(); private OverlaySearchField searchField; private Button selectAllButton; @@ -99,7 +102,7 @@ public class FilteringScreen extends Screen { private Button hideButton; private Button showButton; private Button backButton; - private Rectangle selectionCache; + private Predicate<Rectangle> selectionCache; private SearchFilter lastFilter = SearchFilter.matchAll(); @@ -110,15 +113,14 @@ public class FilteringScreen extends Screen { { Component selectAllText = Component.translatable("config.roughlyenoughitems.filteredEntries.selectAll"); this.selectAllButton = new Button(0, 0, Minecraft.getInstance().font.width(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); + this.points.clear(); + this.points.add(new PointPair(new Point(-Integer.MAX_VALUE / 2, -Integer.MAX_VALUE / 2), new Point(Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 2))); }); } { Component selectNoneText = Component.translatable("config.roughlyenoughitems.filteredEntries.selectNone"); this.selectNoneButton = new Button(0, 0, Minecraft.getInstance().font.width(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); + this.points.clear(); }); } { @@ -126,7 +128,7 @@ public class FilteringScreen extends Screen { this.hideButton = new Button(0, 0, Minecraft.getInstance().font.width(hideText) + 10, 20, hideText, button -> { for (int i = 0; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); - EntryListEntry entry = entries.get(i); + FilteringListEntry entry = entries.get(i); entry.getBounds().y = entry.backupY - scrolling.scrollAmountInt(); if (entry.isSelected() && !entry.isFiltered()) { filteringEntry.configFiltered.add(stack); @@ -141,7 +143,7 @@ public class FilteringScreen extends Screen { this.showButton = new Button(0, 0, Minecraft.getInstance().font.width(showText) + 10, 20, showText, button -> { for (int i = 0; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); - EntryListEntry entry = entries.get(i); + FilteringListEntry entry = entries.get(i); entry.getBounds().y = entry.backupY - scrolling.scrollAmountInt(); if (entry.isSelected() && filteringEntry.configFiltered.remove(stack)) { filteringEntry.edited = true; @@ -214,7 +216,7 @@ public class FilteringScreen extends Screen { if (bounds.isEmpty()) return; ScissorsHandler.INSTANCE.scissor(bounds); - for (EntryListEntry entry : entries) + for (FilteringListEntry entry : entries) entry.clearStacks(); int skip = Math.max(0, Mth.floor(scrolling.scrollAmount() / (float) entrySize())); int nextIndex = skip * innerBounds.width / entrySize(); @@ -222,7 +224,7 @@ public class FilteringScreen extends Screen { BatchedEntryRendererManager manager = new BatchedEntryRendererManager(); for (; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); - EntryListEntry entry = entries.get(nextIndex); + FilteringListEntry entry = entries.get(nextIndex); entry.getBounds().y = entry.backupY - scrolling.scrollAmountInt(); if (entry.getBounds().y > bounds.getMaxY()) break; @@ -267,32 +269,40 @@ public class FilteringScreen extends Screen { } this.font.drawShadow(matrices, this.title.getVisualOrderText(), this.width / 2.0F - this.font.width(this.title) / 2.0F, 12.0F, -1); + Component hint = new TranslatableComponent("config.roughlyenoughitems.filteringRulesScreen.hint").withStyle(ChatFormatting.YELLOW); + this.font.drawShadow(matrices, hint, this.width - this.font.width(hint) - 15, 12.0F, -1); } - private Rectangle getSelection() { + private Predicate<Rectangle> getSelection() { return selectionCache; } private void updateSelectionCache() { - if (selectionPoint != null) { - Point p = secondPoint; - if (p == null) { - p = PointHelper.ofMouse(); - p.translate(0, scrolling.scrollAmountInt()); + if (!points.isEmpty()) { + Predicate<Rectangle> predicate = rect -> false; + for (PointPair pair : points) { + Point firstPoint = pair.firstPoint(); + Point secondPoint = pair.secondPoint(); + if (secondPoint == null) { + secondPoint = PointHelper.ofMouse(); + secondPoint.translate(0, scrolling.scrollAmountInt()); + } + int left = Math.min(firstPoint.x, secondPoint.x); + int top = Math.min(firstPoint.y, secondPoint.y); + int right = Math.max(firstPoint.x, secondPoint.x); + int bottom = Math.max(firstPoint.y, secondPoint.y); + Rectangle rectangle = new Rectangle(left, top - scrolling.scrollAmountInt(), Math.max(1, right - left), Math.max(1, bottom - top)); + predicate = predicate.or(rectangle::intersects); } - int left = Math.min(p.x, selectionPoint.x); - int top = Math.min(p.y, selectionPoint.y); - int right = Math.max(p.x, selectionPoint.x); - int bottom = Math.max(p.y, selectionPoint.y); - selectionCache = new Rectangle(left, top - scrolling.scrollAmountInt(), right - left, bottom - top); + selectionCache = predicate; return; } - selectionCache = new Rectangle(0, 0, 0, 0); + selectionCache = rect -> false; } @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double dx, double dy) { - if (scrolling.mouseDragged(mouseX, mouseY, button, dx, dy, ConfigObject.getInstance().doesSnapToRows(), entrySize())) + if (scrolling.mouseDragged(mouseX, mouseY, button, dx, dy)) return true; return super.mouseDragged(mouseX, mouseY, button, dx, dy); } @@ -326,11 +336,11 @@ public class FilteringScreen extends Screen { int slotsToPrepare = Math.max(entryStacks.size() * 3, width * pageHeight * 3); int currentX = 0; int currentY = 0; - List<EntryListEntry> entries = Lists.newArrayList(); + List<FilteringListEntry> entries = Lists.newArrayList(); for (int i = 0; i < slotsToPrepare; i++) { int xPos = currentX * entrySize + innerBounds.x; int yPos = currentY * entrySize + innerBounds.y; - entries.add(new EntryListEntry(xPos, yPos, entrySize)); + entries.add(new FilteringListEntry(xPos, yPos, entrySize)); currentX++; if (currentX >= width) { currentX = 0; @@ -348,41 +358,41 @@ public class FilteringScreen extends Screen { } @Override - public boolean mouseClicked(double double_1, double double_2, int int_1) { - if (scrolling.updateDraggingState(double_1, double_2, int_1)) + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (scrolling.updateDraggingState(mouseX, mouseY, button)) return true; - if (getBounds().contains(double_1, double_2)) { - if (searchField.mouseClicked(double_1, double_2, int_1)) { - this.selectionPoint = null; - this.secondPoint = null; + if (getBounds().contains(mouseX, mouseY)) { + if (searchField.mouseClicked(mouseX, mouseY, button)) { + this.points.clear(); return true; - } else if (selectAllButton.mouseClicked(double_1, double_2, int_1)) { + } else if (selectAllButton.mouseClicked(mouseX, mouseY, button)) { return true; - } else if (selectNoneButton.mouseClicked(double_1, double_2, int_1)) { + } else if (selectNoneButton.mouseClicked(mouseX, mouseY, button)) { return true; - } else if (hideButton.mouseClicked(double_1, double_2, int_1)) { + } else if (hideButton.mouseClicked(mouseX, mouseY, button)) { return true; - } else if (showButton.mouseClicked(double_1, double_2, int_1)) { + } else if (showButton.mouseClicked(mouseX, mouseY, button)) { return true; - } - if (int_1 == 0) { - this.selectionPoint = new Point(double_1, double_2 + scrolling.scrollAmount()); - this.secondPoint = null; + } else if (button == 0) { + if (!Screen.hasShiftDown()) { + this.points.clear(); + } + this.points.add(new PointPair(new Point(mouseX, mouseY + scrolling.scrollAmount()), null)); |
