Skip to content

Commit

Permalink
Merge branch 'fix/tooltip-brackets' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Jan 4, 2023
2 parents e647788 + 1809a33 commit 577efa7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/main/java/gregtech/api/enums/Materials.java
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +1467,12 @@ public Materials(
aColor);
mExtraData = aExtraData;
mMaterialList.addAll(aMaterialList);
mChemicalFormula = mMaterialList.stream()
.map(MaterialStack::toString)
.collect(Collectors.joining())
.replaceAll("_", "-");
if (mMaterialList.size() == 1) mChemicalFormula = mMaterialList.get(0).toString(true);
else
mChemicalFormula = mMaterialList.stream()
.map(MaterialStack::toString)
.collect(Collectors.joining())
.replaceAll("_", "-");

int tAmountOfComponents = 0, tMeltingPoint = 0;
for (MaterialStack tMaterial : mMaterialList) {
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/gregtech/api/objects/MaterialStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ public boolean equals(Object aObject) {

@Override
public String toString() {
return toString(false);
}

public String toString(boolean single) {
String temp1 = "", temp2 = mMaterial.getToolTip(true), temp3 = "", temp4 = "";
if (mAmount > 1) {
temp4 = GT_Utility.toSubscript(mAmount);

if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
temp1 = "(";
temp3 = ")";
}
}
return String.valueOf(
new StringBuilder().append(temp1).append(temp2).append(temp3).append(temp4));
if ((!single || mAmount > 1) && isMaterialListComplex(this)) {
temp1 = "(";
temp3 = ")";
}
return temp1 + temp2 + temp3 + temp4;
}

private boolean isMaterialListComplex(MaterialStack materialStack) {
Expand Down

0 comments on commit 577efa7

Please sign in to comment.