aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.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/widget/RecipeChoosePageWidget.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/widget/RecipeChoosePageWidget.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java
index df1860b4c..cab4aaf38 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java
@@ -28,6 +28,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import me.shedaniel.math.api.Point;
import me.shedaniel.math.api.Rectangle;
import me.shedaniel.rei.api.REIHelper;
+import me.shedaniel.rei.api.widgets.Button;
import me.shedaniel.rei.api.widgets.Panel;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.RecipeViewingScreen;
@@ -37,6 +38,7 @@ import net.minecraft.client.util.Window;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
@@ -52,7 +54,7 @@ public class RecipeChoosePageWidget extends DraggableWidget {
private RecipeViewingScreen recipeViewingScreen;
private TextFieldWidget textFieldWidget;
private Panel base1, base2;
- private ButtonWidget btnDone;
+ private Button btnDone;
public RecipeChoosePageWidget(RecipeViewingScreen recipeViewingScreen, int currentPage, int maxPage) {
super(getPointFromConfig());
@@ -67,6 +69,7 @@ public class RecipeChoosePageWidget extends DraggableWidget {
return new Point(window.getScaledWidth() * .5, window.getScaledHeight() * .5);
}
+ @NotNull
@Override
public Rectangle getBounds() {
return bounds;
@@ -137,11 +140,12 @@ public class RecipeChoosePageWidget extends DraggableWidget {
return stringBuilder_1.toString();
};
textFieldWidget.setText(String.valueOf(currentPage + 1));
- widgets.add(btnDone = ButtonWidget.create(new Rectangle(bounds.x + bounds.width - 45, bounds.y + bounds.height + 3, 40, 20), new TranslatableText("gui.done"), buttonWidget -> {
- recipeViewingScreen.page = MathHelper.clamp(getIntFromString(textFieldWidget.getText()).orElse(0) - 1, 0, recipeViewingScreen.getTotalPages(recipeViewingScreen.getSelectedCategory()) - 1);
- recipeViewingScreen.choosePageActivated = false;
- recipeViewingScreen.init();
- }));
+ widgets.add(btnDone = Widgets.createButton(new Rectangle(bounds.x + bounds.width - 45, bounds.y + bounds.height + 3, 40, 20), new TranslatableText("gui.done"))
+ .onClick(button -> {
+ recipeViewingScreen.page = MathHelper.clamp(getIntFromString(textFieldWidget.getText()).orElse(0) - 1, 0, recipeViewingScreen.getTotalPages(recipeViewingScreen.getSelectedCategory()) - 1);
+ recipeViewingScreen.choosePageActivated = false;
+ recipeViewingScreen.init();
+ }));
textFieldWidget.setFocused(true);
}