diff --git a/app/content/entities/camera/camera.gd b/app/content/entities/camera/camera.gd index cc5e6fe..a07509c 100644 --- a/app/content/entities/camera/camera.gd +++ b/app/content/entities/camera/camera.gd @@ -8,8 +8,7 @@ const Entity = preload ("../entity.gd") @onready var http_request = $HTTPRequest @onready var mesh = $MeshInstance3D @onready var refresh_timer = $RefreshTimer -@onready var button = $Button -@onready var slider = $Slider +@onready var settings = $Settings var cam_active = R.state(false) var cam_fps = R.state(10) @@ -18,23 +17,26 @@ var cam_fps = R.state(10) func _ready(): super() - button.on_button_up.connect(func(): - cam_active.value=!cam_active.value - ) - - R.bind(slider, "value", cam_fps, slider.on_value_changed) - R.effect(func(_arg): refresh_timer.wait_time=1.0 / cam_fps.value ) + remove_child(settings) + + R.effect(func(_arg): + if show_settings.value: + add_child(settings) + elif settings.is_inside_tree(): + remove_child(settings) + camera_follower.reset() + App.house.save_all_entities() + ) + R.effect(func(_arg): if cam_active.value: refresh_timer.start() - button.label="videocam" else: refresh_timer.stop() - button.label="videocam_off" ) icon.value = "photo_camera" @@ -111,4 +113,14 @@ func load_image(url: String): var texture = ImageTexture.create_from_image(image) view.texture = texture view.pixel_size = pixel_size - mesh.visible = false \ No newline at end of file + mesh.visible = false + +func get_options(): + return { + "cam_active": cam_active.value, + "cam_fps": cam_fps.value, + } + +func set_options(options): + if options.has("cam_active"): cam_active.value = options["cam_active"] + if options.has("cam_fps"): cam_fps.value = options["cam_fps"] \ No newline at end of file diff --git a/app/content/entities/camera/camera.tscn b/app/content/entities/camera/camera.tscn index 3249641..50f4d2b 100644 --- a/app/content/entities/camera/camera.tscn +++ b/app/content/entities/camera/camera.tscn @@ -2,8 +2,8 @@ [ext_resource type="Script" path="res://content/entities/camera/camera.gd" id="1_htxq3"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="2_e2u6o"] -[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_8whxu"] -[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_lfexu"] +[ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="3_j7lrc"] +[ext_resource type="PackedScene" uid="uid://dejilst6cwqvi" path="res://content/entities/camera/settings.tscn" id="3_qlnvv"] [sub_resource type="QuadMesh" id="QuadMesh_830bv"] size = Vector2(0.15, 0.15) @@ -29,19 +29,12 @@ shape = SubResource("BoxShape3D_te0pn") script = ExtResource("2_e2u6o") resizable = true +[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")] +script = ExtResource("3_j7lrc") +focus_point = NodePath("../Settings") + [node name="RefreshTimer" type="Timer" parent="."] wait_time = 0.1 -[node name="Button" parent="." instance=ExtResource("3_8whxu")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, -0.1, 0) -label = "videocam_off" -icon = true - -[node name="Slider" parent="." instance=ExtResource("4_lfexu")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.1, 0) -min = 1.0 -max = 30.0 -value = 1.0 -step = 1.0 -label_unit = "FPS" -size = Vector3(0.1, 0.02, 0.01) +[node name="Settings" parent="." instance=ExtResource("3_qlnvv")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.24, 0, 0) diff --git a/app/content/entities/camera/settings.gd b/app/content/entities/camera/settings.gd new file mode 100644 index 0000000..2ce7481 --- /dev/null +++ b/app/content/entities/camera/settings.gd @@ -0,0 +1,26 @@ +extends Node3D + +const Camera = preload ("./camera.gd") + +@onready var close_button: Button3D = $Close +@onready var id_input: Input3D = $IDInput +@onready var video_button: Button3D = $VideoButton +@onready var fps_slider: Slider3D = $FPSSlider + +var camera: Camera + +func _ready(): + camera = get_parent() + + close_button.on_button_up.connect(func(): + camera.show_settings.value=false + ) + + id_input.text = camera.entity_id + + R.effect(func(_arg): + video_button.label="videocam" if camera.cam_active.value else "videocam_off" + ) + + R.bind(video_button, "active", camera.cam_active, video_button.on_toggled) + R.bind(fps_slider, "value", camera.cam_fps, fps_slider.on_value_changed) diff --git a/app/content/entities/camera/settings.tscn b/app/content/entities/camera/settings.tscn new file mode 100644 index 0000000..ccca277 --- /dev/null +++ b/app/content/entities/camera/settings.tscn @@ -0,0 +1,98 @@ +[gd_scene load_steps=9 format=3 uid="uid://dejilst6cwqvi"] + +[ext_resource type="Script" path="res://content/entities/camera/settings.gd" id="1_1ixy6"] +[ext_resource type="PackedScene" uid="uid://dnam3fe36gg62" path="res://content/ui/components/panel/panel.tscn" id="1_myvk1"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="2_wwobq"] +[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="3_dog14"] +[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_t8xp5"] +[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="5_opf0y"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_oovyb"] +resource_local_to_scene = true +render_priority = 10 +shader = ExtResource("2_wwobq") +shader_parameter/color = Color(1, 1, 1, 0.3) +shader_parameter/border_color = Color(1, 1, 1, 1) +shader_parameter/edge_color = Color(0, 0, 0, 1) +shader_parameter/size = Vector2(7.5, 5) +shader_parameter/border_size = 0.01 +shader_parameter/border_fade_in = 0.05 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.2 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_cftc5"] +size = Vector2(0.3, 0.2) + +[node name="Settings" type="Node3D"] +script = ExtResource("1_1ixy6") + +[node name="Panel" parent="." instance=ExtResource("1_myvk1")] +material_override = SubResource("ShaderMaterial_oovyb") +mesh = SubResource("QuadMesh_cftc5") +skeleton = NodePath("../..") +size = Vector2(0.3, 0.2) + +[node name="Name" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.07, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "Camera Settings" +font_size = 24 +outline_size = 0 +horizontal_alignment = 0 + +[node name="Close" parent="." instance=ExtResource("5_opf0y")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.12, 0.07, 0) +label = "close" +icon = true + +[node name="IDLabel" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.03, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "ID:" +font_size = 18 +outline_size = 0 +horizontal_alignment = 0 + +[node name="IDInput" parent="." instance=ExtResource("3_dog14")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0.03, 0) +disabled = true + +[node name="VideoLabel" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.01, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "Video: " +font_size = 18 +outline_size = 0 +horizontal_alignment = 0 + +[node name="VideoButton" parent="." instance=ExtResource("5_opf0y")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, -0.01, 0) +label = "videocam_off" +icon = true + +[node name="FPSLabel" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.05, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "Refresh Rate: " +font_size = 18 +outline_size = 0 +horizontal_alignment = 0 + +[node name="FPSSlider" parent="." instance=ExtResource("4_t8xp5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.05, 0) +min = 1.0 +max = 30.0 +value = 1.0 +step = 1.0 +label_unit = "FPS" +size = Vector3(0.11, 0.02, 0.01) diff --git a/app/content/entities/entity.gd b/app/content/entities/entity.gd index db4015b..f31f833 100644 --- a/app/content/entities/entity.gd +++ b/app/content/entities/entity.gd @@ -1,16 +1,35 @@ extends StaticBody3D +var camera_follower: CameraFollower + @export var entity_id: String var icon = R.state("question_mark") var icon_color = R.state(Color(1, 1, 1, 1)) +var show_settings = R.state(false) func _ready(): var movable = get_node("Movable") + camera_follower = get_node_or_null("CameraFollower") + + if camera_follower == null: + camera_follower = CameraFollower.new() + add_child(camera_follower) + + R.effect(func(_args): + if show_settings.value == true: + camera_follower.enabled=true + ) if movable: movable.on_moved.connect(func(): App.house.save_all_entities() ) +func set_options(_options): + return + func get_options(): - return {} \ No newline at end of file + return {} + +func toggle_settings(): + show_settings.value = !show_settings.value \ No newline at end of file diff --git a/app/content/entities/light/light.gd b/app/content/entities/light/light.gd index 642fc0f..b32e5a2 100644 --- a/app/content/entities/light/light.gd +++ b/app/content/entities/light/light.gd @@ -8,14 +8,10 @@ const Entity = preload ("../entity.gd") @onready var lightbulb = $Lightbulb @onready var slider: Slider3D = $Slider @onready var color_wheel = $ColorWheel -@onready var modes = $Modes -@onready var mode_next = $Modes/Next -@onready var mode_before = $Modes/Previous -@onready var mode_label = $Modes/Label +@onready var modes: Select3D = $Modes @onready var snap_sound = $SnapSound @onready var settings = $Settings @onready var movable = $Movable -@onready var camera_follower = $CameraFollower var active = R.state(false) var brightness = R.state(0) # 0-255 @@ -25,7 +21,6 @@ var color_wheel_supported = R.state(false) var show_brightness = R.state(true) var show_modes = R.state(true) var modes_supported = R.state(false) -var show_settings = R.state(false) # Called when the node enters the scene tree for the first time. func _ready(): @@ -74,30 +69,17 @@ func _ready(): modes_supported.value = true if stateInfo["attributes"].has("effect")&&stateInfo["attributes"]["effect"] != null: - mode_label.text = stateInfo["attributes"]["effect"] + modes.selected = stateInfo["attributes"]["effect"] - mode_next.on_button_down.connect(func(): - var index=stateInfo["attributes"]["effect_list"].find(stateInfo["attributes"]["effect"]) - if index == - 1: - index=0 - else: - index=(index + 1) % stateInfo["attributes"]["effect_list"].size() + var options = {} - mode_label.text=stateInfo["attributes"]["effect_list"][index] + for effect in stateInfo["attributes"]["effect_list"]: + options[effect] = effect - HomeApi.set_state(entity_id, "on", {"effect": stateInfo["attributes"]["effect_list"][index]}) - ) + modes.options = options - mode_before.on_button_down.connect(func(): - var index=stateInfo["attributes"]["effect_list"].find(stateInfo["attributes"]["effect"]) - if index == - 1: - index=0 - else: - index=(index - 1) % stateInfo["attributes"]["effect_list"].size() - - mode_label.text=stateInfo["attributes"]["effect_list"][index] - - HomeApi.set_state(entity_id, "on", {"effect": stateInfo["attributes"]["effect_list"][index]}) + modes.on_select.connect(func(option): + HomeApi.set_state(entity_id, "on", {"effect": option}) ) if stateInfo.has("attributes")&&stateInfo["attributes"].has("supported_color_modes")&&stateInfo["attributes"]["supported_color_modes"].has("rgb"): @@ -168,13 +150,6 @@ func quick_action(): func _toggle(): HomeApi.set_state(entity_id, "off" if active.value else "on") -func toggle_settings(): - if show_settings.value == false: - show_settings.value = true - camera_follower.enabled = true - else: - show_settings.value = false - func get_options(): return { "color_wheel": show_color_wheel.value, @@ -183,6 +158,6 @@ func get_options(): } func set_options(options): - show_color_wheel.value = options["color_wheel"] - show_brightness.value = options["brightness"] - show_modes.value = options["modes"] \ No newline at end of file + if options.has("color_wheel"): show_color_wheel.value = options["color_wheel"] + if options.has("brightness"): show_brightness.value = options["brightness"] + if options.has("modes"): show_modes.value = options["modes"] \ No newline at end of file diff --git a/app/content/entities/light/light.tscn b/app/content/entities/light/light.tscn index 0019344..fc9e230 100644 --- a/app/content/entities/light/light.tscn +++ b/app/content/entities/light/light.tscn @@ -1,12 +1,12 @@ -[gd_scene load_steps=11 format=3 uid="uid://cw86rc42dv2d8"] +[gd_scene load_steps=11 format=3 uid="uid://4smofj8ou0g7"] [ext_resource type="Script" path="res://content/entities/light/light.gd" id="1_ykxy3"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_4sfxb"] [ext_resource type="Material" uid="uid://vce66e7sbc3n" path="res://content/entities/light/light_on.tres" id="5_50gph"] [ext_resource type="PackedScene" uid="uid://chrjqr4l7atrc" path="res://content/ui/components/color_wheel/color_wheel.tscn" id="5_qj75k"] [ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="6_mhjlm"] +[ext_resource type="PackedScene" uid="uid://wgnowarejk5y" path="res://content/ui/components/select/select.tscn" id="7_wbegr"] [ext_resource type="AudioStream" uid="uid://du7ur0lu28cvn" path="res://assets/sound/finger-snap.mp3" id="8_3togy"] -[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="8_nhcff"] [ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="9_a7u7m"] [ext_resource type="PackedScene" uid="uid://de34yde00ngkv" path="res://content/entities/light/settings.tscn" id="10_su84f"] @@ -24,6 +24,11 @@ shape = SubResource("SphereShape3D_ukj14") script = ExtResource("4_4sfxb") resizable = true +[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")] +script = ExtResource("9_a7u7m") +enabled = false +focus_point = NodePath("../Settings") + [node name="Lightbulb" type="CSGCombiner3D" parent="."] transform = Transform3D(1, 9.69949e-05, 0.000589194, -9.77749e-05, 0.999999, 0.00135802, -0.000589065, -0.00135808, 0.999999, 0, 0, 0) material_override = ExtResource("5_50gph") @@ -50,37 +55,12 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.15, 0, 0) color = Color(0, 0.616667, 1, 1) size = Vector3(0.15, 0.2, 0.01) -[node name="Modes" type="Node3D" parent="."] +[node name="Modes" parent="." instance=ExtResource("7_wbegr")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.11, 0) -[node name="Next" parent="Modes" instance=ExtResource("8_nhcff")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.04, 0, 0) -label = "navigate_next" -icon = true - -[node name="Previous" parent="Modes" instance=ExtResource("8_nhcff")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.1, 0, 0) -label = "navigate_before" -icon = true - -[node name="Label" type="Label3D" parent="Modes"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.01, 0, 0) -pixel_size = 0.001 -text = "Default" -horizontal_alignment = 0 - [node name="SnapSound" type="AudioStreamPlayer" parent="."] stream = ExtResource("8_3togy") volume_db = -20.0 -[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")] -script = ExtResource("9_a7u7m") -enabled = false -focus_point = NodePath("../FocusPoint") - -[node name="FocusPoint" type="Marker3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29, 0, 0) -gizmo_extents = 0.1 - [node name="Settings" parent="." instance=ExtResource("10_su84f")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29, 0, 0) diff --git a/app/content/entities/line_chart/line_chart.gd b/app/content/entities/line_chart/line_chart.gd index 1fb7627..9906f4f 100644 --- a/app/content/entities/line_chart/line_chart.gd +++ b/app/content/entities/line_chart/line_chart.gd @@ -5,14 +5,35 @@ const Entity = preload ("../entity.gd") @onready var line_chart = $LineChart @onready var timer = $Timer @onready var label = $Label3D +@onready var settings = $Settings + +enum Duration { + ONE_HOUR, + ONE_DAY, + ONE_WEEK, + ONE_MONTH, + ONE_YEAR +} + +var duration = R.state(Duration.ONE_DAY) func _ready(): super() icon.value = "finance" - label.text = entity_id + remove_child(settings) + + R.effect(func(_arg): + if show_settings.value: + add_child(settings) + elif settings.is_inside_tree(): + remove_child(settings) + camera_follower.reset() + App.house.save_all_entities() + ) + if HomeApi.has_connected() == false: await HomeApi.on_connect @@ -22,6 +43,11 @@ func _ready(): request_history() + R.effect(func(_arg): + duration.value + request_history() + ) + timer.timeout.connect(request_history) func request_history(): @@ -29,12 +55,25 @@ func request_history(): var now = Time.get_unix_time_from_datetime_dict(Time.get_datetime_dict_from_system()) - # 2 days ago - var two_days_ago = now - 2 * 24 * 60 * 60 + var date - var start = Time.get_datetime_string_from_unix_time(two_days_ago) + ".000Z" + match duration.value: + Duration.ONE_HOUR: + date = now - 2 * 60 * 60 + Duration.ONE_DAY: + date = now - 24 * 60 * 60 + Duration.ONE_WEEK: + date = now - 7 * 24 * 60 * 60 + Duration.ONE_MONTH: + date = now - 30 * 24 * 60 * 60 + Duration.ONE_YEAR: + date = now - 365 * 24 * 60 * 60 + _: + date = now - 24 * 60 * 60 - var result = await HomeApi.get_history(entity_id, start) + var start = Time.get_datetime_string_from_unix_time(date) + ".000Z" + + var result = await HomeApi.get_history(entity_id, start, "hour") if result == null: return @@ -49,3 +88,11 @@ func request_history(): func get_interface(): return "line_chart" + +func get_options(): + return { + "duration": duration.value + } + +func set_options(options: Dictionary): + if options.has("duration"): duration.value = options["duration"] \ No newline at end of file diff --git a/app/content/entities/line_chart/line_chart.tscn b/app/content/entities/line_chart/line_chart.tscn index 58b0ef5..9348ea5 100644 --- a/app/content/entities/line_chart/line_chart.tscn +++ b/app/content/entities/line_chart/line_chart.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://cltcs0gokeald"] +[gd_scene load_steps=7 format=3 uid="uid://cltcs0gokeald"] [ext_resource type="Script" path="res://content/entities/line_chart/line_chart.gd" id="1_5dxim"] [ext_resource type="PackedScene" uid="uid://cwvykoymlrrel" path="res://content/ui/components/line_chart/line_chart.tscn" id="2_k4shm"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="3_lidml"] +[ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="4_ovcs6"] +[ext_resource type="PackedScene" uid="uid://q5p1701gdfiq" path="res://content/entities/line_chart/settings.tscn" id="5_w7tql"] [sub_resource type="BoxShape3D" id="BoxShape3D_rmm5v"] size = Vector3(0.5, 0.3, 0.001) @@ -22,6 +24,10 @@ shape = SubResource("BoxShape3D_rmm5v") script = ExtResource("3_lidml") resizable = true +[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")] +script = ExtResource("4_ovcs6") +focus_point = NodePath("../Settings") + [node name="Timer" type="Timer" parent="."] wait_time = 60.0 autostart = true @@ -32,3 +38,6 @@ pixel_size = 0.001 text = "sensor.tada" font_size = 18 outline_size = 4 + +[node name="Settings" parent="." instance=ExtResource("5_w7tql")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.67, 0.15, 0) diff --git a/app/content/entities/line_chart/settings.gd b/app/content/entities/line_chart/settings.gd new file mode 100644 index 0000000..56d2032 --- /dev/null +++ b/app/content/entities/line_chart/settings.gd @@ -0,0 +1,20 @@ +extends Node3D + +const LineChart = preload ("./line_chart.gd") + +@onready var close_button: Button3D = $Close +@onready var id_input: Input3D = $IDInput +@onready var duration_select: Select3D = $DurationSelect + +var line_chart: LineChart + +func _ready(): + line_chart = get_parent() + + close_button.on_button_up.connect(func(): + line_chart.show_settings.value=false + ) + + id_input.text = line_chart.entity_id + + R.bind(duration_select, "selected", line_chart.duration, duration_select.on_select) \ No newline at end of file diff --git a/app/content/entities/line_chart/settings.tscn b/app/content/entities/line_chart/settings.tscn new file mode 100644 index 0000000..3485dc9 --- /dev/null +++ b/app/content/entities/line_chart/settings.tscn @@ -0,0 +1,85 @@ +[gd_scene load_steps=9 format=3 uid="uid://q5p1701gdfiq"] + +[ext_resource type="Script" path="res://content/entities/line_chart/settings.gd" id="1_xxfkt"] +[ext_resource type="PackedScene" uid="uid://dnam3fe36gg62" path="res://content/ui/components/panel/panel.tscn" id="2_4g761"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_vjmg5"] +[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_oroek"] +[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="5_ecnnd"] +[ext_resource type="PackedScene" uid="uid://wgnowarejk5y" path="res://content/ui/components/select/select.tscn" id="6_egqee"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_boysj"] +resource_local_to_scene = true +render_priority = 10 +shader = ExtResource("3_vjmg5") +shader_parameter/color = Color(1, 1, 1, 0.3) +shader_parameter/border_color = Color(1, 1, 1, 1) +shader_parameter/edge_color = Color(0, 0, 0, 1) +shader_parameter/size = Vector2(7.5, 5) +shader_parameter/border_size = 0.01 +shader_parameter/border_fade_in = 0.05 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.2 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_e21ey"] +size = Vector2(0.3, 0.2) + +[node name="Settings" type="Node3D"] +script = ExtResource("1_xxfkt") + +[node name="Panel" parent="." instance=ExtResource("2_4g761")] +material_override = SubResource("ShaderMaterial_boysj") +mesh = SubResource("QuadMesh_e21ey") +skeleton = NodePath("../..") +size = Vector2(0.3, 0.2) + +[node name="Name" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.07, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "Chart Settings" +font_size = 24 +outline_size = 0 +horizontal_alignment = 0 + +[node name="Close" parent="." instance=ExtResource("4_oroek")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.12, 0.07, 0) +label = "close" +icon = true + +[node name="IDLabel" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.03, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "ID:" +font_size = 18 +outline_size = 0 +horizontal_alignment = 0 + +[node name="IDInput" parent="." instance=ExtResource("5_ecnnd")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0.03, 0) +disabled = true + +[node name="VideoLabel" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.01, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "Duration:" +font_size = 18 +outline_size = 0 +horizontal_alignment = 0 + +[node name="DurationSelect" parent="." instance=ExtResource("6_egqee")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.01, 0) +options = { +0: "Last Hour", +1: "Last Day", +2: "Last Week", +3: "Last Month", +4: "Last Year" +} +size = Vector3(0.16, 0.03, 0.01) diff --git a/app/content/main.tscn b/app/content/main.tscn index 489332d..97cb486 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://eecv28y6jxk4"] +[gd_scene load_steps=14 format=3 uid="uid://eecv28y6jxk4"] [ext_resource type="PackedScene" uid="uid://clc5dre31iskm" path="res://addons/godot-xr-tools/xr/start_xr.tscn" id="1_i4c04"] [ext_resource type="Script" path="res://content/main.gd" id="1_uvrd4"] @@ -12,6 +12,7 @@ [ext_resource type="Script" path="res://lib/utils/screenshot.gd" id="12_e13ym"] [ext_resource type="PackedScene" uid="uid://ds60i5n211hi3" path="res://content/system/miniature/miniature.tscn" id="12_lmxhs"] [ext_resource type="PackedScene" uid="uid://bhyddd1f0ry1x" path="res://content/ui/onboarding/onboarding.tscn" id="12_uq2nj"] +[ext_resource type="PackedScene" uid="uid://lrehk38exd5n" path="res://content/system/keyboard/keyboard.tscn" id="13_kylpi"] [node name="Main" type="Node3D"] script = ExtResource("1_uvrd4") @@ -25,6 +26,7 @@ visible = false shadow_enabled = true [node name="StartXR" parent="." instance=ExtResource("1_i4c04")] +render_target_size_multiplier = 1.5 enable_passthrough = true [node name="XROrigin3D" type="XROrigin3D" parent="."] @@ -57,3 +59,6 @@ transform = Transform3D(1, -1.39636e-11, 0, 4.42413e-11, 1, 0, 0, 0, 1, -0.57679 [node name="Screenshot" type="Node" parent="."] script = ExtResource("12_e13ym") + +[node name="Keyboard" parent="." instance=ExtResource("13_kylpi")] +transform = Transform3D(0.5, 0, 0, 0, 0.237697, 0.439887, 0, -0.439887, 0.237697, -0.0241798, 0.452996, -0.531271) diff --git a/app/content/system/assist/chat.gd b/app/content/system/assist/chat.gd index be46121..954fa22 100644 --- a/app/content/system/assist/chat.gd +++ b/app/content/system/assist/chat.gd @@ -15,7 +15,7 @@ const FontTools = preload ("res://lib/utils/font_tools.gd") if !is_inside_tree(): return label.text = text - var text_width = FontTools.get_font_size(label).x + var text_width = FontTools.get_label_size(label).x var offset = (text_width - base_width) / 0.2 diff --git a/app/content/system/keyboard/keyboard.gd b/app/content/system/keyboard/keyboard.gd index ac8ae7b..6315662 100644 --- a/app/content/system/keyboard/keyboard.gd +++ b/app/content/system/keyboard/keyboard.gd @@ -20,9 +20,12 @@ var caps = false: update_labels() func _ready(): - get_parent().remove_child.call_deferred(self) - _create_keys() + + if Engine.is_editor_hint(): + return + get_parent().remove_child.call_deferred(self) + _prepare_keyboard_spawn() _connect_key_events() diff --git a/app/content/system/miniature/miniature.tscn b/app/content/system/miniature/miniature.tscn index 213d16e..cf3f350 100644 --- a/app/content/system/miniature/miniature.tscn +++ b/app/content/system/miniature/miniature.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=9 format=3 uid="uid://ds60i5n211hi3"] +[gd_scene load_steps=7 format=3 uid="uid://ds60i5n211hi3"] [ext_resource type="Script" path="res://content/system/miniature/miniature.gd" id="1_b53yn"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="2_x7oed"] [ext_resource type="Script" path="res://content/system/miniature/entity_select.gd" id="3_tgpny"] -[ext_resource type="Material" uid="uid://bcfcough6ucvc" path="res://content/system/miniature/mini_wall.tres" id="4_be66c"] [sub_resource type="BoxShape3D" id="BoxShape3D_bckw3"] @@ -16,8 +15,6 @@ albedo_color = Color(0.404, 0.22, 0.627, 0.5) radius = 0.3 height = 1.75 -[sub_resource type="QuadMesh" id="QuadMesh_4asi8"] - [node name="Miniature" type="Node3D"] script = ExtResource("1_b53yn") @@ -46,8 +43,3 @@ mesh = SubResource("CapsuleMesh_f3avi") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.757576, 0) gizmo_extents = 0.1 script = ExtResource("3_tgpny") - -[node name="MeshInstance3D" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.92, 0, 0) -material_override = ExtResource("4_be66c") -mesh = SubResource("QuadMesh_4asi8") diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index 8dd9d2b..b26b971 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -5,7 +5,7 @@ [ext_resource type="Script" path="res://content/ui/components/panel/panel.gd" id="3_skm86"] [ext_resource type="AudioStream" uid="uid://c1yu80uj3fsn7" path="res://assets/sound/click.wav" id="4_51sb0"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_syops"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_w8rdk"] resource_local_to_scene = true render_priority = 10 shader = ExtResource("2_db5by") @@ -20,7 +20,7 @@ shader_parameter/corner_radius = 0.2 shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 -[sub_resource type="QuadMesh" id="QuadMesh_btecp"] +[sub_resource type="QuadMesh" id="QuadMesh_6niqb"] size = Vector2(0.04, 0.04) [sub_resource type="BoxShape3D" id="BoxShape3D_xwopm"] @@ -43,8 +43,8 @@ collision_mask = 0 [node name="Panel3D" type="MeshInstance3D" parent="Body"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) -material_override = SubResource("ShaderMaterial_syops") -mesh = SubResource("QuadMesh_btecp") +material_override = SubResource("ShaderMaterial_w8rdk") +mesh = SubResource("QuadMesh_6niqb") skeleton = NodePath("../..") script = ExtResource("3_skm86") size = Vector2(0.04, 0.04) diff --git a/app/content/ui/components/input/input.tscn b/app/content/ui/components/input/input.tscn index 3357290..ebe4c9c 100644 --- a/app/content/ui/components/input/input.tscn +++ b/app/content/ui/components/input/input.tscn @@ -5,7 +5,7 @@ [ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_nl02b"] [ext_resource type="FontFile" uid="uid://drsixxc4tmvjf" path="res://assets/fonts/Montserrat-Medium.ttf" id="4_yukbj"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_j4b8n"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_4vor6"] resource_local_to_scene = true render_priority = 10 shader = ExtResource("3_nl02b") @@ -20,7 +20,7 @@ shader_parameter/corner_radius = 0.2 shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 -[sub_resource type="QuadMesh" id="QuadMesh_ltwsx"] +[sub_resource type="QuadMesh" id="QuadMesh_dndsq"] size = Vector2(0.15, 0.03) [sub_resource type="BoxShape3D" id="BoxShape3D_x4yp8"] @@ -83,8 +83,8 @@ collision_mask = 6 [node name="Panel3D" type="MeshInstance3D" parent="Body"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) -material_override = SubResource("ShaderMaterial_j4b8n") -mesh = SubResource("QuadMesh_ltwsx") +material_override = SubResource("ShaderMaterial_4vor6") +mesh = SubResource("QuadMesh_dndsq") script = ExtResource("3_3bvrj") size = Vector2(0.15, 0.03) diff --git a/app/content/ui/components/input/text_handler.gd b/app/content/ui/components/input/text_handler.gd index 4839358..70ce758 100644 --- a/app/content/ui/components/input/text_handler.gd +++ b/app/content/ui/components/input/text_handler.gd @@ -81,7 +81,7 @@ func _calculate_text_gaps(): for i in range(text.length()): var chars = text.substr(0, i + 1) # Can't use single chars because of kerning. - var size = FontTools.get_font_size(label, chars) + var size = FontTools.get_label_size(label, chars) offsets.append(size.x) diff --git a/app/content/ui/components/label_container/label_container.gd b/app/content/ui/components/label_container/label_container.gd index 601c983..73120ea 100644 --- a/app/content/ui/components/label_container/label_container.gd +++ b/app/content/ui/components/label_container/label_container.gd @@ -28,5 +28,5 @@ func _ready(): func _update_text(): label.font_size = font_size label.text = text - var text_size = FontTools.get_font_size(label) + var text_size = FontTools.get_label_size(label) size = Vector3(text_size.x, text_size.y, 0.1) \ No newline at end of file diff --git a/app/content/ui/components/select/option.gd b/app/content/ui/components/select/option.gd new file mode 100644 index 0000000..cf3a4a4 --- /dev/null +++ b/app/content/ui/components/select/option.gd @@ -0,0 +1,34 @@ +@tool +extends Node3D + +const LabelFont = preload ("res://assets/fonts/Raleway-Medium.ttf") + +@onready var label = $Body/Label3D +@onready var collision = $Body/CollisionShape3D +@onready var area_collision = $Area3D/CollisionShape3D + +var text = "test" +var value = "" +var disabled = false: + set(value): + disabled = value + + if is_node_ready() == false: return + + collision.disabled = value + area_collision.disabled = value + +func _ready(): + label.text = text + + _update() + +func get_size() -> Vector2: + return LabelFont.get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, 10000, 18) * 0.001 + +func _update(): + var size = get_size() + collision.shape.size = Vector3(size.x, size.y, 0.004) + area_collision.shape.size = Vector3(size.x, size.y, 0.01) + collision.position = Vector3(size.x / 2, -size.y / 2, 0.002) + area_collision.position = Vector3(size.x / 2, -size.y / 2, 0.005) diff --git a/app/content/ui/components/select/option.tscn b/app/content/ui/components/select/option.tscn new file mode 100644 index 0000000..7a6a3cf --- /dev/null +++ b/app/content/ui/components/select/option.tscn @@ -0,0 +1,37 @@ +[gd_scene load_steps=5 format=3 uid="uid://c7yxuroa2pfyu"] + +[ext_resource type="FontFile" uid="uid://cs508knjj1lnw" path="res://assets/fonts/Raleway-Medium.ttf" id="1_2dk7o"] +[ext_resource type="Script" path="res://content/ui/components/select/option.gd" id="1_cdx1b"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_v323n"] +resource_local_to_scene = true +size = Vector3(0.032, 0.022, 0.004) + +[sub_resource type="BoxShape3D" id="BoxShape3D_6yqdi"] +resource_local_to_scene = true +size = Vector3(0.032, 0.022, 0.01) + +[node name="Option" type="Node3D"] +script = ExtResource("1_cdx1b") + +[node name="Body" type="StaticBody3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Body"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.016, -0.011, 0.002) +shape = SubResource("BoxShape3D_v323n") + +[node name="Label3D" type="Label3D" parent="Body"] +pixel_size = 0.001 +render_priority = 40 +text = "test" +font = ExtResource("1_2dk7o") +font_size = 18 +outline_size = 0 +horizontal_alignment = 0 +vertical_alignment = 0 + +[node name="Area3D" type="Area3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.016, -0.011, 0.005) +shape = SubResource("BoxShape3D_6yqdi") diff --git a/app/content/ui/components/select/select.gd b/app/content/ui/components/select/select.gd new file mode 100644 index 0000000..79e4072 --- /dev/null +++ b/app/content/ui/components/select/select.gd @@ -0,0 +1,138 @@ +@tool +extends Container3D +class_name Select3D + +const FontTools = preload ("res://lib/utils/font_tools.gd") +const SelectFont = preload ("res://assets/fonts/Raleway-Medium.ttf") +const OptionScene = preload ("./option.tscn") +const Option = preload ("./option.gd") + +signal on_select(value: String) + +@onready var body = $Body +@onready var panel = $Body/Panel +@onready var label = $Body/Label +@onready var icon = $Body/Icon +@onready var collision = $Body/CollisionShape3D +@onready var area_collision = $Area3D/CollisionShape3D +@onready var options_body = $Options +@onready var options_panel = $Options/Panel +@onready var options_collision = $Options/CollisionShape3D + +@export var options: Dictionary = {}: + set(value): + options = value + + if is_node_ready() == false: return + + _update_options() +@export var selected: Variant = null: + set(value): + if selected != value: + on_select.emit(value) + + selected = value + + if is_node_ready() == false: return + + _update() + +@export var mandatory: bool = true + +@export var open: bool = false: + set(value): + if open == value: return + + open = value + + if is_node_ready() == false: return + + _update_options_visible() +var _options_list = [] + +func _ready(): + _update() + _update_options() + _update_options_visible() + +func _on_focus_out(_event: EventFocus): + open = false + +func _on_press_up(event: EventPointer): + if event.target == body: + open = !open + + if event.target.get_parent() is Option: + selected = event.target.get_parent().value + open = false + +func _on_touch_leave(event: EventTouch): + if event.target == body: + open = !open + + if event.target.get_parent() is Option: + selected = event.target.get_parent().value + open = false + +func _update(): + if selected == null||options == null||options.has(selected) == false: + label.text = "Select..." + else: + label.text = options[selected] + + label.position = Vector3( - size.x / 2 + 0.01, 0, 0.01) + icon.position = Vector3(size.x / 2, 0, 0.01) + + panel.size = Vector2(size.x, size.y) + collision.shape.size = Vector3(size.x, size.y, 0.01) + collision.position = Vector3(0, 0, 0.005) + area_collision.shape.size = Vector3(size.x, size.y, 0.01) + area_collision.position = Vector3(0, 0, 0.015) + +func _update_options_visible(): + options_body.visible = open + options_collision.disabled = !open + + icon.text = "arrow_drop_up" if open else "arrow_drop_down" + + for option in _options_list: + option.disabled = !open + +func _update_options(): + for option in _options_list: + options_body.remove_child(option) + option.queue_free() + + _options_list.clear() + + var total_size = Vector2(0, 0) + + var display_options = options + + if mandatory == false: + display_options[null] = "Deselect" + + var keys = display_options.keys() + keys.sort() + + for i in range(keys.size()): + var key = keys[i] + var option = OptionScene.instantiate() + option.value = key + option.text = display_options[key] + + options_body.add_child(option) + _options_list.append(option) + + var size = option.get_size() + size.y += 0.01 + total_size = Vector2(max(total_size.x, size.x), total_size.y + size.y) + + option.position = Vector3(0.01, -i * size.y - 0.01, 0) + + total_size += Vector2(0.02, 0.01) + options_panel.size = total_size + options_panel.position = Vector3(total_size.x / 2, -total_size.y / 2, 0) + options_body.position = Vector3( - size.x / 2, -size.y / 2, 0.02) + options_collision.shape.size = Vector3(total_size.x, total_size.y, 0.01) + options_collision.position = Vector3(total_size.x / 2, -total_size.y / 2, -0.005) diff --git a/app/content/ui/components/select/select.tscn b/app/content/ui/components/select/select.tscn new file mode 100644 index 0000000..857e1a6 --- /dev/null +++ b/app/content/ui/components/select/select.tscn @@ -0,0 +1,120 @@ +[gd_scene load_steps=12 format=3 uid="uid://wgnowarejk5y"] + +[ext_resource type="Script" path="res://content/ui/components/select/select.gd" id="1_0yka7"] +[ext_resource type="PackedScene" uid="uid://dnam3fe36gg62" path="res://content/ui/components/panel/panel.tscn" id="2_5mspw"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_8yxox"] +[ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="4_61i7u"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_o58sw"] +resource_local_to_scene = true +render_priority = 10 +shader = ExtResource("3_8yxox") +shader_parameter/color = Color(1, 1, 1, 0.3) +shader_parameter/border_color = Color(1, 1, 1, 1) +shader_parameter/edge_color = Color(0, 0, 0, 1) +shader_parameter/size = Vector2(5, 1) +shader_parameter/border_size = 0.01 +shader_parameter/border_fade_in = 0.05 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.2 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_xblx4"] +size = Vector2(0.2, 0.04) + +[sub_resource type="BoxShape3D" id="BoxShape3D_uwnbp"] +resource_local_to_scene = true +size = Vector3(0.2, 0.04, 0.01) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_fnoxg"] +resource_local_to_scene = true +render_priority = 10 +shader = ExtResource("3_8yxox") +shader_parameter/color = Color(1, 1, 1, 0.3) +shader_parameter/border_color = Color(1, 1, 1, 1) +shader_parameter/edge_color = Color(0, 0, 0, 1) +shader_parameter/size = Vector2(0.5, 0.25) +shader_parameter/border_size = 0.01 +shader_parameter/border_fade_in = 0.05 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.2 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_6v0t1"] +size = Vector2(0.02, 0.01) + +[sub_resource type="BoxShape3D" id="BoxShape3D_cv4hj"] +resource_local_to_scene = true +size = Vector3(0.02, 0.01, 0.01) + +[sub_resource type="BoxShape3D" id="BoxShape3D_n5ty8"] +resource_local_to_scene = true +size = Vector3(0.2, 0.04, 0.01) + +[node name="Select" type="Node3D" groups=["ui_focus"]] +script = ExtResource("1_0yka7") +size = Vector3(0.2, 0.04, 0.01) + +[node name="Body" type="StaticBody3D" parent="." groups=["ui_focus_skip"]] +collision_layer = 6 +collision_mask = 0 + +[node name="Panel" parent="Body" instance=ExtResource("2_5mspw")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.01) +material_override = SubResource("ShaderMaterial_o58sw") +mesh = SubResource("QuadMesh_xblx4") +skeleton = NodePath("../..") +size = Vector2(0.2, 0.04) + +[node name="Label" type="Label3D" parent="Body"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.09, 0, 0.01) +pixel_size = 0.001 +double_sided = false +render_priority = 30 +text = "Select..." +font_size = 18 +outline_size = 0 +horizontal_alignment = 0 + +[node name="Icon" type="Label3D" parent="Body"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1, 0, 0.01) +pixel_size = 0.001 +double_sided = false +render_priority = 30 +text = "arrow_drop_down" +font = ExtResource("4_61i7u") +font_size = 30 +outline_size = 0 +horizontal_alignment = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Body"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) +shape = SubResource("BoxShape3D_uwnbp") + +[node name="Options" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.1, -0.02, 0.02) +visible = false +collision_layer = 6 +collision_mask = 0 + +[node name="Panel" parent="Options" instance=ExtResource("2_5mspw")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.005, 0) +material_override = SubResource("ShaderMaterial_fnoxg") +mesh = SubResource("QuadMesh_6v0t1") +skeleton = NodePath("../..") +size = Vector2(0.02, 0.01) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Options"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.005, -0.005) +shape = SubResource("BoxShape3D_cv4hj") +disabled = true + +[node name="Area3D" type="Area3D" parent="." groups=["ui_focus_skip"]] +collision_layer = 4 +collision_mask = 0 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.015) +shape = SubResource("BoxShape3D_n5ty8") diff --git a/app/lib/globals/event_system.gd b/app/lib/globals/event_system.gd index 866f7fd..798c020 100644 --- a/app/lib/globals/event_system.gd +++ b/app/lib/globals/event_system.gd @@ -106,6 +106,9 @@ func _handle_focus(target: Variant, event: EventBubble): if target.is_in_group("ui_focus_stop"): return true + if target == _active_node: + return true + if is_instance_valid(_active_node) == false: _active_node = null diff --git a/app/lib/globals/home_api.gd b/app/lib/globals/home_api.gd index 17a2271..ed2c1b2 100644 --- a/app/lib/globals/home_api.gd +++ b/app/lib/globals/home_api.gd @@ -146,7 +146,7 @@ func get_voice_assistant() -> VoiceAssistant: return api.get_voice_assistant() -func get_history(entity_id, start, end=null): +func get_history(entity_id, start, interval, end=null): assert(has_connected(), "Not connected") if api.has_method("get_history") == false: @@ -155,4 +155,4 @@ func get_history(entity_id, start, end=null): if groups.is_group(entity_id): return null - return await api.get_history(entity_id, start, end) + return await api.get_history(entity_id, start, interval, end) diff --git a/app/lib/home_apis/hass_ws/connection.gd b/app/lib/home_apis/hass_ws/connection.gd index 2cb2109..98ab847 100644 --- a/app/lib/home_apis/hass_ws/connection.gd +++ b/app/lib/home_apis/hass_ws/connection.gd @@ -56,7 +56,7 @@ func start(url: String, token: String) -> ConnectionError: connecting = true print("Connecting to %s" % url + "/api/websocket") - var error = socket.connect_to_url(url + "/api/websocket") + var error = socket.connect_to_url(url + "/api/websocket", TLSOptions.client_unsafe()) if error != OK: print("Error connecting to %s: %s" % [url, error]) diff --git a/app/lib/home_apis/hass_ws/handlers/history.gd b/app/lib/home_apis/hass_ws/handlers/history.gd index 283694a..80687a9 100644 --- a/app/lib/home_apis/hass_ws/handlers/history.gd +++ b/app/lib/home_apis/hass_ws/handlers/history.gd @@ -6,7 +6,7 @@ var integration_exists: bool = false func _init(hass: HASS_API): self.api = hass -func get_history(entity_id: String, start: String, end=null): +func get_history(entity_id: String, start: String, interval: String="5minute", end=null): var meta_response = await api.connection.send_request_packet({ "type": "recorder/get_statistics_metadata", "statistic_ids": [ @@ -23,7 +23,7 @@ func get_history(entity_id: String, start: String, end=null): "statistic_ids": [ entity_id ], - "period": "5minute", + "period": interval, "types": [ "state", "mean" @@ -37,5 +37,5 @@ func get_history(entity_id: String, start: String, end=null): "unit": meta_response.payload.result[0]["display_unit_of_measurement"], "has_mean": meta_response.payload.result[0]["has_mean"], "unit_class": meta_response.payload.result[0]["unit_class"], - "data": data_response.payload.result[entity_id] + "data": data_response.payload.result[entity_id] if data_response.payload.result.has(entity_id) else [] } diff --git a/app/lib/home_apis/hass_ws/hass.gd b/app/lib/home_apis/hass_ws/hass.gd index 860955b..21ec00f 100644 --- a/app/lib/home_apis/hass_ws/hass.gd +++ b/app/lib/home_apis/hass_ws/hass.gd @@ -164,5 +164,5 @@ func update_room(room: String): func get_voice_assistant(): return assist_handler -func get_history(entity_id, start, end=null): - return await history_handler.get_history(entity_id, start, end) \ No newline at end of file +func get_history(entity_id, start, interval, end=null): + return await history_handler.get_history(entity_id, start, interval, end) \ No newline at end of file diff --git a/app/lib/utils/font_tools.gd b/app/lib/utils/font_tools.gd index ff311bb..90a6370 100644 --- a/app/lib/utils/font_tools.gd +++ b/app/lib/utils/font_tools.gd @@ -1,5 +1,5 @@ ## Returns the size of a Label3D in standard units -static func get_font_size(label: Label3D, chars=null) -> Vector2: +static func get_label_size(label: Label3D, chars=null) -> Vector2: var font = label.font if font == null: @@ -7,4 +7,4 @@ static func get_font_size(label: Label3D, chars=null) -> Vector2: var size = font.get_string_size(label.text if chars == null else chars, label.horizontal_alignment, label.width, label.font_size) * label.pixel_size - return size \ No newline at end of file + return size diff --git a/app/project.godot b/app/project.godot index f390c71..d950909 100644 --- a/app/project.godot +++ b/app/project.godot @@ -29,6 +29,10 @@ EventSystem="*res://lib/globals/event_system.gd" Request="*res://lib/globals/request.gd" TouchManager="*res://lib/utils/touch/touch.gd" +[debug_draw_3d] + +settings/3d/volumetric_defaults/thickness=0.001 + [display] window/vsync/vsync_mode=0 @@ -49,6 +53,12 @@ folder_colors={ import/fbx/enabled=false +[global_group] + +ui_focus="Makes the node foucsable" +ui_focus_skip="Skip the focus check on this node" +ui_focus_stop="Stops checking for focus entirely" + [gui] theme/custom_font="res://assets/fonts/Montserrat-Medium.ttf"