aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-02-09 21:21:30 +0800
committershedaniel <daniel@shedaniel.me>2022-02-09 21:21:30 +0800
commita0162fe0f6f73bc2dbfdee29ae2e32a06b5e13a7 (patch)
tree32c69421a4aedb6d38c38b04f19ac19932756a91 /runtime/src/main/java
parentcaa850ff55576c8aef92c28ab5dcf87a319f6e3a (diff)
downloadRoughlyEnoughItems-a0162fe0f6f73bc2dbfdee29ae2e32a06b5e13a7.tar.gz
RoughlyEnoughItems-a0162fe0f6f73bc2dbfdee29ae2e32a06b5e13a7.tar.bz2
RoughlyEnoughItems-a0162fe0f6f73bc2dbfdee29ae2e32a06b5e13a7.zip
Close #757
Diffstat (limited to 'runtime/src/main/java')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java47
2 files changed, 47 insertions, 7 deletions
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 e79aecaa8..c05d7f8a8 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
@@ -274,6 +274,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
}
@Override
+ public FavoriteAddWidgetMode getFavoriteAddWidgetMode() {
+ return advanced.layout.favoriteAddWidgetMode;
+ }
+
+ @Override
public ModifierKeyCode getFavoriteKeyCode() {
return basics.keyBindings.favoriteKeybind == null ? ModifierKeyCode.unknown() : basics.keyBindings.favoriteKeybind;
}
@@ -594,6 +599,8 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
private int maxRecipesPageHeight = 300;
@Comment("Declares whether entry rendering time should be debugged.") private boolean debugRenderTimeRequired = false;
@Comment("Merges displays with equal contents under 1 display.") private boolean mergeDisplayUnderOne = true;
+ @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
+ private FavoriteAddWidgetMode favoriteAddWidgetMode = FavoriteAddWidgetMode.ALWAYS_VISIBLE;
}
public static class Accessibility {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java
index a8f4d68d4..f06cd8f20 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java
@@ -333,7 +333,7 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
DraggableStack currentStack = DraggingContext.getInstance().getCurrentStack();
if (currentStack instanceof RegionDraggableStack) {
RegionDraggableStack<?> stack = (RegionDraggableStack<?>) currentStack;
-
+
return stack.getEntry().region != region || !Objects.equals(stack.getEntry().getEntry(), entry);
}
}
@@ -451,7 +451,17 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.bounds.setBounds(updateArea(widget.fullBounds));
boolean hovered = containsMouse(mouseX, mouseY);
- this.alpha.setTo(hovered ? 1f : isAvailable(mouseX, mouseY) ? 0.3f : 0f, 260);
+ switch (ConfigObject.getInstance().getFavoriteAddWidgetMode()) {
+ case ALWAYS_INVISIBLE:
+ this.alpha.setAs(0);
+ break;
+ case AUTO_HIDE:
+ this.alpha.setTo(hovered ? 1f : isAvailable(mouseX, mouseY) ? 0.5f : 0f, 260);
+ break;
+ case ALWAYS_VISIBLE:
+ this.alpha.setAs(hovered ? 1f : 0.5f);
+ break;
+ }
this.alpha.update(delta);
int buttonColor = 0xFFFFFF | (Math.round(0x74 * alpha.floatValue()) << 24);
fillGradient(matrices, bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), buttonColor, buttonColor);
@@ -526,6 +536,7 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
rows.add(new SectionSeparatorRow());
}
if (!rows.isEmpty()) rows.remove(rows.size() - 1);
+ rows.add(new EmptySectionRow(4));
return rows;
});
private final ScrollingContainer scroller = new ScrollingContainer() {
@@ -557,10 +568,10 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
fillGradient(matrices, bounds.x, bounds.y, bounds.getMaxX(), bounds.getMaxY(), buttonColor, buttonColor);
scroller.updatePosition(delta);
- if (expendState.progress() > 0.1f) {
+ if (expendState.value()) {
ScissorsHandler.INSTANCE.scissor(scrollBounds);
matrices.pushPose();
- matrices.translate(0, scroller.scrollAmount(), 0);
+ matrices.translate(0, -scroller.scrollAmount(), 0);
int y = scrollBounds.y;
for (Row row : rows.get()) {
row.render(matrices, scrollBounds.x, y, scrollBounds.width, row.getRowHeight(), mouseX, mouseY, delta);
@@ -573,14 +584,14 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
private Rectangle updatePanelArea(Rectangle fullArea) {
int currentWidth = 16 + Math.round(Math.min((float) expendState.progress(), 1) * (fullArea.getWidth() - 16 - 8));
- int currentHeight = 16 + Math.round((float) expendState.progress() * (fullArea.getHeight() * 0.4f - 16 - 8));
+ int currentHeight = 16 + Math.round((float) expendState.progress() * (fullArea.getHeight() * 0.4f - 16 - 8 + 4));
return new Rectangle(fullArea.x + 4, fullArea.getMaxY() - currentHeight - 4, currentWidth, currentHeight);
}
@Override
public boolean mouseScrolled(double d, double e, double f) {
if (scrollBounds.contains(d, e)) {
- scroller.offset(ClothConfigInitializer.getScrollStep() * f, true);
+ scroller.offset(ClothConfigInitializer.getScrollStep() * -f, true);
return true;
}
return super.mouseScrolled(d, e, f);
@@ -647,6 +658,28 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
}
}
+ private static class EmptySectionRow extends Row {
+ private final int height;
+
+ public EmptySectionRow(int height) {
+ this.height = height;
+ }
+
+ @Override
+ public int getRowHeight() {
+ return height;
+ }
+
+ @Override
+ public void render(PoseStack matrices, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
+ }
+
+ @Override
+ public List<? extends GuiEventListener> children() {
+ return Collections.emptyList();
+ }
+ }
+
private class SectionEntriesRow extends Row {
private final List<FavoriteEntry> entries;
private final List<SectionFavoriteWidget> widgets;
@@ -751,7 +784,7 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
currentY++;
}
- if (notSteppingOnExclusionZones(xPos, yPos + lastY + scroller.scrollAmountInt(), entrySize, entrySize, scrollBounds)) {
+ if (notSteppingOnExclusionZones(xPos, yPos + lastY - scroller.scrollAmountInt(), entrySize, entrySize, scrollBounds)) {
widget.moveTo(animated.test(widget), xPos, yPos);
break;
} else {