Skip to content

Commit

Permalink
Add steam fill bars to steam machines (GTNewHorizons#3690)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
  • Loading branch information
3 people authored Dec 22, 2024
1 parent f8b1a19 commit d8e4d67
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/gregtech/api/gui/modularui/GTUITextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ public class GTUITextures {
.fullImage(GregTech.ID, "gui/progressbar/water_plasma_heater");
public static final UITexture PROGRESSBAR_UV_TREATMENT = UITexture
.fullImage(GregTech.ID, "gui/progressbar/uvtreatment");
public static final UITexture PROGRESSBAR_STEAM_FILL = UITexture
.fullImage(GregTech.ID, "gui/progressbar/steam_fill");
public static final UITexture PROGRESSBAR_STEAM_FILL_STEEL = UITexture
.fullImage(GregTech.ID, "gui/progressbar/steam_fill_steel");

public static FallbackableUITexture fallbackableProgressbar(String name, UITexture fallback) {
return new FallbackableUITexture(UITexture.fullImage(GregTech.ID, "gui/progressbar/" + name), fallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import gregtech.GTMod;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.SoundResource;
import gregtech.api.enums.SteamVariant;
import gregtech.api.gui.modularui.GTUIInfos;
import gregtech.api.gui.modularui.GTUITextures;
import gregtech.api.gui.modularui.SteamTexture;
Expand Down Expand Up @@ -1298,6 +1299,8 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont
if (!isSteampowered()) {
builder.widget(createFluidAutoOutputButton());
builder.widget(createItemAutoOutputButton());
} else {
builder.widget(createSteamProgressBar(builder));
}

BasicUIProperties uiProperties = getUIProperties();
Expand Down Expand Up @@ -1462,6 +1465,26 @@ protected CycleButtonWidget createFluidAutoOutputButton() {
.setSize(18, 18);
}

// Used for ui syncing
private long getSteamVar = 0;

protected Widget createSteamProgressBar(ModularWindow.Builder builder) {
builder.widget(new FakeSyncWidget.LongSyncer(this::getSteamVar, val -> getSteamVar = val));

return new ProgressBar().setProgress(() -> (float) getSteamVar() / maxSteamStore())
.setDirection(ProgressBar.Direction.UP)
.setTexture(
getSteamVariant() == SteamVariant.BRONZE ? GTUITextures.PROGRESSBAR_STEAM_FILL
: GTUITextures.PROGRESSBAR_STEAM_FILL_STEEL,
54)
.setSynced(true, false)
.dynamicTooltip(() -> Collections.singletonList("Steam: " + getSteamVar + "/" + maxSteamStore() + "L"))
.setTooltipShowUpDelay(TOOLTIP_DELAY)
.setUpdateTooltipEveryTick(true)
.setSize(10, 54)
.setPos(7, 24);
}

protected Widget setNEITransferRect(Widget widget, String transferRectID) {
if (GTUtility.isStringInvalid(transferRectID)) {
return widget;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d8e4d67

Please sign in to comment.