From 5e2eccadbd91171c01cdb209d1338bcfb7786b1c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 2 Jan 2020 14:31:16 +0800 Subject: 3.3 Fix #58 Close #134 Close #158 Fix #227 --- .../java/me/shedaniel/rei/api/DisplayHelper.java | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/api/DisplayHelper.java') diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 25c04295d..4314b0e7c 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -11,16 +11,17 @@ import me.shedaniel.rei.gui.config.SearchFieldLocation; import net.minecraft.util.ActionResult; import java.util.List; +import java.util.function.Supplier; import static net.minecraft.util.ActionResult.PASS; public interface DisplayHelper { - + @SuppressWarnings("deprecation") static DisplayHelper getInstance() { return RoughlyEnoughItemsCore.getDisplayHelper(); } - + /** * Gets the sorted version of all responsible bounds handlers * @@ -29,14 +30,14 @@ public interface DisplayHelper { * @see DisplayHelper#getResponsibleBoundsHandler(Class) for the unsorted version */ List> getSortedBoundsHandlers(Class screenClass); - + /** * Gets all registered bounds handlers * * @return the list of registered bounds handlers */ List> getAllBoundsHandlers(); - + /** * Gets all responsible bounds handlers * @@ -45,29 +46,29 @@ public interface DisplayHelper { * @see DisplayHelper#getSortedBoundsHandlers(Class) for the sorted version */ DisplayBoundsHandler getResponsibleBoundsHandler(Class screenClass); - + /** * Registers a bounds handler * * @param handler the handler to register */ void registerBoundsHandler(DisplayBoundsHandler handler); - + /** * Gets the base bounds handler api for exclusion zones * * @return the base bounds handler */ BaseBoundsHandler getBaseBoundsHandler(); - - public static interface DisplayBoundsHandler { + + interface DisplayBoundsHandler { /** * Gets the base supported class for the bounds handler * * @return the base class */ Class getBaseSupportedClass(); - + /** * Gets the left bounds of the overlay * @@ -75,7 +76,7 @@ public interface DisplayHelper { * @return the left bounds */ Rectangle getLeftBounds(T screen); - + /** * Gets the right bounds of the overlay * @@ -83,7 +84,7 @@ public interface DisplayHelper { * @return the right bounds */ Rectangle getRightBounds(T screen); - + /** * Checks if item slot can fit the screen * @@ -92,12 +93,12 @@ public interface DisplayHelper { * @param screen the current screen * @param fullBounds the current bounds * @return whether the item slot can fit - * @see BaseBoundsHandler#registerExclusionZones(Class, BaseBoundsHandler.ExclusionZoneSupplier) for easier api + * @see BaseBoundsHandler#registerExclusionZones(Class, Supplier) for easier api */ default ActionResult canItemSlotWidgetFit(int left, int top, T screen, Rectangle fullBounds) { return PASS; } - + /** * Checks if item slot can fit the screen * @@ -113,7 +114,7 @@ public interface DisplayHelper { default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) { return canItemSlotWidgetFit(left, top, screen, fullBounds); } - + /** * Checks if mouse is inside the overlay * @@ -127,7 +128,7 @@ public interface DisplayHelper { default ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) { return isInZone(mouseX, mouseY); } - + /** * Checks if mouse is inside the overlay * @@ -138,7 +139,7 @@ public interface DisplayHelper { default ActionResult isInZone(double mouseX, double mouseY) { return PASS; } - + /** * Gets the item list bounds by the overlay bounds * @@ -148,12 +149,12 @@ public interface DisplayHelper { default Rectangle getItemListArea(Rectangle rectangle) { return new Rectangle(rectangle.x + 1, rectangle.y + 2 + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + (ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22), rectangle.width - 2, rectangle.height - (ConfigObject.getInstance().getSearchFieldLocation() != SearchFieldLocation.CENTER ? 27 + 22 : 27) + (!ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22)); } - + default Rectangle getFavoritesListArea(Rectangle rectangle) { int offset = 31 + (ConfigObject.getInstance().doesShowUtilsButtons() ? 25 : 0); return new Rectangle(rectangle.x + 1, rectangle.y + 2 + offset, rectangle.width - 2, rectangle.height - 5 - offset); } - + /** * Checks if REI should recalculate the overlay bounds * @@ -164,7 +165,7 @@ public interface DisplayHelper { default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { return false; } - + /** * Gets the priority of the handler, the higher it is, the earlier it is called. * @@ -174,5 +175,5 @@ public interface DisplayHelper { return 0f; } } - + } -- cgit