diff options
| author | shedaniel <daniel@shedaniel.me> | 2023-02-19 02:05:30 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2024-04-16 00:38:18 +0900 |
| commit | ab7a2bb72b9ee9591049d4ec3c8815d57986bd2c (patch) | |
| tree | a8c0c0fb76ac58537f5d4bafdc55a416f3a31b43 /runtime/src | |
| parent | eb2b1d1ecc00ba435e97b5d89879ebe379fd7390 (diff) | |
| download | RoughlyEnoughItems-ab7a2bb72b9ee9591049d4ec3c8815d57986bd2c.tar.gz RoughlyEnoughItems-ab7a2bb72b9ee9591049d4ec3c8815d57986bd2c.tar.bz2 RoughlyEnoughItems-ab7a2bb72b9ee9591049d4ec3c8815d57986bd2c.zip | |
Mini Displays Favorites
Diffstat (limited to 'runtime/src')
21 files changed, 441 insertions, 78 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/FavoritesConfigManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/FavoritesConfigManager.java index b4a73f007..7c10ded8a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/FavoritesConfigManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/FavoritesConfigManager.java @@ -1,6 +1,6 @@ /* * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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 diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/collapsible/CollapsibleConfigManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/collapsible/CollapsibleConfigManager.java index edcca423d..1a7781111 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/collapsible/CollapsibleConfigManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/collapsible/CollapsibleConfigManager.java @@ -1,6 +1,6 @@ /* * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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 diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java index 17d34c12f..e84b9f942 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java @@ -27,8 +27,11 @@ import com.mojang.serialization.DataResult; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry; import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponent; +import me.shedaniel.rei.api.client.gui.widgets.Slot; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.Objects; @@ -93,6 +96,8 @@ public class DelegatingFavoriteEntryProviderImpl extends FavoriteEntry { @Override public FavoriteEntry copy() { + if (value != null && toJson != null) return value.copy(); + if (value != null) return FavoriteEntry.delegateResult(() -> DataResult.success(value.copy()), toJson); return FavoriteEntry.delegateResult(supplier, toJson); } @@ -114,4 +119,10 @@ public class DelegatingFavoriteEntryProviderImpl extends FavoriteEntry { public boolean isSame(FavoriteEntry other) { return getUnwrapped().isSame(other.getUnwrapped()); } + + @Override + @Nullable + public DraggableComponent<?> asDraggableComponent(Slot slot) { + return getUnwrapped().asDraggableComponent(slot); + } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java index 838c14516..4e1cbc59f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java @@ -26,9 +26,7 @@ package me.shedaniel.rei.impl.client.gui.dragging; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; -import me.shedaniel.math.FloatingRectangle; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; +import me.shedaniel.math.*; import me.shedaniel.rei.RoughlyEnoughItemsCoreClient; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.drag.DraggableBoundsProvider; @@ -87,13 +85,14 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag if (entry.dragging) { matrices.pushPose(); matrices.translate(0, 0, 600); - entry.bounds.update(delta); + entry.point.update(delta); + entry.dimension.update(delta); int width = entry.component.getWidth(); int height = entry.component.getHeight(); Vec2 mouseStartOffset = entry.mouseStartOffset; - entry.bounds.setTo(new FloatingRectangle(mouseX - width / 2 - mouseStartOffset.x, mouseY - height / 2 - mouseStartOffset.y, width, height), - reducedMotion ? 0 : 30); - entry.component.render(matrices, entry.bounds.value().getBounds(), mouseX, mouseY, delta); + entry.point.setTo(new FloatingPoint(mouseX - mouseStartOffset.x * width, mouseY - mouseStartOffset.y * height), reducedMotion ? 0 : 30); + entry.dimension.setTo(new FloatingDimension(width, height), reducedMotion ? 0 : 700); + entry.component.render(matrices, getCurrentBounds(), mouseX, mouseY, delta); matrices.popPose(); VoxelShape shape = entry.getBoundsProvider().bounds(); @@ -216,16 +215,18 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag public Point getCurrentPosition() { if (!isDraggingComponent()) return null; Vec2 mouseStartOffset = entry.mouseStartOffset; - FloatingRectangle rectangle = entry.bounds.value(); - return new Point(rectangle.getCenterX() + mouseStartOffset.x, rectangle.getCenterY() + mouseStartOffset.y); + FloatingPoint point = entry.point.value(); + FloatingDimension dimension = entry.dimension.value(); + return new Point(point.x + mouseStartOffset.x * dimension.width, point.y + mouseStartOffset.y * dimension.height); } @Override @Nullable public Rectangle getCurrentBounds() { if (!isDraggingComponent()) return null; - FloatingRectangle rectangle = entry.bounds.value(); - return rectangle.getBounds(); + FloatingPoint point = entry.point.value(); + FloatingDimension dimension = entry.dimension.value(); + return new Rectangle(point.x - dimension.width / 2, point.y - dimension.height / 2, dimension.width, dimension.height); } @Override @@ -249,7 +250,8 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag private final DraggableComponent<?> component; private final Point start; private long startDragging = -1; - private final ValueAnimator<FloatingRectangle> bounds; + private final ValueAnimator<FloatingPoint> point; + private final ValueAnimator<FloatingDimension> dimension; private final Vec2 mouseStartOffset; private boolean dragging = false; private DraggableBoundsProvider boundsProvider; @@ -257,9 +259,10 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag private DraggableEntry(DraggableComponent<?> component, Point start) { this.component = component; this.start = start; - this.bounds = ValueAnimator.ofFloatingRectangle() - .setAs(component.getOriginBounds(start).getFloatingBounds()); - this.mouseStartOffset = new Vec2((float) (start.x - bounds.value().getCenterX()), (float) (start.y - bounds.value().getCenterY())); + FloatingRectangle floatingBounds = component.getOriginBounds(start).getFloatingBounds(); + this.point = ValueAnimator.ofFloatingPoint().setAs(new FloatingPoint(floatingBounds.getCenterX(), floatingBounds.getCenterY())); + this.dimension = ValueAnimator.ofFloatingDimension().setAs(new FloatingDimension(floatingBounds.width, floatingBounds.height)); + this.mouseStartOffset = new Vec2((float) (start.x - point.value().x) / (float) dimension.value().width, (float) (start.y - point.value().y) / (float) dimension.value().height); } public DraggableBoundsProvider getBoundsProvider() { 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 cb5ff971c..483f37dff 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 @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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.gui.screen.collapsible; import com.google.common.collect.Multimap; 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 187313152..1ade1dbeb 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 @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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.gui.screen.collapsible; import com.mojang.blaze3d.systems.RenderSystem; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java index 0e040ebf6..a2a1b915f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayCompositeWidget.java @@ -27,14 +27,15 @@ import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.config.ConfigObject; +import me.shedaniel.rei.api.client.gui.config.RecipeBorderType; import me.shedaniel.rei.api.client.gui.drag.DraggedAcceptorResult; import me.shedaniel.rei.api.client.gui.drag.DraggingContext; import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponent; import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponentProviderWidget; -import me.shedaniel.rei.api.client.gui.widgets.DelegateWidgetWithBounds; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget; import me.shedaniel.rei.impl.display.DisplaySpec; @@ -47,10 +48,12 @@ import java.util.stream.StreamSupport; public class DisplayCompositeWidget extends DelegateWidgetWithBounds implements DraggableComponentProviderWidget<Object> { private final DisplaySpec display; + private final List<Widget> widgets; public DisplayCompositeWidget(DisplaySpec display, List<Widget> widgets, Rectangle bounds) { super(Widgets.concat(widgets), () -> bounds); this.display = display; + this.widgets = widgets; } @Override @@ -62,7 +65,9 @@ public class DisplayCompositeWidget extends DelegateWidgetWithBounds implements .findFirst() .orElseGet(() -> { if (containsMouse(mouseX, mouseY)) { - return (DraggableComponent<Object>) (DraggableComponent<?>) new DisplayDraggableComponent(widget, display.provideInternalDisplay(), getBounds(), getBounds()); + return (DraggableComponent<Object>) (DraggableComponent<?>) new DisplayDraggableComponent( + Widgets.concat(CollectionUtils.filterToList(widgets, w -> !(w instanceof Panel))), + display.provideInternalDisplay(), getBounds(), getBounds()); } else { return null; } @@ -114,22 +119,41 @@ public class DisplayCompositeWidget extends DelegateWidgetWithBounds implements private final Display display; private final Rectangle originBounds; private final Rectangle bounds; + private final Panel panel; + private final Slot slot; + public boolean onFavoritesRegion; public DisplayDraggableComponent(Widget widget, Display display, Rectangle originBounds, Rectangle bounds) { this.widget = widget; this.display = display; this.originBounds = originBounds; this.bounds = bounds; + this.panel = Widgets.createRecipeBase(bounds.clone()); + this.slot = Widgets.createSlot(new Rectangle()) + .disableBackground() + .disableHighlight() + .disableTooltips(); + for (EntryIngredient ingredient : display.getOutputEntries()) { + slot.entries(ingredient); + } } @Override public int getWidth() { - return bounds.width; + if (this.onFavoritesRegion) { + return 18; + } + + return bounds.width / 2; } @Override public int getHeight() { - return bounds.height; + if (this.onFavoritesRegion) { + return 18; + } + + return bounds.height / 2; } @Override @@ -139,11 +163,47 @@ public class DisplayCompositeWidget extends DelegateWidgetWithBounds implements @Override public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + if (DraggingContext.getInstance().isDraggingComponent()) { + FavoritesListWidget favorites = ScreenOverlayImpl.getFavoritesListWidget(); + if (favorites != null) { + Rectangle favoritesBounds = favorites.getRegion().getBounds(); + if (!this.onFavoritesRegion && new Rectangle(favoritesBounds.x + 5, favoritesBounds.y + 5, favoritesBounds.width - 10, favoritesBounds.height - 10) + .contains(DraggingContext.getInstance().getCurrentPosition())) { + this.onFavoritesRegion = true; + } else if (this.onFavoritesRegion && !favoritesBounds.contains(DraggingContext.getInstance().getCurrentPosition())) { + this.onFavoritesRegion = false; + } + } else { + this.onFavoritesRegion = false; + } + } else { + this.onFavoritesRegion = false; + } + matrices.pushPose(); - matrices.translate(bounds.getX(), bounds.getY(), 0); - matrices.scale(bounds.width / (float) this.bounds.getWidth(), bounds.height / (float) this.bounds.getHeight(), 1); - matrices.translate(-this.bounds.getX(), -this.bounds.getY(), 0); - widget.render(matrices, -1000, -1000, delta); + if (bounds.width <= Math.max(18, this.bounds.width / 2 - 6) && bounds.height <= Math.max(18, this.bounds.height / 2 - 6) && this.onFavoritesRegion) { + this.panel.yTextureOffset(RecipeBorderType.LIGHTER.getYOffset()); + this.panel.getBounds().setBounds(bounds); + this.panel.render(matrices, mouseX, mouseY, delta); + matrices.pushPose(); + matrices.translate(0, 0.5, 0); + this.slot.getBounds().setBounds(bounds.getCenterX() - 7, bounds.getCenterY() - 7, 14, 14); + this.slot.render(matrices, mouseX, mouseY, delta); + matrices.popPose(); + } else { + this.panel.yTextureOffset(ConfigObject.getInstance().getRecipeBorderType().getYOffset()); + matrices.pushPose(); + matrices.translate(bounds.getX(), bounds.getY(), 1); + matrices.scale(bounds.width / (float) this.bounds.getWidth(), bounds.height / (float) this.bounds.getHeight(), 1); + matrices.translate(-this.bounds.getX(), -this.bounds.getY(), 0); + this.panel.getBounds().setBounds(this.bounds); + this.panel.render(matrices, mouseX, mouseY, delta); + matrices.popPose(); + matrices.translate(bounds.getX(), bounds.getY(), 1); + matrices.scale(bounds.width / (float) this.bounds.getWidth(), bounds.height / (float) this.bounds.getHeight(), 1); + matrices.translate(-this.bounds.getX(), -this.bounds.getY(), 0); + widget.render(matrices, -1000, -1000, delta); + } matrices.popPose(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesListWidget.java index db5a2c9f3..0b285f0f9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesListWidget.java @@ -126,9 +126,9 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableCo @Override @Nullable public DraggableComponent<Object> getHovered(DraggingContext<Screen> context, double mouseX, double mouseY) { - DraggableComponent<?> stack = region.getHoveredStack(context, mouseX, mouseY); + DraggableComponent<?> stack = region.getHovered(context, mouseX, mouseY); if (stack != null) return (DraggableComponent<Object>) stack; - stack = systemRegion.getHoveredStack(context, mouseX, mouseY); + stack = systemRegion.getHovered(context, mouseX, mouseY); if (stack != null) return (DraggableComponent<Object>) stack; if (favoritePanel.containsMouse(mouseX, mouseY)) { stack = favoritePanel.getHoveredStack(mouseX, mouseY); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/listeners/FavoritesRegionListener.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/listeners/FavoritesRegionListener.java index 078be4703..1e8f9cce8 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/listeners/FavoritesRegionListener.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/listeners/FavoritesRegionListener.java @@ -27,6 +27,8 @@ import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.drag.DraggableStack; import me.shedaniel.rei.api.client.gui.drag.DraggingContext; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponent; +import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesEntriesManager; import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget; import me.shedaniel.rei.impl.client.gui.widget.region.RealRegionEntry; @@ -36,6 +38,7 @@ import net.minecraft.client.gui.screens.Screen; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -70,6 +73,15 @@ public class FavoritesRegionListener implements RegionListener<FavoriteEntry> { } @Override + @Nullable + public FavoriteEntry convertDraggableComponent(DraggingContext<Screen> context, DraggableComponent<?> component) { + return component.<Display>getIf() + .map(Supplier::get) + .map(FavoriteEntry::fromDisplay) + .orElse(null); + } + + @Override public void onSetNewEntries(List<RegionEntryWidget<FavoriteEntry>> regionEntryListEntries) { favoritesListWidget.setSystemRegionEntries(null); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java index 21dd3a2f0..c0c0830f5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java @@ -35,6 +35,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteEntryType; import me.shedaniel.rei.api.client.gui.drag.DraggableStack; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponent; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.CollectionUtils; @@ -148,10 +149,10 @@ public class FavoritesPanel extends WidgetWithBounds { } @Nullable - public DraggableStack getHoveredStack(double mouseX, double mouseY) { + public DraggableComponent<?> getHoveredStack(double mouseX, double mouseY) { for (FavoritesPanelRow row : rows.get()) { if (row instanceof FavoritesPanelEntriesRow entriesRow) { - DraggableStack hoveredStack = entriesRow.getHoveredStack(mouseX, mouseY); + DraggableComponent<?> hoveredStack = entriesRow.getHoveredStack(mouseX, mouseY); if (hoveredStack != null) { return hoveredStack; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java index 034ae0095..8a55c331f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java @@ -31,7 +31,7 @@ import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; -import me.shedaniel.rei.api.client.gui.drag.DraggableStack; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponent; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.client.util.ClientEntryStacks; @@ -39,6 +39,7 @@ import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.gui.widget.DisplayedEntryWidget; import me.shedaniel.rei.impl.client.gui.widget.favorites.panel.FavoritesPanel; +import me.shedaniel.rei.impl.client.gui.widget.region.EntryStacksRegionWidget; import me.shedaniel.rei.impl.client.gui.widget.region.RealRegionEntry; import me.shedaniel.rei.impl.client.gui.widget.region.RegionDraggableStack; import net.minecraft.client.gui.components.events.GuiEventListener; @@ -118,12 +119,12 @@ public class FavoritesPanelEntriesRow extends FavoritesPanelRow { } @Nullable - public DraggableStack getHoveredStack(double mouseX, double mouseY) { + public DraggableComponent<?> getHoveredStack(double mouseX, double mouseY) { for (SectionFavoriteWidget widget : widgets) { if (widget.containsMouse(mouseX, mouseY + panel.getScrolledAmount())) { RealRegionEntry<FavoriteEntry> entry = new RealRegionEntry<>(panel.getParent().getRegion(), widget.entry.copy(), entrySize()); entry.size.setAs(entrySize() * 100); - return new RegionDraggableStack<>(entry, widget); + return EntryStacksRegionWidget.wrapDraggable(new RegionDraggableStack<>(entry, widget), entry.region, entry); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java index 724735edc..a8903ca37 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/EntryStacksRegionWidget.java @@ -37,7 +37,12 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.entry.region.RegionEntry; -import me.shedaniel.rei.api.client.gui.drag.*; +import me.shedaniel.rei.api.client.gui.drag.DraggableStack; +import me.shedaniel.rei.api.client.gui.drag.DraggedAcceptorResult; +import me.shedaniel.rei.api.client.gui.drag.DraggingContext; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponent; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponentProviderWidget; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponentVisitorWidget; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.common.entry.EntrySerializer; @@ -62,7 +67,7 @@ import java.util.stream.Stream; import static me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget.entrySize; -public class EntryStacksRegionWidget<T extends RegionEntry<T>> extends WidgetWithBounds implements DraggableStackProviderWidget, DraggableStackVisitorWidget { +public class EntryStacksRegionWidget<T extends RegionEntry<T>> extends WidgetWithBounds implements DraggableComponentProviderWidget<Object>, DraggableComponentVisitorWidget { public final RegionListener<T> listener; protected int blockedCount; private Rectangle bounds = new Rectangle(), innerBounds; @@ -178,17 +183,81 @@ public class EntryStacksRegionWidget<T extends RegionEntry<T>> extends WidgetWit @Override @Nullable - public DraggableStack getHoveredStack(DraggingContext<Screen> context, double mouseX, double mouseY) { + public DraggableComponent<Object> getHovered(DraggingContext<Screen> context, double mouseX, double mouseY) { if (innerBounds.contains(mouseX, mouseY)) { for (RealRegio |
