From 02f6ba7a5dbdc5b4ef71b52ec0b998a4075535de Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 15 Feb 2022 12:17:40 +0800 Subject: Fix #430 --- .../rei/impl/client/config/ConfigObjectImpl.java | 6 ++++ .../gui/widget/BatchedEntryRendererManager.java | 5 +++- .../impl/client/gui/widget/EntryListWidget.java | 34 ++++++++++++++++++++-- .../assets/roughlyenoughitems/lang/en_us.json | 3 ++ 4 files changed, 44 insertions(+), 4 deletions(-) (limited to 'runtime') 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 c05d7f8a8..4f7a26c09 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 @@ -446,6 +446,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { appearance.syntaxHighlightingMode = mode; } + @Override + public boolean isFocusModeZoomed() { + return appearance.isFocusModeZoomed; + } + @Override public SearchMode getTooltipSearchMode() { return advanced.search.tooltipSearch; @@ -556,6 +561,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @UsePercentage(min = 0.1, max = 1.0, prefix = "Limit: ") private double favoritesHorizontalEntriesBoundaries = 1.0; private int favoritesHorizontalEntriesBoundariesColumns = 50; @UseSpecialSearchFilterSyntaxHighlightingScreen private SyntaxHighlightingMode syntaxHighlightingMode = SyntaxHighlightingMode.COLORFUL; + private boolean isFocusModeZoomed = false; } public static class Functionality { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java index 6dd72b66a..fe14aff52 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java @@ -203,7 +203,10 @@ public class BatchedEntryRendererManager { try { if (entry.containsMouse(mouseX, mouseY)) { entry.queueTooltip(matrices, mouseX, mouseY, delta); - entry.drawHighlighted(matrices, mouseX, mouseY, delta); + + if (entry.hasHighlight()) { + entry.drawHighlighted(matrices, mouseX, mouseY, delta); + } } entry.drawExtra(matrices, mouseX, mouseY, delta); } catch (Throwable throwable) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java index 01699eb16..8d0e8b291 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java @@ -32,6 +32,8 @@ import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.math.Matrix4f; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; +import me.shedaniel.clothconfig2.api.animator.NumberAnimator; +import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -441,6 +443,7 @@ public class EntryListWidget extends WidgetWithBounds implements OverlayListWidg public void updateEntriesPosition() { int entrySize = entrySize(); + boolean focusModeZoomed = ConfigObject.getInstance().isFocusModeZoomed(); this.innerBounds = updateInnerBounds(bounds); if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { this.renders = Lists.newArrayList(); @@ -453,7 +456,7 @@ public class EntryListWidget extends WidgetWithBounds implements OverlayListWidg int slotX = currentX * entrySize + innerBounds.x; int slotY = currentY * entrySize + innerBounds.y; if (notSteppingOnExclusionZones(slotX - 1, slotY - 1, entrySize, entrySize, innerBounds)) { - entries.add((EntryListEntry) new EntryListEntry(slotX, slotY, entrySize).noBackground()); + entries.add((EntryListEntry) new EntryListEntry(slotX, slotY, entrySize, focusModeZoomed).noBackground()); } } } @@ -477,7 +480,7 @@ public class EntryListWidget extends WidgetWithBounds implements OverlayListWidg for (int i = 0; i < slotsToPrepare; i++) { int xPos = currentX * entrySize + innerBounds.x; int yPos = currentY * entrySize + innerBounds.y; - entries.add((EntryListEntry) new EntryListEntry(xPos, yPos, entrySize).noBackground()); + entries.add((EntryListEntry) new EntryListEntry(xPos, yPos, entrySize, focusModeZoomed).noBackground()); currentX++; if (currentX >= width) { currentX = 0; @@ -596,9 +599,34 @@ public class EntryListWidget extends WidgetWithBounds implements OverlayListWidg private class EntryListEntry extends EntryListEntryWidget { private Display display; private EntryStack our; + private NumberAnimator size = null; - private EntryListEntry(int x, int y, int entrySize) { + private EntryListEntry(int x, int y, int entrySize, boolean zoomed) { super(new Point(x, y), entrySize); + if (zoomed) { + noHighlight(); + size = ValueAnimator.ofDouble(1f) + .withConvention(() -> { + double mouseX = PointHelper.getMouseFloatingX(); + double mouseY = PointHelper.getMouseFloatingY(); + int x1 = getBounds().getCenterX() - entrySize / 2; + int y1 = getBounds().getCenterY() - entrySize / 2; + boolean hovering = mouseX >= x1 && mouseX < x1 + entrySize && mouseY >= y1 && mouseY < y1 + entrySize; + return hovering ? 1.5 : 1.0; + }, 200); + } + } + + @Override + protected void drawExtra(PoseStack matrices, int mouseX, int mouseY, float delta) { + if (size != null) { + size.update(delta); + int centerX = getBounds().getCenterX(); + int centerY = getBounds().getCenterY(); + int entrySize = (int) Math.round(entrySize() * size.value()); + getBounds().setBounds(centerX - entrySize / 2, centerY - entrySize / 2, entrySize, entrySize); + } + super.drawExtra(matrices, mouseX, mouseY, delta); } @Override diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index 6824a0d97..9b974a1e6 100755 --- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -278,6 +278,9 @@ "config.roughlyenoughitems.syntaxHighlightingMode.plain_underscored": "Plain (Underscored)", "config.roughlyenoughitems.syntaxHighlightingMode.colorful": "Colorful", "config.roughlyenoughitems.syntaxHighlightingMode.colorful_underscored": "Colorful (Underscored)", + "config.roughlyenoughitems.isFocusModeZoomed": "Entry Focus Mode:", + "config.roughlyenoughitems.isFocusModeZoomed.boolean.true": "Zoomed", + "config.roughlyenoughitems.isFocusModeZoomed.boolean.false": "Highlighted", "config.roughlyenoughitems.filtering.shouldFilterDisplays": "Should Filter Displays:", "config.roughlyenoughitems.filteringScreen": "Customized Filtering", "config.roughlyenoughitems.filteringRulesScreen": "Customized Filtering Rules", -- cgit