diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-01-02 14:31:16 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-01-02 14:31:16 +0800 |
| commit | 5e2eccadbd91171c01cdb209d1338bcfb7786b1c (patch) | |
| tree | 6c7387de5baea8b335e8abe58651018f77ad2d41 /src/main/java/me/shedaniel/rei/api/DisplayHelper.java | |
| parent | e8714fe8fc1dcaec7ad299c63e2b657870c8fb40 (diff) | |
| download | RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.tar.gz RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.tar.bz2 RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.zip | |
3.3
Fix #58
Close #134
Close #158
Fix #227
Diffstat (limited to 'src/main/java/me/shedaniel/rei/api/DisplayHelper.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/api/DisplayHelper.java | 41 |
1 files changed, 21 insertions, 20 deletions
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<DisplayBoundsHandler<?>> getSortedBoundsHandlers(Class<?> screenClass); - + /** * Gets all registered bounds handlers * * @return the list of registered bounds handlers */ List<DisplayBoundsHandler<?>> 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<T> { + + interface DisplayBoundsHandler<T> { /** * 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; } } - + } |
