generated from CleanroomMC/ForgeDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Milestone
Description
I would like the ability to change the color of an IKey by calling a method directly on it. Currently, you cannot accomplish this, since IKeys do not work with String concatenation of TextFormatting color codes.
Right now, the only way to do this is by having different translations for each color variant:
tooltip.setAutoUpdate(true);
int speed = syncValue.getIntValue();
int maxSpeed = syncValue.getIntValue();
double ratio = 1.0 * speed / maxSpeed;
if (ratio < 0.4) {
tooltip.addLine(IKey.lang("key.low", speed, maxSpeed)); // Speed: §c%,d / %,d RPM
} else if (ratio < 0.8) {
tooltip.addLine(IKey.lang("key.medium", speed, maxSpeed)); // Speed: §e%,d / %,d RPM
} else {
tooltip.addLine(IKey.lang("key.high", speed, maxSpeed)); // Speed: §a%,d / %,d RPM
}Instead, I would like to be able to do something to de-duplicate translations which are identical except for their color. For example, something to this effect:
// ...
TextFormatting color;
if (ratio < 0.4) {
color = TextFormatting.RED;
} else if (ratio < 0.8) {
color = TextFormatting.YELLOW;
} else {
color = TextFormatting.GREEN;
}
tooltip.addLine(IKey.comp(
IKey.lang("key"), // Speed: %s
IKey.lang("key.rpm", speed, maxSpeed).color(color) // %,d / %,d RPM
));Metadata
Metadata
Assignees
Labels
No labels