aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-11-08 23:15:08 +0800
committershedaniel <daniel@shedaniel.me>2021-11-08 23:19:59 +0800
commitaba4c079befd4bb32f732b65c746a22559644d35 (patch)
treebba42a67cb78edc54fc6ad600ea983fcd9873bc0 /runtime
parentdac507c52b7f8e6363d8ca90f533aa789c4adc09 (diff)
downloadRoughlyEnoughItems-aba4c079befd4bb32f732b65c746a22559644d35.tar.gz
RoughlyEnoughItems-aba4c079befd4bb32f732b65c746a22559644d35.tar.bz2
RoughlyEnoughItems-aba4c079befd4bb32f732b65c746a22559644d35.zip
Big Visual and Functional Changes
- Fix #503 - Shift Click to select page, normal click to go back to page 1 - Allow non-consuming draggable visitors - Add scale down animation when dragging a stack to the main item list to dismiss it - Make Cheat Mode not active in Display Screens - Add colors to cosmetic transfer handler errors - Implement JEI animations, fix #501 - Allow favorites dragged stacks to go back to where they are if they are ignored, instead of being at the end of the favorites - Implement favorites & entry list column and row limits - Implement display page height limit - Updated localizations
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java21
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java40
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java86
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java43
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java84
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DefaultDisplayChoosePageWidget.java22
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListEntryWidget.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java37
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryStacksRegionWidget.java51
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java9
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabWidget.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RealRegionEntry.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionDraggableStack.java16
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionEntryListEntry.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RegionListener.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java4
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/lang/cs_cz.json3
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/lang/en_gb.json30
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json6
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json2
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json3
24 files changed, 342 insertions, 151 deletions
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 b674d0099..d5d89a653 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
@@ -33,6 +33,7 @@ import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.api.client.config.ConfigManager;
import me.shedaniel.rei.api.client.config.ConfigObject;
+import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation;
import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation;
import me.shedaniel.rei.api.client.gui.screen.DisplayScreen;
import me.shedaniel.rei.api.client.gui.widgets.TextField;
@@ -55,6 +56,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
+import static me.shedaniel.rei.impl.client.gui.widget.EntryListWidget.entrySize;
+
@ApiStatus.Internal
@Environment(EnvType.CLIENT)
public class REIRuntimeImpl implements REIRuntime {
@@ -194,8 +197,7 @@ public class REIRuntimeImpl implements REIRuntime {
}
@Override
- public Rectangle calculateEntryListArea() {
- Rectangle bounds = ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen);
+ public Rectangle calculateEntryListArea(Rectangle bounds) {
SearchFieldLocation searchFieldLocation = getContextualSearchFieldLocation();
int yOffset = 2;
@@ -212,7 +214,20 @@ public class REIRuntimeImpl implements REIRuntime {
int yOffset = 8;
if (!ConfigObject.getInstance().isLowerConfigButton()) yOffset += 25;
- return new Rectangle(bounds.x, bounds.y + yOffset, bounds.width, bounds.height - 3 - yOffset);
+ bounds = new Rectangle(bounds.x, bounds.y + yOffset, bounds.width, bounds.height - 3 - yOffset);
+
+ int widthReduction = (int) Math.round(bounds.width * (1 - ConfigObject.getInstance().getFavoritesHorizontalEntriesBoundariesPercentage()));
+ if (ConfigObject.getInstance().getDisplayPanelLocation() == DisplayPanelLocation.LEFT)
+ bounds.x += widthReduction;
+ bounds.width -= widthReduction;
+ int maxWidth = (int) Math.ceil(entrySize() * ConfigObject.getInstance().getFavoritesHorizontalEntriesBoundariesColumns() + entrySize() * 0.75) + 8;
+ if (bounds.width > maxWidth) {
+ if (ConfigObject.getInstance().getDisplayPanelLocation() == DisplayPanelLocation.LEFT)
+ bounds.x += bounds.width - maxWidth;
+ bounds.width = maxWidth;
+ }
+
+ return bounds;
}
@Override
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 096a49e8b..73521ae30 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
@@ -170,6 +170,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
}
@Override
+ public int getMaxRecipesPageHeight() {
+ return advanced.layout.maxRecipesPageHeight;
+ }
+
+ @Override
public boolean doesDisableRecipeBook() {
return functionality.disableRecipeBook;
}
@@ -349,16 +354,39 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
@ApiStatus.Experimental
@Override
- public double getHorizontalEntriesBoundaries() {
+ public double getHorizontalEntriesBoundariesPercentage() {
return Mth.clamp(appearance.horizontalEntriesBoundaries, 0.1, 1);
}
@ApiStatus.Experimental
@Override
- public double getVerticalEntriesBoundaries() {
+ public double getVerticalEntriesBoundariesPercentage() {
return Mth.clamp(appearance.verticalEntriesBoundaries, 0.1, 1);
}
+ @ApiStatus.Experimental
+ @Override
+ public double getHorizontalEntriesBoundariesColumns() {
+ return Mth.clamp(appearance.horizontalEntriesBoundariesColumns, 1, 1000);
+ }
+
+ @ApiStatus.Experimental
+ @Override
+ public double getVerticalEntriesBoundariesRows() {
+ return Mth.clamp(appearance.verticalEntriesBoundariesRows, 1, 1000);
+ }
+
+ @ApiStatus.Experimental
+ @Override
+ public double getFavoritesHorizontalEntriesBoundariesPercentage() {
+ return Mth.clamp(appearance.favoritesHorizontalEntriesBoundaries, 0.1, 1);
+ }
+
+ @Override
+ public double getFavoritesHorizontalEntriesBoundariesColumns() {
+ return Mth.clamp(appearance.favoritesHorizontalEntriesBoundariesColumns, 1, 1000);
+ }
+
@Override
public SyntaxHighlightingMode getSyntaxHighlightingMode() {
return appearance.syntaxHighlightingMode;
@@ -469,6 +497,10 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
@UsePercentage(min = 0.1, max = 1.0, prefix = "Limit: ") private double horizontalEntriesBoundaries = 1.0;
@UsePercentage(min = 0.1, max = 1.0, prefix = "Limit: ") private double verticalEntriesBoundaries = 1.0;
+ private int horizontalEntriesBoundariesColumns = 50;
+ private int verticalEntriesBoundariesRows = 1000;
+ @UsePercentage(min = 0.1, max = 1.0, prefix = "Limit: ") private double favoritesHorizontalEntriesBoundaries = 1.0;
+ private int favoritesHorizontalEntriesBoundariesColumns = 50;
@UseSpecialSearchFilterSyntaxHighlightingScreen private SyntaxHighlightingMode syntaxHighlightingMode = SyntaxHighlightingMode.COLORFUL;
}
@@ -506,7 +538,9 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
private EntryPanelOrderingConfig entryPanelOrdering = EntryPanelOrderingConfig.REGISTRY_ASCENDING;
@Comment("Declares the maximum amount of recipes displayed in a page if possible.") @ConfigEntry.BoundedDiscrete(min = 2, max = 99)
- private int maxRecipesPerPage = 3;
+ private int maxRecipesPerPage = 8;
+ @Comment("Declares the maximum amount of recipes displayed in a page if possible.") @ConfigEntry.BoundedDiscrete(min = 100, max = 1000)
+ private int maxRecipesPageHeight = 300;
@Comment("Declares whether entry rendering time should be debugged.") private boolean debugRenderTimeRequired = false;
@Comment("Merges displays with equal contents under 1 display.") private boolean mergeDisplayUnderOne = true;
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
index bc53fca48..f95afd48b 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
@@ -37,10 +37,12 @@ import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.api.client.config.ConfigManager;
import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.favorites.FavoriteEntry;
+import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation;
import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation;
import me.shedaniel.rei.api.client.gui.drag.DraggableStackProvider;
import me.shedaniel.rei.api.client.gui.drag.DraggableStackVisitor;
import me.shedaniel.rei.api.client.gui.drag.DraggingContext;
+import me.shedaniel.rei.api.client.gui.screen.DisplayScreen;
import me.shedaniel.rei.api.client.gui.widgets.Button;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
@@ -63,11 +65,7 @@ import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.craftable.CraftableFilter;
import me.shedaniel.rei.impl.client.gui.dragging.CurrentDraggingStack;
import me.shedaniel.rei.impl.client.gui.modules.Menu;
-import me.shedaniel.rei.impl.client.gui.screen.DefaultDisplayViewingScreen;
-import me.shedaniel.rei.impl.client.gui.widget.EntryListWidget;
-import me.shedaniel.rei.impl.client.gui.widget.FavoritesListWidget;
-import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets;
-import me.shedaniel.rei.impl.client.gui.widget.LateRenderable;
+import me.shedaniel.rei.impl.client.gui.widget.*;
import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField;
import me.shedaniel.rei.impl.common.util.Weather;
import net.minecraft.client.Minecraft;
@@ -97,6 +95,8 @@ import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;
+import static me.shedaniel.rei.impl.client.gui.widget.EntryListWidget.entrySize;
+
@ApiStatus.Internal
public class ScreenOverlayImpl extends ScreenOverlay {
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png");
@@ -112,6 +112,8 @@ public class ScreenOverlayImpl extends ScreenOverlay {
private Button leftButton, rightButton;
private Widget configButton;
private CurrentDraggingStack draggingStack = new CurrentDraggingStack();
+ @Nullable
+ public DefaultDisplayChoosePageWidget choosePageWidget;
@Nullable
private ScreenOverlayImpl.OverlayMenu overlayMenu = null;
@@ -231,7 +233,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
this.children().clear();
this.closeOverlayMenu();
this.window = Minecraft.getInstance().getWindow();
- this.bounds = ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen);
+ this.bounds = calculateOverlayBounds();
widgets.add(ENTRY_LIST_WIDGET);
if (ConfigObject.getInstance().isFavoritesEnabled()) {
if (favoritesListWidget == null) {
@@ -240,7 +242,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
favoritesListWidget.favoritePanel.resetRows();
widgets.add(favoritesListWidget);
}
- ENTRY_LIST_WIDGET.updateArea(REIRuntimeImpl.getSearchField() == null ? "" : REIRuntimeImpl.getSearchField().getText());
+ ENTRY_LIST_WIDGET.updateArea(this.bounds, REIRuntimeImpl.getSearchField() == null ? "" : REIRuntimeImpl.getSearchField().getText());
REIRuntimeImpl.getSearchField().getBounds().setBounds(getSearchFieldArea());
this.widgets.add(REIRuntimeImpl.getSearchField());
REIRuntimeImpl.getSearchField().setResponder(s -> ENTRY_LIST_WIDGET.updateSearch(s, false));
@@ -280,7 +282,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
ConfigManager.getInstance().openConfigScreen(REIRuntime.getInstance().getPreviousScreen());
})
.onRender((matrices, button) -> {
- if (ClientHelper.getInstance().isCheating() && ClientHelperImpl.getInstance().hasOperatorPermission()) {
+ if (ClientHelper.getInstance().isCheating() && !(Minecraft.getInstance().screen instanceof DisplayScreen) && ClientHelperImpl.getInstance().hasOperatorPermission()) {
button.setTint(ClientHelperImpl.getInstance().hasPermissionToUsePackets() ? 721354752 : 1476440063);
} else {
button.removeTint();
@@ -326,9 +328,16 @@ public class ScreenOverlayImpl extends ScreenOverlay {
}
if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) {
widgets.add(Widgets.createClickableLabel(new Point(bounds.x + (bounds.width / 2), bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), NarratorChatListener.NO_TITLE, label -> {
- ENTRY_LIST_WIDGET.setPage(0);
- ENTRY_LIST_WIDGET.updateEntriesPosition();
- }).tooltipLine(I18n.get("text.rei.go_back_first_page")).focusable(false).onRender((matrices, label) -> {
+ if (!Screen.hasShiftDown()) {
+ ENTRY_LIST_WIDGET.setPage(0);
+ ENTRY_LIST_WIDGET.updateEntriesPosition();
+ } else {
+ ScreenOverlayImpl.getInstance().choosePageWidget = new DefaultDisplayChoosePageWidget(page -> {
+ ENTRY_LIST_WIDGET.setPage(page);
+ ENTRY_LIST_WIDGET.updateEntriesPosition();
+ }, ENTRY_LIST_WIDGET.getPage(), ENTRY_LIST_WIDGET.getTotalPages());
+ }
+ }).tooltipLine(I18n.get("text.rei.go_back_first_page") + "\n \n§7" + I18n.get("text.rei.shift_click_to", I18n.get("text.rei.choose_page"))).focusable(false).onRender((matrices, label) -> {
label.setClickable(ENTRY_LIST_WIDGET.getTotalPages() > 1);
label.setMessage(new TextComponent(String.format("%s/%s", ENTRY_LIST_WIDGET.getPage() + 1, Math.max(ENTRY_LIST_WIDGET.getTotalPages(), 1))));
}).rainbow(new Random().nextFloat() < 1.0E-4D || ClientHelperImpl.getInstance().isAprilFools.get()));
@@ -464,7 +473,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
- if (shouldReload) {
+ if (shouldReload || !calculateOverlayBounds().equals(bounds)) {
ENTRY_LIST_WIDGET.updateSearch(REIRuntimeImpl.getSearchField().getText(), true);
init();
} else {
@@ -515,6 +524,23 @@ public class ScreenOverlayImpl extends ScreenOverlay {
}
}
+ private static Rectangle calculateOverlayBounds() {
+ Rectangle bounds = ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen);
+
+ int widthReduction = (int) Math.round(bounds.width * (1 - ConfigObject.getInstance().getHorizontalEntriesBoundariesPercentage()));
+ if (ConfigObject.getInstance().getDisplayPanelLocation() == DisplayPanelLocation.RIGHT)
+ bounds.x += widthReduction;
+ bounds.width -= widthReduction;
+ int maxWidth = (int) Math.ceil(entrySize() * ConfigObject.getInstance().getHorizontalEntriesBoundariesColumns() + entrySize() * 0.75);
+ if (bounds.width > maxWidth) {
+ if (ConfigObject.getInstance().getDisplayPanelLocation() == DisplayPanelLocation.RIGHT)
+ bounds.x += bounds.width - maxWidth;
+ bounds.width = maxWidth;
+ }
+
+ return bounds;
+ }
+
public void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
if (REIRuntime.getInstance().isOverlayVisible()) {
REIRuntimeImpl.getSearchField().laterRender(matrices, mouseX, mouseY, delta);
@@ -532,9 +558,15 @@ public class ScreenOverlayImpl extends ScreenOverlay {
overlayMenu.wrappedMenu.render(matrices, mouseX, mouseY, delta);
}
}
+ if (choosePageWidget != null) {
+ setBlitOffset(500);
+ this.fillGradient(matrices, 0, 0, window.getGuiScaledWidth(), window.getGuiScaledHeight(), -1072689136, -804253680);
+ setBlitOffset(0);
+ choosePageWidget.render(matrices, mouseX, mouseY, delta);
+ }
}
Screen currentScreen = Minecraft.getInstance().screen;
- if (!(currentScreen instanceof DefaultDisplayViewingScreen) || !((DefaultDisplayViewingScreen) currentScreen).choosePageActivated) {
+ if (choosePageWidget == null) {
for (Tooltip tooltip : TOOLTIPS) {
if (tooltip != null)
renderTooltip(matrices, tooltip);
@@ -611,6 +643,12 @@ public class ScreenOverlayImpl extends ScreenOverlay {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (REIRuntime.getInstance().isOverlayVisible()) {
+ if (keyCode == 256 && choosePageWidget != null) {
+ choosePageWidget = null;
+ return true;
+ }
+ if (choosePageWidget != null)
+ return choosePageWidget.keyPressed(keyCode, scanCode, modifiers);
if (REIRuntimeImpl.getSearchField().keyPressed(keyCode, scanCode, modifiers))
return true;
for (GuiEventListener listener : widgets)
@@ -655,6 +693,9 @@ public class ScreenOverlayImpl extends ScreenOverlay {
public boolean charTyped(char char_1, int int_1) {
if (!REIRuntime.getInstance().isOverlayVisible())
return false;
+ if (choosePageWidget != null) {
+ return choosePageWidget.charTyped(char_1, int_1);
+ }
if (REIRuntimeImpl.getSearchField().charTyped(char_1, int_1))
return true;
for (GuiEventListener listener : widgets)
@@ -671,6 +712,15 @@ public class ScreenOverlayImpl extends ScreenOverlay {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
boolean visible = REIRuntime.getInstance().isOverlayVisible();
+ if (choosePageWidget != null) {
+ if (choosePageWidget.containsMouse(mouseX, mouseY)) {
+ return choosePageWidget.mouseClicked(mouseX, mouseY, button);
+ } else {
+ choosePageWidget = null;
+ init();
+ return false;
+ }
+ }
if (visible && configButton.mouseClicked(mouseX, mouseY, button)) {
this.setFocused(configButton);
if (button == 0)
@@ -756,9 +806,19 @@ public class ScreenOverlayImpl extends ScreenOverlay {
public boolean mouseDragged(double double_1, double double_2, int int_1, double double_3, double double_4) {
if (!REIRuntime.getInstance().isOverlayVisible())
return false;
+ if (choosePageWidget != null) {
+ return choosePageWidget.mouseDragged(double_1, double_2, int_1, double_3, double_4);
+ }
return (this.getFocused() != null && this.isDragging() && int_1 == 0) && this.getFocused().mouseDragged(double_1, double_2, int_1, double_3, double_4);
}
+ @Override
+ public GuiEventListener getFocused() {
+ if (choosePageWidget != null)
+ return choosePageWidget;
+ return super.getFocused();
+ }
+
public boolean isInside(double mouseX, double mouseY) {
return bounds.contains(mouseX, mouseY) && isNotInExclusionZones(mouseX, mouseY);
}
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 742a5bc39..4d8bb74f8 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
@@ -28,10 +28,7 @@ import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.math.impl.PointHelper;
import me.shedaniel.rei.RoughlyEnoughItemsCoreClient;
-import me.shedaniel.rei.api.client.gui.drag.DraggableStack;
-import me.shedaniel.rei.api.client.gui.drag.DraggableStackProvider;
-import me.shedaniel.rei.api.client.gui.drag.DraggableStackVisitor;
-import me.shedaniel.rei.api.client.gui.drag.DraggingContext;
+import me.shedaniel.rei.api.client.gui.drag.*;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.common.util.Animator;
import me.shedaniel.rei.impl.client.gui.widget.LateRenderable;
@@ -118,12 +115,12 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag
while (iterator.hasNext()) {
RenderBackEntry renderBackEntry = iterator.next();
renderBackEntry.update(delta);
- if (Math.abs(renderBackEntry.x.doubleValue() - renderBackEntry.x.target()) <= 2 && Math.abs(renderBackEntry.y.doubleValue() - renderBackEntry.y.target()) <= 2) {
+ if (renderBackEntry.width.doubleValue() < 2 || renderBackEntry.height.doubleValue() < 2 || (Math.abs(renderBackEntry.x.doubleValue() - renderBackEntry.x.target()) <= 2 && Math.abs(renderBackEntry.y.doubleValue() - renderBackEntry.y.target()) <= 2 && Math.abs(renderBackEntry.width.doubleValue() - renderBackEntry.width.target()) <= 1 && Math.abs(renderBackEntry.height.doubleValue() - renderBackEntry.height.target()) <= 1)) {
iterator.remove();
} else {
matrices.pushPose();
matrices.translate(0, 0, 600);
- renderBackEntry.stack.render(matrices, new Rectangle(renderBackEntry.x.intValue(), renderBackEntry.y.intValue(), 16, 16), mouseX, mouseY, delta);
+ renderBackEntry.stack.render(matrices, new Rectangle(Math.round(renderBackEntry.x.floatValue()), Math.round(renderBackEntry.y.floatValue()), Math.round(renderBackEntry.width.floatValue()), Math.round(renderBackEntry.height.floatValue())), mouseX, mouseY, delta);
matrices.popPose();
}
}
@@ -156,8 +153,8 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag
private boolean drop() {
if (entry != null && entry.dragging) {
- boolean released = visitor.acceptDraggedStack(this, entry.stack);
- entry.stack.release(released);
+ DraggedAcceptorResult result = visitor.acceptDraggedStackWithResult(this, entry.stack);
+ entry.stack.release(result);
entry = null;
return true;
}
@@ -185,7 +182,15 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag
@Override
public void renderBackToPosition(DraggableStack stack, Point initialPosition, Supplier<Point> position) {
- backToOriginals.add(new RenderBackEntry(stack, initialPosition, position));
+ backToOriginals.add(new RenderBackEntry(stack, new Rectangle(initialPosition.x - 8, initialPosition.y - 8, 16, 16), () -> {
+ Point point = position.get();
+ return new Rectangle(point.x, point.y, 16, 16);
+ }));
+ }
+
+ @Override
+ public void renderBackToPosition(DraggableStack stack, Rectangle initialPosition, Supplier<Rectangle> bounds) {
+ backToOriginals.add(new RenderBackEntry(stack, initialPosition, bounds));
}
private class DraggableEntry {
@@ -238,30 +243,38 @@ public class CurrentDraggingStack extends Widget implements LateRenderable, Drag
private static class RenderBackEntry {
private final DraggableStack stack;
- private final Supplier<Point> position;
+ private final Supplier<Rectangle> position;
private Animator x = new Animator();
private Animator y = new Animator();
+ private Animator width = new Animator();
+ private Animator height = new Animator();
private int lastDestination = -1;
- public RenderBackEntry(DraggableStack stack, Point initialPosition, Supplier<Point> position) {
+ public RenderBackEntry(DraggableStack stack, Rectangle initialPosition, Supplier<Rectangle> position) {
this.stack = stack;
- this.x.setAs(initialPosition.x - 8);
- this.y.setAs(initialPosition.y - 8);
+ this.x.setAs(initialPosition.x);
+ this.y.setAs(initialPosition.y);
+ this.width.setAs(initialPosition.width);
+ this.height.setAs(initialPosition.height);
this.position = position;
}
- public Point getPosition() {
+ public Rectangle getPosition() {
return position.get();
}
public void update(double delta) {
this.x.update(delta);
this.y.update(delta);
- Point position = getPosition();
+ this.width.update(delta);
+ this.height.update(delta);
+ Rectangle position = getPosition();
if (lastDestination != position.hashCode()) {
lastDestination = position.hashCode();
this.x.setTo(position.x, 200);
this.y.setTo(position.y, 200);
+ this.width.setTo(position.width, 200);
+ this.height.setTo(position.height, 200);
}
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
index 3478a2cc3..37e329a95 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
@@ -51,6 +51,7 @@ import me.shedaniel.rei.api.common.util.ImmutableTextComponent;
import me.shedaniel.rei.impl.client.ClientHelperImpl;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.RecipeDisplayExporter;
+import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.widget.DefaultDisplayChoosePageWidget;
import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets;
@@ -60,6 +61,7 @@ import me.shedaniel.rei.impl.display.DisplaySpec;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
@@ -84,8 +86,6 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
private final List<TabWidget> tabs = Lists.newArrayList();
public int page;
public int categoryPages = -1;
- public boolean choosePageActivated = false;
- public DefaultDisplayChoosePageWidget choosePageWidget;
@Nullable
private Panel workingStationsBaseWidget;
private Button recipeBack, recipeNext, categoryBack, categoryNext;
@@ -107,20 +107,12 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
- if (keyCode == 256 && choosePageActivated) {
- choosePageActivated = false;
- init();
- return true;
- }
if (keyCode == 258 && !minecraft.options.keyInventory.matches(keyCode, scanCode)) {
boolean next = !hasShiftDown();
if (!this.changeFocus(next))
this.changeFocus(next);
return true;
- }
- if (choosePageActivated)
- return choosePageWidget.keyPressed(keyCode, scanCode, modifiers);
- else if (ConfigObject.getInstance().getNextPageKeybind().matchesKey(keyCode, scanCode)) {
+ } else if (ConfigObject.getInstance().getNextPageKeybind().matchesKey(keyCode, scanCode)) {
if (recipeNext.isEnabled())
recipeNext.onClick();
return recipeNext.isEnabled();
@@ -155,9 +147,9 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
this.tabs.clear();
this.preWidgets.clear();
this.widgets.clear();
- int largestHeight = Math.max(height - 34 - 30, 100);
+ int largestHeight = Math.min(Math.max(height - 34 - 30, 100), ConfigObject.getInstance().getMaxRecipesPageHeight());
int maxWidthDisplay = CollectionUtils.<DisplaySpec, Integer>mapAndMax(getCurrentDisplayed(), display -> getCurrentCategory().getDisplayWidth(display.provideInternalDisplay()), Comparator.naturalOrder()).orElse(150);
- int maxHeight = Math.min(largestHeight, CollectionUtils.<DisplayCategory<?>, Integer>mapAndMax(categories,
+ int maxHeight = Math.min(largestHeight, CollectionUtils.<DisplayCategory<?>, Integer>mapAndMax(categories,
category -> (category.getDisplayHeight() + 4) * Math.max(1, Math.min(getRecipesPerPage(largestHeight, category) + 1, Math.max(categoryMap.get(category).size(), ConfigObject.getInstance().getMaxRecipePerPage()))) + 36, Comparator.naturalOrder()).orElse(66));
int totalDisplayHeight = (getCurrentCategory().getDisplayHeight() + 4) * Math.max(1, getRecipesPerPage(maxHeight, getCurrentCategory()) + 1) + 36;
int guiWidth = Math.max(maxWidthDisplay + 10, 190);
@@ -166,7 +158,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
this.bounds.setLocation(this.bounds.getX(), this.bounds.getY() + 15);
this.bounds.setSize(this.bounds.getWidth(), this.bounds.getHeight() - 10);
}