diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-08-27 20:11:03 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-08-27 20:11:03 +0800 |
| commit | ff9c8e83f0eaf3791e4939b491979d23bdca5577 (patch) | |
| tree | ef323a6dc477a03f05b00c3d2e405f121ec97650 /RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java | |
| parent | 5bf10e476366e9aff291d55c050a324734bae911 (diff) | |
| download | RoughlyEnoughItems-ff9c8e83f0eaf3791e4939b491979d23bdca5577.tar.gz RoughlyEnoughItems-ff9c8e83f0eaf3791e4939b491979d23bdca5577.tar.bz2 RoughlyEnoughItems-ff9c8e83f0eaf3791e4939b491979d23bdca5577.zip | |
Put the search bar to the side automatically if there is no space.
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java')
| -rw-r--r-- | RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 5e0af4f96..d97953d72 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -435,19 +435,38 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } private Rectangle getSearchFieldArea() { - int widthRemoved = 1 + (ConfigObject.getInstance().isCraftableFilterEnabled() ? 22 : 0) + (ConfigObject.getInstance().isLowerConfigButton() ? 22 : 0); - SearchFieldLocation searchFieldLocation = ConfigObject.getInstance().getSearchFieldLocation(); - if (searchFieldLocation == SearchFieldLocation.BOTTOM_SIDE) - return new Rectangle(bounds.x + 2, window.getGuiScaledHeight() - 22, bounds.width - 6 - widthRemoved, 18); - if (searchFieldLocation == SearchFieldLocation.TOP_SIDE) - return new Rectangle(bounds.x + 2, 4, bounds.width - 6 - widthRemoved, 18); - for (OverlayDecider decider : DisplayHelper.getInstance().getSortedOverlayDeciders(Minecraft.getInstance().screen.getClass())) { - if (decider instanceof DisplayHelper.DisplayBoundsProvider) { - Rectangle containerBounds = ((DisplayHelper.DisplayBoundsProvider<Screen>) decider).getScreenBounds(Minecraft.getInstance().screen); - return new Rectangle(containerBounds.x, window.getGuiScaledHeight() - 22, containerBounds.width - widthRemoved, 18); + int widthRemoved = 1; + if (ConfigObject.getInstance().isCraftableFilterEnabled()) widthRemoved += 22; + if (ConfigObject.getInstance().isLowerConfigButton()) widthRemoved += 22; + SearchFieldLocation searchFieldLocation = ScreenHelper.getContextualSearchFieldLocation(); + switch (searchFieldLocation) { + case TOP_SIDE: + return getTopSideSearchFieldArea(widthRemoved); + case BOTTOM_SIDE: + return getBottomSideSearchFieldArea(widthRemoved); + default: + case CENTER: { + for (OverlayDecider decider : DisplayHelper.getInstance().getSortedOverlayDeciders(Minecraft.getInstance().screen.getClass())) { + if (decider instanceof DisplayHelper.DisplayBoundsProvider) { + Rectangle containerBounds = ((DisplayHelper.DisplayBoundsProvider<Screen>) decider).getScreenBounds(Minecraft.getInstance().screen); + return getBottomCenterSearchFieldArea(containerBounds, widthRemoved); + } + } + return new Rectangle(); } } - return new Rectangle(); + } + + private Rectangle getTopSideSearchFieldArea(int widthRemoved) { + return new Rectangle(bounds.x + 2, 4, bounds.width - 6 - widthRemoved, 18); + } + + private Rectangle getBottomSideSearchFieldArea(int widthRemoved) { + return new Rectangle(bounds.x + 2, window.getGuiScaledHeight() - 22, bounds.width - 6 - widthRemoved, 18); + } + + private Rectangle getBottomCenterSearchFieldArea(Rectangle containerBounds, int widthRemoved) { + return new Rectangle(containerBounds.x, window.getGuiScaledHeight() - 22, containerBounds.width - widthRemoved, 18); } private Rectangle getCraftableToggleArea() { |
