claude godot 4 port
This commit is contained in:
@@ -1,55 +1,71 @@
|
||||
@tool
|
||||
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
|
||||
@export var show_celsius: bool = true:
|
||||
set = set_show_celsius
|
||||
@export var show_fahrenheit: bool = true:
|
||||
set = set_show_fahrenheit
|
||||
@export var degrees_celsius: float = 0.0:
|
||||
set = set_degrees_celsius,
|
||||
get = get_degrees_celsius
|
||||
@export var degrees_fahrenheit: float = 0.0:
|
||||
set = set_degrees_fahrenheit,
|
||||
get = get_degrees_fahrenheit
|
||||
@export var temperature_unknown: bool = true:
|
||||
set = set_temperature_unknown
|
||||
|
||||
var _c: float = 0.0
|
||||
var _f: float = 0.0
|
||||
|
||||
func _ready():
|
||||
_check_slash()
|
||||
_update_text()
|
||||
|
||||
func set_temperature_unknown(new:bool):
|
||||
func set_temperature_unknown(new: bool):
|
||||
temperature_unknown = new
|
||||
_update_text()
|
||||
|
||||
func set_show_celsius(new:bool):
|
||||
func set_show_celsius(new: bool):
|
||||
show_celsius = new
|
||||
$celsius.visible = new
|
||||
$degrees.visible = new
|
||||
if has_node("celsius"):
|
||||
$celsius.visible = new
|
||||
$degrees.visible = new
|
||||
_check_slash()
|
||||
|
||||
func set_show_fahrenheit(new:bool):
|
||||
func set_show_fahrenheit(new: bool):
|
||||
show_fahrenheit = new
|
||||
$fahrenheit.visible = new
|
||||
$degrees2.visible = new
|
||||
if has_node("fahrenheit"):
|
||||
$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)
|
||||
func set_degrees_celsius(new: float):
|
||||
_c = new
|
||||
_f = Constants.celsius_to_fahrenheit(new)
|
||||
_update_text()
|
||||
|
||||
func set_degrees_fahrenheit(new:float):
|
||||
degrees_fahrenheit = new
|
||||
degrees_celsius = Constants.fahrenheit_to_celsius(degrees_fahrenheit)
|
||||
func get_degrees_celsius() -> float:
|
||||
return _c
|
||||
|
||||
func set_degrees_fahrenheit(new: float):
|
||||
_f = new
|
||||
_c = Constants.fahrenheit_to_celsius(new)
|
||||
_update_text()
|
||||
|
||||
|
||||
func get_degrees_fahrenheit() -> float:
|
||||
return _f
|
||||
|
||||
func _update_text():
|
||||
if !$celsius:
|
||||
if !has_node("celsius"):
|
||||
return
|
||||
if temperature_unknown:
|
||||
$celsius.text = '?'
|
||||
$fahrenheit.text = '?'
|
||||
else:
|
||||
$celsius.text = str(stepify(degrees_celsius, 1))
|
||||
$fahrenheit.text = str(stepify(degrees_fahrenheit, 1))
|
||||
$celsius.text = str(snapped(_c, 1))
|
||||
$fahrenheit.text = str(snapped(_f, 1))
|
||||
|
||||
func _check_slash():
|
||||
if !$slash:
|
||||
if !has_node("slash"):
|
||||
return
|
||||
$slash.visible = show_celsius and show_fahrenheit
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://b8tpwmho88e23
|
||||
@@ -1,55 +1,57 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=4 format=3]
|
||||
|
||||
[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]
|
||||
[ext_resource type="Script" path="res://scenes/temperature_display/temperature_display.gd" id="1"]
|
||||
[ext_resource type="FontVariation" path="res://assets/font/resource/temperature_bold.tres" id="2"]
|
||||
[ext_resource type="FontVariation" path="res://assets/font/resource/temperature_normal.tres" id="3"]
|
||||
|
||||
[node name="temperature_display" type="HBoxContainer"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
custom_constants/separation = -2
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
theme_override_constants/separation = -2
|
||||
alignment = 1
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ 143.0 ]
|
||||
}
|
||||
script = ExtResource("1")
|
||||
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 )
|
||||
offset_top = 2.0
|
||||
offset_right = 18.0
|
||||
offset_bottom = 38.0
|
||||
theme_override_fonts/font = ExtResource("2")
|
||||
theme_override_font_sizes/font_size = 38
|
||||
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 )
|
||||
offset_left = 16.0
|
||||
offset_top = 2.0
|
||||
offset_right = 45.0
|
||||
offset_bottom = 38.0
|
||||
theme_override_fonts/font = ExtResource("3")
|
||||
theme_override_font_sizes/font_size = 38
|
||||
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 )
|
||||
offset_left = 43.0
|
||||
offset_top = 2.0
|
||||
offset_right = 75.0
|
||||
offset_bottom = 38.0
|
||||
theme_override_fonts/font = ExtResource("3")
|
||||
theme_override_font_sizes/font_size = 38
|
||||
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 )
|
||||
offset_left = 73.0
|
||||
offset_top = 2.0
|
||||
offset_right = 91.0
|
||||
offset_bottom = 38.0
|
||||
theme_override_fonts/font = ExtResource("2")
|
||||
theme_override_font_sizes/font_size = 38
|
||||
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 )
|
||||
offset_left = 89.0
|
||||
offset_top = 2.0
|
||||
offset_right = 118.0
|
||||
offset_bottom = 38.0
|
||||
theme_override_fonts/font = ExtResource("3")
|
||||
theme_override_font_sizes/font_size = 38
|
||||
text = "°F"
|
||||
|
||||
Reference in New Issue
Block a user