aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-02-15 12:17:40 +0800
committershedaniel <daniel@shedaniel.me>2022-02-15 12:17:40 +0800
commit02f6ba7a5dbdc5b4ef71b52ec0b998a4075535de (patch)
tree83872751c71cfed6f1a0f92eaa4a8d9d9cf1d668
parentaec0542e5f5e912450debdc0bff33b62910f5479 (diff)
downloadRoughlyEnoughItems-02f6ba7a5dbdc5b4ef71b52ec0b998a4075535de.tar.gz
RoughlyEnoughItems-02f6ba7a5dbdc5b4ef71b52ec0b998a4075535de.tar.bz2
RoughlyEnoughItems-02f6ba7a5dbdc5b4ef71b52ec0b998a4075535de.zip
Fix #430
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java34
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json3
5 files changed, 47 insertions, 4 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
index 5771c4481..4b7ad135b 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
@@ -192,6 +192,9 @@ public interface ConfigObject {
@ApiStatus.Experimental
SyntaxHighlightingMode getSyntaxHighlightingMode();
+ @ApiStatus.Experimental
+ boolean isFocusModeZoomed();
+
SearchMode getTooltipSearchMode();
SearchMode getTagSearchMode();
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
@@ -447,6 +447,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
}
@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<Double> 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",