From 5ba67029c7eca6691652f4ea5979af066333f82d Mon Sep 17 00:00:00 2001 From: Nitwel Date: Fri, 26 Apr 2024 13:30:11 +0200 Subject: [PATCH] add hover & active state to button and input --- app/content/system/hands/hands.tscn | 8 +-- app/content/system/keyboard/keyboard.tscn | 2 +- app/content/ui/components/button/button.gd | 28 ++++++-- .../components/button/button.material.depren | Bin 0 -> 460 bytes app/content/ui/components/button/button.tscn | 16 +++-- .../button/button_active.material.depren | Bin 0 -> 495 bytes app/content/ui/components/input/input.gd | 18 +++-- app/content/ui/components/input/input.tscn | 28 ++++---- .../components/notification/notification.tscn | 3 +- .../ui/components/pagination/button.material | 3 - .../pagination/button_active.material | 3 - .../ui/components/pagination/pagination.gd | 12 ++-- .../ui/components/pagination/pagination.tscn | 5 +- .../ui/components/panel}/glass.gdshader | 0 app/content/ui/components/panel/panel.gd | 67 ++++++++++++++++++ .../ui/components/panel/panel.material | 3 + app/content/ui/components/panel/panel.tscn | 15 ++++ app/content/ui/components/slider/slider.tscn | 2 +- app/content/ui/menu/edit/edit_menu.tscn | 2 +- app/content/ui/menu/menu.tscn | 2 +- app/content/ui/menu/room/room_menu.tscn | 2 +- app/content/ui/menu/room/views/overview.tscn | 2 +- app/content/ui/menu/room/views/rooms.tscn | 2 +- app/content/ui/menu/settings/settings_menu.gd | 8 +++ .../ui/menu/settings/settings_menu.tscn | 12 +++- app/content/ui/menu/view/view_menu.tscn | 2 +- app/content/ui/onboarding/onboarding.tscn | 2 +- app/export_presets.cfg | 4 +- 28 files changed, 189 insertions(+), 62 deletions(-) create mode 100644 app/content/ui/components/button/button.material.depren create mode 100644 app/content/ui/components/button/button_active.material.depren delete mode 100644 app/content/ui/components/pagination/button.material delete mode 100644 app/content/ui/components/pagination/button_active.material rename app/{assets/materials => content/ui/components/panel}/glass.gdshader (100%) create mode 100644 app/content/ui/components/panel/panel.gd create mode 100644 app/content/ui/components/panel/panel.material create mode 100644 app/content/ui/components/panel/panel.tscn diff --git a/app/content/system/hands/hands.tscn b/app/content/system/hands/hands.tscn index 517a26b..b3ecf48 100644 --- a/app/content/system/hands/hands.tscn +++ b/app/content/system/hands/hands.tscn @@ -51,7 +51,7 @@ transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0, shape = SubResource("CapsuleShape3D_dopke") [node name="ThumbTip" type="BoneAttachment3D" parent="XRHandLeft"] -transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928488, 0.0498668, 0.0560917, -0.112777) +transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928487, 0.0498668, 0.0560917, -0.112777) bone_name = "Thumb_Tip_L" bone_idx = 4 use_external_skeleton = true @@ -61,7 +61,7 @@ external_skeleton = NodePath("../left_hand/Armature_001/Skeleton3D") gizmo_extents = 0.02 [node name="MiddleTip" type="BoneAttachment3D" parent="XRHandLeft"] -transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996577, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653568, 0.032112, 0.00654224, -0.171612) +transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996576, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653567, 0.032112, 0.00654224, -0.171612) bone_name = "Middle_Tip_L" bone_idx = 14 use_external_skeleton = true @@ -112,7 +112,7 @@ transform = Transform3D(1, 0, 4.7579e-13, 0, 1, 0, -1.34149e-12, 1.77636e-15, 1, material_override = SubResource("StandardMaterial3D_n27ki") [node name="IndexTip" type="BoneAttachment3D" parent="XRHandRight"] -transform = Transform3D(0.19221, 0.669966, 0.717079, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345977, -0.164767, -0.0355401) +transform = Transform3D(0.19221, 0.669966, 0.717078, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345978, -0.164767, -0.0355401) bone_name = "Index_Tip_R" bone_idx = 9 use_external_skeleton = true @@ -142,7 +142,7 @@ external_skeleton = NodePath("../right_hand/Armature/Skeleton3D") gizmo_extents = 0.02 [node name="MiddleTip" type="BoneAttachment3D" parent="XRHandRight"] -transform = Transform3D(0.0812011, 0.650531, 0.755126, -0.0155557, -0.756709, 0.653568, 0.996576, -0.0648169, -0.0513262, -0.032112, -0.171612, -0.00654216) +transform = Transform3D(0.0812011, 0.650531, 0.755126, -0.0155557, -0.756708, 0.653568, 0.996576, -0.0648169, -0.0513262, -0.032112, -0.171612, -0.00654216) bone_name = "Middle_Tip_R" bone_idx = 14 use_external_skeleton = true diff --git a/app/content/system/keyboard/keyboard.tscn b/app/content/system/keyboard/keyboard.tscn index d83d06b..94318be 100644 --- a/app/content/system/keyboard/keyboard.tscn +++ b/app/content/system/keyboard/keyboard.tscn @@ -4,7 +4,7 @@ [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_xdpwr"] [ext_resource type="Script" path="res://content/ui/components/grid_container/grid_container.gd" id="3_mx544"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_86fct"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="5_0dbg6"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="5_0dbg6"] [sub_resource type="BoxShape3D" id="BoxShape3D_k5ib7"] size = Vector3(0.86, 0.27, 0.02) diff --git a/app/content/ui/components/button/button.gd b/app/content/ui/components/button/button.gd index 36d4f6d..8e2f592 100644 --- a/app/content/ui/components/button/button.gd +++ b/app/content/ui/components/button/button.gd @@ -12,7 +12,7 @@ const ECHO_WAIT_INITIAL = 0.5 const ECHO_WAIT_REPEAT = 0.1 @onready var body: StaticBody3D = $Body -@onready var mesh: MeshInstance3D = $Body/MeshInstance3D +@onready var panel: Panel3D = $Body/Panel3D @onready var collision: CollisionShape3D = $Body/CollisionShape3D @onready var label_node: Label3D = $Body/Label @onready var finger_area: Area3D = $FingerArea @@ -59,7 +59,14 @@ const ECHO_WAIT_REPEAT = 0.1 @export var toggleable: bool = false @export var disabled: bool = false @export var echo: bool = false -@export var initial_active: bool = false +@export var initial_active: bool = false: + set(value): + if initial_active == value: + return + + initial_active = value + if !is_inside_tree(): return + update_animation(1.0 if initial_active else 0.0) var active: bool = false: set(value): @@ -69,6 +76,7 @@ var active: bool = false: on_toggled.emit(value) active = value if !is_inside_tree(): return + panel.active = active update_animation(1.0 if active else 0.0) var echo_timer: Timer = null @@ -138,6 +146,15 @@ func _on_press_up(event): active = false on_button_up.emit() +func _on_ray_enter(_event: EventPointer): + if disabled: + return + + panel.hovering = true + +func _on_ray_leave(_event: EventPointer): + panel.hovering = false + func _on_touch_enter(event: EventTouch): if event.target != finger_area: return @@ -203,11 +220,10 @@ func _update(): finger_area.position = Vector3(0, 0, -0.015) touch.position = Vector3(0, 0, size.z / 2) - mesh.mesh.size = Vector2(size.x, size.y) - mesh.material_override.set_shader_parameter("size", Vector2(size.x, size.y) * 25) + panel.size = Vector2(size.x, size.y) + panel.position = Vector3(0, 0, size.z / 2) collision.shape.size = Vector3(size.x, size.y, size.z) label_node.width = size.x / label_node.pixel_size - mesh.position = Vector3(0, 0, size.z / 2) label_node.position = Vector3(0, 0, size.z / 2 + 0.001) - finger_area_collision.shape.size = Vector3(size.x, size.y, 0.03) + finger_area_collision.shape.size = Vector3(size.x, size.y, 0.03) \ No newline at end of file diff --git a/app/content/ui/components/button/button.material.depren b/app/content/ui/components/button/button.material.depren new file mode 100644 index 0000000000000000000000000000000000000000..4b2de305f008e69a2c83e12c0a72b4d3802f2e62 GIT binary patch literal 460 zcmV;-0WZvKx znVAe=w7E_+0C_P0kX=3^WzKDaB<=gf;+MgvP+-(Dq7EINnq{?tSI5OnYbi1SGXOIH zn(Hc*j;F&OWXvh-jivVg&VPkt1OyNXsQ_^KFYtq7FSgFN(Q3U>=>O(F!GFvDfj>O) zjZUq{A@Oh}MY*7tr4G#^h&N*lsn)64>!&$}%S-t*H#>CyXYMg$b8OAETC1(u+qzGq z>I9)GF`X(9Qi_HN=i@)ce}l~bf~thMV3caqK19f>&007MxW1&$GX!dhgQIjnUL!Y=7YbQmx$ z0W9Daa0J-4=H_HjG}|po7?dqAJ4#Ez1Lq0BLRN(O9t}a{i_6aP*wzVxR-~P&#?nHS z!%SCX`UiqV5?r#F^a?O=u?8Ov#@bZBg@i9xA&~sI2h7j$8wwUuQ$s_J C^V8e_ literal 0 HcmV?d00001 diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index 881bb56..9000ad3 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -1,10 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://bsjqdvkt0u87c"] +[gd_scene load_steps=7 format=3 uid="uid://bsjqdvkt0u87c"] [ext_resource type="Script" path="res://content/ui/components/button/button.gd" id="1_74x7g"] -[ext_resource type="Material" uid="uid://iercgso83b0a" path="res://content/ui/components/pagination/button.material" id="2_ebyeq"] +[ext_resource type="Material" uid="uid://crycqex1ucj04" path="res://content/ui/components/panel/panel.material" id="2_28wsr"] +[ext_resource type="Script" path="res://content/ui/components/panel/panel.gd" id="3_skm86"] -[sub_resource type="QuadMesh" id="QuadMesh_bt05p"] -resource_local_to_scene = true +[sub_resource type="QuadMesh" id="QuadMesh_bu2il"] size = Vector2(0.04, 0.04) [sub_resource type="BoxShape3D" id="BoxShape3D_xwopm"] @@ -25,11 +25,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) collision_layer = 2 collision_mask = 0 -[node name="MeshInstance3D" type="MeshInstance3D" parent="Body"] +[node name="Panel3D" type="MeshInstance3D" parent="Body"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) -material_override = ExtResource("2_ebyeq") -mesh = SubResource("QuadMesh_bt05p") +material_override = ExtResource("2_28wsr") +mesh = SubResource("QuadMesh_bu2il") skeleton = NodePath("../..") +script = ExtResource("3_skm86") +size = Vector2(0.04, 0.04) [node name="CollisionShape3D" type="CollisionShape3D" parent="Body"] shape = SubResource("BoxShape3D_xwopm") diff --git a/app/content/ui/components/button/button_active.material.depren b/app/content/ui/components/button/button_active.material.depren new file mode 100644 index 0000000000000000000000000000000000000000..1931367145a402590cf689d26500e94585eda32d GIT binary patch literal 495 zcmV+v0ESmkJTQ-v#=vOP9g-{y zNN6G~+u%!;Jq_8#f0QS?oMdlQY$HgLSYBg7kj_;_2R%SYbJ)qJpV^;mi|GF?1vmgb z06zdru~o?F>XdF{b^1W|B9roY64Pg^2X%js|G=wc<&r{z3XmUT0!!IeV_H~+(q!c4 z_%r^C|MCIVTLr_aLAh+z?Ry*?s|R7%m_k|dfWdmwAOejbU9gX&!TY55G^T5bfPI+G|BL`Fn@%kr?XPEatgOceMp>jNfbbvRK8 z3DLpfkMIll01HK9p}cbeg^H8OkXXy21po(wNpUhngp(I#73SiK;6Y lB`oM2bqRW<7`Rx2FAX-@rg|e4Le9@U-28yw;IL9tLqi#C;4J_E literal 0 HcmV?d00001 diff --git a/app/content/ui/components/input/input.gd b/app/content/ui/components/input/input.gd index 7c4860b..bb0ade7 100644 --- a/app/content/ui/components/input/input.gd +++ b/app/content/ui/components/input/input.gd @@ -5,7 +5,7 @@ class_name Input3D var text_handler = preload ("res://content/ui/components/input/text_handler.gd").new() @onready var caret: MeshInstance3D = $Body/Label/Caret -@onready var mesh_box: MeshInstance3D = $Body/Box +@onready var panel: Panel3D = $Body/Panel3D @onready var body: StaticBody3D = $Body @onready var collision: CollisionShape3D = $Body/Collision @onready var animation: AnimationPlayer = $AnimationPlayer @@ -104,6 +104,15 @@ func _on_press_move(event): caret.position.x = text_handler.get_caret_position() label.text = text_handler.get_display_text() +func _on_ray_enter(_event: EventPointer): + if disabled: + return + + panel.hovering = true + +func _on_ray_leave(_event: EventPointer): + panel.hovering = false + func _on_focus_in(_event): if disabled: return @@ -111,6 +120,7 @@ func _on_focus_in(_event): caret.position.x = text_handler.get_caret_position() label.text = text_handler.get_display_text() caret.visible = true + panel.active = true animation.play("blink") func update_caret_position(event): @@ -136,6 +146,7 @@ func _on_focus_out(_event): animation.stop() caret.visible = false + panel.active = false func _draw_debug_text_gaps(): if text_handler.gap_offsets == null: @@ -151,9 +162,8 @@ func _draw_debug_text_gaps(): func _update(): text_handler.width = size.x - mesh_box.mesh.size = Vector2(size.x, size.y) - mesh_box.position.z = size.z / 2 - mesh_box.material_override.set_shader_parameter("size", mesh_box.mesh.size) + panel.size = Vector2(size.x, size.y) + panel.position.z = size.z / 2 collision.shape.size = size label.position = Vector3( - size.x / 2 + 0.002, 0, size.z / 2) label.text = text_handler.get_display_text() diff --git a/app/content/ui/components/input/input.tscn b/app/content/ui/components/input/input.tscn index c047dcd..d135253 100644 --- a/app/content/ui/components/input/input.tscn +++ b/app/content/ui/components/input/input.tscn @@ -1,26 +1,26 @@ -[gd_scene load_steps=12 format=3 uid="uid://blrhy2uccrdn4"] +[gd_scene load_steps=13 format=3 uid="uid://blrhy2uccrdn4"] [ext_resource type="Script" path="res://content/ui/components/input/input.gd" id="1_uml3t"] +[ext_resource type="Script" path="res://content/ui/components/panel/panel.gd" id="3_3bvrj"] [ext_resource type="FontVariation" uid="uid://d2ofyimg5s65q" path="res://assets/fonts/ui_font_500.tres" id="3_ij5fh"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="3_nl02b"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_nl02b"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_c5qdm"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_ioqea"] resource_local_to_scene = true -render_priority = 20 +render_priority = 10 shader = ExtResource("3_nl02b") 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.15, 0.03) -shader_parameter/border_size = 0.001 -shader_parameter/border_fade_in = 0.005 +shader_parameter/size = Vector2(3.75, 0.75) +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.01 +shader_parameter/corner_radius = 0.2 shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 -[sub_resource type="QuadMesh" id="QuadMesh_5rrua"] -resource_local_to_scene = true +[sub_resource type="QuadMesh" id="QuadMesh_qgsvu"] size = Vector2(0.15, 0.03) [sub_resource type="BoxShape3D" id="BoxShape3D_x4yp8"] @@ -80,10 +80,12 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) collision_layer = 6 collision_mask = 6 -[node name="Box" type="MeshInstance3D" parent="Body"] +[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_c5qdm") -mesh = SubResource("QuadMesh_5rrua") +material_override = SubResource("ShaderMaterial_ioqea") +mesh = SubResource("QuadMesh_qgsvu") +script = ExtResource("3_3bvrj") +size = Vector2(0.15, 0.03) [node name="Collision" type="CollisionShape3D" parent="Body"] shape = SubResource("BoxShape3D_x4yp8") diff --git a/app/content/ui/components/notification/notification.tscn b/app/content/ui/components/notification/notification.tscn index ebf6457..1bf9444 100644 --- a/app/content/ui/components/notification/notification.tscn +++ b/app/content/ui/components/notification/notification.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=11 format=3 uid="uid://bqj7qwj5mgd30"] [ext_resource type="Script" path="res://content/ui/components/notification/notification.gd" id="1_yw3yb"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="2_b68od"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="2_b68od"] [ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="3_1ljpc"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_ocg5j"] @@ -191,7 +191,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.08, 0, 0.001) pixel_size = 0.001 render_priority = 15 outline_render_priority = 14 -text = "Example" font_size = 10 outline_size = 0 horizontal_alignment = 0 diff --git a/app/content/ui/components/pagination/button.material b/app/content/ui/components/pagination/button.material deleted file mode 100644 index 2a64a16..0000000 --- a/app/content/ui/components/pagination/button.material +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dbcd34e34bfbe649b5ee3b0c2df93869b18124ec89499cc54f9c5c287f83d0cc -size 465 diff --git a/app/content/ui/components/pagination/button_active.material b/app/content/ui/components/pagination/button_active.material deleted file mode 100644 index 502b5cf..0000000 --- a/app/content/ui/components/pagination/button_active.material +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8221dc259207ca47a110c885bf1e5535f3bef64dd7ddbb0aaac91de95afd2159 -size 496 diff --git a/app/content/ui/components/pagination/pagination.gd b/app/content/ui/components/pagination/pagination.gd index 4ec7733..f175fa3 100644 --- a/app/content/ui/components/pagination/pagination.gd +++ b/app/content/ui/components/pagination/pagination.gd @@ -7,9 +7,6 @@ signal on_page_changed(page: int) const ButtonScene = preload ("res://content/ui/components/button/button.tscn") const LabelScene = preload ("res://content/ui/components/label_container/label_container.tscn") -const ButtonMaterial = preload ("button.material") -const ButtonActiveMaterial = preload ("button_active.material") - @onready var prev_button = $Prev @onready var next_button = $Next @@ -83,6 +80,7 @@ func _update(): var button = ButtonScene.instantiate() button.size = Vector3(size.y, size.y, size.z) + button.toggleable = true if i == 0: button.label = "1" @@ -95,15 +93,17 @@ func _update(): else: button.label = str(clamp(page + 1, 3, pages - 3) - center_pos + i + 1) - button.on_button_up.connect(func(): + button.on_button_down.connect(func(): page=int(button.label) - 1 on_page_changed.emit(page) ) + if (int(button.label) - 1) == page: + button.initial_active = true + button.disabled = true + add_child(button) move_child(button, -2) - button.get_node("Body/MeshInstance3D").material_override = ButtonActiveMaterial if (int(button.label) - 1) == page else ButtonMaterial - super._update() \ No newline at end of file diff --git a/app/content/ui/components/pagination/pagination.tscn b/app/content/ui/components/pagination/pagination.tscn index a4e2d84..6df6cd9 100644 --- a/app/content/ui/components/pagination/pagination.tscn +++ b/app/content/ui/components/pagination/pagination.tscn @@ -5,19 +5,20 @@ [node name="Pagination" type="Node3D"] script = ExtResource("1_3ylfj") +page = 1 pages = 4 visible_pages = 7 gap = 0.01 size = Vector3(9.92, 0.05, 0.01) [node name="Prev" parent="." instance=ExtResource("2_lsc4w")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.025, 0, 0) label = "navigate_before" icon = true -disabled = true size = Vector3(0.05, 0.05, 0.01) [node name="Next" parent="." instance=ExtResource("2_lsc4w")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.325, 0, 0) label = "navigate_next" icon = true size = Vector3(0.05, 0.05, 0.01) diff --git a/app/assets/materials/glass.gdshader b/app/content/ui/components/panel/glass.gdshader similarity index 100% rename from app/assets/materials/glass.gdshader rename to app/content/ui/components/panel/glass.gdshader diff --git a/app/content/ui/components/panel/panel.gd b/app/content/ui/components/panel/panel.gd new file mode 100644 index 0000000..e881274 --- /dev/null +++ b/app/content/ui/components/panel/panel.gd @@ -0,0 +1,67 @@ +@tool +extends MeshInstance3D +class_name Panel3D + +const PanelMaterial = preload ("panel.material") + +const COLOR = Color(1.0, 1.0, 1.0, 0.3) +const BORDER_COLOR = Color(1.0, 1.0, 1.0, 1.0) +const COLOR_ACTIVE = Color(0.949, 0.353, 0.22, 0.3) +const BORDER_COLOR_ACTIVE = Color(0.949, 0.353, 0.22, 1.0) +const COLOR_HOVER = Color(0.5, 0.5, 0.5, 0.3) +const BORDER_COLOR_HOVER = Color(0.7, 0.7, 0.7, 1.0) + +@export var hovering = false: + set(value): + hovering = value + _update_style() + +@export var active = false: + set(value): + active = value + _update_style() + +@export var size = Vector2(1, 1): + set(value): + size = value + _update_size() + +@export var corner_radius = 0.2: + set(value): + corner_radius = value + _update_corner_radius() + +@export var border = 0.6: + set(value): + border = value + _update_border() + +func _ready(): + mesh = QuadMesh.new() + material_override = PanelMaterial.duplicate() + _update_style() + _update_size() + _update_corner_radius() + _update_border() + +func _update_border(): + material_override.set_shader_parameter("border_size", border * 1.0 / 60.0) + material_override.set_shader_parameter("border_fade_in", border * 5.0 / 60.0) + +func _update_corner_radius(): + material_override.set_shader_parameter("corner_radius", corner_radius) + +func _update_style(): + if active: + material_override.set_shader_parameter("color", COLOR_ACTIVE) + material_override.set_shader_parameter("border_color", BORDER_COLOR_ACTIVE) + elif hovering: + material_override.set_shader_parameter("color", COLOR_HOVER) + material_override.set_shader_parameter("border_color", BORDER_COLOR_HOVER) + else: + material_override.set_shader_parameter("color", COLOR) + material_override.set_shader_parameter("border_color", BORDER_COLOR) + +func _update_size(): + mesh.size = size + material_override.set_shader_parameter("size", size * 25) \ No newline at end of file diff --git a/app/content/ui/components/panel/panel.material b/app/content/ui/components/panel/panel.material new file mode 100644 index 0000000..2b72ad3 --- /dev/null +++ b/app/content/ui/components/panel/panel.material @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5698a4c471cde4f3d6593fd94837a5f7238dfc832323c3ee96658f480a23c7a3 +size 450 diff --git a/app/content/ui/components/panel/panel.tscn b/app/content/ui/components/panel/panel.tscn new file mode 100644 index 0000000..5dcc34a --- /dev/null +++ b/app/content/ui/components/panel/panel.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=4 format=3 uid="uid://dnam3fe36gg62"] + +[ext_resource type="Script" path="res://content/ui/components/panel/panel.gd" id="1_2jq4a"] +[ext_resource type="Material" uid="uid://crycqex1ucj04" path="res://content/ui/components/panel/panel.material" id="1_8jj0l"] + +[sub_resource type="QuadMesh" id="QuadMesh_vflbj"] +size = Vector2(0.04, 0.04) + +[node name="Panel" type="MeshInstance3D"] +material_override = ExtResource("1_8jj0l") +mesh = SubResource("QuadMesh_vflbj") +script = ExtResource("1_2jq4a") +size = Vector2(0.04, 0.04) +corner_radius = null +border = null diff --git a/app/content/ui/components/slider/slider.tscn b/app/content/ui/components/slider/slider.tscn index e3cb992..4971508 100644 --- a/app/content/ui/components/slider/slider.tscn +++ b/app/content/ui/components/slider/slider.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=9 format=3 uid="uid://pk5k1q8bx0rj"] [ext_resource type="Script" path="res://content/ui/components/slider/slider.gd" id="1_ylune"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="2_by0d8"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="2_by0d8"] [sub_resource type="BoxShape3D" id="BoxShape3D_h1mn1"] resource_local_to_scene = true diff --git a/app/content/ui/menu/edit/edit_menu.tscn b/app/content/ui/menu/edit/edit_menu.tscn index 68979c1..d2d6055 100644 --- a/app/content/ui/menu/edit/edit_menu.tscn +++ b/app/content/ui/menu/edit/edit_menu.tscn @@ -5,7 +5,7 @@ [ext_resource type="Script" path="res://content/ui/components/grid_container/grid_container.gd" id="3_0xvyw"] [ext_resource type="PackedScene" uid="uid://bef3gamrm6at2" path="res://content/ui/components/pagination/pagination.tscn" id="4_4jiu6"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_lpv7m"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="4_xunmy"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="4_xunmy"] [ext_resource type="Script" path="res://content/ui/menu/edit/entities.gd" id="5_t34xe"] [ext_resource type="Script" path="res://content/ui/components/flex_container/flex_container.gd" id="6_cr6p6"] diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index b0ab2de..8fafd24 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://content/ui/menu/menu.gd" id="1_ng4u3"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="2_8coxu"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="3_htaoi"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_htaoi"] [ext_resource type="Script" path="res://content/ui/components/tabs/tabs.gd" id="4_eavfx"] [ext_resource type="PackedScene" uid="uid://crrb0l3ekuotj" path="res://content/ui/menu/edit/edit_menu.tscn" id="4_r2raj"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="5_w4i01"] diff --git a/app/content/ui/menu/room/room_menu.tscn b/app/content/ui/menu/room/room_menu.tscn index fb961f8..41831b3 100644 --- a/app/content/ui/menu/room/room_menu.tscn +++ b/app/content/ui/menu/room/room_menu.tscn @@ -6,7 +6,7 @@ [ext_resource type="PackedScene" uid="uid://dd71loi64gnmp" path="res://content/ui/menu/room/views/overview.tscn" id="6_206ad"] [ext_resource type="Script" path="res://content/ui/components/tabs/tabs_content.gd" id="6_ba00g"] [ext_resource type="PackedScene" uid="uid://bpta22fahai46" path="res://content/ui/menu/room/views/rooms.tscn" id="7_2f8e0"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="7_bxp1w"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="7_bxp1w"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_2asng"] render_priority = -3 diff --git a/app/content/ui/menu/room/views/overview.tscn b/app/content/ui/menu/room/views/overview.tscn index 6abd572..31fd148 100644 --- a/app/content/ui/menu/room/views/overview.tscn +++ b/app/content/ui/menu/room/views/overview.tscn @@ -2,7 +2,7 @@ [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_fteh8"] [ext_resource type="Script" path="res://content/ui/menu/room/views/overview.gd" id="1_jesad"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="3_2yl2s"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_2yl2s"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_n3lbn"] render_priority = -3 diff --git a/app/content/ui/menu/room/views/rooms.tscn b/app/content/ui/menu/room/views/rooms.tscn index ecac368..5074cea 100644 --- a/app/content/ui/menu/room/views/rooms.tscn +++ b/app/content/ui/menu/room/views/rooms.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://content/ui/menu/room/views/rooms.gd" id="1_3a1oa"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_y3lty"] [ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="2_hstw7"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="4_jx6i3"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="4_jx6i3"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_dah0r"] render_priority = -3 diff --git a/app/content/ui/menu/settings/settings_menu.gd b/app/content/ui/menu/settings/settings_menu.gd index 226f03f..48ed1d5 100644 --- a/app/content/ui/menu/settings/settings_menu.gd +++ b/app/content/ui/menu/settings/settings_menu.gd @@ -12,8 +12,10 @@ const credits_scene = preload ("./credits.tscn") @onready var clear_save = $Content/ClearSave @onready var background = $Background @onready var voice_assist = $Content/VoiceAssist +@onready var version_label = $Content/LabelVersion func _ready(): + _load_game_version() var settings_store = Store.settings.state background.visible = false @@ -96,3 +98,9 @@ func _ready(): R.bind(voice_assist, "label", button_label) R.bind(voice_assist, "active", settings_store, "voice_assistant") + +func _load_game_version(): + var presets = ConfigFile.new() + presets.load("res://export_presets.cfg") + + version_label.text = "%s (%s)" % [presets.get_value("preset.1.options", "version/name", "v0.0.0"), presets.get_value("preset.1.options", "version/code", 0)] diff --git a/app/content/ui/menu/settings/settings_menu.tscn b/app/content/ui/menu/settings/settings_menu.tscn index 2844629..7932225 100644 --- a/app/content/ui/menu/settings/settings_menu.tscn +++ b/app/content/ui/menu/settings/settings_menu.tscn @@ -5,7 +5,7 @@ [ext_resource type="Script" path="res://content/functions/clickable.gd" id="3_qmg6q"] [ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="4_q3x6k"] [ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="5_eiwd4"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="6_mubnp"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="6_mubnp"] [sub_resource type="BoxShape3D" id="BoxShape3D_3qdps"] size = Vector3(0.07, 0.02, 0.01) @@ -180,6 +180,16 @@ font_size = 18 outline_size = 0 horizontal_alignment = 0 +[node name="LabelVersion" type="Label3D" parent="Content"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.41, -0.31, 0) +pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 +text = "v0.0.0" +font_size = 10 +outline_size = 0 +horizontal_alignment = 2 + [node name="Background" type="MeshInstance3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.21, -0.16, 0) material_override = SubResource("ShaderMaterial_3iv64") diff --git a/app/content/ui/menu/view/view_menu.tscn b/app/content/ui/menu/view/view_menu.tscn index 4a6699e..700af91 100644 --- a/app/content/ui/menu/view/view_menu.tscn +++ b/app/content/ui/menu/view/view_menu.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://content/ui/menu/view/view_menu.gd" id="1_hxajx"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="2_qan1b"] [ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_d3xhb"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="5_cjxo5"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="5_cjxo5"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_e5hvo"] render_priority = 10 diff --git a/app/content/ui/onboarding/onboarding.tscn b/app/content/ui/onboarding/onboarding.tscn index a6d12e1..dbb4d3f 100644 --- a/app/content/ui/onboarding/onboarding.tscn +++ b/app/content/ui/onboarding/onboarding.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=7 format=3 uid="uid://bhyddd1f0ry1x"] [ext_resource type="Script" path="res://content/ui/onboarding/onboarding.gd" id="1_k4yvw"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="2_87aan"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="2_87aan"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_hlpow"] [sub_resource type="BoxShape3D" id="BoxShape3D_nfwtf"] diff --git a/app/export_presets.cfg b/app/export_presets.cfg index e4b6cb7..7ccfc03 100644 --- a/app/export_presets.cfg +++ b/app/export_presets.cfg @@ -6,7 +6,7 @@ runnable=true dedicated_server=false custom_features="" export_filter="all_resources" -include_filter="*.j2,*.woff2" +include_filter="*.j2,*.woff2,export_presets.cfg" exclude_filter="" export_path="builds/android/immersive-home-debug.apk" encryption_include_filters="" @@ -230,7 +230,7 @@ runnable=false dedicated_server=false custom_features="" export_filter="all_resources" -include_filter="*.j2,*.woff2" +include_filter="*.j2,*.woff2,export_presets.cfg" exclude_filter="" export_path="builds/android/immersive-home.apk" encryption_include_filters=""