add media player settings

This commit is contained in:
Nitwel 2024-05-29 18:26:31 +02:00
parent 85ebcd3edd
commit 4a4d359773
6 changed files with 190 additions and 13 deletions

View File

@ -6,7 +6,7 @@
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_2gpr3"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="4_upyp3"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_t0vpw"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_e3jsi"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("2_m4moa")
@ -21,7 +21,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_s453u"]
[sub_resource type="QuadMesh" id="QuadMesh_bmhxb"]
size = Vector2(0.3, 0.25)
[sub_resource type="BoxShape3D" id="BoxShape3D_bu024"]
@ -34,8 +34,8 @@ script = ExtResource("1_gw2gi")
[node name="Panel" parent="." instance=ExtResource("1_78ups")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -7.45058e-09, 0)
material_override = SubResource("ShaderMaterial_t0vpw")
mesh = SubResource("QuadMesh_s453u")
material_override = SubResource("ShaderMaterial_e3jsi")
mesh = SubResource("QuadMesh_bmhxb")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.25)

View File

@ -7,7 +7,7 @@
[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_3ewpv"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_s8u61"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("3_vjmg5")
@ -22,7 +22,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_t2fh8"]
[sub_resource type="QuadMesh" id="QuadMesh_4hbc0"]
size = Vector2(0.3, 0.2)
[sub_resource type="BoxShape3D" id="BoxShape3D_53oq0"]
@ -34,8 +34,8 @@ collision_mask = 0
script = ExtResource("1_xxfkt")
[node name="Panel" parent="." instance=ExtResource("2_4g761")]
material_override = SubResource("ShaderMaterial_3ewpv")
mesh = SubResource("QuadMesh_t2fh8")
material_override = SubResource("ShaderMaterial_s8u61")
mesh = SubResource("QuadMesh_4hbc0")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.2)

View File

@ -12,14 +12,40 @@ const Entity = preload ("../entity.gd")
@onready var artist = $PlayingInfo/Artist
@onready var http_request = $PlayingInfo/HTTPRequest
@onready var slider = $Slider
@onready var settings = $Settings
var playing = false
var volume = 50
var show_volume = R.state(true)
var show_image = R.state(true)
# Called when the node enters the scene tree for the first time.
func _ready():
super()
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 show_volume.value:
add_child(slider)
else:
remove_child(slider)
)
R.effect(func(_arg):
logo.visible=show_image.value
)
icon.value = "pause_circle"
var stateInfo = await HomeApi.get_state(entity_id)
@ -94,3 +120,13 @@ func load_image(url: String):
var texture = ImageTexture.create_from_image(image)
logo.texture = texture
logo.pixel_size = pixel_size
func get_options():
return {
"show_volume": show_volume.value,
"show_image": show_image.value
}
func set_options(options):
if options.has("show_volume"): show_volume.value = options["show_volume"]
if options.has("show_image"): show_image.value = options["show_image"]

View File

@ -1,10 +1,12 @@
[gd_scene load_steps=7 format=3 uid="uid://dyktdg7ggiwl4"]
[gd_scene load_steps=9 format=3 uid="uid://dyktdg7ggiwl4"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_8opk3"]
[ext_resource type="Script" path="res://content/entities/media_player/media_player.gd" id="1_ame17"]
[ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="3_24ewx"]
[ext_resource type="Script" path="res://content/functions/movable.gd" id="3_bguto"]
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_w73hw"]
[ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="5_koe28"]
[ext_resource type="PackedScene" uid="uid://cm070pgl3s7gm" path="res://content/entities/media_player/settings.tscn" id="6_iuvm7"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vi3eg"]
size = Vector3(0.23, 0.142768, 0.01)
@ -13,6 +15,14 @@ size = Vector3(0.23, 0.142768, 0.01)
collision_mask = 0
script = ExtResource("1_ame17")
[node name="Movable" type="Node" parent="."]
script = ExtResource("3_bguto")
resizable = true
[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")]
script = ExtResource("3_24ewx")
focus_point = NodePath("../Settings")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0364514, -0.01)
shape = SubResource("BoxShape3D_vi3eg")
@ -56,10 +66,6 @@ pixel_size = 0.001
[node name="HTTPRequest" type="HTTPRequest" parent="PlayingInfo"]
[node name="Movable" type="Node" parent="."]
script = ExtResource("3_bguto")
resizable = true
[node name="Slider" parent="." instance=ExtResource("4_w73hw")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0562844, 0)
max = 100.0
@ -74,3 +80,6 @@ text = "volume_up"
font = ExtResource("5_koe28")
font_size = 18
outline_size = 4
[node name="Settings" parent="." instance=ExtResource("6_iuvm7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.27, 0, 0)

View File

@ -0,0 +1,30 @@
extends StaticBody3D
const MediaPlayer = preload ("./media_player.gd")
@onready var close_button: Button3D = $Close
@onready var id_input: Input3D = $IDInput
@onready var volume_button: Button3D = $VolumeButton
@onready var image_button: Button3D = $ImageButton
var media_player: MediaPlayer
func _ready():
media_player = get_parent()
close_button.on_button_up.connect(func():
media_player.show_settings.value=false
)
id_input.text = media_player.entity_id
R.effect(func(_arg):
volume_button.label="check" if media_player.show_volume.value else "close"
)
R.effect(func(_arg):
image_button.label="check" if media_player.show_image.value else "close"
)
R.bind(volume_button, "active", media_player.show_volume, volume_button.on_toggled)
R.bind(image_button, "active", media_player.show_image, image_button.on_toggled)

View File

@ -0,0 +1,102 @@
[gd_scene load_steps=9 format=3 uid="uid://cm070pgl3s7gm"]
[ext_resource type="Script" path="res://content/entities/media_player/settings.gd" id="1_03bil"]
[ext_resource type="PackedScene" uid="uid://dnam3fe36gg62" path="res://content/ui/components/panel/panel.tscn" id="2_kt6qc"]
[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_abcrk"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_u2igx"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="5_1jm5m"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_j16so"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("3_abcrk")
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_48hjm"]
size = Vector2(0.3, 0.2)
[sub_resource type="BoxShape3D" id="BoxShape3D_53oq0"]
size = Vector3(0.3, 0.2, 0.02)
[node name="Settings" type="StaticBody3D"]
script = ExtResource("1_03bil")
[node name="Panel" parent="." instance=ExtResource("2_kt6qc")]
material_override = SubResource("ShaderMaterial_j16so")
mesh = SubResource("QuadMesh_48hjm")
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 = "Media Player Settings"
font_size = 20
outline_size = 0
horizontal_alignment = 0
[node name="Close" parent="." instance=ExtResource("4_u2igx")]
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_1jm5m")]
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.02, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Show Volume:"
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="VolumeButton" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.02, 0)
label = "close"
icon = true
toggleable = true
[node name="VideoLabel2" 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 = "Show Image:"
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="ImageButton" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.07, 0)
label = "close"
icon = true
toggleable = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.01)
shape = SubResource("BoxShape3D_53oq0")