Skip to content

Commit 76889b3

Browse files
committed
fix and reorganize fluid slot tooltips to match item slot tooltips
hide phantom slot controls if the slot is empty add todo
1 parent 6fbf055 commit 76889b3

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed

src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import net.minecraftforge.fluids.IFluidTank;
1818
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
1919

20+
import com.cleanroommc.modularui.api.MCHelper;
2021
import com.cleanroommc.modularui.api.drawable.IKey;
2122
import com.cleanroommc.modularui.network.NetworkUtils;
2223
import com.cleanroommc.modularui.screen.RichTooltip;
@@ -247,31 +248,25 @@ public int getFluidAmount() {
247248
}
248249

249250
public void handleTooltip(@NotNull RichTooltip tooltip) {
250-
IKey nameKey = getFluidNameKey();
251-
252-
if (nameKey != IKey.EMPTY) {
253-
tooltip.addLine(nameKey);
254-
}
255-
256-
if (showAmountInTooltip()) {
257-
tooltip.addLine(IKey.lang("gregtech.fluid.amount", getFluidAmount(), getCapacity()));
258-
}
259-
260-
if (isPhantom() && showAmountInTooltip()) {
261-
tooltip.addLine(IKey.lang("modularui.fluid.phantom.control"));
262-
}
263-
264251
FluidStack tankFluid = getFluid();
265-
if (tankFluid == null) {
252+
if (GTUtility.isEmpty(tankFluid)) {
266253
tankFluid = getLockedFluid();
267254
}
268255

269-
if (tankFluid != null) {
256+
if (!GTUtility.isEmpty(tankFluid)) {
257+
tooltip.addLine(KeyUtil.fluid(tankFluid));
258+
270259
FluidTooltipUtil.handleFluidTooltip(tooltip, tankFluid);
271260

272261
if (showAmountInTooltip()) {
273262
FluidTooltipUtil.addIngotMolFluidTooltip(tooltip, tankFluid);
274263
}
264+
265+
tooltip.addLine(MCHelper.getFluidModName(tankFluid));
266+
267+
if (isPhantom() && showAmountInTooltip()) {
268+
tooltip.addLine(IKey.lang("modularui.fluid.phantom.control"));
269+
}
275270
}
276271
}
277272

src/main/java/gregtech/api/util/FluidTooltipUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static void addIngotMolFluidTooltip(@NotNull RichTooltip tooltip, @NotNul
142142
if (extra != 0) {
143143
fluidAmount += String.format(" + %d L", extra);
144144
}
145-
tooltip.add(TextFormatting.GRAY + LocalizationUtils.format("gregtech.gui.amount_raw") + fluidAmount);
145+
tooltip.addLine(TextFormatting.GRAY + LocalizationUtils.format("gregtech.gui.amount_raw") + fluidAmount);
146146
}
147147
}
148148
}

src/main/java/gregtech/common/covers/filter/SimpleItemFilter.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,20 @@ public void initUI(Consumer<gregtech.api.gui.Widget> widgetGroup) {
127127
markDirty();
128128
}
129129
}))
130-
.tooltip(tooltip -> {
131-
tooltip.setAutoUpdate(true);
132-
tooltip.textColor(Color.GREY.main);
133-
})
130+
.tooltipAutoUpdate(true)
131+
.tooltipTextColor(Color.GREY.main)
134132
.tooltipBuilder(tooltip -> {
135133
if (dirtyNotifiable instanceof CoverRoboticArm coverArm &&
136134
coverArm.getTransferMode() != TransferMode.TRANSFER_ANY ||
137135
dirtyNotifiable instanceof CoverItemVoidingAdvanced coverItem &&
138136
coverItem.getVoidingMode() != VoidingMode.VOID_ANY) {
139-
tooltip.addLine(IKey.lang("cover.item_filter.config_amount"));
140137
int count = this.filterReader.getTagAt(index)
141138
.getInteger(SimpleItemFilterReader.COUNT);
142-
if (count > 0)
139+
if (count > 0) {
140+
tooltip.addLine(IKey.lang("cover.item_filter.config_amount"));
143141
tooltip.addLine(
144142
IKey.str("Count: %s", TextFormattingUtil.formatNumbers(count)));
143+
}
145144
}
146145
}))
147146
.build().marginRight(4))

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFluidHatch.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager,
327327
.pos(124, 62))
328328

329329
// common ui
330+
// todo split up these lines into their own widgets and use a scrolling text widget for the name
330331
.child(new RichTextWidget()
331332
.size(81 - 6, (isExportHatch ? 46 : 55) - 8)
332333
// .padding(3, 4)

src/main/java/gregtech/common/mui/widget/GTFluidSlot.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public final class GTFluidSlot extends Widget<GTFluidSlot> implements Interactab
3636

3737
public GTFluidSlot() {
3838
tooltip().titleMargin();
39+
tooltipBuilder(tooltip -> {
40+
if (isSynced()) {
41+
syncHandler.handleTooltip(tooltip);
42+
}
43+
});
3944
}
4045

4146
public static GTFluidSyncHandler sync(IFluidTank tank) {
@@ -50,8 +55,6 @@ public void onInit() {
5055
if (syncHandler.canLockFluid() || syncHandler.isPhantom()) {
5156
getContext().getRecipeViewerSettings().addGhostIngredientSlot(this);
5257
}
53-
tooltipBuilder(syncHandler::handleTooltip);
54-
syncHandler.setChangeConsumer($ -> markTooltipDirty());
5558
}
5659

5760
public GTFluidSlot syncHandler(IFluidTank fluidTank) {
@@ -60,7 +63,7 @@ public GTFluidSlot syncHandler(IFluidTank fluidTank) {
6063

6164
public GTFluidSlot syncHandler(GTFluidSyncHandler syncHandler) {
6265
setSyncHandler(syncHandler);
63-
this.syncHandler = syncHandler;
66+
syncHandler.setChangeConsumer($ -> markTooltipDirty());
6467
return this;
6568
}
6669

@@ -73,6 +76,12 @@ public boolean isValidSyncHandler(SyncHandler syncHandler) {
7376
return syncHandler instanceof GTFluidSyncHandler;
7477
}
7578

79+
@Override
80+
protected void setSyncHandler(@Nullable SyncHandler syncHandler) {
81+
super.setSyncHandler(syncHandler);
82+
this.syncHandler = (GTFluidSyncHandler) syncHandler;
83+
}
84+
7685
@Override
7786
public void draw(ModularGuiContext context, WidgetThemeEntry<?> widgetTheme) {
7887
FluidStack content = this.syncHandler.getFluid();

0 commit comments

Comments
 (0)