From ea634e7ba29146d4ebc2c05b61257fa6c3b0642e Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 5 Feb 2021 10:08:44 +0800 Subject: More relocation Signed-off-by: shedaniel --- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java') diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 094815ffb..e80a2a899 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -34,6 +34,8 @@ import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.*; +import me.shedaniel.rei.api.ingredient.EntryStack; +import me.shedaniel.rei.api.registry.category.DisplayCategory; import me.shedaniel.rei.api.widgets.Button; import me.shedaniel.rei.api.widgets.Panel; import me.shedaniel.rei.api.widgets.Widgets; @@ -76,9 +78,9 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { private final List widgets = Lists.newArrayList(); private final Map> recipeBounds = Maps.newHashMap(); private final List tabs = Lists.newArrayList(); - private final Map, List> categoriesMap; - private final List> categories; - private final RecipeCategory selectedCategory; + private final Map, List> categoriesMap; + private final List> categories; + private final DisplayCategory selectedCategory; public int page; public int categoryPages = -1; public boolean choosePageActivated = false; @@ -91,21 +93,21 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { private EntryStack ingredientStackToNotice = EntryStack.empty(); private EntryStack resultStackToNotice = EntryStack.empty(); - public RecipeViewingScreen(Map, List> categoriesMap, @Nullable ResourceLocation category) { + public RecipeViewingScreen(Map, List> categoriesMap, @Nullable ResourceLocation category) { super(NarratorChatListener.NO_TITLE); this.bounds = new Rectangle(0, 0, 176, 150); this.categoriesMap = categoriesMap; this.categories = Lists.newArrayList(categoriesMap.keySet()); - RecipeCategory selected = categories.get(0); + DisplayCategory selected = categories.get(0); if (category != null) { - for (RecipeCategory recipeCategory : categories) { - if (recipeCategory.getIdentifier().equals(category)) { - selected = recipeCategory; + for (DisplayCategory displayCategory : categories) { + if (displayCategory.getIdentifier().equals(category)) { + selected = displayCategory; break; } } } - this.selectedCategory = (RecipeCategory) selected; + this.selectedCategory = (DisplayCategory) selected; } @ApiStatus.Internal @@ -308,12 +310,12 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { tab.setRenderer(categories.get(j), categories.get(j).getLogo(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * tabsPerPage == categories.indexOf(selectedCategory)); } } - Optional supplier = RecipeHelper.getInstance().getAutoCraftButtonArea(selectedCategory); + Optional supplier = RecipeRegistry.getInstance().getAutoCraftButtonArea(selectedCategory); int recipeHeight = selectedCategory.getDisplayHeight(); - List currentDisplayed = getCurrentDisplayed(); + List currentDisplayed = getCurrentDisplayed(); for (int i = 0; i < currentDisplayed.size(); i++) { - final RecipeDisplay display = currentDisplayed.get(i); - final Supplier displaySupplier = () -> display; + final Display display = currentDisplayed.get(i); + final Supplier displaySupplier = () -> display; int displayWidth = selectedCategory.getDisplayWidth(displaySupplier.get()); 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 setupDisplay = selectedCategory.setupDisplay(display, displayBounds); @@ -330,7 +332,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { recipeChoosePageWidget = null; workingStationsBaseWidget = null; - List>> workingStations = RecipeHelper.getInstance().getWorkingStations(selectedCategory.getIdentifier()); + List>> workingStations = RecipeRegistry.getInstance().getWorkingStations(selectedCategory.getIdentifier()); if (!workingStations.isEmpty()) { int hh = Mth.floor((bounds.height - 16) / 18f); int actualHeight = Math.min(hh, workingStations.size()); @@ -362,8 +364,8 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { return widgets; } - public List getCurrentDisplayed() { - List list = Lists.newArrayList(); + public List getCurrentDisplayed() { + List list = Lists.newArrayList(); int recipesPerPage = getRecipesPerPage(); for (int i = 0; i <= recipesPerPage; i++) if (page * (recipesPerPage + 1) + i < categoriesMap.get(selectedCategory).size()) @@ -371,7 +373,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { return list; } - public RecipeCategory getSelectedCategory() { + public DisplayCategory getSelectedCategory() { return selectedCategory; } @@ -463,7 +465,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { return super.keyReleased(keyCode, scanCode, modifiers); } - public int getTotalPages(RecipeCategory category) { + public int getTotalPages(DisplayCategory category) { return Mth.ceil(categoriesMap.get(category).size() / (double) (getRecipesPerPage() + 1)); } -- cgit