Skip to content
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
52288e8
stuff
serenibyss Dec 10, 2023
fa6c9b4
group slots, fix shift clicking
serenibyss Dec 10, 2023
5acd5fd
clean up toggle buttons
serenibyss Dec 10, 2023
707f89b
cleanups
serenibyss Dec 10, 2023
56f1ecd
2.4 fix
serenibyss Dec 17, 2023
7c18f9a
Logo as part of GTGuiTheme
serenibyss Dec 17, 2023
23e54e5
clickable progress bar (partial)
serenibyss Dec 17, 2023
ca3f023
finish previous commit
serenibyss Dec 17, 2023
6359932
fix progress bar sync
serenibyss Dec 17, 2023
453b0fe
fix button/toggle button theme builder calls
serenibyss Dec 17, 2023
c7cdbf8
fix rebase
ghzdude Feb 28, 2025
41c6ead
move mui2 related methods into builder
ghzdude Feb 28, 2025
70dd55d
use unary operator instead
ghzdude Feb 28, 2025
bee91a7
port arc, assembler, autoclave
ghzdude Feb 28, 2025
8ae5c93
spotless
ghzdude Feb 28, 2025
a56538d
simplify builder to modify map ui directly
ghzdude Feb 28, 2025
c1576f1
move back to consumer
ghzdude Feb 28, 2025
ed7c327
add comment clarifying null supression
ghzdude May 17, 2025
d39b1ff
set mui2 for map ui
ghzdude May 17, 2025
9fe269c
use progress value directly in widget
ghzdude May 17, 2025
80a721c
rework slot overlay methods
ghzdude May 19, 2025
da09ea8
port steam machines to mui2
ghzdude May 19, 2025
4f6cfac
actually port steam machines to mui2
ghzdude May 19, 2025
4db04a4
port singleblock generators to mui2
ghzdude May 19, 2025
e9b07ec
spotless
ghzdude May 19, 2025
a3e50d0
improve/cleanup existing mui2 code
ghzdude May 19, 2025
1cc2681
spotless
ghzdude May 19, 2025
14a0221
null check ui builder and simplify
ghzdude May 19, 2025
8f1d82f
Merge branch 'master' into gh/sb-recipe-map-mui
Zorbatron Jun 25, 2025
2ca12cb
Actually merge master in properly :facepalm:
Zorbatron Jul 2, 2025
a3b023b
remove old ui code from SteamBoiler and extending classes
ghzdude Aug 15, 2025
8a94916
fix SteamLavaBoiler lava fluid slot
ghzdude Aug 15, 2025
8473cb2
use `slotOverlay()` directly
ghzdude Aug 15, 2025
bbb2991
rename mui2 special drawable
ghzdude Aug 15, 2025
9c9b9a5
rename mui2 special drawable and method
ghzdude Aug 15, 2025
88bfa5a
remove irrelevant todo
ghzdude Aug 15, 2025
e7d7b82
remove commented code
ghzdude Aug 15, 2025
83dc765
actually sync the sync value and remove todo
ghzdude Aug 15, 2025
8d1cc64
spotless
ghzdude Aug 15, 2025
79891d8
initial rework of `addInventorySlotGroup()` for mui2
ghzdude Aug 17, 2025
ef0a7b8
more work on the rewrite
ghzdude Aug 18, 2025
7595eb3
use modular panel instead of redundant parent widget
ghzdude Sep 20, 2025
e8bc2c9
rework mostly done
ghzdude Sep 27, 2025
7a53dd9
clean + spotless
ghzdude Sep 27, 2025
7651ce1
cleanup pt 2
ghzdude Sep 28, 2025
0639de4
fix no energy indicator
ghzdude Sep 28, 2025
caae70e
replace special texture with a widget consumer
ghzdude Sep 28, 2025
341a3ac
fix special textures
ghzdude Sep 28, 2025
526c738
remove if condition for simple machines
ghzdude Sep 28, 2025
9f57e43
increase progress widget margin
ghzdude Sep 29, 2025
ecd5559
improve centering slots around progress widget
ghzdude Sep 29, 2025
1bb7c67
improve item/fluid groups
ghzdude Sep 29, 2025
05f15e8
make `setSize()` a builder method
ghzdude Sep 29, 2025
13fc654
create CalculatedGrid to simplify and cleanup logic
ghzdude Sep 30, 2025
7cb191a
fix logo in SimpleGeneratorMetaTileEntity
ghzdude Sep 30, 2025
393d540
remove unused field
ghzdude Oct 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import gregtech.api.gui.ModularUI;
import gregtech.api.gui.widgets.LabelWidget;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.mui.GTGuiTextures;
import gregtech.api.mui.GTGuis;
import gregtech.api.recipes.RecipeMap;
import gregtech.client.renderer.ICubeRenderer;
import gregtech.client.renderer.texture.Textures;
Expand All @@ -28,10 +30,16 @@
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.factory.PosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import com.cleanroommc.modularui.widget.Widget;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Objects;
import java.util.function.Function;

public class SimpleGeneratorMetaTileEntity extends WorkableTieredMetaTileEntity implements IActiveOutputSide {
Expand Down Expand Up @@ -128,6 +136,44 @@ protected void renderOverlays(CCRenderState renderState, Matrix4 translation, IV
workable.isWorkingEnabled());
}

@Override
public boolean usesMui2() {
RecipeMap<?> map = getRecipeMap();
return map != null && map.getRecipeMapUI().usesMui2();
}

@Override
public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) {
RecipeMap<?> workableRecipeMap = Objects.requireNonNull(workable.getRecipeMap(), "recipe map is null");
int yOffset = 0;
if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 ||
workableRecipeMap.getMaxOutputs() >= 6 || workableRecipeMap.getMaxFluidOutputs() >= 6) {
yOffset = FONT_HEIGHT;
}

ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset);
Widget<?> widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems,
exportItems, importFluids, exportFluids, yOffset, guiSyncManager);

panel.child(widget)
.child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5))
// .child(new ItemSlot()
// .slot(SyncHandlers.itemSlot(chargerInventory, 0))
// .pos(79, 62 + yOffset)
// .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY)
// .tooltip(t -> t.addLine(IKey.lang("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()],
// GTValues.VNF[getTier()]))))
.bindPlayerInventory();

if (exportItems.getSlots() + exportFluids.getTanks() <= 9) {
panel.child(new Widget<>()
.size(17)
.pos(152, 63 + yOffset)
.background(GTGuiTextures.getLogo(getUITheme())));
}
return panel;
}

@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import gregtech.api.gui.widgets.ToggleButtonWidget;
import gregtech.api.items.itemhandlers.GTItemStackHandler;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.mui.GTGuiTextures;
import gregtech.api.mui.GTGuis;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.util.GTTransferUtils;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -54,11 +56,21 @@
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.factory.PosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.value.sync.BooleanSyncValue;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import com.cleanroommc.modularui.value.sync.SyncHandlers;
import com.cleanroommc.modularui.widget.Widget;
import com.cleanroommc.modularui.widgets.ItemSlot;
import com.cleanroommc.modularui.widgets.ToggleButton;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;

import static gregtech.api.capability.GregtechDataCodes.*;
Expand Down Expand Up @@ -478,6 +490,90 @@ public void clearMachineInventory(@NotNull List<@NotNull ItemStack> itemBuffer)
clearInventory(itemBuffer, chargerInventory);
}

@Override
public boolean usesMui2() {
RecipeMap<?> map = getRecipeMap();
return map != null && map.getRecipeMapUI().usesMui2();
}

@Override
public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) {
RecipeMap<?> workableRecipeMap = Objects.requireNonNull(workable.getRecipeMap(), "recipe map is null");
int yOffset = 0;
if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 ||
workableRecipeMap.getMaxOutputs() >= 6 || workableRecipeMap.getMaxFluidOutputs() >= 6) {
yOffset = FONT_HEIGHT;
}

ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset);
Widget<?> widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems,
exportItems, importFluids, exportFluids, yOffset, guiSyncManager);

BooleanSyncValue hasEnergy = new BooleanSyncValue(workable::isHasNotEnoughEnergy);

panel.child(widget)
.child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5))
.child(new ItemSlot()
.slot(SyncHandlers.itemSlot(chargerInventory, 0))
.pos(79, 62 + yOffset)
.background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY)
.addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip",
GTValues.VNF[getTier()], GTValues.VNF[getTier()])))
.child(new Widget<>()
.size(18, 18)
.pos(79, 42 + yOffset)
.background(GTGuiTextures.INDICATOR_NO_ENERGY)
// todo flicker appears on ui open even when it has enough energy
// will need to test this
.setEnabledIf($ -> hasEnergy.getBoolValue()))
.bindPlayerInventory();

int leftButtonStartX = 7;

if (exportItems.getSlots() > 0) {

panel.child(new ToggleButton()
.pos(leftButtonStartX, 62 + yOffset)
.overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT)
.value(new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val))
.addTooltip(true, IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled"))
.addTooltip(false, IKey.lang("gregtech.gui.item_auto_output.tooltip.disabled")));

leftButtonStartX += 18;
}

if (exportFluids.getTanks() > 0) {

panel.child(new ToggleButton()
.pos(leftButtonStartX, 62 + yOffset)
.overlay(GTGuiTextures.BUTTON_FLUID_OUTPUT)
.value(new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val))
.addTooltip(true, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled"))
.addTooltip(false, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled")));
}

if (exportItems.getSlots() + exportFluids.getTanks() <= 9) {
panel.child(new Widget<>()
.size(17)
.pos(152, 63 + yOffset)
.background(GTGuiTextures.getLogo(getUITheme())));

if (hasGhostCircuitInventory() && circuitInventory != null) {
panel.child(new gregtech.api.mui.widget.GhostCircuitSlotWidget()
.pos(124, 62 + yOffset)
.slot(SyncHandlers.itemSlot(circuitInventory, 0))
.background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY));
}
}
return panel;
}

@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer);
}

@Deprecated
protected ModularUI.Builder createGuiTemplate(EntityPlayer player) {
RecipeMap<?> workableRecipeMap = workable.getRecipeMap();
int yOffset = 0;
Expand Down Expand Up @@ -557,11 +653,6 @@ protected void getCircuitSlotTooltip(SlotWidget widget) {
widget.setTooltipText("gregtech.gui.configurator_slot.tooltip", configString);
}

@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer);
}

@Override
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import gregtech.api.gui.GuiTextures;
import gregtech.api.gui.ModularUI;
import gregtech.api.gui.widgets.ImageWidget;
import gregtech.api.mui.GTGuiTheme;
import gregtech.api.mui.GTGuis;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.util.GTUtility;
import gregtech.client.particle.VanillaParticleEffects;
Expand All @@ -34,6 +36,11 @@
import codechicken.lib.render.pipeline.ColourMultiplier;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.factory.PosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import com.cleanroommc.modularui.widget.Widget;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
Expand All @@ -43,6 +50,8 @@

public abstract class SteamMetaTileEntity extends MetaTileEntity {

// todo quick and dirty fix to not show input tank in ui, find better solution
protected static final FluidTankList EMPTY = new FluidTankList(false);
protected static final int STEAM_CAPACITY = 16000;

protected final boolean isHighPressure;
Expand Down Expand Up @@ -127,6 +136,35 @@ public FluidTankList createImportFluidHandler() {
return new FluidTankList(false, steamFluidTank);
}

@Override
public boolean usesMui2() {
RecipeMap<?> map = getRecipeMap();
return map != null && map.getRecipeMapUI().usesMui2();
}

@Override
public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) {
RecipeMap<?> map = Objects.requireNonNull(getRecipeMap());

ModularPanel modularPanel = GTGuis.defaultPanel(this);

// todo this method needs options to ignore certain handlers
// actually, steam machines manually construct their ui instead of using the recipe map ui
Widget<?> widget = map.getRecipeMapUI().buildWidget(workableHandler::getProgressPercent, importItems,
exportItems, EMPTY, exportFluids, 0, guiSyncManager);

modularPanel.child(widget)
.child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5))
.bindPlayerInventory();

return modularPanel;
}

@Override
public GTGuiTheme getUITheme() {
return isHighPressure ? GTGuiTheme.STEEL : GTGuiTheme.BRONZE;
}

public ModularUI.Builder createUITemplate(EntityPlayer player) {
return ModularUI.builder(GuiTextures.BACKGROUND_STEAM.get(isHighPressure), 176, 166)
.label(6, 6, getMetaFullName()).shouldColor(false)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/mui/GTGuiTheme.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gregtech.api.mui;

import gregtech.api.GTValues;
import gregtech.api.cover.CoverWithUI;
import gregtech.common.ConfigHolder;

Expand Down Expand Up @@ -56,6 +57,7 @@ private static String gregtech(String s) {
.simpleToggleButton(IDs.STANDARD_BUTTON,
IDs.STANDARD_SLOT,
ConfigHolder.client.defaultUIColor)
.logo(() -> GTValues.XMAS.get() ? GTGuiTextures.GREGTECH_LOGO_XMAS : GTGuiTextures.GREGTECH_LOGO)
.build();

public static final GTGuiTheme COVER = templateBuilder(Names.COVER)
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package gregtech.api.mui.widget;

import gregtech.api.GregTechAPI;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.RecipeMaps;
import gregtech.integration.IntegrationModule;
import gregtech.integration.jei.JustEnoughItemsModule;
import gregtech.integration.jei.recipe.RecipeMapCategory;
import gregtech.modules.GregTechModules;

import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.api.widget.Interactable;
import com.cleanroommc.modularui.widgets.ProgressWidget;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class RecipeProgressWidget extends ProgressWidget implements Interactable {

private RecipeMap<?> recipeMap;

public RecipeProgressWidget recipeMap(RecipeMap<?> recipeMap) {
this.recipeMap = recipeMap;
if (GregTechAPI.moduleManager.isModuleEnabled(GregTechModules.MODULE_JEI)) {
tooltip(t -> t.addLine(IKey.lang("gui.widget.recipeProgressWidget.default_tooltip")));
}
return this;
}

@Override
public @NotNull Result onMousePressed(int mouseButton) {
if (recipeMap == null) {
return Result.IGNORE;
}
if (mouseButton == 0 || mouseButton == 1) {
if (!GregTechAPI.moduleManager.isModuleEnabled(GregTechModules.MODULE_JEI)) {
return Result.ACCEPT;
}

Collection<RecipeMapCategory> categories = RecipeMapCategory.getCategoriesFor(recipeMap);
if (categories != null && !categories.isEmpty()) {
List<String> categoryID = new ArrayList<>();
if (recipeMap == RecipeMaps.FURNACE_RECIPES) {
categoryID.add("minecraft.smelting");
} else {
for (RecipeMapCategory category : categories) {
categoryID.add(category.getUid());
}
}

if (JustEnoughItemsModule.jeiRuntime == null) {
IntegrationModule.logger.error("GTCEu JEI integration has crashed, this is not a good thing");
return Result.ACCEPT;
}
JustEnoughItemsModule.jeiRuntime.getRecipesGui().showCategories(categoryID);
return Result.SUCCESS;
}
}
return Result.IGNORE;
}
}
3 changes: 2 additions & 1 deletion src/main/java/gregtech/api/recipes/RecipeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public RecipeMap(@NotNull String unlocalizedName, @NotNull R defaultRecipeBuilde
@NotNull RecipeMapUIFunction recipeMapUI, int maxInputs, int maxOutputs, int maxFluidInputs,
int maxFluidOutputs) {
this.unlocalizedName = unlocalizedName;
this.recipeMapUI = recipeMapUI.apply(this);

this.maxInputs = maxInputs;
this.maxFluidInputs = maxFluidInputs;
Expand All @@ -154,6 +153,8 @@ public RecipeMap(@NotNull String unlocalizedName, @NotNull R defaultRecipeBuilde
this.primaryRecipeCategory = GTRecipeCategory.create(GTValues.MODID, unlocalizedName, getTranslationKey(),
this);

this.recipeMapUI = recipeMapUI.apply(this);

defaultRecipeBuilder.setRecipeMap(this);
defaultRecipeBuilder.category(primaryRecipeCategory);
this.recipeBuilderSample = defaultRecipeBuilder;
Expand Down
Loading
Loading