aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
diff options
context:
space:
mode:
authorDaniel She <shekwancheung0528@gmail.com>2019-05-10 00:20:16 +0800
committerGitHub <noreply@github.com>2019-05-10 00:20:16 +0800
commit67fc756047f34bdbb9f028e48fc725534b3beafc (patch)
tree670f0694b3313eaf712020a9d60dc34404725777 /src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
parent766b4837c2512cefa3188adc897605a83144f711 (diff)
parent467511401a783fc0a8d625947e69519da1c815e1 (diff)
downloadRoughlyEnoughItems-67fc756047f34bdbb9f028e48fc725534b3beafc.tar.gz
RoughlyEnoughItems-67fc756047f34bdbb9f028e48fc725534b3beafc.tar.bz2
RoughlyEnoughItems-67fc756047f34bdbb9f028e48fc725534b3beafc.zip
Merge pull request #86 from shedaniel/1.14-dev
REi v2.9 (WIP)
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
index 16af460f4..2bb1b4486 100644
--- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
@@ -43,16 +43,15 @@ public class RecipeViewingScreen extends Screen {
public int largestWidth, largestHeight;
public boolean choosePageActivated;
public RecipeChoosePageWidget recipeChoosePageWidget;
- private Window window;
private Rectangle bounds;
private RecipeCategory selectedCategory;
private ButtonWidget recipeBack, recipeNext, categoryBack, categoryNext;
- public RecipeViewingScreen(Window window, Map<RecipeCategory, List<RecipeDisplay>> categoriesMap) {
+ public RecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> categoriesMap) {
super(new StringTextComponent(""));
this.categoryPages = 0;
- this.window = window;
this.widgets = Lists.newArrayList();
+ Window window = MinecraftClient.getInstance().window;
this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, 176, 186);
this.categoriesMap = categoriesMap;
this.categories = Lists.newArrayList();
@@ -119,11 +118,11 @@ public class RecipeViewingScreen extends Screen {
this.children.clear();
this.tabs.clear();
this.widgets.clear();
- this.largestWidth = window.getScaledWidth() - 100;
- this.largestHeight = window.getScaledHeight() - 40;
+ this.largestWidth = width - 100;
+ this.largestHeight = height - 40;
this.guiWidth = MathHelper.clamp(getCurrentDisplayed().stream().map(display -> selectedCategory.getDisplayWidth(display)).max(Integer::compareTo).orElse(150) + 30, 0, largestWidth);
this.guiHeight = MathHelper.floor(MathHelper.clamp((selectedCategory.getDisplayHeight() + 7d) * (getRecipesPerPage() + 1d) + 40d, 186d, (double) largestHeight));
- this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, guiWidth, guiHeight);
+ this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight);
this.page = MathHelper.clamp(page, 0, getTotalPages(selectedCategory) - 1);
widgets.add(categoryBack = new ButtonWidget((int) bounds.getX() + 5, (int) bounds.getY() + 5, 12, 12, new TranslatableTextComponent("text.rei.left_arrow")) {
@@ -235,7 +234,7 @@ public class RecipeViewingScreen extends Screen {
int j = i + categoryPages * 6;
if (categories.size() > j) {
TabWidget tab;
- tabs.add(tab = new TabWidget(i, this, new Rectangle(bounds.x + 4 + 28 * i, bounds.y - 28, 28, 28)) {
+ tabs.add(tab = new TabWidget(i, new Rectangle(bounds.x + 4 + 28 * i, bounds.y - 28, 28, 28)) {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (getBounds().contains(mouseX, mouseY)) {
@@ -250,7 +249,7 @@ public class RecipeViewingScreen extends Screen {
return false;
}
});
- tab.setItem(categories.get(j).getCategoryIcon(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * 6 == categories.indexOf(selectedCategory));
+ tab.setRenderer(categories.get(j), categories.get(j).getIcon(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * 6 == categories.indexOf(selectedCategory));
}
}
Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(selectedCategory);