From d8e4d67d790e566866f8e222f503dad1092df220 Mon Sep 17 00:00:00 2001 From: Mary <33456283+FourIsTheNumber@users.noreply.github.com> Date: Sun, 22 Dec 2024 09:43:43 -0500 Subject: [PATCH] Add steam fill bars to steam machines (#3690) Co-authored-by: Martin Robertz Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com> --- .../api/gui/modularui/GTUITextures.java | 4 +++ .../implementations/MTEBasicMachine.java | 23 ++++++++++++++++++ .../textures/gui/progressbar/steam_fill.png | Bin 0 -> 170 bytes .../gui/progressbar/steam_fill_steel.png | Bin 0 -> 160 bytes 4 files changed, 27 insertions(+) create mode 100644 src/main/resources/assets/gregtech/textures/gui/progressbar/steam_fill.png create mode 100644 src/main/resources/assets/gregtech/textures/gui/progressbar/steam_fill_steel.png diff --git a/src/main/java/gregtech/api/gui/modularui/GTUITextures.java b/src/main/java/gregtech/api/gui/modularui/GTUITextures.java index 4ea333c5011..9293b9b1fad 100644 --- a/src/main/java/gregtech/api/gui/modularui/GTUITextures.java +++ b/src/main/java/gregtech/api/gui/modularui/GTUITextures.java @@ -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); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java index 18efdb07c9b..98c27dcd329 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java @@ -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; @@ -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(); @@ -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; diff --git a/src/main/resources/assets/gregtech/textures/gui/progressbar/steam_fill.png b/src/main/resources/assets/gregtech/textures/gui/progressbar/steam_fill.png new file mode 100644 index 0000000000000000000000000000000000000000..5f2081135f96eb4c2b92753683675bfc5b338b20 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^Aa)K18;}g1ulx&0F%}28J29*~C-V}>N%3@X42ft> zz9N$H8y#ir)8?BIbFhXPv{bGeK5X~~3ItSV5^N{Lyg{K-Bk zOm*X{PJ@Y!jg1S}ujkL7yllmajzSHV^JwZ1hzRjA%=yTpT%p|N3bc>G)78&qol`;+ E0Ffm+9{>OV literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/gregtech/textures/gui/progressbar/steam_fill_steel.png b/src/main/resources/assets/gregtech/textures/gui/progressbar/steam_fill_steel.png new file mode 100644 index 0000000000000000000000000000000000000000..116370bf4ac5442eadce1d7632aa6a65a0b0907b GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^Aa)K18;}g1ulx&0F%}28J29*~C-V}>iSl%D42fuc zdu^fM0Rs-Vhx6m69ZZu^>qrv_%L~mBy8imBZR-!d#zQK1Z#}tp_1Olkq!+hxXEQcB zC