mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-21 20:42:12 +00:00
add formatted electron volt commands
This commit is contained in:
1 parent
cb34f8f2bc
commit
72e618fd4e
1 file changed
+19
-2
+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;
|
||||
|
||||
Reference in new issue
Block a user