add formatted electron volt commands

This commit is contained in:
Guillaume Mercier committed 2026-11-10 18:59:04 -05:00
1 parent cb34f8f2bc
commit 72e618fd4e
1 file changed
+19 -2
@@ -8,6 +8,8 @@ import com.gtnewhorizon.gtnhlib.templatedtext.command.UnitCommand;
import com.gtnewhorizon.gtnhlib.util.TextFormatUtil;
import com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil;
import java.util.function.Supplier;
public class TooltipTemplatedTextLoader extends TemplatedTextLoader {
public TooltipTemplatedTextLoader(@NotNull String style) {
@@ -31,8 +33,13 @@ public class TooltipTemplatedTextLoader extends TemplatedTextLoader {
this.addCommand(new UnitCommand(new ThemedEUCapacityFormatter()), "fmt-eu-capacity");
this.addCommand(new UnitCommand(new ThemedAmpFormatter()), "fmt-amps");
this.addCommand(new UnitCommand(new ThemedHeatFormatter()), "fmt-heat");
// TODO: make electron volt commands dynamic based on value. (rely on engineering exponential format)
// maybe do the same for time
// spotless:off
this.addCommand(new UnitCommand(new ThemedElectronVoltFormatter(NumberFormatUtil.LOC_CACHE::getUnitElectronVolt)), "fmt-electron-volt-unit");
this.addCommand(new UnitCommand(new ThemedElectronVoltFormatter(NumberFormatUtil.LOC_CACHE::getUnitKiloElectronVolt)), "fmt-KeV", "fmt-kev");
this.addCommand(new UnitCommand(new ThemedElectronVoltFormatter(NumberFormatUtil.LOC_CACHE::getUnitMegaElectronVolt)), "fmt-MeV", "fmt-mev");
this.addCommand(new UnitCommand(new ThemedElectronVoltFormatter(NumberFormatUtil.LOC_CACHE::getUnitGigaElectronVolt)), "fmt-GeV", "fmt-gev");
this.addCommand(new UnitCommand(new ThemedElectronVoltFormatter(NumberFormatUtil.LOC_CACHE::getUnitTeraElectronVolt)), "fmt-TeV", "fmt-tev");
// spotless:on
}
private static class ThemedEUThroughputFormatter extends TextFormatUtil.ThroughputUnitFormatterWithDualTheme {
@@ -78,6 +85,16 @@ public class TooltipTemplatedTextLoader extends TemplatedTextLoader {
}
}
private static class ThemedElectronVoltFormatter extends TextFormatUtil.UnitFormatterWithTheme {
public ThemedElectronVoltFormatter(@NotNull Supplier<@NotNull String> unitSupplier) {
super(
TextThemingGuidelines.TOOLTIPS::getElectronVolt,
NumberFormatUtil.LOC_CACHE::getSpacingElectronVolt,
unitSupplier);
}
}
@Override
protected String formatLine(String parsedLine) {
return TextThemingGuidelines.TOOLTIPS.getDefault() + parsedLine;