66import gregtech .api .gui .resources .TextureArea ;
77import gregtech .api .gui .widgets .SlotWidget ;
88import gregtech .api .gui .widgets .TankWidget ;
9+ import gregtech .api .metatileentity .MetaTileEntity ;
910import gregtech .api .mui .GTGuiTextures ;
11+ import gregtech .api .mui .GTGuis ;
1012import gregtech .api .mui .widget .RecipeProgressWidget ;
1113import gregtech .api .recipes .Recipe ;
1214import gregtech .api .recipes .RecipeMap ;
@@ -76,6 +78,9 @@ public class RecipeMapUI<R extends RecipeMap<?>> {
7678 private UITexture progressTexture = GTGuiTextures .PROGRESS_BAR_ARROW ;
7779 private ProgressWidget .Direction progressDirection = ProgressWidget .Direction .RIGHT ;
7880 private Consumer <Widget <?>> extraOverlays = null ;
81+ private int width = GTGuis .DEFAULT_WIDTH ;
82+ private int height = GTGuis .DEFAULT_HIEGHT ;
83+ private boolean isLeftGreater = false ;
7984
8085 /**
8186 * @param recipeMap the recipemap corresponding to this ui
@@ -540,14 +545,31 @@ public void setSlotOverlay(byte key, @NotNull TextureArea texture) {
540545
541546 /* *********************** MUI 2 *********************** */
542547
543- public ModularPanel constructPanel (ModularPanel panel , DoubleSupplier progressSupplier ,
544- IItemHandlerModifiable importItems ,
545- IItemHandlerModifiable exportItems , FluidTankList importFluids ,
546- FluidTankList exportFluids , int yOffset , PanelSyncManager syncManager ) {
548+ public RecipeMapUI <R > setSize (int width , int height ) {
549+ this .width = width ;
550+ this .height = height ;
551+ return this ;
552+ }
553+
554+ public ModularPanel constructPanel (MetaTileEntity mte , DoubleSupplier progressSupplier ,
555+ IItemHandlerModifiable importItems , IItemHandlerModifiable exportItems ,
556+ FluidTankList importFluids , FluidTankList exportFluids ,
557+ int yOffset , PanelSyncManager syncManager ) {
558+ int inputHeight = calculateHeight (determineSlotsGrid (importItems .getSlots (), importFluids .getTanks ()),
559+ importFluids .getTanks ());
560+ int outputHeight = calculateHeight (determineSlotsGrid (exportItems .getSlots (), exportFluids .getTanks ()),
561+ exportFluids .getTanks ());
562+ ModularPanel panel = GTGuis .createPanel (mte , this .width , adjustHeight (inputHeight , outputHeight ));
563+
547564 DoubleSyncValue progressValue = new DoubleSyncValue (progressSupplier );
548565
566+ int h = 3 * 18 ;
567+ if (Math .max (inputHeight , outputHeight ) < 3 ) {
568+ h -= 18 ;
569+ }
570+
549571 Flow row = Flow .row ()
550- .height (3 * 18 )
572+ .height (h )
551573 .debugName ("row:recipemapui.parent" )
552574 .alignX (0.5f )
553575 .crossAxisAlignment (Alignment .CrossAxis .CENTER )
@@ -582,8 +604,6 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu
582604 return panel .child (row );
583605 }
584606
585- boolean isLeftGreater = false ;
586-
587607 private int calculateWidth (int inputItems , int inputFluids ,
588608 int outputItems , int outputFluids ,
589609 int progressSize , int margin ) {
@@ -609,6 +629,23 @@ private boolean isSingleRow(int[] grid, int fluidCount) {
609629 return grid [1 ] >= fluidCount && grid [0 ] < 3 ;
610630 }
611631
632+ private int adjustHeight (int inputHeight , int outputHeight ) {
633+ if (Math .max (inputHeight , outputHeight ) < 4 ) {
634+ return this .height - 18 ;
635+ }
636+ return this .height ;
637+ }
638+
639+ private int calculateHeight (int [] inputs , int inputFluids ) {
640+ int inputHeight ;
641+ if (isSingleRow (inputs , inputFluids )) {
642+ inputHeight = Math .max (inputs [1 ], inputs [3 ]);
643+ } else {
644+ inputHeight = inputs [1 ] + inputs [3 ];
645+ }
646+ return inputHeight ;
647+ }
648+
612649 /**
613650 * @param grid [item grid width, item grid height, fluid grid width, fluid grid height]
614651 */
0 commit comments