mirror of
https://github.com/Shiewk/Widgets.git
synced 2026-04-28 11:34:17 +02:00
Option to hide label on TPS widget
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
public class TPSWidget extends BasicTextWidget {
|
||||
public TPSWidget(Identifier id) {
|
||||
super(id, List.of(
|
||||
new ToggleWidgetSetting("show_label", Text.translatable("widgets.widgets.tps.showLabel"), true),
|
||||
new ToggleWidgetSetting("dynamic_color", Text.translatable("widgets.widgets.tps.dynamicColor"), true)
|
||||
));
|
||||
getSettings().optionById("textcolor").setShowCondition(() -> !this.dynamicColor);
|
||||
@@ -26,6 +27,7 @@ public class TPSWidget extends BasicTextWidget {
|
||||
private static int updatesSinceWorldChange = 0;
|
||||
|
||||
private boolean dynamicColor = true;
|
||||
private boolean showLabel = true;
|
||||
|
||||
public static void worldChanged(){
|
||||
updatesSinceWorldChange = 0;
|
||||
@@ -72,11 +74,19 @@ public class TPSWidget extends BasicTextWidget {
|
||||
|
||||
private void updateTPS(float tps, float targetTickRate, boolean loadingFinished) {
|
||||
if (!loadingFinished){
|
||||
if (showLabel){
|
||||
this.renderText = Text.literal(Text.translatable("widgets.widgets.tps.tps", "???").getString());
|
||||
} else {
|
||||
this.renderText = Text.literal("???");
|
||||
}
|
||||
if (dynamicColor) this.textColor = 0x00ff00;
|
||||
} else {
|
||||
tps = Math.round(tps * 10f) / 10f;
|
||||
if (showLabel){
|
||||
this.renderText = Text.literal(Text.translatable("widgets.widgets.tps.tps", tps).getString());
|
||||
} else {
|
||||
this.renderText = Text.literal(String.valueOf(tps));
|
||||
}
|
||||
if (dynamicColor){
|
||||
if (tps >= targetTickRate * 0.990){
|
||||
this.textColor = 0x00ff00;
|
||||
@@ -108,5 +118,6 @@ public class TPSWidget extends BasicTextWidget {
|
||||
public void onSettingsChanged(WidgetSettings settings) {
|
||||
super.onSettingsChanged(settings);
|
||||
this.dynamicColor = ((ToggleWidgetSetting) settings.optionById("dynamic_color")).getValue();
|
||||
this.showLabel = ((ToggleWidgetSetting) settings.optionById("show_label")).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,5 +91,6 @@
|
||||
"widgets.widgets.tps.tps": "%s TPS",
|
||||
"widgets.widgets.tps.dynamicColor": "Farbe dynamisch anzeigen",
|
||||
"widgets.widgets.tps": "TPS",
|
||||
"widgets.widgets.tps.description": "Zeigt die TPS im Einzelspielermodus an oder schätzt die TPS im Mehrspielermodus"
|
||||
"widgets.widgets.tps.description": "Zeigt die TPS im Einzelspielermodus an oder schätzt die TPS im Mehrspielermodus",
|
||||
"widgets.widgets.tps.showLabel": "Beschriftung anzeigen"
|
||||
}
|
||||
|
||||
@@ -91,5 +91,6 @@
|
||||
"widgets.widgets.tps.tps": "%s TPS",
|
||||
"widgets.widgets.tps.dynamicColor": "Dynamic Color",
|
||||
"widgets.widgets.tps": "TPS",
|
||||
"widgets.widgets.tps.description": "Shows the current TPS when in singleplayer or estimates server TPS when in multiplayer"
|
||||
"widgets.widgets.tps.description": "Shows the current TPS when in singleplayer or estimates server TPS when in multiplayer",
|
||||
"widgets.widgets.tps.showLabel": "Show label"
|
||||
}
|
||||
Reference in New Issue
Block a user