initial commit, hope i didnt push any keys :P
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
extends HBoxContainer
|
||||
tool
|
||||
|
||||
export var show_celsius := true setget set_show_celsius
|
||||
export var show_fahrenheit := true setget set_show_fahrenheit
|
||||
export var degrees_celsius := 0.0 setget set_degrees_celsius
|
||||
export var degrees_fahrenheit := 0.0 setget set_degrees_fahrenheit
|
||||
export var temperature_unknown := true setget set_temperature_unknown
|
||||
|
||||
func _ready():
|
||||
_check_slash()
|
||||
_update_text()
|
||||
|
||||
func set_temperature_unknown(new:bool):
|
||||
temperature_unknown = new
|
||||
_update_text()
|
||||
|
||||
func set_show_celsius(new:bool):
|
||||
show_celsius = new
|
||||
$celsius.visible = new
|
||||
$degrees.visible = new
|
||||
_check_slash()
|
||||
|
||||
func set_show_fahrenheit(new:bool):
|
||||
show_fahrenheit = new
|
||||
$fahrenheit.visible = new
|
||||
$degrees2.visible = new
|
||||
_check_slash()
|
||||
|
||||
func set_degrees_celsius(new:float):
|
||||
degrees_celsius = new
|
||||
degrees_fahrenheit = Constants.celsius_to_fahrenheit(degrees_celsius)
|
||||
_update_text()
|
||||
|
||||
func set_degrees_fahrenheit(new:float):
|
||||
degrees_fahrenheit = new
|
||||
degrees_celsius = Constants.fahrenheit_to_celsius(degrees_fahrenheit)
|
||||
_update_text()
|
||||
|
||||
|
||||
|
||||
func _update_text():
|
||||
if !$celsius:
|
||||
return
|
||||
if temperature_unknown:
|
||||
$celsius.text = '?'
|
||||
$fahrenheit.text = '?'
|
||||
else:
|
||||
$celsius.text = str(stepify(degrees_celsius, 1))
|
||||
$fahrenheit.text = str(stepify(degrees_fahrenheit, 1))
|
||||
|
||||
func _check_slash():
|
||||
if !$slash:
|
||||
return
|
||||
$slash.visible = show_celsius and show_fahrenheit
|
||||
@@ -0,0 +1,55 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/temperature_display/temperature_display.gd" type="Script" id=1]
|
||||
[ext_resource path="res://assets/font/resource/temperature_bold.tres" type="DynamicFont" id=2]
|
||||
[ext_resource path="res://assets/font/resource/temperature_normal.tres" type="DynamicFont" id=3]
|
||||
|
||||
[node name="temperature_display" type="HBoxContainer"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
custom_constants/separation = -2
|
||||
alignment = 1
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ 143.0 ]
|
||||
}
|
||||
degrees_fahrenheit = 32.0
|
||||
|
||||
[node name="celsius" type="Label" parent="."]
|
||||
margin_top = 2.0
|
||||
margin_right = 18.0
|
||||
margin_bottom = 38.0
|
||||
custom_fonts/font = ExtResource( 2 )
|
||||
text = "?"
|
||||
|
||||
[node name="degrees" type="Label" parent="."]
|
||||
margin_left = 16.0
|
||||
margin_top = 2.0
|
||||
margin_right = 45.0
|
||||
margin_bottom = 38.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = "°C"
|
||||
|
||||
[node name="slash" type="Label" parent="."]
|
||||
margin_left = 43.0
|
||||
margin_top = 2.0
|
||||
margin_right = 75.0
|
||||
margin_bottom = 38.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = " / "
|
||||
|
||||
[node name="fahrenheit" type="Label" parent="."]
|
||||
margin_left = 73.0
|
||||
margin_top = 2.0
|
||||
margin_right = 91.0
|
||||
margin_bottom = 38.0
|
||||
custom_fonts/font = ExtResource( 2 )
|
||||
text = "?"
|
||||
|
||||
[node name="degrees2" type="Label" parent="."]
|
||||
margin_left = 89.0
|
||||
margin_top = 2.0
|
||||
margin_right = 118.0
|
||||
margin_bottom = 38.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = "°F"
|
||||
Reference in New Issue
Block a user