aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-10-29 19:35:05 +0800
committershedaniel <daniel@shedaniel.me>2022-10-29 19:35:05 +0800
commit46d2c64c4303bc007055268075ea9be4e9852e5e (patch)
treeec1bd5a909bc2c7cea522dfb6e4b9b7797c370e2
parent651e6f10ced5fc042f72fdbb1750b573c6e0a3f8 (diff)
downloadRoughlyEnoughItems-46d2c64c4303bc007055268075ea9be4e9852e5e.tar.gz
RoughlyEnoughItems-46d2c64c4303bc007055268075ea9be4e9852e5e.tar.bz2
RoughlyEnoughItems-46d2c64c4303bc007055268075ea9be4e9852e5e.zip
Make backspacing categories less granular
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java29
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java3
3 files changed, 24 insertions, 13 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
index 4c18502d2..88f339f3c 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
@@ -48,7 +48,6 @@ import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.entry.type.EntryType;
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
import me.shedaniel.rei.api.common.util.CollectionUtils;
-import me.shedaniel.rei.impl.client.ClientHelperImpl;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget;
@@ -92,13 +91,27 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis
this.categories = Lists.newArrayList(categoryMap.keySet());
this.tabsPerPage = tabsPerPage;
if (category != null) {
- for (int i = 0; i < categories.size(); i++) {
- if (categories.get(i).getCategoryIdentifier().equals(category)) {
- this.selectedCategoryIndex = i;
- break;
- }
+ selectCategory(category, false);
+ }
+ }
+
+ protected void selectCategory(CategoryIdentifier<?> category) {
+ selectCategory(category, true);
+ }
+
+ protected void selectCategory(CategoryIdentifier<?> category, boolean init) {
+ for (int i = 0; i < categories.size(); i++) {
+ if (categories.get(i).getCategoryIdentifier().equals(category)) {
+ this.selectedCategoryIndex = i;
+ break;
}
}
+
+ recalculateCategoryPage();
+
+ if (init) {
+ init();
+ }
}
@Override
@@ -156,7 +169,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis
currentCategoryIndex--;
if (currentCategoryIndex < 0)
currentCategoryIndex = categories.size() - 1;
- ClientHelperImpl.getInstance().openDisplayViewingScreen(categoryMap, categories.get(currentCategoryIndex).getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice);
+ selectCategory(categories.get(currentCategoryIndex).getCategoryIdentifier());
}
@Override
@@ -165,7 +178,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis
currentCategoryIndex++;
if (currentCategoryIndex >= categories.size())
currentCategoryIndex = 0;
- ClientHelperImpl.getInstance().openDisplayViewingScreen(categoryMap, categories.get(currentCategoryIndex).getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice);
+ selectCategory(categories.get(currentCategoryIndex).getCategoryIdentifier());
}
protected void transformIngredientNotice(List<Widget> setupDisplay, List<EntryStack<?>> noticeStacks) {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
index 205cc9a23..e4dd97f76 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
@@ -44,7 +44,6 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.ImmutableTextComponent;
-import me.shedaniel.rei.impl.client.ClientHelperImpl;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.InternalTextures;
import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
@@ -203,7 +202,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
if (widget.selected)
return false;
- ClientHelperImpl.getInstance().openDisplayViewingScreen(categoryMap, tabCategory.getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice);
+ selectCategory(tabCategory.getCategoryIdentifier());
return true;
}));
tab.setRenderer(tabCategory, tabCategory.getIcon(), tabCategory.getTitle(), j == selectedCategoryIndex);
@@ -325,7 +324,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen
else if (amount > 0) selectedCategoryIndex--;
if (selectedCategoryIndex < 0) selectedCategoryIndex = categories.size() - 1;
else if (selectedCategoryIndex >= categories.size()) selectedCategoryIndex = 0;
- ClientHelperImpl.getInstance().openDisplayViewingScreen(categoryMap, categories.get(selectedCategoryIndex).getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice);
+ selectCategory(categories.get(selectedCategoryIndex).getCategoryIdentifier());
return true;
}
if (bounds.contains(PointHelper.ofMouse())) {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
index 969716706..64ec3f39b 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
@@ -52,7 +52,6 @@ import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.api.common.util.ImmutableTextComponent;
-import me.shedaniel.rei.impl.client.ClientHelperImpl;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.InternalTextures;
import me.shedaniel.rei.impl.client.gui.RecipeDisplayExporter;
@@ -255,7 +254,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
if (widget.getId() + categoryPages * tabsPerPage == selectedCategoryIndex)
return false;
- ClientHelperImpl.getInstance().openDisplayViewingScreen(categoryMap, categories.get(widget.getId() + categoryPages * tabsPerPage).getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice);
+ selectCategory(categories.get(widget.getId() + categoryPages * tabsPerPage).getCategoryIdentifier());
return true;
}));
tab.setRenderer(categories.get(tabIndex), categories.get(tabIndex).getIcon(), categories.get(tabIndex).getTitle(), tab.getId() + categoryPages * tabsPerPage == selectedCategoryIndex);