aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-28 19:19:54 +0800
committershedaniel <daniel@shedaniel.me>2023-05-29 21:07:18 +0800
commite49c13cfb2f951a66bc413a9070f4a4443034436 (patch)
tree52555014597624659d48febb9664c2380dec6628 /runtime/src/main/java
parenta9ca748c641b843b987b687c677124f5f70cee5b (diff)
downloadRoughlyEnoughItems-e49c13cfb2f951a66bc413a9070f4a4443034436.tar.gz
RoughlyEnoughItems-e49c13cfb2f951a66bc413a9070f4a4443034436.tar.bz2
RoughlyEnoughItems-e49c13cfb2f951a66bc413a9070f4a4443034436.zip
Add better arrow icons
Diffstat (limited to 'runtime/src/main/java')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java11
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java25
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java45
3 files changed, 68 insertions, 13 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
index 93c9adb00..8da0a8cf6 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
@@ -109,8 +109,10 @@ import static me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget.
@ApiStatus.Internal
public class ScreenOverlayImpl extends ScreenOverlay {
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png");
- private static final ResourceLocation ARROW_LEFT_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_left.png");
- private static final ResourceLocation ARROW_RIGHT_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_right.png");
+ public static final ResourceLocation ARROW_LEFT_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_left.png");
+ public static final ResourceLocation ARROW_RIGHT_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_right.png");
+ public static final ResourceLocation ARROW_LEFT_SMALL_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_left_small.png");
+ public static final ResourceLocation ARROW_RIGHT_SMALL_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_right_small.png");
private static final List<Tooltip> TOOLTIPS = Lists.newArrayList();
private static final List<Runnable> AFTER_RENDER = Lists.newArrayList();
private static EntryListWidget entryListWidget = null;
@@ -296,7 +298,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
RenderSystem.setShaderTexture(0, ARROW_LEFT_TEXTURE);
Rectangle bounds = leftButton.getBounds();
matrices.pushPose();
- blit(matrices, bounds.x + 4, bounds.y + 4, 0, 0, 9, 9, 9, 9);
+ blit(matrices, bounds.x + 4, bounds.y + 4, 0, 0, 8, 8, 8, 8);
matrices.popPose();
helper.setBlitOffset(helper.getBlitOffset() - 1);
}));
@@ -333,8 +335,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
RenderSystem.setShaderTexture(0, ARROW_RIGHT_TEXTURE);
Rectangle bounds = rightButton.getBounds();
matrices.pushPose();
- matrices.translate(-0.5, 0, 0);
- blit(matrices, bounds.x + 4, bounds.y + 4, 0, 0, 9, 9, 9, 9);
+ blit(matrices, bounds.x + 4, bounds.y + 4, 0, 0, 8, 8, 8, 8);
matrices.popPose();
helper.setBlitOffset(helper.getBlitOffset() - 1);
}));
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
index 2df64cd27..ca34a497d 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
@@ -43,8 +43,10 @@ import me.shedaniel.rei.api.client.view.ViewSearchBuilder;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
+import me.shedaniel.rei.api.common.util.ImmutableTextComponent;
import me.shedaniel.rei.impl.client.ClientHelperImpl;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
+import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets;
import me.shedaniel.rei.impl.client.gui.widget.TabWidget;
@@ -207,7 +209,8 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen
tab.setRenderer(tabCategory, tabCategory.getIcon(), tabCategory.getTitle(), j == selectedCategoryIndex);
}
}
- this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + 2, bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), new TranslatableComponent("text.rei.left_arrow"))
+ Button tabLeft, tabRight;
+ this.widgets.add(tabLeft = Widgets.createButton(new Rectangle(bounds.x + 2, bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), ImmutableTextComponent.EMPTY)
.onClick(button -> {
tabsPage--;
if (tabsPage < 0)
@@ -216,7 +219,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen
})
.tooltipLine(new TranslatableComponent("text.rei.previous_page"))
.enabled(categories.size() > tabsPerPage));
- this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + bounds.width - (isCompactTabButtons ? tabButtonsSize + 2 : tabButtonsSize + 3), bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), new TranslatableComponent("text.rei.right_arrow"))
+ this.widgets.add(tabRight = Widgets.createButton(new Rectangle(bounds.x + bounds.width - (isCompactTabButtons ? tabButtonsSize + 2 : tabButtonsSize + 3), bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), ImmutableTextComponent.EMPTY)
.onClick(button -> {
tabsPage++;
if (tabsPage > Mth.ceil(categories.size() / (float) tabsPerPage) - 1)
@@ -225,6 +228,24 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen
})
.tooltipLine(new TranslatableComponent("text.rei.next_page"))
.enabled(categories.size() > tabsPerPage));
+ this.widgets.add(Widgets.withTranslate(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
+ Rectangle tabLeftBounds = tabLeft.getBounds();
+ Rectangle tabRightBounds = tabRight.getBounds();
+ if (isCompactTabButtons) {
+ matrices.pushPose();
+ matrices.translate(0, 0.5, 0);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_LEFT_SMALL_TEXTURE);
+ blit(matrices, tabLeftBounds.x + 2, tabLeftBounds.y + 2, 0, 0, 6, 6, 6, 6);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_RIGHT_SMALL_TEXTURE);
+ blit(matrices, tabRightBounds.x + 2, tabRightBounds.y + 2, 0, 0, 6, 6, 6, 6);
+ matrices.popPose();
+ } else {
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_LEFT_TEXTURE);
+ blit(matrices, tabLeftBounds.x + 4, tabLeftBounds.y + 4, 0, 0, 8, 8, 8, 8);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_RIGHT_TEXTURE);
+ blit(matrices, tabRightBounds.x + 4, tabRightBounds.y + 4, 0, 0, 8, 8, 8, 8);
+ }
+ }), 0, 0, 1));
this.widgets.add(Widgets.createClickableLabel(new Point(bounds.x + 4 + scrollListBounds.width / 2, bounds.y + 6), categories.get(selectedCategoryIndex).getTitle(), label -> {
ViewSearchBuilder.builder().addAllCategories().open();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
index 3e3a16ff9..046bde6fe 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
@@ -169,7 +169,8 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
}
this.page = Mth.clamp(page, 0, getCurrentTotalPages() - 1);
- this.widgets.add(Widgets.createButton(new Rectangle(bounds.x, bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), new TranslatableComponent("text.rei.left_arrow"))
+ Button tabLeft, tabRight;
+ this.widgets.add(tabLeft = Widgets.createButton(new Rectangle(bounds.x, bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), ImmutableTextComponent.EMPTY)
.onClick(button -> {
categoryPages--;
if (categoryPages < 0)
@@ -178,7 +179,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
})
.tooltipLine(new TranslatableComponent("text.rei.previous_page"))
.enabled(categories.size() > tabsPerPage));
- this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + bounds.width - tabButtonsSize - (isCompactTabButtons ? 0 : 1), bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), new TranslatableComponent("text.rei.right_arrow"))
+ this.widgets.add(tabRight = Widgets.createButton(new Rectangle(bounds.x + bounds.width - tabButtonsSize - (isCompactTabButtons ? 0 : 1), bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), ImmutableTextComponent.EMPTY)
.onClick(button -> {
categoryPages++;
if (categoryPages > Mth.ceil(categories.size() / (float) tabsPerPage) - 1)
@@ -187,17 +188,49 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
})
.tooltipLine(new TranslatableComponent("text.rei.next_page"))
.enabled(categories.size() > tabsPerPage));
- this.widgets.add(categoryBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), new TranslatableComponent("text.rei.left_arrow"))
+ this.widgets.add(categoryBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), ImmutableTextComponent.EMPTY)
.onClick(button -> previousCategory()).tooltipLine(new TranslatableComponent("text.rei.previous_category")));
this.widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 7), getCurrentCategory().getTitle(), clickableLabelWidget -> {
ViewSearchBuilder.builder().addAllCategories().open();
}).tooltip(new TranslatableComponent("text.rei.view_all_categories")));
- this.widgets.add(categoryNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), new TranslatableComponent("text.rei.right_arrow"))
+ this.widgets.add(categoryNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), ImmutableTextComponent.EMPTY)
.onClick(button -> nextCategory()).tooltipLine(new TranslatableComponent("text.rei.next_category")));
this.categoryBack.setEnabled(categories.size() > 1);
this.categoryNext.setEnabled(categories.size() > 1);
+ this.widgets.add(Widgets.withTranslate(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
+ Rectangle tabLeftBounds = tabLeft.getBounds();
+ Rectangle tabRightBounds = tabRight.getBounds();
+ if (isCompactTabButtons) {
+ matrices.pushPose();
+ matrices.translate(0, 0.5, 0);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_LEFT_SMALL_TEXTURE);
+ blit(matrices, tabLeftBounds.x + 2, tabLeftBounds.y + 2, 0, 0, 6, 6, 6, 6);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_RIGHT_SMALL_TEXTURE);
+ blit(matrices, tabRightBounds.x + 2, tabRightBounds.y + 2, 0, 0, 6, 6, 6, 6);
+ matrices.popPose();
+ } else {
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_LEFT_TEXTURE);
+ blit(matrices, tabLeftBounds.x + 4, tabLeftBounds.y + 4, 0, 0, 8, 8, 8, 8);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_RIGHT_TEXTURE);
+ blit(matrices, tabRightBounds.x + 4, tabRightBounds.y + 4, 0, 0, 8, 8, 8, 8);
+ }
+ Rectangle recipeBackBounds = recipeBack.getBounds();
+ Rectangle recipeNextBounds = recipeNext.getBounds();
+ Rectangle categoryBackBounds = categoryBack.getBounds();
+ Rectangle categoryNextBounds = categoryNext.getBounds();
+ matrices.pushPose();
+ matrices.translate(0.5, 0.5, 0);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_LEFT_TEXTURE);
+ blit(matrices, recipeBackBounds.x + 2, recipeBackBounds.y + 2, 0, 0, 8, 8, 8, 8);
+ blit(matrices, categoryBackBounds.x + 2, categoryBackBounds.y + 2, 0, 0, 8, 8, 8, 8);
+ matrices.translate(-0.5, 0, 0);
+ RenderSystem.setShaderTexture(0, ScreenOverlayImpl.ARROW_RIGHT_TEXTURE);
+ blit(matrices, recipeNextBounds.x + 2, recipeNextBounds.y + 2, 0, 0, 8, 8, 8, 8);
+ blit(matrices, categoryNextBounds.x + 2, categoryNextBounds.y + 2, 0, 0, 8, 8, 8, 8);
+ matrices.popPose();
+ }), 0, 0, 1));
- this.widgets.add(recipeBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 19, 12, 12), new TranslatableComponent("text.rei.left_arrow"))
+ this.widgets.add(recipeBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 19, 12, 12), ImmutableTextComponent.EMPTY)
.onClick(button -> {
page--;
if (page < 0)
@@ -218,7 +251,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
label.setMessage(new ImmutableTextComponent(String.format("%d/%d", page + 1, getCurrentTotalPages())));
label.setClickable(getCurrentTotalPages() > 1);
}).tooltipFunction(label -> label.isClickable() ? new Component[]{new TranslatableComponent("text.rei.go_back_first_page"), new TextComponent(" "), new TranslatableComponent("text.rei.shift_click_to", new TranslatableComponent("text.rei.choose_page")).withStyle(ChatFormatting.GRAY)} : null));
- this.widgets.add(recipeNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 19, 12, 12), new TranslatableComponent("text.rei.right_arrow"))
+ this.widgets.add(recipeNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 19, 12, 12), ImmutableTextComponent.EMPTY)
.onClick(button -> {
page++;
if (page >= getCurrentTotalPages())