Skip to content

Commit 37af081

Browse files
committed
address todo for dynamic color tooltip
1 parent 6e486e5 commit 37af081

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeTurbine.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -392,19 +392,9 @@ yield new ProgressWidget()
392392
if (isStructureFormed()) {
393393
int speed = rotorSpeedValue.getIntValue();
394394
int maxSpeed = rotorMaxSpeedValue.getIntValue();
395-
float percent = maxSpeed == 0 ? 0 : 1.0f * speed / maxSpeed;
396-
397-
// TODO working dynamic color substitutions into IKey.lang
398-
if (percent < 0.4) {
399-
t.addLine(
400-
IKey.lang("gregtech.multiblock.turbine.rotor_speed.low", speed, maxSpeed));
401-
} else if (percent < 0.8) {
402-
t.addLine(IKey.lang("gregtech.multiblock.turbine.rotor_speed.medium", speed,
403-
maxSpeed));
404-
} else {
405-
t.addLine(
406-
IKey.lang("gregtech.multiblock.turbine.rotor_speed.high", speed, maxSpeed));
407-
}
395+
396+
t.addLine(KeyUtil.lang("gregtech.multiblock.turbine.rotor_speed",
397+
getSpeedFormat(maxSpeed, speed), speed, maxSpeed));
408398
} else {
409399
t.addLine(IKey.lang("gregtech.multiblock.invalid_structure"));
410400
}
@@ -461,6 +451,18 @@ yield new ProgressWidget()
461451
};
462452
}
463453

454+
private @NotNull TextFormatting getSpeedFormat(int maxSpeed, int speed) {
455+
float percent = maxSpeed == 0 ? 0 : 1.0f * speed / maxSpeed;
456+
457+
if (percent < 0.4) {
458+
return TextFormatting.RED;
459+
} else if (percent < 0.8) {
460+
return TextFormatting.YELLOW;
461+
} else {
462+
return TextFormatting.GREEN;
463+
}
464+
}
465+
464466
/**
465467
* @return an array of [fuel stored, fuel capacity]
466468
*/

src/main/resources/assets/gregtech/lang/en_us.lang

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5729,9 +5729,7 @@ gregtech.multiblock.large_combustion_engine.obstructed.desc=Engine Intakes must
57295729

57305730
gregtech.multiblock.turbine.fuel_amount=Fuel: %sL %s
57315731
gregtech.multiblock.turbine.fuel_needed=Consumes %s per %s ticks
5732-
gregtech.multiblock.turbine.rotor_speed.high=§7Rotor Speed: §a%,d / %,d RPM
5733-
gregtech.multiblock.turbine.rotor_speed.medium=§7Rotor Speed: §e%,d / %,d RPM
5734-
gregtech.multiblock.turbine.rotor_speed.low=§7Rotor Speed: §c%,d / %,d RPM
5732+
gregtech.multiblock.turbine.rotor_speed=§7Rotor Speed: %s%,d / %,d RPM
57355733
gregtech.multiblock.turbine.rotor_durability.high=§7Rotor Durability: §a%,d%%
57365734
gregtech.multiblock.turbine.rotor_durability.medium=§7Rotor Durability: §e%,d%%
57375735
gregtech.multiblock.turbine.rotor_durability.low=§cRotor durability low!

0 commit comments

Comments
 (0)