diff options
Diffstat (limited to 'RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java')
| -rw-r--r-- | RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 8c949bf75..6e2819812 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.gui; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; @@ -81,11 +80,8 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { private final Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap; private final List<RecipeCategory<?>> categories; private final RecipeCategory<RecipeDisplay> selectedCategory; - public int guiWidth; - public int guiHeight; public int page; public int categoryPages = -1; - public int largestWidth, largestHeight; public boolean choosePageActivated = false; public RecipeChoosePageWidget recipeChoosePageWidget; private int tabsPerPage = 5; @@ -98,8 +94,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { public RecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap, @Nullable ResourceLocation category) { super(NarratorChatListener.NO_TITLE); - Window window = Minecraft.getInstance().getWindow(); - this.bounds = new Rectangle(window.getGuiScaledWidth() / 2 - guiWidth / 2, window.getGuiScaledHeight() / 2 - guiHeight / 2, 176, 150); + this.bounds = new Rectangle(0, 0, 176, 150); this.categoriesMap = categoriesMap; this.categories = Lists.newArrayList(categoriesMap.keySet()); RecipeCategory<?> selected = categories.get(0); @@ -224,17 +219,21 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { this.tabs.clear(); this.preWidgets.clear(); this.widgets.clear(); - this.largestWidth = width - 100; - this.largestHeight = Math.max(height - 34 - 30, 100); + int largestWidth = width - 100; + int largestHeight = Math.max(height - 34 - 30, 100); int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), selectedCategory::getDisplayWidth, Comparator.naturalOrder()).orElse(150); - this.guiWidth = Math.max(maxWidthDisplay + 40, 190); - this.guiHeight = Mth.floor(Mth.clamp((double) (selectedCategory.getDisplayHeight() + 4) * (getRecipesPerPage() + 1) + 36, 100, largestHeight)); - if (!ConfigObject.getInstance().shouldResizeDynamically()) this.guiHeight = largestHeight; + int guiWidth = Math.max(maxWidthDisplay + 40, 190); + int guiHeight = Mth.floor(Mth.clamp((double) (selectedCategory.getDisplayHeight() + 4) * (getRecipesPerPage() + 1) + 36, 100, largestHeight)); + if (!ConfigObject.getInstance().shouldResizeDynamically()) guiHeight = largestHeight; this.tabsPerPage = Math.max(5, Mth.floor((guiWidth - 20d) / tabSize)); if (this.categoryPages == -1) { this.categoryPages = Math.max(0, categories.indexOf(selectedCategory) / tabsPerPage); } this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight); + if (ConfigObject.getInstance().isSubsetsEnabled()) { + this.bounds.setLocation(this.bounds.getX(), this.bounds.getY() + 15); + this.bounds.setSize(this.bounds.getWidth(), this.bounds.getHeight() - 10); + } this.page = Mth.clamp(page, 0, getTotalPages(selectedCategory) - 1); this.widgets.add(Widgets.createButton(new Rectangle(bounds.x, bounds.y - 16, 10, 10), new TranslatableComponent("text.rei.left_arrow")) .onClick(button -> { @@ -391,12 +390,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { if (selectedCategory.getFixedRecipesPerPage() > 0) return selectedCategory.getFixedRecipesPerPage() - 1; int height = selectedCategory.getDisplayHeight(); - return Mth.clamp(Mth.floor(((double) largestHeight - 36) / ((double) height + 4)) - 1, 0, Math.min(ConfigObject.getInstance().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1)); - } - - private int getRecipesPerPageByHeight() { - int height = selectedCategory.getDisplayHeight(); - return Mth.clamp(Mth.floor(((double) guiHeight - 36) / ((double) height + 4)), 0, Math.min(ConfigObject.getInstance().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1)); + return Mth.clamp(Mth.floor(((double) this.bounds.getHeight() - 36) / ((double) height + 4)) - 1, 0, Math.min(ConfigObject.getInstance().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1)); } @Override |
