diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-06-28 19:19:54 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-06-28 19:19:54 +0800 |
| commit | 1c6216ba6df00cf2b535ace35b001d35ec010ed5 (patch) | |
| tree | 0de74bdb61e614bdd7066aa163e7f38eec40bfe1 /runtime/src/main | |
| parent | 774bceacf9a2ceb92aa5ac66a7bf81fcf03d28c0 (diff) | |
| download | RoughlyEnoughItems-1c6216ba6df00cf2b535ace35b001d35ec010ed5.tar.gz RoughlyEnoughItems-1c6216ba6df00cf2b535ace35b001d35ec010ed5.tar.bz2 RoughlyEnoughItems-1c6216ba6df00cf2b535ace35b001d35ec010ed5.zip | |
Add better arrow icons
Diffstat (limited to 'runtime/src/main')
5 files changed, 67 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 10588b9f8..2ee632c45 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 @@ -107,8 +107,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; @@ -294,7 +296,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); })); @@ -331,8 +333,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 544801a3c..d3de364ec 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 @@ -45,6 +45,7 @@ import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; 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; @@ -206,7 +207,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), Component.translatable("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), Component.literal("")) .onClick(button -> { tabsPage--; if (tabsPage < 0) @@ -215,7 +217,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen }) .tooltipLine(Component.translatable("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), Component.translatable("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), Component.literal("")) .onClick(button -> { tabsPage++; if (tabsPage > Mth.ceil(categories.size() / (float) tabsPerPage) - 1) @@ -224,6 +226,24 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen }) .tooltipLine(Component.translatable("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 e576f54b1..011d46a51 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 @@ -166,7 +166,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), Component.translatable("text.rei.left_arrow")) + Button tabLeft, tabRight; + this.widgets.add(tabLeft = Widgets.createButton(new Rectangle(bounds.x, bounds.y - (isCompactTabButtons ? 16 : 20), tabButtonsSize, tabButtonsSize), Component.literal("")) .onClick(button -> { categoryPages--; if (categoryPages < 0) @@ -175,7 +176,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { }) .tooltipLine(Component.translatable("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), Component.translatable("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), Component.literal("")) .onClick(button -> { categoryPages++; if (categoryPages > Mth.ceil(categories.size() / (float) tabsPerPage) - 1) @@ -184,17 +185,49 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { }) .tooltipLine(Component.translatable("text.rei.next_page")) .enabled(categories.size() > tabsPerPage)); - this.widgets.add(categoryBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), Component.translatable("text.rei.left_arrow")) + this.widgets.add(categoryBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), Component.literal("")) .onClick(button -> previousCategory()).tooltipLine(Component.translatable("text.rei.previous_category"))); this.widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 7), getCurrentCategory().getTitle(), clickableLabelWidget -> { ViewSearchBuilder.builder().addAllCategories().open(); }).tooltip(Component.translatable("text.rei.view_all_categories"))); - this.widgets.add(categoryNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), Component.translatable("text.rei.right_arrow")) + this.widgets.add(categoryNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), Component.literal("")) .onClick(button -> nextCategory()).tooltipLine(Component.translatable("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), Component.translatable("text.rei.left_arrow")) + this.widgets.add(recipeBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 19, 12, 12), Component.literal("")) .onClick(button -> { page--; if (page < 0) @@ -215,7 +248,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { label.setMessage(Component.literal(String.format("%d/%d", page + 1, getCurrentTotalPages()))); label.setClickable(getCurrentTotalPages() > 1); }).tooltipFunction(label -> label.isClickable() ? new Component[]{Component.translatable("text.rei.go_back_first_page"), Component.literal(" "), Component.translatable("text.rei.shift_click_to", Component.translatable("text.rei.choose_page")).withStyle(ChatFormatting.GRAY)} : null)); - this.widgets.add(recipeNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 19, 12, 12), Component.translatable("text.rei.right_arrow")) + this.widgets.add(recipeNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 19, 12, 12), Component.literal("")) .onClick(button -> { page++; if (page >= getCurrentTotalPages()) diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/arrow_left_small.png b/runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/arrow_left_small.png Binary files differnew file mode 100644 index 000000000..08d3581ce --- /dev/null +++ b/runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/arrow_left_small.png diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/arrow_right_small.png b/runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/arrow_right_small.png Binary files differnew file mode 100644 index 000000000..7fd10dfd7 --- /dev/null +++ b/runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/arrow_right_small.png |
