Skip to content

Commit 277c8ee

Browse files
committed
HPCA component widget tooltips and remove old MUI0 methods
1 parent 2a0041d commit 277c8ee

File tree

7 files changed

+45
-75
lines changed

7 files changed

+45
-75
lines changed

src/main/java/gregtech/api/capability/IHPCAComponentHatch.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ default void setDamaged(boolean damaged) {}
5858
default UITexture getComponentIcon2() {
5959
return GTGuiTextures.HPCA_ICON_EMPTY_COMPONENT;
6060
}
61+
62+
/**
63+
* The untranslated name of the tile implementing an HPCA component
64+
*/
65+
String getTileName();
6166
}

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityHPCA.java

Lines changed: 14 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import gregtech.api.util.GTUtility;
2222
import gregtech.api.util.KeyUtil;
2323
import gregtech.api.util.RelativeDirection;
24-
import gregtech.api.util.TextComponentUtil;
2524
import gregtech.api.util.TextFormattingUtil;
2625
import gregtech.client.renderer.ICubeRenderer;
2726
import gregtech.client.renderer.texture.Textures;
@@ -89,12 +88,9 @@ public class MetaTileEntityHPCA extends MultiblockWithDisplayBase
8988

9089
private double temperature = IDLE_TEMPERATURE; // start at idle temperature
9190

92-
private final gregtech.api.gui.widgets.ProgressWidget.TimedProgressSupplier progressSupplier;
93-
9491
public MetaTileEntityHPCA(ResourceLocation metaTileEntityId) {
9592
super(metaTileEntityId);
9693
this.energyContainer = new EnergyContainerList(new ArrayList<>());
97-
this.progressSupplier = new gregtech.api.gui.widgets.ProgressWidget.TimedProgressSupplier(200, 47, false);
9894
this.hpcaHandler = new HPCAGridHandler(this);
9995
}
10096

@@ -369,7 +365,12 @@ protected MultiblockUIFactory createUIFactory() {
369365
.minElementMargin(1)
370366
.mapTo(3, 9, value -> new DynamicDrawable(() -> hpcaHandler.getComponentTexture2(value))
371367
.asWidget()
372-
// could add tooltips here showing the name of the component
368+
.tooltipAutoUpdate(true)
369+
.tooltipBuilder(tooltip -> {
370+
if (isStructureFormed()) {
371+
tooltip.addLine(hpcaHandler.getComponentKey(value));
372+
}
373+
})
373374
.size(14))));
374375
}
375376

@@ -835,76 +836,6 @@ public int getMaxCoolantDemand() {
835836
return maxCoolant;
836837
}
837838

838-
public void addInfo(List<ITextComponent> textList) {
839-
// Max Computation
840-
ITextComponent data = TextComponentUtil.stringWithColor(TextFormatting.AQUA,
841-
Integer.toString(getMaxCWUt()));
842-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
843-
"gregtech.multiblock.hpca.info_max_computation", data));
844-
845-
// Cooling
846-
TextFormatting coolingColor = getMaxCoolingAmount() < getMaxCoolingDemand() ? TextFormatting.RED :
847-
TextFormatting.GREEN;
848-
data = TextComponentUtil.stringWithColor(coolingColor, Integer.toString(getMaxCoolingDemand()));
849-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
850-
"gregtech.multiblock.hpca.info_max_cooling_demand", data));
851-
852-
data = TextComponentUtil.stringWithColor(coolingColor, Integer.toString(getMaxCoolingAmount()));
853-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
854-
"gregtech.multiblock.hpca.info_max_cooling_available", data));
855-
856-
// Coolant Required
857-
if (getMaxCoolantDemand() > 0) {
858-
data = TextComponentUtil.stringWithColor(
859-
TextFormatting.YELLOW,
860-
getMaxCoolantDemand() + "L ");
861-
ITextComponent coolantName = TextComponentUtil.translationWithColor(TextFormatting.YELLOW,
862-
"gregtech.multiblock.hpca.info_coolant_name");
863-
data.appendSibling(coolantName);
864-
} else {
865-
data = TextComponentUtil.stringWithColor(TextFormatting.GREEN, "0");
866-
}
867-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
868-
"gregtech.multiblock.hpca.info_max_coolant_required", data));
869-
870-
// Bridging
871-
if (numBridges > 0) {
872-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GREEN,
873-
"gregtech.multiblock.hpca.info_bridging_enabled"));
874-
} else {
875-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.RED,
876-
"gregtech.multiblock.hpca.info_bridging_disabled"));
877-
}
878-
}
879-
880-
public void addWarnings(List<ITextComponent> textList) {
881-
List<ITextComponent> warnings = new ArrayList<>();
882-
if (numBridges > 1) {
883-
warnings.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
884-
"gregtech.multiblock.hpca.warning_multiple_bridges"));
885-
}
886-
if (computationProviders.isEmpty()) {
887-
warnings.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
888-
"gregtech.multiblock.hpca.warning_no_computation"));
889-
}
890-
if (getMaxCoolingDemand() > getMaxCoolingAmount()) {
891-
warnings.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
892-
"gregtech.multiblock.hpca.warning_low_cooling"));
893-
}
894-
if (!warnings.isEmpty()) {
895-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.YELLOW,
896-
"gregtech.multiblock.hpca.warning_structure_header"));
897-
textList.addAll(warnings);
898-
}
899-
}
900-
901-
public void addErrors(List<ITextComponent> textList) {
902-
if (components.stream().anyMatch(IHPCAComponentHatch::isDamaged)) {
903-
textList.add(TextComponentUtil.translationWithColor(TextFormatting.RED,
904-
"gregtech.multiblock.hpca.error_damaged"));
905-
}
906-
}
907-
908839
public void addWarnings2(KeyManager keyManager) {
909840
List<IKey> warnings = new ArrayList<>();
910841
if (numBridges > 1) {
@@ -951,6 +882,14 @@ public UITexture getComponentTexture2(int index) {
951882
return components.get(index).getComponentIcon2();
952883
}
953884

885+
public IKey getComponentKey(int index) {
886+
if (components.size() <= index) {
887+
return IKey.EMPTY;
888+
}
889+
890+
return IKey.lang(components.get(index).getTileName());
891+
}
892+
954893
public void tryGatherClientComponents(World world, BlockPos pos, EnumFacing frontFacing,
955894
EnumFacing upwardsFacing, boolean flip) {
956895
EnumFacing relativeUp = RelativeDirection.UP.getRelativeFacing(frontFacing, upwardsFacing, flip);

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/hpca/MetaTileEntityHPCABridge.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,9 @@ public int getUpkeepEUt() {
6363
public boolean canBeDamaged() {
6464
return false;
6565
}
66+
67+
@Override
68+
public String getTileName() {
69+
return getMetaFullName();
70+
}
6671
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/hpca/MetaTileEntityHPCAComputation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,9 @@ public int getCoolingPerTick() {
9191
public boolean canBeDamaged() {
9292
return true;
9393
}
94+
95+
@Override
96+
public String getTileName() {
97+
return getMetaFullName();
98+
}
9499
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/hpca/MetaTileEntityHPCACooler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@ public boolean isActiveCooler() {
7777
public int getMaxCoolantPerTick() {
7878
return advanced ? 8 : 0;
7979
}
80+
81+
@Override
82+
public String getTileName() {
83+
return getMetaFullName();
84+
}
8085
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/hpca/MetaTileEntityHPCAEmpty.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ public int getUpkeepEUt() {
4444
public boolean canBeDamaged() {
4545
return false;
4646
}
47+
48+
@Override
49+
public String getTileName() {
50+
return getMetaFullName();
51+
}
4752
}

src/test/java/gregtech/common/metatileentities/multiblock/hpca/helper/HPCAComponentHatchTestImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ public boolean isBridge() {
4040
public TextureArea getComponentIcon() {
4141
return null;
4242
}
43+
44+
// not tested
45+
@Override
46+
public String getTileName() {
47+
return "";
48+
}
4349
}

0 commit comments

Comments
 (0)