Files
uniqlone/scenes/current_time_screen/current_time_screen.gd
T

38 lines
1.2 KiB
GDScript

extends HBoxContainer
onready var time_display = $VBoxContainer/time_display
onready var weather_display = $VBoxContainer/weather_display
onready var location_display = $VBoxContainer/location_display
onready var temperature_display = $VBoxContainer/temperature_display
onready var audio = $VBoxContainer/audio
func _ready():
Config.connect("changed", self, '_on_config_changed')
_on_config_changed()
func _on_config_changed():
$"%location_display".text = Config.flags.location
$"%time_display".use_12_hours = Config.flags.use_12_hour_clock
$"%temperature_display".show_celsius = Config.flags.show_celsius
$"%temperature_display".show_fahrenheit = Config.flags.show_fahrenheit
func hourly_weather_update(json):
var WC = Constants.WEATHER.UNKNOWN
var temp = 0.0
if json != null:
WC = json['current']['condition']['code']
temp = json['current']['temp_c']
var weather = Constants.code_to_weather(WC)
temperature_display.set_degrees_celsius(temp)
temperature_display.temperature_unknown = weather == Constants.WEATHER.UNKNOWN
weather_display.set_weather(weather)
func minute_timer_update(time):
time_display.set_moment(Moment.new(time['hour'], time['minute']))
time_display.use_12_hours = Config.flags.use_12_hour_clock