From 9ce069457bca016c8793c73844e5cc984deac365 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 10 Mar 2020 02:03:11 +0800 Subject: new widget api Signed-off-by: shedaniel --- .../shedaniel/rei/gui/ContainerScreenOverlay.java | 28 +++++++--------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java') diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 46cf478f0..f41298751 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -30,6 +30,7 @@ import me.shedaniel.math.api.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.*; +import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.gui.config.SearchFieldLocation; import me.shedaniel.rei.gui.widget.*; import me.shedaniel.rei.impl.ScreenHelper; @@ -271,26 +272,13 @@ public class ContainerScreenOverlay extends WidgetWithBounds { } } if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { - widgets.add(new ClickableLabelWidget(new Point(bounds.x + (bounds.width / 2), bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), "") { - @Override - public void render(int mouseX, int mouseY, float delta) { - clickable(ENTRY_LIST_WIDGET.getTotalPages() > 1); - setText(String.format("%s/%s", ENTRY_LIST_WIDGET.getPage() + 1, Math.max(ENTRY_LIST_WIDGET.getTotalPages(), 1))); - super.render(mouseX, mouseY, delta); - } - - @Override - public void onLabelClicked() { - MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - ENTRY_LIST_WIDGET.setPage(0); - ENTRY_LIST_WIDGET.updateEntriesPosition(); - } - - @Override - public boolean changeFocus(boolean boolean_1) { - return false; - } - }.tooltip(() -> I18n.translate("text.rei.go_back_first_page"))); + widgets.add(Widgets.createClickableLabel(new Point(bounds.x + (bounds.width / 2), bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), "", label -> { + ENTRY_LIST_WIDGET.setPage(0); + ENTRY_LIST_WIDGET.updateEntriesPosition(); + }).tooltipLine(I18n.translate("text.rei.go_back_first_page")).focusable(false).onRender(label -> { + label.setClickable(ENTRY_LIST_WIDGET.getTotalPages() > 1); + label.setText(String.format("%s/%s", ENTRY_LIST_WIDGET.getPage() + 1, Math.max(ENTRY_LIST_WIDGET.getTotalPages(), 1))); + })); } if (ConfigObject.getInstance().isCraftableFilterEnabled()) { this.widgets.add(craftableToggleButton = new CraftableToggleButtonWidget(getCraftableToggleArea()) { -- cgit