Skip to content

Commit

Permalink
move trifunction back to bifunction and remove panel parameter
Browse files Browse the repository at this point in the history
cleanup/add todos
  • Loading branch information
ghzdude committed Jan 30, 2025
1 parent 901c7b6 commit a82d411
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public TraceabilityPredicate autoAbilities(boolean checkEnergyIn, boolean checkM
protected MultiblockUIFactory createUIFactory() {
IntSyncValue recipeMapValue = new IntSyncValue(this::getRecipeMapIndex, this::setRecipeMapIndex);
return super.createUIFactory()
.createFlexButton((panel, syncManager, guiData) -> {
.createFlexButton((guiData, syncManager) -> {
if (getAvailableRecipeMaps() == null || getAvailableRecipeMaps().length <= 1)
return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import gregtech.api.util.JsonUtils;
import gregtech.api.util.KeyUtil;
import gregtech.api.util.TextFormattingUtil;
import gregtech.api.util.function.TriFunction;
import gregtech.common.ConfigHolder;

import net.minecraft.network.PacketBuffer;
Expand Down Expand Up @@ -47,18 +46,16 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Supplier;

public class MultiblockUIFactory {

private final MultiblockWithDisplayBase mte;
protected Consumer<Builder> displayText, warningText, errorText;
protected TriFunction<ModularPanel, PanelSyncManager, PosGuiData, IWidget> flexButton = (panel, syncManager,
posGuiData) -> null;
protected BiFunction<PosGuiData, PanelSyncManager, IWidget> flexButton = (guiData, syncManager) -> null;
private int width = 198, height = 202;
private int screenHeight = 109;
private Supplier<IWidget> customScreen;
private Consumer<List<IWidget>> childrenConsumer;

public MultiblockUIFactory(@NotNull MultiblockWithDisplayBase mte) {
Expand Down Expand Up @@ -197,7 +194,8 @@ public MultiblockUIFactory configureDisplayText(Consumer<Builder> displayText) {
* <br>
* Size will be 18x18.
*/
public MultiblockUIFactory createFlexButton(TriFunction<ModularPanel, PanelSyncManager, PosGuiData, IWidget> flexButton) {
public MultiblockUIFactory createFlexButton(
BiFunction<PosGuiData, PanelSyncManager, IWidget> flexButton) {
this.flexButton = flexButton;
return this;
}
Expand Down Expand Up @@ -296,7 +294,7 @@ protected Widget<?> createScreen(PanelSyncManager syncManager) {
@NotNull
protected Flow createButtons(@NotNull ModularPanel mainPanel, @NotNull PanelSyncManager panelSyncManager,
PosGuiData guiData) {
IWidget flexButton = this.flexButton.apply(mainPanel, panelSyncManager, guiData);
IWidget flexButton = this.flexButton.apply(guiData, panelSyncManager);
if (flexButton == null) {
flexButton = GTGuiTextures.BUTTON_NO_FLEX.asWidget()
.size(18)
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/gregtech/api/util/function/TriFunction.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ protected void configureWarningText(MultiblockUIFactory.Builder builder) {
@Override
protected MultiblockUIFactory createUIFactory() {
return super.createUIFactory()
.createFlexButton((panel, syncManager, guiData) -> {
.createFlexButton((guiData, syncManager) -> {
// todo remove cast in next mui2 version
PanelSyncHandler throttle = (PanelSyncHandler) syncManager.panel("throttle_panel",
this::makeThrottlePanel, true);

Expand All @@ -206,14 +207,14 @@ protected MultiblockUIFactory createUIFactory() {
.overlay(GTGuiTextures.FILTER_SETTINGS_OVERLAY)
// todo lang
.addTooltipLine("Configure Boiler Throttle")
// TODO make this work
.background(GTGuiTextures.BUTTON)
.onMousePressed(i -> {
if (throttle.isPanelOpen()) {
throttle.closePanel();
} else {
throttle.openPanel();
}
// todo remove this call in next mui2 version
Interactable.playButtonClickSound();
return true;
});
Expand Down

0 comments on commit a82d411

Please sign in to comment.