initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
extends BaseWidgetNode
|
||||
class_name SpeedWidgetNode
|
||||
|
||||
var K2MI = 0.6213712
|
||||
|
||||
var speed_kmh: float
|
||||
var speed_mph: float
|
||||
var label_node: Label
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
label_node = get_node("VBoxContainer/SpeedLabel")
|
||||
SensorSignals.speed_updated.connect(_on_speed_updated)
|
||||
|
||||
func _on_speed_updated(ip_address: String, pnt_speed_kmh: float):
|
||||
speed_kmh = pnt_speed_kmh
|
||||
speed_mph = speed_kmh * K2MI
|
||||
var display_speed: int = 0
|
||||
if speed_mph >= 1:
|
||||
display_speed = int(round(speed_mph))
|
||||
label_node.text = str(display_speed)
|
||||
@@ -0,0 +1 @@
|
||||
uid://s6pwa5oevfwf
|
||||
@@ -0,0 +1,36 @@
|
||||
[gd_scene format=3 uid="uid://c71ads44rsa4u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://s6pwa5oevfwf" path="res://widgets/speed/scripts/speed_widget_node.gd" id="1_yqqoq"]
|
||||
[ext_resource type="Script" uid="uid://cr4y57bw6jfd1" path="res://MoveableControl.gd" id="2_383ed"]
|
||||
|
||||
[node name="SpeedWidget" type="Node2D" unique_id=186354912]
|
||||
script = ExtResource("1_yqqoq")
|
||||
metadata/_custom_type_script = "uid://s6pwa5oevfwf"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=596189086]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="SpeedLabel" type="Label" parent="VBoxContainer" unique_id=2101712075]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 48
|
||||
text = "10"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="UnitLabel" type="Label" parent="VBoxContainer" unique_id=123505815]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "MPH"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="MovableControl" type="Control" parent="." unique_id=805495128 node_paths=PackedStringArray("move_target")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 145.0
|
||||
offset_bottom = 197.0
|
||||
mouse_filter = 1
|
||||
script = ExtResource("2_383ed")
|
||||
move_target = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://cr4y57bw6jfd1"
|
||||
Reference in New Issue
Block a user