aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me')
-rw-r--r--src/main/java/me/shedaniel/rei/api/ConfigObject.java2
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java17
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java11
3 files changed, 20 insertions, 10 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java
index 08a70ab04..34c98c225 100644
--- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java
+++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java
@@ -155,4 +155,6 @@ public interface ConfigObject {
@ApiStatus.Experimental
boolean isSubsetsEnabled();
+
+ boolean shouldResizeDynamically();
}
diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
index 96fe5479a..87c134700 100644
--- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
@@ -223,17 +223,18 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen {
this.preWidgets.clear();
this.widgets.clear();
this.largestWidth = width - 100;
- this.largestHeight = Math.max(height - 36, 100);
+ this.largestHeight = Math.max(height - 34 - 30, 100);
int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), selectedCategory::getDisplayWidth, Comparator.naturalOrder()).orElse(150);
- this.guiWidth = maxWidthDisplay + 20;
+ this.guiWidth = Math.max(maxWidthDisplay + 40, 0);
this.guiHeight = MathHelper.floor(MathHelper.clamp((double) (selectedCategory.getDisplayHeight() + 4) * (getRecipesPerPage() + 1) + 36, 100, largestHeight));
+ if (!ConfigObject.getInstance().shouldResizeDynamically()) this.guiHeight = largestHeight;
this.tabsPerPage = Math.max(5, MathHelper.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);
this.page = MathHelper.clamp(page, 0, getTotalPages(selectedCategory) - 1);
- this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + 2, bounds.y - 16, 10, 10), new TranslatableText("text.rei.left_arrow"))
+ this.widgets.add(Widgets.createButton(new Rectangle(bounds.x, bounds.y - 16, 10, 10), new TranslatableText("text.rei.left_arrow"))
.onClick(button -> {
categoryPages--;
if (categoryPages < 0)
@@ -241,7 +242,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen {
RecipeViewingScreen.this.init();
})
.enabled(categories.size() > tabsPerPage));
- this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10), new TranslatableText("text.rei.right_arrow"))
+ this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + bounds.width - 10, bounds.y - 16, 10, 10), new TranslatableText("text.rei.right_arrow"))
.onClick(button -> {
categoryPages++;
if (categoryPages > MathHelper.ceil(categories.size() / (float) tabsPerPage) - 1)
@@ -283,7 +284,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen {
RecipeViewingScreen.this.init();
}).onRender((matrices, label) -> {
label.setText(new LiteralText(String.format("%d/%d", page + 1, getTotalPages(selectedCategory))));
- label.setClickable(categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight());
+ label.setClickable(getTotalPages(selectedCategory) > 1);
}).tooltipSupplier(label -> label.isClickable() ? I18n.translate("text.rei.choose_page") : null));
widgets.add(recipeNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 19, 12, 12), new TranslatableText("text.rei.right_arrow"))
.onClick(button -> {
@@ -292,8 +293,8 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen {
page = 0;
RecipeViewingScreen.this.init();
}).tooltipLine(I18n.translate("text.rei.next_page")));
- recipeBack.setEnabled(categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight());
- recipeNext.setEnabled(categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight());
+ recipeBack.setEnabled(getTotalPages(selectedCategory) > 1);
+ recipeNext.setEnabled(getTotalPages(selectedCategory) > 1);
int tabV = isCompactTabs ? 166 : 192;
for (int i = 0; i < tabsPerPage; i++) {
int j = i + categoryPages * tabsPerPage;
@@ -316,7 +317,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen {
final RecipeDisplay display = currentDisplayed.get(i);
final Supplier<RecipeDisplay> displaySupplier = () -> display;
int displayWidth = selectedCategory.getDisplayWidth(displaySupplier.get());
- final Rectangle displayBounds = new Rectangle(getBounds().getCenterX() - displayWidth / 2, getBounds().y - 2 + 36 + recipeHeight * i + 4 * i, displayWidth, recipeHeight);
+ final Rectangle displayBounds = new Rectangle(getBounds().getCenterX() - displayWidth / 2, getBounds().getCenterY() + 16 - recipeHeight * (getRecipesPerPage() + 1) / 2 - 2 * (getRecipesPerPage() + 1) + recipeHeight * i + 4 * i, displayWidth, recipeHeight);
List<Widget> setupDisplay = selectedCategory.setupDisplay(display, displayBounds);
transformIngredientNotice(setupDisplay, ingredientStackToNotice);
transformResultNotice(setupDisplay, resultStackToNotice);
diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
index 710c768f3..18853b482 100644
--- a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
+++ b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
@@ -163,7 +163,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
@Override
public int getMaxRecipePerPage() {
- return appearance.maxRecipePerPage;
+ return appearance.maxRecipesPerPage;
}
@Override
@@ -336,6 +336,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
return experimental.isSubsetsEnabled;
}
+ @Override
+ public boolean shouldResizeDynamically() {
+ return appearance.resizeDynamically;
+ }
+
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@interface DontApplyFieldName {}
@@ -381,7 +386,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
private SearchFieldLocation searchFieldLocation = SearchFieldLocation.CENTER;
@Comment("Declares the position of the item list panel.") private boolean mirrorItemPanel = false;
@Comment("Declares the maximum amount of recipes displayed in a page if possible.") @ConfigEntry.BoundedDiscrete(min = 2, max = 99)
- private int maxRecipePerPage = 3;
+ private int maxRecipesPerPage = 15;
private boolean clickableRecipeArrows = true;
@Comment("Declares the appearance of recipe's border.") @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
private RecipeBorderType recipeBorder = RecipeBorderType.DEFAULT;
@@ -395,6 +400,8 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
@UsePercentage(min = 0.25, max = 4.0) private double entrySize = 1.0;
private boolean useCompactTabs = true;
private boolean lowerConfigButton = false;
+ @Comment("Declares whether REI should resize its recipe window dynamically")
+ private boolean resizeDynamically = false;
}
public static class Technical {