diff options
author | miozune <miozune@gmail.com> | 2023-12-04 05:34:27 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-03 21:34:27 +0100 |
commit | f74c7cc297d1d19d38a19683cd277ad9ce605d3a (patch) | |
tree | b2a5d66ec5a959099240fb1db239ffc0f9531839 /src/main/java/gregtech/common/gui | |
parent | b08cde7de4ec93cba05fb070991ad1dffb800ce1 (diff) | |
download | GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.tar.gz GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.tar.bz2 GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.zip |
Refactor RecipeMap (#2345)
* Remove deprecated and unused things
* Move recipemap subclasses
* Move GT_Recipe_Map to outside and rename to RecipeMap
* Move recipemap instances to separated class & remove prepending s
* Remove useless GT_Recipe constructors
* Always use ModularUI
* Rename IGT_RecipeMap -> IRecipeMap
* Add RecipeMapBuilder
* Remove more deprecated and unused things
* Fix RecipeMap type parameters
* Use multimap for recipe index
* Fix bending recipe error in dev env
* Remove mUniqueIdentifier
* Update AE2FC
* Less edgy texture for NEI recipe background
* Add replicator fluid output slot for NEI and machine GUI
* Fix fluid fuels not having fuel value in large boilers
* Remove GT_RectHandler and NEI_TransferRectHost
* Remove RecipeMapHandler
* Move NEI energy description from RecipeMapFrontend to Power
* Refactor the way to filter fusion recipes
* Check restriction for some properties
* Remove showVoltageAmperage
* Make Power accept GT_Recipe
* Fix NPE
* Move NEI duration description to Power from Frontend
* Directly implement IRecipeProcessingAwareHatch for GT_MetaTileEntity_Hatch_InputBus_ME
* Make Power integrated with GT_OverclockCalculator
* Rename Power -> OverclockDescriber
* Don't modify recipe find logic until postload finishes
* Reformat reserved MTE ids
* Fix check for too few inputs on recipe addition
* Move replicator logic to backend
* Stop un-hiding assline recipes
* Allow setting custom recipe comparator & implement for fusion
* Update AE2FC
* Rename getRecipeList and getRecipes -> getRecipeMap
* Automatically register recipe catalysts
* Cleanup the way to detect recipe collision
* Make use of BasicUIProperties for basic machines
* Make use of BasicUIProperties for UIHelper
* Rename specialHandler -> recipeTransformer
* Add way to automatically register handler info
* Add recipe category
* Add some APIs for addons
* Rename blastRecipes ->
blastFurnaceRecipes
* Remove GT_MetaTileEntity_BasicMachine_GT_Recipe#mSharedTank and #mRequiresFluidForFiltering
* Don't require setting duration and EU/t for fuel recipes
* Don't require setting EU/t for primitive blast furnace recipes
* Revert change to addMultiblockChemicalRecipe
* Fix large boiler general desc recipe not being added
* Hide duration and EU/t from large boiler
* Cleanup recipe stacktrace draw
* Extend metadata usage of recipe builder to recipe itself
* Implement metadata handling & NEI comparator for PCB factory
* Some rename around NEIRecipeInfo
* Some toString implementations
* Add more APIs for addons & some rename
* Infer handler icon from recipe catalyst if one is not set
* Also shrink recipe title when OC is not used
* Remove rare earth centrifuge recipe
* Use metadata for replicator backend
* Adjust geothermal generator output slot
* Allow having multiple transferrects
* Store recipemap reference in backend
* Rename vacuumRecipes -> vacuumFreezerRecipes
* Add config to tweak visibility of recipe categories
* Remove mHideRecyclingRecipes in favor of recipe category config
* Fix typo fluidSolidfierRecipes -> fluidSolidifierRecipes
* Refactor findRecipe and ProcessingLogic to use Stream
* Fix BBF handler icon & remove bronze blast furnace
* Add fluent API for findRecipe
* Add way to stop adding progressbar
* Change arg order for special texture
* Avoid overwriting interesting failure with NO_RECIPE
* Some changes for FuelBackend
* Set space project icon
* Remove localization from TT
* Remove CNC recipe adder
* Move recipe extractor from AE2FC
* Minor internal change for ProcessingLogic#applyRecipe
* More javadoc on #getAvailableRecipeMaps
* Better implementation of #ofSupplier
* Move replicator exponent config to GT_Proxy
* Remove RC & IC2 macerator handling
* Rename StreamUtil -> GT_StreamUtil
* Refactor code around RecipeMetadataStorage
* Revise #compileRecipe javadoc
* Switch extreme diesel recipe loader to downstream recipe map
* Optimize #reMap
* Rename reload -> reloadNEICache
* Minor tweak for drawEnergyInfo
* a bit more doc
* Adjust recipe catalysts
* Add toString implementation for GT_Fluid for debug
* Minor revision for OilCrackerBackend
* Index replicator recipes by material
---------
Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common/gui')
-rw-r--r-- | src/main/java/gregtech/common/gui/modularui/UIHelper.java | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/src/main/java/gregtech/common/gui/modularui/UIHelper.java b/src/main/java/gregtech/common/gui/modularui/UIHelper.java index 0893310342..dffeeff48f 100644 --- a/src/main/java/gregtech/common/gui/modularui/UIHelper.java +++ b/src/main/java/gregtech/common/gui/modularui/UIHelper.java @@ -6,74 +6,75 @@ import java.util.List; import java.util.stream.Collectors; import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.math.Pos2d; import gregtech.api.enums.SteamVariant; import gregtech.api.gui.modularui.SteamTexture; -import gregtech.api.util.GT_Recipe; +import gregtech.api.recipe.BasicUIProperties; +import gregtech.api.util.MethodsReturnNonnullByDefault; +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault public class UIHelper { /** * Iterates over candidates for slot placement. */ + @SuppressWarnings("SimplifyStreamApiCallChains") public static void forEachSlots(ForEachSlot forEachItemInputSlot, ForEachSlot forEachItemOutputSlot, ForEachSlot forEachSpecialSlot, ForEachSlot forEachFluidInputSlot, ForEachSlot forEachFluidOutputSlot, - IDrawable itemSlotBackground, IDrawable fluidSlotBackground, @Nullable GT_Recipe.GT_Recipe_Map recipeMap, - int itemInputCount, int itemOutputCount, int fluidInputCount, int fluidOutputCount, SteamVariant steamVariant, - Pos2d offset) { - List<Pos2d> itemInputPositions = recipeMap != null ? recipeMap.getItemInputPositions(itemInputCount) - : UIHelper.getItemInputPositions(itemInputCount); - itemInputPositions = itemInputPositions.stream() + IDrawable itemSlotBackground, IDrawable fluidSlotBackground, BasicUIProperties uiProperties, int itemInputCount, + int itemOutputCount, int fluidInputCount, int fluidOutputCount, SteamVariant steamVariant, Pos2d offset) { + List<Pos2d> itemInputPositions = uiProperties.itemInputPositionsGetter.apply(itemInputCount) + .stream() .map(p -> p.add(offset)) .collect(Collectors.toList()); for (int i = 0; i < itemInputPositions.size(); i++) { forEachItemInputSlot.accept( i, - getBackgroundsForSlot(itemSlotBackground, recipeMap, false, false, i, false, steamVariant), + getBackgroundsForSlot(itemSlotBackground, uiProperties, false, false, i, false, steamVariant), itemInputPositions.get(i)); } - List<Pos2d> itemOutputPositions = recipeMap != null ? recipeMap.getItemOutputPositions(itemOutputCount) - : UIHelper.getItemOutputPositions(itemOutputCount); - itemOutputPositions = itemOutputPositions.stream() + List<Pos2d> itemOutputPositions = uiProperties.itemOutputPositionsGetter.apply(itemOutputCount) + .stream() .map(p -> p.add(offset)) .collect(Collectors.toList()); for (int i = 0; i < itemOutputPositions.size(); i++) { forEachItemOutputSlot.accept( i, - getBackgroundsForSlot(itemSlotBackground, recipeMap, false, true, i, false, steamVariant), + getBackgroundsForSlot(itemSlotBackground, uiProperties, false, true, i, false, steamVariant), itemOutputPositions.get(i)); } forEachSpecialSlot.accept( 0, - getBackgroundsForSlot(itemSlotBackground, recipeMap, false, false, 0, true, steamVariant), - (recipeMap != null ? recipeMap.getSpecialItemPosition() : UIHelper.getSpecialItemPosition()).add(offset)); + getBackgroundsForSlot(itemSlotBackground, uiProperties, false, false, 0, true, steamVariant), + uiProperties.specialItemPositionGetter.get() + .add(offset)); - List<Pos2d> fluidInputPositions = recipeMap != null ? recipeMap.getFluidInputPositions(fluidInputCount) - : UIHelper.getFluidInputPositions(fluidInputCount); - fluidInputPositions = fluidInputPositions.stream() + List<Pos2d> fluidInputPositions = uiProperties.fluidInputPositionsGetter.apply(fluidInputCount) + .stream() .map(p -> p.add(offset)) .collect(Collectors.toList()); for (int i = 0; i < fluidInputPositions.size(); i++) { forEachFluidInputSlot.accept( i, - getBackgroundsForSlot(fluidSlotBackground, recipeMap, true, false, i, false, steamVariant), + getBackgroundsForSlot(fluidSlotBackground, uiProperties, true, false, i, false, steamVariant), fluidInputPositions.get(i)); } - List<Pos2d> fluidOutputPositions = recipeMap != null ? recipeMap.getFluidOutputPositions(fluidOutputCount) - : UIHelper.getFluidOutputPositions(fluidOutputCount); - fluidOutputPositions = fluidOutputPositions.stream() + List<Pos2d> fluidOutputPositions = uiProperties.fluidOutputPositionsGetter.apply(fluidOutputCount) + .stream() .map(p -> p.add(offset)) .collect(Collectors.toList()); for (int i = 0; i < fluidOutputPositions.size(); i++) { forEachFluidOutputSlot.accept( i, - getBackgroundsForSlot(fluidSlotBackground, recipeMap, true, true, i, false, steamVariant), + getBackgroundsForSlot(fluidSlotBackground, uiProperties, true, true, i, false, steamVariant), fluidOutputPositions.get(i)); } } @@ -172,25 +173,32 @@ public class UIHelper { return getGridPositions(itemCount, xOrigin, yOrigin, xDirMaxCount, yDirMaxCount); } - private static IDrawable[] getBackgroundsForSlot(IDrawable base, GT_Recipe.GT_Recipe_Map recipeMap, boolean isFluid, + private static IDrawable[] getBackgroundsForSlot(IDrawable base, BasicUIProperties uiProperties, boolean isFluid, boolean isOutput, int index, boolean isSpecial, SteamVariant steamVariant) { - if (recipeMap != null) { - IDrawable overlay; - if (steamVariant != SteamVariant.NONE) { - SteamTexture steamTexture = recipeMap.getOverlayForSlotSteam(isFluid, isOutput, index, isSpecial); - if (steamTexture != null) { - overlay = steamTexture.get(steamVariant); - } else { - overlay = null; - } + IDrawable overlay = getOverlay(uiProperties, isFluid, isOutput, index, isSpecial, steamVariant); + if (overlay != null) { + return new IDrawable[] { base, overlay }; + } else { + return new IDrawable[] { base }; + } + } + + @Nullable + private static IDrawable getOverlay(BasicUIProperties uiProperties, boolean isFluid, boolean isOutput, int index, + boolean isSpecial, SteamVariant steamVariant) { + if (isSpecial && !uiProperties.useSpecialSlot) { + return null; + } + if (steamVariant != SteamVariant.NONE) { + SteamTexture steamTexture = uiProperties.getOverlayForSlotSteam(index, isFluid, isOutput, isSpecial); + if (steamTexture != null) { + return steamTexture.get(steamVariant); } else { - overlay = recipeMap.getOverlayForSlot(isFluid, isOutput, index, isSpecial); - } - if (overlay != null) { - return new IDrawable[] { base, overlay }; + return null; } + } else { + return uiProperties.getOverlayForSlot(index, isFluid, isOutput, isSpecial); } - return new IDrawable[] { base }; } @FunctionalInterface |