aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-03-18 00:35:36 +0800
committershedaniel <daniel@shedaniel.me>2020-03-18 00:35:36 +0800
commit550fe32e612801daa99493aa0bade083f3330133 (patch)
tree7825027dd8933d542a831e2bda6626c63f4cd8db /src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
parent9e990de7685960391d78ca2cca0ff68bebe1a8cd (diff)
downloadRoughlyEnoughItems-550fe32e612801daa99493aa0bade083f3330133.tar.gz
RoughlyEnoughItems-550fe32e612801daa99493aa0bade083f3330133.tar.bz2
RoughlyEnoughItems-550fe32e612801daa99493aa0bade083f3330133.zip
4.0.14: Better widgets system
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
index 3c5322254..f146e9fef 100644
--- a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
@@ -31,7 +31,6 @@ import me.shedaniel.math.api.Point;
import me.shedaniel.math.api.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.config.RecipeScreenType;
-import me.shedaniel.rei.gui.widget.ButtonWidget;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.gui.widget.WidgetWithBounds;
import me.shedaniel.rei.impl.ScreenHelper;
@@ -46,6 +45,7 @@ import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
@@ -103,19 +103,12 @@ public class PreRecipeViewingScreen extends Screen {
protected void init() {
this.children.clear();
this.widgets.clear();
- this.widgets.add(new ButtonWidget(new Rectangle(width / 2 - 100, height - 40, 200, 20), NarratorManager.EMPTY) {
- @Override
- public void render(int mouseX, int mouseY, float delta) {
- enabled = isSet;
- setText(enabled ? I18n.translate("text.rei.select") : I18n.translate("config.roughlyenoughitems.recipeScreenType.unset"));
- super.render(mouseX, mouseY, delta);
- }
-
- @Override
- public void onPressed() {
- callback.accept(original);
- }
- });
+ this.widgets.add(Widgets.createButton(new Rectangle(width / 2 - 100, height - 40, 200, 20), NarratorManager.EMPTY)
+ .onRender(button -> {
+ button.setEnabled(isSet);
+ button.setText(isSet ? I18n.translate("text.rei.select") : I18n.translate("config.roughlyenoughitems.recipeScreenType.unset"));
+ })
+ .onClick(button -> callback.accept(original)));
this.widgets.add(new ScreenTypeSelection(width / 2 - 200 - 5, height / 2 - 112 / 2 - 10, 0));
this.widgets.add(Widgets.createLabel(new Point(width / 2 - 200 - 5 + 104, height / 2 - 112 / 2 + 115), I18n.translate("config.roughlyenoughitems.recipeScreenType.original")).noShadow().color(-1124073473));
this.widgets.add(new ScreenTypeSelection(width / 2 + 5, height / 2 - 112 / 2 - 10, 112));
@@ -187,6 +180,7 @@ public class PreRecipeViewingScreen extends Screen {
this.v = v;
}
+ @NotNull
@Override
public Rectangle getBounds() {
return bounds;