ovr-utils/ovr-utils/overlays/battery.gd

30 lines
645 B
GDScript3
Raw Normal View History

2021-05-18 10:50:01 +02:00
extends Label
var _delay = 0
func _process(delta: float) -> void:
_delay += delta
if _delay > 1:
update_text()
_delay = 0
2021-05-20 12:26:49 +02:00
2021-05-18 10:50:01 +02:00
func update_text():
2021-05-20 12:26:49 +02:00
var l = "??"
var r = "??"
2021-05-18 10:50:01 +02:00
if OverlayInit.left_id:
2021-05-20 12:26:49 +02:00
l = OverlayInit.ovr_config.get_device_battery_percentage(OverlayInit.left_id)
l = str(int(l * 100))
if OverlayInit.ovr_config.is_device_charging(OverlayInit.left_id):
l += "+"
2021-05-18 10:50:01 +02:00
if OverlayInit.right_id:
2021-05-20 12:26:49 +02:00
r = OverlayInit.ovr_config.get_device_battery_percentage(OverlayInit.right_id)
r = str(int(r * 100))
2021-05-18 10:50:01 +02:00
if OverlayInit.ovr_config.is_device_charging(OverlayInit.right_id):
r += "+"
2021-05-20 12:26:49 +02:00
text = "L: " + l + "% R: " + r + "%"