From 90cfe87ae84263f56936b68078fd1276986d1109 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 18 Apr 2024 12:10:20 +0200 Subject: [PATCH 01/24] improve mini view selection --- app/content/system/armband/armband.gd | 15 --------------- app/content/system/armband/armband.tscn | 23 ----------------------- app/content/system/dot/dot.gd | 4 ++-- app/content/system/house/mini/Entity.gd | 3 +++ app/export_presets.cfg | 4 +++- 5 files changed, 8 insertions(+), 41 deletions(-) delete mode 100644 app/content/system/armband/armband.gd delete mode 100644 app/content/system/armband/armband.tscn diff --git a/app/content/system/armband/armband.gd b/app/content/system/armband/armband.gd deleted file mode 100644 index c9db1a0..0000000 --- a/app/content/system/armband/armband.gd +++ /dev/null @@ -1,15 +0,0 @@ -extends Node3D - -@onready var menu_button = $Menu -@onready var mini_button = $Mini -@onready var clock = $Clock -@onready var main = $"/root/Main" - -func _ready(): - menu_button.on_button_down.connect(func(): - main.toggle_menu() - ) - - mini_button.on_button_down.connect(func(): - House.body.mini_view = !House.body.mini_view - ) diff --git a/app/content/system/armband/armband.tscn b/app/content/system/armband/armband.tscn deleted file mode 100644 index fa24fd9..0000000 --- a/app/content/system/armband/armband.tscn +++ /dev/null @@ -1,23 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://bexxngoxcegul"] - -[ext_resource type="Script" path="res://content/system/armband/armband.gd" id="1_4tskg"] -[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_egcvm"] - -[node name="Armband" type="Node3D"] -transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) -script = ExtResource("1_4tskg") - -[node name="Menu" parent="." instance=ExtResource("1_egcvm")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.04, 0, 0.04) -label = "menu" -icon = true - -[node name="Mini" parent="." instance=ExtResource("1_egcvm")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, 0, 0.04) -label = "view_comfy" -icon = true - -[node name="Clock" type="Label3D" parent="."] -transform = Transform3D(1, 4.37114e-08, 4.37114e-08, -4.37114e-08, -4.37114e-08, 1, 4.37114e-08, -1, -4.37114e-08, 0, 0.02, -0.02) -pixel_size = 0.001 -text = "10:00" diff --git a/app/content/system/dot/dot.gd b/app/content/system/dot/dot.gd index faded69..548fd14 100644 --- a/app/content/system/dot/dot.gd +++ b/app/content/system/dot/dot.gd @@ -34,7 +34,7 @@ func _ready(): ) func _on_click(_event: EventPointer): - if entity.has_method("quick_action"): + if entity.has_method("quick_action")&&miniature.entity_select.selection_active() == false: entity.quick_action() else: miniature.entity_select.toggle(entity) @@ -61,7 +61,7 @@ func _on_touch_move(_event: EventTouch): func _on_touch_leave(_event: EventTouch): if touch_ran: return - if entity.has_method("quick_action"): + if entity.has_method("quick_action")&&miniature.entity_select.selection_active() == false: entity.quick_action() else: miniature.entity_select.toggle(entity) \ No newline at end of file diff --git a/app/content/system/house/mini/Entity.gd b/app/content/system/house/mini/Entity.gd index 1629924..67ee467 100644 --- a/app/content/system/house/mini/Entity.gd +++ b/app/content/system/house/mini/Entity.gd @@ -58,6 +58,9 @@ func _ready(): dots.add_child(dot) ) +func selection_active(): + return editing.value.size() > 0 + func toggle(entity: Entity): if active_type == null: active_type = entity.entity_id.split(".")[0] diff --git a/app/export_presets.cfg b/app/export_presets.cfg index 7ae243a..e4b6cb7 100644 --- a/app/export_presets.cfg +++ b/app/export_presets.cfg @@ -134,6 +134,7 @@ permissions/mount_format_filesystems=false permissions/mount_unmount_filesystems=false permissions/nfc=false permissions/persistent_activity=false +permissions/post_notifications=false permissions/process_outgoing_calls=false permissions/read_calendar=false permissions/read_call_log=false @@ -244,7 +245,7 @@ custom_template/release="" gradle_build/use_gradle_build=true gradle_build/export_format=0 gradle_build/min_sdk="" -gradle_build/target_sdk="32" +gradle_build/target_sdk="" architectures/armeabi-v7a=false architectures/arm64-v8a=true architectures/x86=false @@ -357,6 +358,7 @@ permissions/mount_format_filesystems=false permissions/mount_unmount_filesystems=false permissions/nfc=false permissions/persistent_activity=false +permissions/post_notifications=false permissions/process_outgoing_calls=false permissions/read_calendar=false permissions/read_call_log=false From 8d1a380977f3793a63a8a75271b2c1db386df0c6 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 18 Apr 2024 12:35:57 +0200 Subject: [PATCH 02/24] clean up light and switch --- app/addons/rdot/graph.gd | 262 ++++++++++++------------ app/content/entities/light/light.gd | 67 +++--- app/content/entities/switch/switch.gd | 47 ++--- app/content/entities/switch/switch.tscn | 6 +- 4 files changed, 183 insertions(+), 199 deletions(-) diff --git a/app/addons/rdot/graph.gd b/app/addons/rdot/graph.gd index 6fde0d0..e61de00 100644 --- a/app/addons/rdot/graph.gd +++ b/app/addons/rdot/graph.gd @@ -4,9 +4,9 @@ class_name RdotGraph static var instance: RdotGraph = null static func getInstance() -> RdotGraph: - if instance == null: - instance = RdotGraph.new() - return instance + if instance == null: + instance = RdotGraph.new() + return instance var activeConsumer: RdotNode = null var inNotificationPhase := false @@ -17,209 +17,209 @@ var postSignalSetFn := Callable() var watcherPending := false var watcher = R.Watcher.new(func(_arg): - if watcherPending: - return + if watcherPending: + return - watcherPending=true - var endOfFrame=func(): + watcherPending=true + var endOfFrame=func(): - watcherPending=false - for s in watcher.getPending(): - s.do_get() + watcherPending=false + for s in watcher.getPending(): + s.do_get() - watcher.watch() + watcher.watch() - endOfFrame.call_deferred() + endOfFrame.call_deferred() ) func setActiveConsumer(consumer: RdotNode) -> RdotNode: - var prev = activeConsumer - activeConsumer = consumer - return prev + var prev = activeConsumer + activeConsumer = consumer + return prev func getActiveConsumer() -> RdotNode: - return activeConsumer + return activeConsumer func isInNotificationPhase() -> bool: - return inNotificationPhase + return inNotificationPhase func producerAccessed(node: RdotNode): - assert(inNotificationPhase == false, "Signal read during notification phase") + assert(inNotificationPhase == false, "Signal read during notification phase") - if activeConsumer == null: - return + if activeConsumer == null: + return - if activeConsumer.consumerOnSignalRead.is_null() == false: - activeConsumer.consumerOnSignalRead.call(node) + if activeConsumer.consumerOnSignalRead.is_null() == false: + activeConsumer.consumerOnSignalRead.call(node) - var idx = activeConsumer.nextProducerIndex; - activeConsumer.nextProducerIndex += 1 + var idx = activeConsumer.nextProducerIndex; + activeConsumer.nextProducerIndex += 1 - assertConsumerNode(activeConsumer) + assertConsumerNode(activeConsumer) - if idx < activeConsumer.producerNode.size()&&activeConsumer.producerNode[idx] != node: - if consumerIsLive(activeConsumer): - var staleProducer = activeConsumer.producerNode[idx] - producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]) + if idx < activeConsumer.producerNode.size()&&activeConsumer.producerNode[idx] != node: + if consumerIsLive(activeConsumer): + var staleProducer = activeConsumer.producerNode[idx] + producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]) - if RdotArray.do_get(activeConsumer.producerNode, idx) != node: - RdotArray.do_set(activeConsumer.producerNode, idx, node) - RdotArray.do_set(activeConsumer.producerIndexOfThis, idx, producerAddLiveConsumer(node, activeConsumer, idx) if consumerIsLive(activeConsumer) else 0) + if RdotArray.do_get(activeConsumer.producerNode, idx) != node: + RdotArray.do_set(activeConsumer.producerNode, idx, node) + RdotArray.do_set(activeConsumer.producerIndexOfThis, idx, producerAddLiveConsumer(node, activeConsumer, idx) if consumerIsLive(activeConsumer) else 0) - RdotArray.do_set(activeConsumer.producerLastReadVersion, idx, node.version) + RdotArray.do_set(activeConsumer.producerLastReadVersion, idx, node.version) func producerIncrementEpoch(): - epoch += 1 + epoch += 1 func producerUpdateValueVersion(node: RdotNode): - if consumerIsLive(node)&&!node.dirty: - return + if consumerIsLive(node)&&!node.dirty: + return - if !node.dirty&&node.lastCleanEpoch == epoch: - return + if !node.dirty&&node.lastCleanEpoch == epoch: + return - if !node.producerMustRecompute(node)&&!consumerPollProducersForChange(node): - node.dirty = false; - node.lastCleanEpoch = epoch - return + if !node.producerMustRecompute(node)&&!consumerPollProducersForChange(node): + node.dirty = false; + node.lastCleanEpoch = epoch + return - if node.producerRecomputeValue.is_null() == false: - node.producerRecomputeValue.call(node) + if node.producerRecomputeValue.is_null() == false: + node.producerRecomputeValue.call(node) - node.dirty = false - node.lastCleanEpoch = epoch + node.dirty = false + node.lastCleanEpoch = epoch func producerNotifyConsumers(node: RdotNode): - if node.liveConsumerNode == null: - return + if node.liveConsumerNode == null: + return - var prev = inNotificationPhase - inNotificationPhase = true + var prev = inNotificationPhase + inNotificationPhase = true - for consumer in node.liveConsumerNode: - if !consumer.dirty: - consumerMarkDirty(consumer) + for consumer in node.liveConsumerNode: + if !consumer.dirty: + consumerMarkDirty(consumer) - inNotificationPhase = prev + inNotificationPhase = prev func producerUpdatesAllowed() -> bool: - return activeConsumer == null||activeConsumer.consumerAllowSignalWrites != false + return activeConsumer == null||activeConsumer.consumerAllowSignalWrites != false func consumerMarkDirty(node: RdotNode): - node.dirty = true - producerNotifyConsumers(node) + node.dirty = true + producerNotifyConsumers(node) - if node.consumerMarkedDirty.is_null() == false: - node.consumerMarkedDirty.call(node) + if node.consumerMarkedDirty.is_null() == false: + node.consumerMarkedDirty.call(node) func consumerBeforeComputation(node: RdotNode) -> RdotNode: - if node: - node.nextProducerIndex = 0 + if node: + node.nextProducerIndex = 0 - return setActiveConsumer(node) + return setActiveConsumer(node) func consumerAfterComputation(node: RdotNode, prevConsumer: RdotNode): - setActiveConsumer(prevConsumer) + setActiveConsumer(prevConsumer) - if node == null||node.producerNode == null||node.producerIndexOfThis == null||node.producerLastReadVersion == null: - return + if node == null||node.producerNode == null||node.producerIndexOfThis == null||node.producerLastReadVersion == null: + return - if consumerIsLive(node): - for i in range(node.nextProducerIndex, node.producerNode.size()): - producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]) + if consumerIsLive(node): + for i in range(node.nextProducerIndex, node.producerNode.size()): + producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]) - while node.producerNode.size() > node.nextProducerIndex: - node.producerNode.pop_back() - node.producerLastReadVersion.pop_back() - node.producerIndexOfThis.pop_back() + while node.producerNode.size() > node.nextProducerIndex: + node.producerNode.pop_back() + node.producerLastReadVersion.pop_back() + node.producerIndexOfThis.pop_back() func consumerPollProducersForChange(node: RdotNode) -> bool: - assertConsumerNode(node) + assertConsumerNode(node) - for i in range(node.producerNode.size()): - var producer = node.producerNode[i] - var seenVersion = node.producerLastReadVersion[i] + for i in range(node.producerNode.size()): + var producer = node.producerNode[i] + var seenVersion = node.producerLastReadVersion[i] - if seenVersion != producer.version: - return true + if seenVersion != producer.version: + return true - producerUpdateValueVersion(producer) + producerUpdateValueVersion(producer) - if seenVersion != producer.version: - return true + if seenVersion != producer.version: + return true - return false + return false func consumerDestroy(node: RdotNode): - assertConsumerNode(node) + assertConsumerNode(node) - if consumerIsLive(node): - for i in range(node.producerNode.size()): - producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]) + if consumerIsLive(node): + for i in range(node.producerNode.size()): + producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]) - node.producerNode.clear() - node.producerLastReadVersion.clear() - node.producerIndexOfThis.clear() + node.producerNode.clear() + node.producerLastReadVersion.clear() + node.producerIndexOfThis.clear() - if node.liveConsumerNode: - node.liveConsumerNode.clear() - node.liveConsumerIndexOfThis.clear() + if node.liveConsumerNode: + node.liveConsumerNode.clear() + node.liveConsumerIndexOfThis.clear() static func producerAddLiveConsumer(node: RdotNode, consumer: RdotNode, indexOfThis: int) -> int: - assertProducerNode(node) - assertConsumerNode(node) + assertProducerNode(node) + assertConsumerNode(node) - if node.liveConsumerNode.size() == 0: - if node.watched.is_null() == false: - node.watched.call(node.wrapper) + if node.liveConsumerNode.size() == 0: + if node.watched.is_null() == false: + node.watched.call(node.wrapper) - for i in range(node.producerNode.size()): - node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i) + for i in range(node.producerNode.size()): + node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i) - node.liveConsumerIndexOfThis.push_back(indexOfThis) - node.liveConsumerNode.push_back(consumer) + node.liveConsumerIndexOfThis.push_back(indexOfThis) + node.liveConsumerNode.push_back(consumer) - return node.liveConsumerNode.size() - 1 + return node.liveConsumerNode.size() - 1 static func producerRemoveLiveConsumerAtIndex(node: RdotNode, idx: int): - assertProducerNode(node) - assertConsumerNode(node) + assertProducerNode(node) + assertConsumerNode(node) - assert(idx < node.liveConsumerNode.size(), "active consumer index %s is out of bounds of %s consumers)" % [idx, node.liveConsumerNode.size()]) + assert(idx < node.liveConsumerNode.size(), "active consumer index %s is out of bounds of %s consumers)" % [idx, node.liveConsumerNode.size()]) - if node.liveConsumerNode.size() == 1: - if node.unwatched.is_null() == false: - node.unwatched.call(node.wrapper) + if node.liveConsumerNode.size() == 1: + if node.unwatched.is_null() == false: + node.unwatched.call(node.wrapper) - for i in range(node.producerNode.size()): - producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]) + for i in range(node.producerNode.size()): + producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]) - var lastIdx = node.liveConsumerNode.size() - 1 - node.liveConsumerNode[idx] = node.liveConsumerNode[lastIdx] - node.liveConsumerIndexOfThis[idx] = node.liveConsumerIndexOfThis[lastIdx] + var lastIdx = node.liveConsumerNode.size() - 1 + node.liveConsumerNode[idx] = node.liveConsumerNode[lastIdx] + node.liveConsumerIndexOfThis[idx] = node.liveConsumerIndexOfThis[lastIdx] - node.liveConsumerNode.pop_back() - node.liveConsumerIndexOfThis.pop_back() + node.liveConsumerNode.pop_back() + node.liveConsumerIndexOfThis.pop_back() - if idx < node.liveConsumerNode.size(): - var idxProducer = node.liveConsumerIndexOfThis[idx] - var consumer = node.liveConsumerNode[idx] - assertConsumerNode(consumer) - consumer.producerIndexOfThis[idxProducer] = idx + if idx < node.liveConsumerNode.size(): + var idxProducer = node.liveConsumerIndexOfThis[idx] + var consumer = node.liveConsumerNode[idx] + assertConsumerNode(consumer) + consumer.producerIndexOfThis[idxProducer] = idx static func consumerIsLive(node: RdotNode) -> bool: - return node.consumerIsAlwaysLive||(node.liveConsumerNode != null&&node.liveConsumerNode.size() > 0) + return node.consumerIsAlwaysLive||(node.liveConsumerNode != null&&node.liveConsumerNode.size() > 0) static func assertConsumerNode(node: RdotNode): - if node.producerNode == null: - node.producerNode = [] - if node.producerIndexOfThis == null: - node.producerIndexOfThis = [] - if node.producerLastReadVersion == null: - node.producerLastReadVersion = [] + if node.producerNode == null: + node.producerNode = [] + if node.producerIndexOfThis == null: + node.producerIndexOfThis = [] + if node.producerLastReadVersion == null: + node.producerLastReadVersion = [] static func assertProducerNode(node: RdotNode): - if node.liveConsumerNode == null: - node.liveConsumerNode = [] - if node.liveConsumerIndexOfThis == null: - node.liveConsumerIndexOfThis = [] \ No newline at end of file + if node.liveConsumerNode == null: + node.liveConsumerNode = [] + if node.liveConsumerIndexOfThis == null: + node.liveConsumerIndexOfThis = [] diff --git a/app/content/entities/light/light.gd b/app/content/entities/light/light.gd index b867392..7335c40 100644 --- a/app/content/entities/light/light.gd +++ b/app/content/entities/light/light.gd @@ -15,9 +15,9 @@ const color_wheel_img := preload ("res://assets/canvas.png") @onready var mode_before = $Modes/Previous @onready var mode_label = $Modes/Label -var state = true -var brightness = 0 # 0-255 -var color = color_on +var active = R.state(false) +var brightness = R.state(0) # 0-255 +var color = R.state(color_on) var color_supported = false # Called when the node enters the scene tree for the first time. @@ -26,7 +26,7 @@ func _ready(): icon.value = "lightbulb" var stateInfo = await HomeApi.get_state(entity_id) - set_state(stateInfo["state"] == "on", stateInfo["attributes"]) + set_state(stateInfo) if stateInfo.has("attributes")&&stateInfo["attributes"].has("effect_list")&&stateInfo["attributes"]["effect_list"].size() > 0: if stateInfo["attributes"].has("effect")&&stateInfo["attributes"]["effect"] != null: @@ -65,79 +65,70 @@ func _ready(): var delta=Vector2(target_point.x, target_point.z) * (1.0 / 0.08) if delta.length() > 1: delta=delta.normalized() - - print("delta", delta) - var color=color_wheel_img.get_image().get_pixel((delta.x * 0.5 + 0.5) * 1000, (delta.y * 0.5 + 0.5) * 1000) + var picked_color=color_wheel_img.get_image().get_pixel((delta.x * 0.5 + 0.5) * 1000, (delta.y * 0.5 + 0.5) * 1000) - print("color", color) - - color_puck.material_override.albedo_color=color + color_puck.material_override.albedo_color=picked_color color_puck.position=Vector3(target_point.x, color_puck.position.y, target_point.z) var attributes={ - "rgb_color": [int(color.r * 255), int(color.g * 255), int(color.b * 255)], + "rgb_color": [int(picked_color.r * 255), int(picked_color.g * 255), int(picked_color.b * 255)], } HomeApi.set_state(entity_id, "on", attributes) - set_state(state, attributes) ) color_supported = true else: remove_child(color_wheel) await HomeApi.watch_state(entity_id, func(new_state): - if (new_state["state"] == "on") == state: - return - set_state(new_state["state"] == "on", new_state["attributes"]) + set_state(new_state) ) slider.on_value_changed.connect(func(new_value): var value=new_value / 100 * 255 - HomeApi.set_state(entity_id, "on" if state else "off", {"brightness": int(value)}) - set_state(state, {"brightness": value}) + HomeApi.set_state(entity_id, "on" if active.value else "off", {"brightness": int(value)}) ) -func set_state(new_state: bool, attributes={}): - if state == false&&new_state == false: +func set_state(stateInfo): + if active.value == false&&stateInfo["state"] == "off": return - state = new_state + var attributes = stateInfo["attributes"] - if attributes.has("brightness"): - brightness = attributes["brightness"] + active.value = stateInfo["state"] == "on" + + if attributes.has("brightness")&&attributes["brightness"] != null: + brightness.value = attributes["brightness"] + slider.value = attributes["brightness"] / 255.0 * 100 if attributes.has("rgb_color")&&attributes["rgb_color"] != null: - color = Color(attributes["rgb_color"][0] / 255.0, attributes["rgb_color"][1] / 255.0, attributes["rgb_color"][2] / 255.0, 1) + color.value = Color(attributes["rgb_color"][0] / 255.0, attributes["rgb_color"][1] / 255.0, attributes["rgb_color"][2] / 255.0, 1) var tween = create_tween() var target_color = color_off - if state: - if brightness == null: - target_color = color if color_supported else color_on + if active.value: + if brightness.value == null: + target_color = color.value if color_supported else color_on else: - target_color = color_off.lerp(color if color_supported else color_on, brightness / 255.0) + target_color = color_off.lerp(color.value if color_supported else color_on, brightness.value / 255.0) icon_color.value = target_color tween.tween_property(lightbulb, "material_override:albedo_color", target_color, 0.3) func _on_click(event): if event.target == self: - var attributes = {} - - if !state&&brightness != null: - attributes["brightness"] = int(brightness) - - HomeApi.set_state(entity_id, "on" if !state else "off", attributes) - set_state(!state, attributes) + _toggle() func quick_action(): + _toggle() + +func _toggle(): var attributes = {} - if !state&&brightness != null: - attributes["brightness"] = int(brightness) + if !active.value&&brightness.value != null: + attributes["brightness"] = int(brightness.value) - HomeApi.set_state(entity_id, "on" if !state else "off", attributes) - set_state(!state, attributes) \ No newline at end of file + HomeApi.set_state(entity_id, "off" if active.value else "on", attributes) \ No newline at end of file diff --git a/app/content/entities/switch/switch.gd b/app/content/entities/switch/switch.gd index 1a0c5d7..17ef18c 100644 --- a/app/content/entities/switch/switch.gd +++ b/app/content/entities/switch/switch.gd @@ -4,42 +4,35 @@ const Entity = preload ("../entity.gd") @onready var sprite: AnimatedSprite3D = $Icon +var active = R.state(false) + # Called when the node enters the scene tree for the first time. func _ready(): super() var stateInfo = await HomeApi.get_state(entity_id) + + set_state(stateInfo) + + await HomeApi.watch_state(entity_id, func(new_state): + set_state(new_state) + ) + + R.effect(func(_arg): + sprite.set_frame(1 if active.value else 0) + ) + +func set_state(stateInfo): if stateInfo == null: return - if stateInfo["state"] == "on": - sprite.set_frame(0) - else: - sprite.set_frame(1) - + active.value = stateInfo["state"] == "on" icon.value = "toggle_" + stateInfo["state"] - await HomeApi.watch_state(entity_id, func(new_state): - if new_state["state"] == "on": - sprite.set_frame(0) - else: - sprite.set_frame(1) - - icon.value="toggle_" + new_state["state"] - ) - func _on_click(_event): - HomeApi.set_state(entity_id, "off" if sprite.get_frame() == 0 else "on") - if sprite.get_frame() == 0: - sprite.set_frame(1) - else: - sprite.set_frame(0) - -func _on_request_completed(): - pass + _toggle() func quick_action(): - HomeApi.set_state(entity_id, "off" if sprite.get_frame() == 0 else "on") - if sprite.get_frame() == 0: - sprite.set_frame(1) - else: - sprite.set_frame(0) \ No newline at end of file + _toggle() + +func _toggle(): + HomeApi.set_state(entity_id, "off" if active.value else "on") \ No newline at end of file diff --git a/app/content/entities/switch/switch.tscn b/app/content/entities/switch/switch.tscn index 0fbeddc..d143a95 100644 --- a/app/content/entities/switch/switch.tscn +++ b/app/content/entities/switch/switch.tscn @@ -13,17 +13,17 @@ radius = 0.0482081 animations = [{ "frames": [{ "duration": 1.0, -"texture": ExtResource("1_w68gw") +"texture": ExtResource("2_86ba1") }, { "duration": 1.0, -"texture": ExtResource("2_86ba1") +"texture": ExtResource("1_w68gw") }], "loop": true, "name": &"default", "speed": 5.0 }] -[node name="Switch" type="StaticBody3D" ] +[node name="Switch" type="StaticBody3D"] collision_mask = 0 script = ExtResource("1_8ffhi") From 4fe0f1e4c92956ac65fd490cc11c3ed3e96918fb Mon Sep 17 00:00:00 2001 From: Nitwel Date: Sun, 21 Apr 2024 18:25:57 +0200 Subject: [PATCH 03/24] test out border shader --- app/content/main.tscn | 6 ++- app/content/ui/glass.gdshader | 33 ++++++++++++++++ app/content/ui/test.gd | 39 +++++++++++++++++++ app/content/ui/test.tscn | 72 +++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 app/content/ui/glass.gdshader create mode 100644 app/content/ui/test.gd create mode 100644 app/content/ui/test.tscn diff --git a/app/content/main.tscn b/app/content/main.tscn index ccad3d5..4a43fd7 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=17 format=3 uid="uid://eecv28y6jxk4"] +[gd_scene load_steps=18 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="PackedScene" uid="uid://lrehk38exd5n" path="res://content/system/keyboard/keyboard.tscn" id="9_e5n3p"] [ext_resource type="PackedScene" uid="uid://cbemihbxkd4ll" path="res://content/system/house/house.tscn" id="9_np6mw"] [ext_resource type="PackedScene" uid="uid://bhyddd1f0ry1x" path="res://content/ui/onboarding/onboarding.tscn" id="12_uq2nj"] +[ext_resource type="PackedScene" uid="uid://dclceqjqfxekx" path="res://content/ui/test.tscn" id="13_eg13b"] [sub_resource type="Sky" id="Sky_vhymk"] sky_material = ExtResource("5_wgwf8") @@ -88,4 +89,7 @@ transform = Transform3D(0.499999, -0.000139169, -6.50204e-05, 5.24307e-05, 0.353 [node name="Onboarding" parent="." instance=ExtResource("12_uq2nj")] transform = Transform3D(0.999999, -1.39632e-11, 0, 9.48097e-12, 0.999999, 0, 0, 0, 0.999999, -0.529594, 0.820154, -0.600147) +[node name="Test" parent="." instance=ExtResource("13_eg13b")] +transform = Transform3D(-0.0709227, 0.000321724, 0.997481, 0.000312568, 1, -0.000300313, -0.997482, 0.000290482, -0.0709229, -0.0248237, 0.934686, -0.49358) + [editable path="XROrigin3D/XRControllerLeft"] diff --git a/app/content/ui/glass.gdshader b/app/content/ui/glass.gdshader new file mode 100644 index 0000000..716cea5 --- /dev/null +++ b/app/content/ui/glass.gdshader @@ -0,0 +1,33 @@ +shader_type spatial; + +uniform vec4 color : source_color = vec4(1.0, 1.0, 1.0, 1.0); +uniform vec2 size = vec2(1.0, 1.0); +uniform float border_size = 0.1; +uniform float border_fade_in: hint_range(0.0, 10.0) = 0.0; +uniform float border_fade_out: hint_range(0.0, 10.0) = 0.0; +uniform float corner_radius = 0.0; + +float rectangle(vec2 position) { + vec2 component_wise_edge_distance = abs(position) - (vec2(0.5, 0.5) * size + corner_radius * (size - 1.0)); + float outsideDistance = length(max(component_wise_edge_distance, 0)); + float insideDistance = min(max(component_wise_edge_distance.x, component_wise_edge_distance.y), 0); + return outsideDistance + insideDistance; +} + +void fragment() { + ALBEDO = color.xyz; + float border_scale = 1.0 + 2.0 * corner_radius; + float d = rectangle((UV - 0.5) * size * border_scale); + float border_width = (border_size + border_fade_in + border_fade_out) * border_scale; + + if (d >= corner_radius - border_width && d <= corner_radius) { + // Inside + float rel_d = (d - corner_radius + border_width) / border_width; + ALPHA = min((rel_d / (border_fade_in * border_scale / border_width)), (1.0 - (rel_d)) / (border_fade_out * border_scale / border_width)); + } else { + // Outside + ALPHA = 0.0; + } + + +} \ No newline at end of file diff --git a/app/content/ui/test.gd b/app/content/ui/test.gd new file mode 100644 index 0000000..c5fc0a8 --- /dev/null +++ b/app/content/ui/test.gd @@ -0,0 +1,39 @@ +extends Node3D + +@onready var coll = $StaticBody3D/CollisionShape3D +@onready var mesh = $StaticBody3D/MeshInstance3D + +@onready var slider = $StaticBody3D/Slider +@onready var slider2 = $StaticBody3D/Slider2 +@onready var slider3 = $StaticBody3D/Slider3 +@onready var slider4 = $StaticBody3D/Slider4 +@onready var slider5 = $StaticBody3D/Slider5 +@onready var slider6 = $StaticBody3D/Slider6 + +func _ready(): + slider.on_value_changed.connect(func(value): + mesh.mesh.size.x=value + coll.shape.size.x=value + mesh.material_override.set_shader_parameter("size", Vector2(mesh.mesh.size.x, mesh.mesh.size.y)) + ) + slider2.on_value_changed.connect(func(value): + mesh.mesh.size.y=value + coll.shape.size.y=value + mesh.material_override.set_shader_parameter("size", Vector2(mesh.mesh.size.x, mesh.mesh.size.y)) + ) + + slider3.on_value_changed.connect(func(value): + mesh.material_override.set_shader_parameter("border_size", value) + ) + + slider4.on_value_changed.connect(func(value): + mesh.material_override.set_shader_parameter("corner_radius", value) + ) + + slider5.on_value_changed.connect(func(value): + mesh.material_override.set_shader_parameter("border_fade_in", value) + ) + + slider6.on_value_changed.connect(func(value): + mesh.material_override.set_shader_parameter("border_fade_out", value) + ) diff --git a/app/content/ui/test.tscn b/app/content/ui/test.tscn new file mode 100644 index 0000000..3351fbf --- /dev/null +++ b/app/content/ui/test.tscn @@ -0,0 +1,72 @@ +[gd_scene load_steps=8 format=3 uid="uid://dclceqjqfxekx"] + +[ext_resource type="Script" path="res://content/ui/test.gd" id="1_jevji"] +[ext_resource type="Shader" path="res://content/ui/glass.gdshader" id="1_p0dkh"] +[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="3_f40pk"] +[ext_resource type="Script" path="res://content/functions/movable.gd" id="4_qjv7o"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_ptbst"] +size = Vector3(2, 1, 0.1) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_xoqnh"] +render_priority = 0 +shader = ExtResource("1_p0dkh") +shader_parameter/color = Color(1, 1, 1, 1) +shader_parameter/size = Vector2(2, 1) +shader_parameter/border_size = 0.04 +shader_parameter/border_fade_in = 0.07 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 3.435 + +[sub_resource type="QuadMesh" id="QuadMesh_4253w"] +size = Vector2(2, 1) + +[node name="Test" type="Node3D"] +script = ExtResource("1_jevji") + +[node name="StaticBody3D" type="StaticBody3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.07) +shape = SubResource("BoxShape3D_ptbst") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"] +material_override = SubResource("ShaderMaterial_xoqnh") +mesh = SubResource("QuadMesh_4253w") +skeleton = NodePath("../..") + +[node name="Slider" parent="StaticBody3D" instance=ExtResource("3_f40pk")] +transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0, 0, 0) +min = 0.1 +max = 2.0 +value = 1.0 +show_label = true +label_unit = "w" + +[node name="Slider2" parent="StaticBody3D" instance=ExtResource("3_f40pk")] +transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.0884458, 0, 0) +min = 0.1 +max = 2.0 +value = 1.0 +show_label = true +label_unit = "h" + +[node name="Slider3" parent="StaticBody3D" instance=ExtResource("3_f40pk")] +transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.179572, 0, 0) +show_label = true +label_unit = "s" + +[node name="Slider4" parent="StaticBody3D" instance=ExtResource("3_f40pk")] +transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.277398, 0, 0) +max = 10.0 +show_label = true +label_unit = "c" + +[node name="Slider5" parent="StaticBody3D" instance=ExtResource("3_f40pk")] +transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.368523, 0, 0) + +[node name="Slider6" parent="StaticBody3D" instance=ExtResource("3_f40pk")] +transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.458309, 0, 0) + +[node name="Movable" type="Node" parent="StaticBody3D"] +script = ExtResource("4_qjv7o") From cc69cafd989dd3d7c81919a56daa54c4fd22c116 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Sun, 21 Apr 2024 23:45:09 +0200 Subject: [PATCH 04/24] update shader and test tscn --- app/content/ui/glass.gdshader | 32 +++++++++++++++++++++++++------- app/content/ui/test.material | 3 +++ app/content/ui/test.tscn | 24 +++++++++--------------- 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 app/content/ui/test.material diff --git a/app/content/ui/glass.gdshader b/app/content/ui/glass.gdshader index 716cea5..d0bf6b2 100644 --- a/app/content/ui/glass.gdshader +++ b/app/content/ui/glass.gdshader @@ -1,12 +1,18 @@ shader_type spatial; +render_mode unshaded, cull_disabled; + uniform vec4 color : source_color = vec4(1.0, 1.0, 1.0, 1.0); +uniform vec4 border_color : source_color = vec4(1.0, 1.0, 1.0, 1.0); uniform vec2 size = vec2(1.0, 1.0); -uniform float border_size = 0.1; +uniform float border_size: hint_range(0.0, 0.5) = 0.1; uniform float border_fade_in: hint_range(0.0, 10.0) = 0.0; uniform float border_fade_out: hint_range(0.0, 10.0) = 0.0; uniform float corner_radius = 0.0; +uniform float grain_amount : hint_range(0.0, 1.0) = 0.05; + + float rectangle(vec2 position) { vec2 component_wise_edge_distance = abs(position) - (vec2(0.5, 0.5) * size + corner_radius * (size - 1.0)); float outsideDistance = length(max(component_wise_edge_distance, 0)); @@ -15,19 +21,31 @@ float rectangle(vec2 position) { } void fragment() { - ALBEDO = color.xyz; + ALBEDO = border_color.xyz; + ALPHA = 0.0; float border_scale = 1.0 + 2.0 * corner_radius; float d = rectangle((UV - 0.5) * size * border_scale); float border_width = (border_size + border_fade_in + border_fade_out) * border_scale; if (d >= corner_radius - border_width && d <= corner_radius) { - // Inside float rel_d = (d - corner_radius + border_width) / border_width; - ALPHA = min((rel_d / (border_fade_in * border_scale / border_width)), (1.0 - (rel_d)) / (border_fade_out * border_scale / border_width)); - } else { - // Outside - ALPHA = 0.0; + float alpha = min((rel_d / (border_fade_in * border_scale / border_width)), (1.0 - (rel_d)) / (border_fade_out * border_scale / border_width)); + if (d < corner_radius - (border_size + border_fade_out) * border_scale) { + ALBEDO = mix(color, border_color, alpha).xyz; + ALPHA = mix(color.w, border_color.w, alpha); + } else { + ALBEDO = border_color.xyz; + ALPHA = mix(0.0, border_color.w, alpha); + } + } else if (d < corner_radius - border_width ) { + ALBEDO = color.xyz; + ALPHA = color.w; } + float noise = (fract(sin(dot(UV, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * 2.0; + + // Add noise to the original color + ALBEDO += noise * grain_amount; + } \ No newline at end of file diff --git a/app/content/ui/test.material b/app/content/ui/test.material new file mode 100644 index 0000000..baf74a1 --- /dev/null +++ b/app/content/ui/test.material @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca6bc1d679f5e116431fb17104d1bcb1083ca0b5e834c20bd5008dbaa7c3b79a +size 413 diff --git a/app/content/ui/test.tscn b/app/content/ui/test.tscn index 3351fbf..51d143e 100644 --- a/app/content/ui/test.tscn +++ b/app/content/ui/test.tscn @@ -1,25 +1,15 @@ -[gd_scene load_steps=8 format=3 uid="uid://dclceqjqfxekx"] +[gd_scene load_steps=7 format=3 uid="uid://dclceqjqfxekx"] [ext_resource type="Script" path="res://content/ui/test.gd" id="1_jevji"] -[ext_resource type="Shader" path="res://content/ui/glass.gdshader" id="1_p0dkh"] +[ext_resource type="Material" uid="uid://dy5bbwaceset8" path="res://content/ui/test.material" id="2_fswvt"] [ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="3_f40pk"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_qjv7o"] [sub_resource type="BoxShape3D" id="BoxShape3D_ptbst"] size = Vector3(2, 1, 0.1) -[sub_resource type="ShaderMaterial" id="ShaderMaterial_xoqnh"] -render_priority = 0 -shader = ExtResource("1_p0dkh") -shader_parameter/color = Color(1, 1, 1, 1) -shader_parameter/size = Vector2(2, 1) -shader_parameter/border_size = 0.04 -shader_parameter/border_fade_in = 0.07 -shader_parameter/border_fade_out = 0.0 -shader_parameter/corner_radius = 3.435 - [sub_resource type="QuadMesh" id="QuadMesh_4253w"] -size = Vector2(2, 1) +size = Vector2(0.8, 0.5) [node name="Test" type="Node3D"] script = ExtResource("1_jevji") @@ -28,10 +18,11 @@ script = ExtResource("1_jevji") [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.07) +visible = false shape = SubResource("BoxShape3D_ptbst") [node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"] -material_override = SubResource("ShaderMaterial_xoqnh") +material_override = ExtResource("2_fswvt") mesh = SubResource("QuadMesh_4253w") skeleton = NodePath("../..") @@ -53,20 +44,23 @@ label_unit = "h" [node name="Slider3" parent="StaticBody3D" instance=ExtResource("3_f40pk")] transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.179572, 0, 0) +max = 0.5 show_label = true label_unit = "s" [node name="Slider4" parent="StaticBody3D" instance=ExtResource("3_f40pk")] transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.277398, 0, 0) -max = 10.0 show_label = true label_unit = "c" [node name="Slider5" parent="StaticBody3D" instance=ExtResource("3_f40pk")] transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.368523, 0, 0) +max = 0.5 [node name="Slider6" parent="StaticBody3D" instance=ExtResource("3_f40pk")] transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.458309, 0, 0) +max = 0.5 +value = 0.0 [node name="Movable" type="Node" parent="StaticBody3D"] script = ExtResource("4_qjv7o") From 407a5096692fb26410bc8f0240fc4549e59555a6 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 22 Apr 2024 23:47:56 +0200 Subject: [PATCH 05/24] work on glass effect --- .../house/mini/mini_wall_shader.gdshader | 21 ++++++++- app/content/ui/glass.gdshader | 22 ++++++++- app/content/ui/glass2.gdshader | 46 +++++++++++++++++++ app/content/ui/test.material | 4 +- app/content/ui/test.tscn | 25 +++++++++- 5 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 app/content/ui/glass2.gdshader diff --git a/app/content/system/house/mini/mini_wall_shader.gdshader b/app/content/system/house/mini/mini_wall_shader.gdshader index b11c4e6..7ae17f2 100644 --- a/app/content/system/house/mini/mini_wall_shader.gdshader +++ b/app/content/system/house/mini/mini_wall_shader.gdshader @@ -1,11 +1,14 @@ shader_type spatial; -render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_lambert, specular_schlick_ggx, unshaded; +render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_schlick_ggx, shadows_disabled; uniform vec4 data[100]; uniform int data_size: hint_range(0, 100, 1); uniform float alpha: hint_range(0.0, 1.0, 0.1) = 0.3; uniform sampler2D color_gradient; +uniform float roughness : hint_range(0.0, 1.0) = 0.15; +uniform vec4 edge_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); + varying vec3 color; float simple_weight(int index, vec3 world_pos, float p) { @@ -17,6 +20,12 @@ float sphere_weight(int index, vec3 world_pos, float r) { return pow(max(0, r - dist) / (r * dist), 2); } +float SchlickFresnel(float u) { + float m = 1.0 - u; + float m2 = m * m; + return m2 * m2 * m; +} + void vertex() { color = vec3(1.0, 1.0, 1.0); @@ -60,4 +69,14 @@ void vertex() { void fragment() { ALBEDO = vec3(color.xyz); ALPHA = alpha; + + float VdotN = dot(VIEW, NORMAL); + float fresnel = clamp(SchlickFresnel(VdotN), 0.0, 1.0); + + // apply glass look + float a = mix(0.001, 1.0, ALPHA); + ALPHA = mix(fresnel * edge_color.a, 1.0, a); + ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO, a); + ROUGHNESS = roughness; + SPECULAR = 0.5 * inversesqrt(ALPHA); } diff --git a/app/content/ui/glass.gdshader b/app/content/ui/glass.gdshader index d0bf6b2..455ebb5 100644 --- a/app/content/ui/glass.gdshader +++ b/app/content/ui/glass.gdshader @@ -1,6 +1,6 @@ shader_type spatial; -render_mode unshaded, cull_disabled; +render_mode diffuse_burley, specular_schlick_ggx, blend_mix, cull_disabled, shadows_disabled; uniform vec4 color : source_color = vec4(1.0, 1.0, 1.0, 1.0); uniform vec4 border_color : source_color = vec4(1.0, 1.0, 1.0, 1.0); @@ -10,6 +10,9 @@ uniform float border_fade_in: hint_range(0.0, 10.0) = 0.0; uniform float border_fade_out: hint_range(0.0, 10.0) = 0.0; uniform float corner_radius = 0.0; +uniform float roughness : hint_range(0.0, 1.0) = 0.15; +uniform vec4 edge_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); + uniform float grain_amount : hint_range(0.0, 1.0) = 0.05; @@ -20,7 +23,17 @@ float rectangle(vec2 position) { return outsideDistance + insideDistance; } +float SchlickFresnel(float u) { + float m = 1.0 - u; + float m2 = m * m; + return m2 * m2 * m; +} + void fragment() { + + float VdotN = dot(VIEW, NORMAL); + float fresnel = clamp(SchlickFresnel(VdotN), 0.0, 1.0); + ALBEDO = border_color.xyz; ALPHA = 0.0; float border_scale = 1.0 + 2.0 * corner_radius; @@ -42,6 +55,13 @@ void fragment() { ALPHA = color.w; } + float a = mix(0.001, 1.0, ALPHA); + ALPHA = mix(fresnel * edge_color.a, 1.0, a); + ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO.rgb, a); + + ROUGHNESS = roughness; + SPECULAR = 0.5 * inversesqrt(ALPHA); + float noise = (fract(sin(dot(UV, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * 2.0; // Add noise to the original color diff --git a/app/content/ui/glass2.gdshader b/app/content/ui/glass2.gdshader new file mode 100644 index 0000000..b12dd58 --- /dev/null +++ b/app/content/ui/glass2.gdshader @@ -0,0 +1,46 @@ +shader_type spatial; +render_mode diffuse_burley, specular_schlick_ggx, blend_mix; + +group_uniforms albedo; +uniform vec4 albedo : source_color = vec4(1.0, 1.0, 1.0, 0.0); +uniform sampler2D albedo_texture : source_color, hint_default_white; + +group_uniforms roughness; +uniform float roughness : hint_range(0.0, 1.0) = 0.15; +uniform sampler2D roughness_texture : hint_roughness_r; + +group_uniforms normal; +uniform float normal_strength : hint_range(-16.0, 16.0) = 1.0; +uniform sampler2D normal_map : hint_normal; + +group_uniforms misc; +uniform vec4 edge_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); + +float SchlickFresnel(float u) { + float m = 1.0 - u; + float m2 = m * m; + return m2 * m2 * m; +} + +void fragment() { + // calculate fresnel values + float VdotN = dot(VIEW, NORMAL); + float fresnel = clamp(SchlickFresnel(VdotN), 0.0, 1.0); + + // sample and mix textures + vec4 _albedo = texture(albedo_texture, UV) * albedo; + float _roughness = texture(roughness_texture, UV).r * roughness; + + // apply glass look + float a = mix(0.001, 1.0, _albedo.a); + ALPHA = mix(fresnel * edge_color.a, 1.0, a); + ALBEDO = mix(edge_color.rgb * edge_color.a, _albedo.rgb, a); + + ROUGHNESS = _roughness; + NORMAL_MAP = texture(normal_map, UV).xyz; + NORMAL_MAP_DEPTH = normal_strength; + + // function to compensate specular for alpha blend + // 0.5 * ALPHA^-0.5 + SPECULAR = 0.5 * inversesqrt(ALPHA); +} \ No newline at end of file diff --git a/app/content/ui/test.material b/app/content/ui/test.material index baf74a1..53681ab 100644 --- a/app/content/ui/test.material +++ b/app/content/ui/test.material @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ca6bc1d679f5e116431fb17104d1bcb1083ca0b5e834c20bd5008dbaa7c3b79a -size 413 +oid sha256:6041f48bfc2a4bc4c88096265fb3baf46881eec9a244104378c98a6c5e0dbb9a +size 442 diff --git a/app/content/ui/test.tscn b/app/content/ui/test.tscn index 51d143e..c13bcd6 100644 --- a/app/content/ui/test.tscn +++ b/app/content/ui/test.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://dclceqjqfxekx"] +[gd_scene load_steps=10 format=3 uid="uid://dclceqjqfxekx"] [ext_resource type="Script" path="res://content/ui/test.gd" id="1_jevji"] [ext_resource type="Material" uid="uid://dy5bbwaceset8" path="res://content/ui/test.material" id="2_fswvt"] [ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="3_f40pk"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_qjv7o"] +[ext_resource type="Shader" path="res://content/ui/glass2.gdshader" id="5_yedor"] [sub_resource type="BoxShape3D" id="BoxShape3D_ptbst"] size = Vector3(2, 1, 0.1) @@ -11,9 +12,24 @@ size = Vector3(2, 1, 0.1) [sub_resource type="QuadMesh" id="QuadMesh_4253w"] size = Vector2(0.8, 0.5) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_tiql8"] +render_priority = 0 +shader = ExtResource("5_yedor") +shader_parameter/albedo = Color(1, 1, 1, 0.388235) +shader_parameter/roughness = 0.15 +shader_parameter/normal_strength = 1.0 +shader_parameter/edge_color = Color(0, 0, 0, 1) + +[sub_resource type="QuadMesh" id="QuadMesh_g82c4"] +size = Vector2(1, 0.5) + [node name="Test" type="Node3D"] script = ExtResource("1_jevji") +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(-0.866023, -0.433016, 0.250001, 0.470665, -0.53724, 0.699892, -0.168754, 0.723789, 0.669068, 0.677175, 0.464924, 0.836006) +shadow_enabled = true + [node name="StaticBody3D" type="StaticBody3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] @@ -64,3 +80,10 @@ value = 0.0 [node name="Movable" type="Node" parent="StaticBody3D"] script = ExtResource("4_qjv7o") + +[node name="MeshInstance3D3" type="MeshInstance3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.0121959) +visible = false +material_override = SubResource("ShaderMaterial_tiql8") +mesh = SubResource("QuadMesh_g82c4") +skeleton = NodePath("../..") From e1a8424cddcad61c6a834ed4c5f656f2d10ce85f Mon Sep 17 00:00:00 2001 From: Nitwel Date: Tue, 23 Apr 2024 14:26:20 +0200 Subject: [PATCH 06/24] use glass ui style --- .../ui => assets/materials}/glass.gdshader | 54 ++++++----- app/content/main.tscn | 8 +- app/content/system/house/mini/mini_wall.tres | 4 +- app/content/system/keyboard/keyboard.tscn | 34 +++++-- app/content/ui/components/button/button.tscn | 28 ++++-- app/content/ui/glass2.gdshader | 46 --------- app/content/ui/menu/menu.tscn | 27 ++++-- app/content/ui/onboarding/onboarding.tscn | 38 +++++--- app/content/ui/test.gd | 39 -------- app/content/ui/test.material | 3 - app/content/ui/test.material.depren | Bin 0 -> 471 bytes app/content/ui/test.tscn | 89 ------------------ 12 files changed, 128 insertions(+), 242 deletions(-) rename app/{content/ui => assets/materials}/glass.gdshader (63%) delete mode 100644 app/content/ui/glass2.gdshader delete mode 100644 app/content/ui/test.gd delete mode 100644 app/content/ui/test.material create mode 100644 app/content/ui/test.material.depren delete mode 100644 app/content/ui/test.tscn diff --git a/app/content/ui/glass.gdshader b/app/assets/materials/glass.gdshader similarity index 63% rename from app/content/ui/glass.gdshader rename to app/assets/materials/glass.gdshader index 455ebb5..45ce262 100644 --- a/app/content/ui/glass.gdshader +++ b/app/assets/materials/glass.gdshader @@ -1,19 +1,22 @@ shader_type spatial; -render_mode diffuse_burley, specular_schlick_ggx, blend_mix, cull_disabled, shadows_disabled; +render_mode diffuse_burley, specular_schlick_ggx, blend_mix, cull_disabled, shadows_disabled, depth_prepass_alpha; -uniform vec4 color : source_color = vec4(1.0, 1.0, 1.0, 1.0); +group_uniforms Color; +uniform vec4 color : source_color = vec4(1.0, 1.0, 1.0, 0.3); uniform vec4 border_color : source_color = vec4(1.0, 1.0, 1.0, 1.0); -uniform vec2 size = vec2(1.0, 1.0); -uniform float border_size: hint_range(0.0, 0.5) = 0.1; -uniform float border_fade_in: hint_range(0.0, 10.0) = 0.0; -uniform float border_fade_out: hint_range(0.0, 10.0) = 0.0; -uniform float corner_radius = 0.0; - -uniform float roughness : hint_range(0.0, 1.0) = 0.15; uniform vec4 edge_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); -uniform float grain_amount : hint_range(0.0, 1.0) = 0.05; +group_uniforms Size; +uniform vec2 size = vec2(1.0, 1.0); +uniform float border_size: hint_range(0.0, 0.5) = 0.001; +uniform float border_fade_in: hint_range(0.0, 0.5) = 0.005; +uniform float border_fade_out: hint_range(0.0, 0.5) = 0.0; +uniform float corner_radius: hint_range(0.0, 0.5) = 0.04; + +group_uniforms Roughness; +uniform float roughness : hint_range(0.0, 1.0) = 0.3; +uniform float grain_amount : hint_range(0.0, 1.0) = 0.02; float rectangle(vec2 position) { @@ -40,32 +43,39 @@ void fragment() { float d = rectangle((UV - 0.5) * size * border_scale); float border_width = (border_size + border_fade_in + border_fade_out) * border_scale; + bool inside = false; + if (d >= corner_radius - border_width && d <= corner_radius) { + // Border float rel_d = (d - corner_radius + border_width) / border_width; float alpha = min((rel_d / (border_fade_in * border_scale / border_width)), (1.0 - (rel_d)) / (border_fade_out * border_scale / border_width)); if (d < corner_radius - (border_size + border_fade_out) * border_scale) { + // Inner Fade ALBEDO = mix(color, border_color, alpha).xyz; ALPHA = mix(color.w, border_color.w, alpha); + inside = true; } else { + // Outer Fade ALBEDO = border_color.xyz; ALPHA = mix(0.0, border_color.w, alpha); } } else if (d < corner_radius - border_width ) { + // Inside ALBEDO = color.xyz; ALPHA = color.w; + inside = true; } - float a = mix(0.001, 1.0, ALPHA); - ALPHA = mix(fresnel * edge_color.a, 1.0, a); - ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO.rgb, a); - - ROUGHNESS = roughness; - SPECULAR = 0.5 * inversesqrt(ALPHA); - - float noise = (fract(sin(dot(UV, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * 2.0; + if (inside) { + float a = mix(0.001, 1.0, ALPHA); + ALPHA = mix(fresnel * edge_color.a, 1.0, a); + ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO.rgb, a); + + ROUGHNESS = roughness; + SPECULAR = 0.5 * inversesqrt(ALPHA); + + float noise = (fract(sin(dot(UV, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * 2.0; - // Add noise to the original color - ALBEDO += noise * grain_amount; - - + ALBEDO += noise * grain_amount; + } } \ No newline at end of file diff --git a/app/content/main.tscn b/app/content/main.tscn index 4a43fd7..f1d7644 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://eecv28y6jxk4"] +[gd_scene load_steps=17 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,7 +12,6 @@ [ext_resource type="PackedScene" uid="uid://lrehk38exd5n" path="res://content/system/keyboard/keyboard.tscn" id="9_e5n3p"] [ext_resource type="PackedScene" uid="uid://cbemihbxkd4ll" path="res://content/system/house/house.tscn" id="9_np6mw"] [ext_resource type="PackedScene" uid="uid://bhyddd1f0ry1x" path="res://content/ui/onboarding/onboarding.tscn" id="12_uq2nj"] -[ext_resource type="PackedScene" uid="uid://dclceqjqfxekx" path="res://content/ui/test.tscn" id="13_eg13b"] [sub_resource type="Sky" id="Sky_vhymk"] sky_material = ExtResource("5_wgwf8") @@ -44,7 +43,7 @@ script = ExtResource("1_uvrd4") environment = SubResource("Environment_7ghp0") [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(0.834925, -0.386727, -0.39159, 0.550364, 0.586681, 0.594058, 2.91038e-11, -0.711511, 0.702675, -2.91038e-10, 7.21041, 2.06458) +transform = Transform3D(1, -2.51787e-05, 0.000567105, -0.000567105, 4.3985e-08, 1, -2.51784e-05, -1, 2.97105e-08, -4.65661e-10, 7.21041, 2.06458) shadow_enabled = true [node name="XROrigin3D" type="XROrigin3D" parent="."] @@ -89,7 +88,4 @@ transform = Transform3D(0.499999, -0.000139169, -6.50204e-05, 5.24307e-05, 0.353 [node name="Onboarding" parent="." instance=ExtResource("12_uq2nj")] transform = Transform3D(0.999999, -1.39632e-11, 0, 9.48097e-12, 0.999999, 0, 0, 0, 0.999999, -0.529594, 0.820154, -0.600147) -[node name="Test" parent="." instance=ExtResource("13_eg13b")] -transform = Transform3D(-0.0709227, 0.000321724, 0.997481, 0.000312568, 1, -0.000300313, -0.997482, 0.000290482, -0.0709229, -0.0248237, 0.934686, -0.49358) - [editable path="XROrigin3D/XRControllerLeft"] diff --git a/app/content/system/house/mini/mini_wall.tres b/app/content/system/house/mini/mini_wall.tres index d8f483f..20f7c8e 100644 --- a/app/content/system/house/mini/mini_wall.tres +++ b/app/content/system/house/mini/mini_wall.tres @@ -4,9 +4,11 @@ [ext_resource type="Texture2D" uid="uid://bbuq4wn7e5o2q" path="res://content/system/house/mini/temp_gradient.tres" id="2_3lwi8"] [resource] -render_priority = 0 +render_priority = -2 shader = ExtResource("1_sbr3e") shader_parameter/data = PackedFloat32Array() shader_parameter/data_size = 0 shader_parameter/alpha = 0.3 +shader_parameter/roughness = 0.15 +shader_parameter/edge_color = Color(0, 0, 0, 1) shader_parameter/color_gradient = ExtResource("2_3lwi8") diff --git a/app/content/system/keyboard/keyboard.tscn b/app/content/system/keyboard/keyboard.tscn index 8c9cfda..6801a03 100644 --- a/app/content/system/keyboard/keyboard.tscn +++ b/app/content/system/keyboard/keyboard.tscn @@ -1,26 +1,40 @@ -[gd_scene load_steps=9 format=3 uid="uid://lrehk38exd5n"] +[gd_scene load_steps=10 format=3 uid="uid://lrehk38exd5n"] [ext_resource type="Script" path="res://content/system/keyboard/keyboard.gd" id="1_maojw"] [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="Material" uid="uid://bnwimm214q67g" path="res://assets/materials/sec-500.material" id="5_8c8rc"] +[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="5_0dbg6"] [ext_resource type="Script" path="res://content/functions/occludable.gd" id="6_y4sdl"] [sub_resource type="BoxShape3D" id="BoxShape3D_k5ib7"] size = Vector3(0.79, 0.01, 0.26) -[sub_resource type="BoxMesh" id="BoxMesh_7rntc"] -size = Vector3(0.79, 0.01, 0.26) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_x72nd"] +render_priority = 0 +shader = ExtResource("5_0dbg6") +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.79, 0.26) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_88pdc"] +size = Vector2(0.79, 0.26) [node name="Keyboard" type="StaticBody3D" groups=["ui_focus_stop"]] transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) -collision_layer = 2 -collision_mask = 2 +collision_layer = 6 +collision_mask = 0 script = ExtResource("1_maojw") [node name="Backspace" parent="." instance=ExtResource("1_xdpwr")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.349964, 0, -0.0700361) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.35, 0, -0.07) focusable = false label = "backspace" icon = true @@ -55,9 +69,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0093171, -0.009645, 0.0028 shape = SubResource("BoxShape3D_k5ib7") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0093171, -0.009645, 0.00284005) -material_override = ExtResource("5_8c8rc") -mesh = SubResource("BoxMesh_7rntc") +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.0093171, -0.009645, 0.00284005) +material_override = SubResource("ShaderMaterial_x72nd") +mesh = SubResource("QuadMesh_88pdc") [node name="Occludable" type="Node" parent="."] script = ExtResource("6_y4sdl") diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index 065d65e..bed70d8 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -1,8 +1,24 @@ -[gd_scene load_steps=7 format=3 uid="uid://bsjqdvkt0u87c"] +[gd_scene load_steps=8 format=3 uid="uid://bsjqdvkt0u87c"] [ext_resource type="Script" path="res://content/ui/components/button/button.gd" id="1_74x7g"] -[ext_resource type="ArrayMesh" uid="uid://iv4lk77axlk4" path="res://assets/immersive_home/button.obj" id="2_cve3l"] -[ext_resource type="Material" uid="uid://bujy3egn1oqac" path="res://assets/materials/pri-500.material" id="2_wx7av"] +[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="4_2xlpt"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_oqan0"] +render_priority = 0 +shader = ExtResource("4_2xlpt") +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.1, 0.1) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_bt05p"] +size = Vector2(0.1, 0.1) [sub_resource type="BoxShape3D" id="BoxShape3D_xwopm"] size = Vector3(0.05, 0.02, 0.05) @@ -23,9 +39,9 @@ collision_layer = 2 collision_mask = 0 [node name="MeshInstance3D" type="MeshInstance3D" parent="Body"] -transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.005, 0) -material_override = ExtResource("2_wx7av") -mesh = ExtResource("2_cve3l") +transform = Transform3D(0.5, 0, 0, 0, -2.18557e-08, 0.5, 0, -0.5, -2.18557e-08, 0, 0.009, 0) +material_override = SubResource("ShaderMaterial_oqan0") +mesh = SubResource("QuadMesh_bt05p") skeleton = NodePath("../..") [node name="CollisionShape3D" type="CollisionShape3D" parent="Body"] diff --git a/app/content/ui/glass2.gdshader b/app/content/ui/glass2.gdshader deleted file mode 100644 index b12dd58..0000000 --- a/app/content/ui/glass2.gdshader +++ /dev/null @@ -1,46 +0,0 @@ -shader_type spatial; -render_mode diffuse_burley, specular_schlick_ggx, blend_mix; - -group_uniforms albedo; -uniform vec4 albedo : source_color = vec4(1.0, 1.0, 1.0, 0.0); -uniform sampler2D albedo_texture : source_color, hint_default_white; - -group_uniforms roughness; -uniform float roughness : hint_range(0.0, 1.0) = 0.15; -uniform sampler2D roughness_texture : hint_roughness_r; - -group_uniforms normal; -uniform float normal_strength : hint_range(-16.0, 16.0) = 1.0; -uniform sampler2D normal_map : hint_normal; - -group_uniforms misc; -uniform vec4 edge_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); - -float SchlickFresnel(float u) { - float m = 1.0 - u; - float m2 = m * m; - return m2 * m2 * m; -} - -void fragment() { - // calculate fresnel values - float VdotN = dot(VIEW, NORMAL); - float fresnel = clamp(SchlickFresnel(VdotN), 0.0, 1.0); - - // sample and mix textures - vec4 _albedo = texture(albedo_texture, UV) * albedo; - float _roughness = texture(roughness_texture, UV).r * roughness; - - // apply glass look - float a = mix(0.001, 1.0, _albedo.a); - ALPHA = mix(fresnel * edge_color.a, 1.0, a); - ALBEDO = mix(edge_color.rgb * edge_color.a, _albedo.rgb, a); - - ROUGHNESS = _roughness; - NORMAL_MAP = texture(normal_map, UV).xyz; - NORMAL_MAP_DEPTH = normal_strength; - - // function to compensate specular for alpha blend - // 0.5 * ALPHA^-0.5 - SPECULAR = 0.5 * inversesqrt(ALPHA); -} \ No newline at end of file diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index 3de734c..b6eece1 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=19 format=3 uid="uid://c3kdssrmv84kv"] [ext_resource type="Script" path="res://content/ui/menu/menu.gd" id="1_ng4u3"] -[ext_resource type="Material" uid="uid://bnwimm214q67g" path="res://assets/materials/sec-500.material" id="2_0x5at"] [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="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"] @@ -18,11 +18,22 @@ size = Vector3(0.38, 0.0128076, 0.32) [sub_resource type="BoxShape3D" id="BoxShape3D_6xn1i"] size = Vector3(0.3, 0.0264844, 0.3) -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_01s1g"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_mhqg4"] +render_priority = 0 +shader = ExtResource("3_htaoi") +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.3, 0.3) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 -[sub_resource type="BoxMesh" id="BoxMesh_08du6"] -material = SubResource("StandardMaterial3D_01s1g") -size = Vector3(0.3, 0.01, 0.3) +[sub_resource type="QuadMesh" id="QuadMesh_4bh1v"] +size = Vector2(0.3, 0.3) [sub_resource type="Animation" id="Animation_61md4"] length = 0.001 @@ -183,9 +194,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.21, -0.00824219, 0.15) shape = SubResource("BoxShape3D_6xn1i") [node name="Background" type="MeshInstance3D" parent="AnimationContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.21, 0, 0.15) -material_override = ExtResource("2_0x5at") -mesh = SubResource("BoxMesh_08du6") +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.21, 0.01, 0.15) +material_override = SubResource("ShaderMaterial_mhqg4") +mesh = SubResource("QuadMesh_4bh1v") skeleton = NodePath("../..") [node name="Tabs" type="Node3D" parent="AnimationContainer" node_paths=PackedStringArray("initial_selected")] diff --git a/app/content/ui/onboarding/onboarding.tscn b/app/content/ui/onboarding/onboarding.tscn index 2f8db91..9e2864b 100644 --- a/app/content/ui/onboarding/onboarding.tscn +++ b/app/content/ui/onboarding/onboarding.tscn @@ -1,22 +1,36 @@ -[gd_scene load_steps=6 format=3 uid="uid://bhyddd1f0ry1x"] +[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="Material" uid="uid://bujy3egn1oqac" path="res://assets/materials/pri-500.material" id="2_aleti"] +[ext_resource type="Shader" path="res://assets/materials/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"] size = Vector3(0.5, 0.3, 0.01) -[sub_resource type="BoxMesh" id="BoxMesh_yknqs"] -size = Vector3(0.5, 0.3, 0.01) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_d2ck8"] +render_priority = -1 +shader = ExtResource("2_87aan") +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(1, 1) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.04 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_ij2lj"] +size = Vector2(0.5, 0.3) [node name="Onboarding" type="StaticBody3D"] collision_layer = 6 -collision_mask = 6 +collision_mask = 0 script = ExtResource("1_k4yvw") [node name="Label3D2" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, -0.1, 0.006) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, -0.1, 0.001) pixel_size = 0.001 text = "Getting Started" font_size = 18 @@ -30,11 +44,11 @@ width = 470.0 shape = SubResource("BoxShape3D_nfwtf") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] -material_override = ExtResource("2_aleti") -mesh = SubResource("BoxMesh_yknqs") +material_override = SubResource("ShaderMaterial_d2ck8") +mesh = SubResource("QuadMesh_ij2lj") [node name="GettingStartedLabel" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.14, 0.006) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.13, 0.001) pixel_size = 0.001 text = "Hey! @@ -49,17 +63,17 @@ autowrap_mode = 3 width = 470.0 [node name="GettingStartedButton" parent="." instance=ExtResource("3_hlpow")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.05, -0.11, 0) +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.05, -0.11, 0.001) label = "open_in_new" icon = true [node name="CloseButton" parent="." instance=ExtResource("3_hlpow")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.21, -0.11, 0) +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.21, -0.11, 0.001) label = "done" icon = true [node name="CloseLabel" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, -0.1, 0.006) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, -0.1, 0.001) pixel_size = 0.001 text = "Understood" font_size = 18 diff --git a/app/content/ui/test.gd b/app/content/ui/test.gd deleted file mode 100644 index c5fc0a8..0000000 --- a/app/content/ui/test.gd +++ /dev/null @@ -1,39 +0,0 @@ -extends Node3D - -@onready var coll = $StaticBody3D/CollisionShape3D -@onready var mesh = $StaticBody3D/MeshInstance3D - -@onready var slider = $StaticBody3D/Slider -@onready var slider2 = $StaticBody3D/Slider2 -@onready var slider3 = $StaticBody3D/Slider3 -@onready var slider4 = $StaticBody3D/Slider4 -@onready var slider5 = $StaticBody3D/Slider5 -@onready var slider6 = $StaticBody3D/Slider6 - -func _ready(): - slider.on_value_changed.connect(func(value): - mesh.mesh.size.x=value - coll.shape.size.x=value - mesh.material_override.set_shader_parameter("size", Vector2(mesh.mesh.size.x, mesh.mesh.size.y)) - ) - slider2.on_value_changed.connect(func(value): - mesh.mesh.size.y=value - coll.shape.size.y=value - mesh.material_override.set_shader_parameter("size", Vector2(mesh.mesh.size.x, mesh.mesh.size.y)) - ) - - slider3.on_value_changed.connect(func(value): - mesh.material_override.set_shader_parameter("border_size", value) - ) - - slider4.on_value_changed.connect(func(value): - mesh.material_override.set_shader_parameter("corner_radius", value) - ) - - slider5.on_value_changed.connect(func(value): - mesh.material_override.set_shader_parameter("border_fade_in", value) - ) - - slider6.on_value_changed.connect(func(value): - mesh.material_override.set_shader_parameter("border_fade_out", value) - ) diff --git a/app/content/ui/test.material b/app/content/ui/test.material deleted file mode 100644 index 53681ab..0000000 --- a/app/content/ui/test.material +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6041f48bfc2a4bc4c88096265fb3baf46881eec9a244104378c98a6c5e0dbb9a -size 442 diff --git a/app/content/ui/test.material.depren b/app/content/ui/test.material.depren new file mode 100644 index 0000000000000000000000000000000000000000..ccca6a25c2acd663c34d0d17921789cb9f6d2056 GIT binary patch literal 471 zcmV;|0Vw`bQ$s@n000005C8y$0{{TO0RR9fwJ-f(g#xV&0A>|SJV0-f#=~&qL(1?x z2K8CE)UpPx^>8T9@jy1I$lks836ey-v+Z1F=>5F^F>3g(Z#DyUXevoiYfT~DQZxWJ z05|}eQ+t{7<+BV%Cbb7jEFZ1lrv4nif=ig7R4^eUrNtlM%TjZiv4LnpZ6xGR@C*0> z{FV>!={QzU!q2gUnurJwP7=2aGJ?{9LJ7IZ{ra_$oLx_FU6wH{VE9 zL2d9>4rA)3FkQlMxof7nVF2F#rRGgfwxC4s=1{Mku8X(31tq>w0 zGq#ZOQ}_w2e|d26;s>k^=Axmb#AIz2aAZydIUsO?89UMrXbJu`!j! Date: Tue, 23 Apr 2024 22:11:18 +0200 Subject: [PATCH 07/24] continue updating the ui --- app/assets/materials/glass.gdshader | 4 +- app/content/main.tscn | 6 +- app/content/system/keyboard/keyboard.tscn | 22 ++- app/content/ui/components/button/button.gd | 30 ++++- app/content/ui/components/button/button.tscn | 36 +++-- .../ui/components/container/container3d.gd | 19 +-- .../flex_container/flex_container.gd | 112 ++++++++++++++++ .../grid_container/grid_container.gd | 55 ++++---- app/content/ui/components/input/input.gd | 36 ++--- app/content/ui/components/input/input.tscn | 62 ++++++--- .../ui/components/input/text_handler.gd | 10 +- .../ui/components/line_chart/line_chart.tscn | 4 +- .../components/notification/notification.tscn | 1 + app/content/ui/components/slider/slider.gd | 85 +++--------- app/content/ui/components/slider/slider.tscn | 126 +++++++++--------- app/content/ui/components/tabs/tabs.gd | 8 +- app/content/ui/menu/edit/edit_menu.gd | 4 - app/content/ui/menu/edit/edit_menu.tscn | 10 +- app/content/ui/menu/menu.gd | 2 - app/content/ui/menu/menu.tscn | 74 ++++++---- app/content/ui/menu/room/room_menu.tscn | 3 +- app/content/ui/menu/view/view_menu.tscn | 69 ++++++---- 22 files changed, 465 insertions(+), 313 deletions(-) create mode 100644 app/content/ui/components/flex_container/flex_container.gd diff --git a/app/assets/materials/glass.gdshader b/app/assets/materials/glass.gdshader index 45ce262..deaaf8e 100644 --- a/app/assets/materials/glass.gdshader +++ b/app/assets/materials/glass.gdshader @@ -1,6 +1,6 @@ shader_type spatial; -render_mode diffuse_burley, specular_schlick_ggx, blend_mix, cull_disabled, shadows_disabled, depth_prepass_alpha; +render_mode diffuse_burley, specular_schlick_ggx, blend_mix, cull_disabled, shadows_disabled; group_uniforms Color; uniform vec4 color : source_color = vec4(1.0, 1.0, 1.0, 0.3); @@ -12,7 +12,7 @@ uniform vec2 size = vec2(1.0, 1.0); uniform float border_size: hint_range(0.0, 0.5) = 0.001; uniform float border_fade_in: hint_range(0.0, 0.5) = 0.005; uniform float border_fade_out: hint_range(0.0, 0.5) = 0.0; -uniform float corner_radius: hint_range(0.0, 0.5) = 0.04; +uniform float corner_radius = 0.04; group_uniforms Roughness; uniform float roughness : hint_range(0.0, 1.0) = 0.3; diff --git a/app/content/main.tscn b/app/content/main.tscn index f1d7644..331c1cb 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -76,16 +76,16 @@ min_camera_height = 0.01 xr_origin = NodePath("../XROrigin3D") [node name="Menu" parent="." instance=ExtResource("8_du83w")] -transform = Transform3D(0.999998, -0.000514899, -6.55874e-05, 1.96975e-05, 0.163911, -0.986474, 0.000518685, 0.986474, 0.163911, -0.0165588, 0.796337, -0.634317) +transform = Transform3D(0.999999, -1.39633e-11, 0, 1.60657e-10, 1, -4.54747e-13, 0, 0, 0.999999, -0.0165677, 0.766337, -0.634317) [node name="Keyboard" parent="." instance=ExtResource("9_e5n3p")] -transform = Transform3D(0.499999, -0.000139169, -6.50204e-05, 5.24307e-05, 0.353553, -0.353553, 0.000144383, 0.353553, 0.353553, -0.0199266, 0.550784, -0.47368) +transform = Transform3D(0.5, -0.000139169, -6.50202e-05, 5.2431e-05, 0.353553, -0.353553, 0.000144384, 0.353553, 0.353553, -0.0199266, 0.550784, -0.47368) [node name="Rooms" type="Node3D" parent="."] [node name="House" parent="." instance=ExtResource("9_np6mw")] [node name="Onboarding" parent="." instance=ExtResource("12_uq2nj")] -transform = Transform3D(0.999999, -1.39632e-11, 0, 9.48097e-12, 0.999999, 0, 0, 0, 0.999999, -0.529594, 0.820154, -0.600147) +transform = Transform3D(1, -9.48098e-12, 0, 9.48098e-12, 1, 0, 0, 0, 1, -0.529594, 0.820154, -0.600147) [editable path="XROrigin3D/XRControllerLeft"] diff --git a/app/content/system/keyboard/keyboard.tscn b/app/content/system/keyboard/keyboard.tscn index 6801a03..33d2ae6 100644 --- a/app/content/system/keyboard/keyboard.tscn +++ b/app/content/system/keyboard/keyboard.tscn @@ -8,15 +8,15 @@ [ext_resource type="Script" path="res://content/functions/occludable.gd" id="6_y4sdl"] [sub_resource type="BoxShape3D" id="BoxShape3D_k5ib7"] -size = Vector3(0.79, 0.01, 0.26) +size = Vector3(0.86, 0.27, 0.02) [sub_resource type="ShaderMaterial" id="ShaderMaterial_x72nd"] -render_priority = 0 +render_priority = -1 shader = ExtResource("5_0dbg6") 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.79, 0.26) +shader_parameter/size = Vector2(0.86, 0.27) shader_parameter/border_size = 0.001 shader_parameter/border_fade_in = 0.005 shader_parameter/border_fade_out = 0.0 @@ -25,7 +25,7 @@ shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 [sub_resource type="QuadMesh" id="QuadMesh_88pdc"] -size = Vector2(0.79, 0.26) +size = Vector2(0.86, 0.27) [node name="Keyboard" type="StaticBody3D" groups=["ui_focus_stop"]] transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) @@ -34,7 +34,7 @@ collision_mask = 0 script = ExtResource("1_maojw") [node name="Backspace" parent="." instance=ExtResource("1_xdpwr")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.35, 0, -0.07) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.38, 0.09, 0) focusable = false label = "backspace" icon = true @@ -42,34 +42,32 @@ echo = true metadata/key = 4194308 [node name="Caps" parent="." instance=ExtResource("1_xdpwr")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.370036, 0, 0.059964) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.39, -0.03, 0) focusable = false label = "keyboard_capslock" icon = true toggleable = true [node name="Paste" parent="." instance=ExtResource("1_xdpwr")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.349964, 0, 0.089964) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.38, -0.09, 0) focusable = false label = "assignment" icon = true [node name="Keys" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.310036, 0, -0.090036) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.325, 0.09, 0) script = ExtResource("3_mx544") columns = 11 -depth_gap = 0.06 -size = Vector3(0.6, 1, 1) +gaps = Vector2(0.01, 0.01) +size = Vector3(0.6, 0.15, 1) [node name="Movable" type="Node" parent="."] script = ExtResource("4_86fct") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0093171, -0.009645, 0.00284005) shape = SubResource("BoxShape3D_k5ib7") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.0093171, -0.009645, 0.00284005) material_override = SubResource("ShaderMaterial_x72nd") mesh = SubResource("QuadMesh_88pdc") diff --git a/app/content/ui/components/button/button.gd b/app/content/ui/components/button/button.gd index 5b71137..0c9e639 100644 --- a/app/content/ui/components/button/button.gd +++ b/app/content/ui/components/button/button.gd @@ -1,6 +1,6 @@ @tool -extends Node3D +extends Container3D class_name Button3D signal on_button_down() @@ -12,8 +12,13 @@ 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 collision: CollisionShape3D = $Body/CollisionShape3D @onready var label_node: Label3D = $Body/Label @onready var finger_area: Area3D = $FingerArea +@onready var finger_area_collision: CollisionShape3D = $FingerArea/CollisionShape3D +@onready var touch_collision: CollisionShape3D = $TouchBody/CollisionShape3D +@onready var touch: StaticBody3D = $TouchBody @export var focusable: bool = true: set(value): @@ -72,6 +77,8 @@ func _ready(): if initial_active: active = true + _update() + Update.props(self, ["active", "external_value", "icon", "label", "font_size", "disabled"]) if echo: @@ -92,8 +99,8 @@ func update_animation(value: float): var tween = create_tween() tween.set_parallel(true) - tween.tween_property(body, "scale:y", lerpf(1.0, 0.5, value), 0.2) - tween.tween_property(body, "position:y", lerpf(0.01, 0.005, value), 0.2) + tween.tween_property(body, "scale:z", lerpf(1.0, 0.5, value), 0.2) + tween.tween_property(body, "position:z", lerpf(size.z / 2, size.z / 4, value), 0.2) func _on_press_down(event): if disabled: @@ -181,12 +188,25 @@ func _touch_change(event: EventTouch): var pos = Vector3(0, 1, 0) for finger in event.fingers: var finger_pos = to_local(finger.area.global_position) - if pos.y > finger_pos.y: + if pos.z > finger_pos.z: pos = finger_pos var button_height = 0.2 var button_center = 0.1 - var percent = clamp((button_center + button_height / 2 - pos.y) / (button_height / 2), 0, 1) + var percent = clamp((button_center + button_height / 2 - pos.z) / (button_height / 2), 0, 1) update_animation(percent) + +func _update(): + body.position = Vector3(0, 0, size.z / 2) + finger_area.position = Vector3(0, 0, -0.015) + touch.position = Vector3(0, 0, size.z / 2) + + mesh.mesh.size = Vector2(size.x, size.y) + 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) diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index bed70d8..a597486 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -1,45 +1,43 @@ -[gd_scene load_steps=8 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="Shader" path="res://assets/materials/glass.gdshader" id="4_2xlpt"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_oqan0"] -render_priority = 0 +render_priority = -1 shader = ExtResource("4_2xlpt") 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.1, 0.1) -shader_parameter/border_size = 0.001 -shader_parameter/border_fade_in = 0.005 +shader_parameter/size = Vector2(1, 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.02 +shader_parameter/corner_radius = 0.2 shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 [sub_resource type="QuadMesh" id="QuadMesh_bt05p"] -size = Vector2(0.1, 0.1) +size = Vector2(0.05, 0.05) [sub_resource type="BoxShape3D" id="BoxShape3D_xwopm"] -size = Vector3(0.05, 0.02, 0.05) +size = Vector3(0.05, 0.05, 0.01) [sub_resource type="BoxShape3D" id="BoxShape3D_bqjii"] -size = Vector3(0.0501598, 0.0390937, 0.0501598) - -[sub_resource type="BoxShape3D" id="BoxShape3D_vkbuh"] -size = Vector3(0.05, 0.03, 0.05) +size = Vector3(0.05, 0.05, 0.03) [node name="Button" type="Node3D" groups=["ui_focus"]] script = ExtResource("1_74x7g") label = "Example Text" +size = Vector3(0.05, 0.05, 0.01) [node name="Body" type="StaticBody3D" parent="." groups=["ui_focus_skip"]] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.01, 0) +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"] -transform = Transform3D(0.5, 0, 0, 0, -2.18557e-08, 0.5, 0, -0.5, -2.18557e-08, 0, 0.009, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) material_override = SubResource("ShaderMaterial_oqan0") mesh = SubResource("QuadMesh_bt05p") skeleton = NodePath("../..") @@ -48,8 +46,9 @@ skeleton = NodePath("../..") shape = SubResource("BoxShape3D_xwopm") [node name="Label" type="Label3D" parent="Body"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.0107199, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.006) pixel_size = 0.001 +double_sided = false text = "Example Text" font_size = 10 outline_size = 0 @@ -57,19 +56,18 @@ autowrap_mode = 3 width = 50.0 [node name="FingerArea" type="Area3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0101447, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015) collision_layer = 4 collision_mask = 0 monitoring = false [node name="CollisionShape3D" type="CollisionShape3D" parent="FingerArea"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.00975001, 0) shape = SubResource("BoxShape3D_bqjii") [node name="TouchBody" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) collision_layer = 4 collision_mask = 0 [node name="CollisionShape3D" type="CollisionShape3D" parent="TouchBody"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.005, 0) -shape = SubResource("BoxShape3D_vkbuh") +shape = SubResource("BoxShape3D_xwopm") diff --git a/app/content/ui/components/container/container3d.gd b/app/content/ui/components/container/container3d.gd index 4818f29..dfb2ff4 100644 --- a/app/content/ui/components/container/container3d.gd +++ b/app/content/ui/components/container/container3d.gd @@ -1,15 +1,18 @@ +@tool + extends Node3D class_name Container3D -@export var size := Vector3(1.0, 1.0, 1.0) : +@export var size := Vector3(1.0, 1.0, 1.0): set(value): - size = value - _update_container() + size = Vector3(max(0, value.x), max(0, value.y), max(0, value.z)) -@export var padding: Vector4 = Vector4(0, 0, 0, 0) : - set(value): - padding = value - _update_container() + if !is_inside_tree(): return -func _update_container(): + _update() + +func _ready(): + _update() + +func _update(): pass \ No newline at end of file diff --git a/app/content/ui/components/flex_container/flex_container.gd b/app/content/ui/components/flex_container/flex_container.gd new file mode 100644 index 0000000..45cb610 --- /dev/null +++ b/app/content/ui/components/flex_container/flex_container.gd @@ -0,0 +1,112 @@ +@tool +extends Container3D +class_name FlexContainer3D + +enum Justification { + START, + CENTER, + END, + SPACE_BETWEEN, + SPACE_AROUND, + SPACE_EVENLY, +} + +@export var justification: Justification = Justification.START: + set(value): + justification = value + _update() +@export var vertical: bool = false: + set(value): + vertical = value + _update() +@export var gap: float = 0.0: + set(value): + gap = value + _update() + +func _ready(): + _update() + + child_entered_tree.connect(func(_arg): + _update() + ) + + child_exiting_tree.connect(func(_arg): + _update() + ) + + child_order_changed.connect(func(): + _update() + ) + +func _update(): + print("update") + var width = size.y if vertical else size.x + var child_size := Vector2(0, 0) + var child_count = 0 + + for child in get_children(): + if child is Container3D == false: + continue + + if vertical: + child_size.x = max(child.size.x, child_size.x) + child_size.y += child.size.y + gap + else: + child_size.x += child.size.x + gap + child_size.y = max(child.size.y, child_size.y) + + child_count += 1 + + if child_count == 0: + return + + var child_scale = Vector2(size.x, size.y) / child_size + child_size.clamp(Vector2(0, 0), Vector2(size.x, size.y)) + + child_scale = child_scale.clamp(Vector2(0.001, 0.001), Vector2(1, 1)) + + print(child_size) + print(child_scale) + + var offset = 0.0 + + match justification: + Justification.START: + offset = 0.0 + Justification.CENTER: + offset = (width - child_size) / 2 + Justification.END: + offset = width - child_size + Justification.SPACE_BETWEEN: + offset = 0.0 + Justification.SPACE_AROUND: + offset = (width - child_size) / child_count / 2 + Justification.SPACE_EVENLY: + offset = (width - child_size) / (child_count + 1) + + for child in get_children(): + if child is Container3D == false: + continue + + child.scale = Vector3(child_scale.x, child_scale.y, 1) + + if vertical: + child.position = Vector3(0, -offset, 0) + offset += child.size.y * child_scale.y + else: + child.position = Vector3(offset, 0, 0) + offset += child.size.x * child_scale.x + + print(offset) + + match justification: + Justification.START, Justification.CENTER, Justification.END: + offset += gap + Justification.SPACE_BETWEEN: + offset += (width - child_size) / (child_count - 1) + Justification.SPACE_AROUND: + offset += (width - child_size) / child_count + Justification.SPACE_EVENLY: + offset += (width - child_size) / (child_count + 1) + \ No newline at end of file diff --git a/app/content/ui/components/grid_container/grid_container.gd b/app/content/ui/components/grid_container/grid_container.gd index 3bff0b0..f4f5702 100644 --- a/app/content/ui/components/grid_container/grid_container.gd +++ b/app/content/ui/components/grid_container/grid_container.gd @@ -2,41 +2,46 @@ extends Container3D class_name GridContainer3D - -@export var columns := 5 : +@export var columns := 5: set(value): columns = value - _update_container() + _update() -@export var rows := 1 : +@export var gaps := Vector2(0, 0): set(value): - rows = value - _update_container() - -@export var depth_gap := 1.0 : - set(value): - depth_gap = value - _update_container() + gaps = value + _update() func _ready(): - _update_container() + _update() -func get_gaps() -> Vector3: - return Vector3( - (float(size.x) / (columns - 1 )) if columns != 1 else 0.0, - (float(size.y) / (rows - 1)) if rows != 1 else 0.0, - depth_gap + child_entered_tree.connect(func(_arg): + _update() ) + child_exiting_tree.connect(func(_arg): + _update() + ) -func _update_container(): - var i := 0 - var gaps := get_gaps() + child_order_changed.connect(func(): + _update() + ) + +func _update(): + var column := 0 + var row_pos := 0.0 + var column_max_height := 0.0 for child in get_children(): - var x := (i % columns) * gaps.x - var y := ((i / columns) % rows) * gaps.y - var z := (i / (columns * rows)) * gaps.z + if child is Container3D == false: + continue - child.set_position(Vector3(x, -y, z)) - i += 1 \ No newline at end of file + column_max_height = max(column_max_height, child.size.y) + + child.position = Vector3(column * ((size.x / columns) + gaps.x), row_pos, 0) + + column += 1 + if column >= columns: + column = 0 + row_pos -= column_max_height + gaps.y + \ No newline at end of file diff --git a/app/content/ui/components/input/input.gd b/app/content/ui/components/input/input.gd index 19c454e..21f2942 100644 --- a/app/content/ui/components/input/input.gd +++ b/app/content/ui/components/input/input.gd @@ -1,24 +1,15 @@ @tool -extends StaticBody3D +extends Container3D class_name Input3D var text_handler = preload ("res://content/ui/components/input/text_handler.gd").new() -@onready var caret: MeshInstance3D = $Label/Caret -@onready var mesh_box: MeshInstance3D = $Box -@onready var collision: CollisionShape3D = $Collision +@onready var caret: MeshInstance3D = $Body/Label/Caret +@onready var mesh_box: MeshInstance3D = $Body/Box +@onready var body: StaticBody3D = $Body +@onready var collision: CollisionShape3D = $Body/Collision @onready var animation: AnimationPlayer = $AnimationPlayer -@onready var label: Label3D = $Label - -@export_range(0.1, 2, 0.01, "suffix:m") var width: float = 0.15: - set(value): - width = value - text_handler.width = value - if !is_inside_tree(): return - - mesh_box.mesh.size.x = width - collision.shape.size.x = width - label.position.x = -width / 2 + 0.002 +@onready var label: Label3D = $Body/Label @export var text: String: set(value): @@ -48,10 +39,11 @@ var keyboard_input: bool = false var input_plane = Plane(Vector3.UP, Vector3.ZERO) func _ready(): - Update.props(self, ["text", "disabled", "width"]) - text_handler.label = label + Update.props(self, ["text", "disabled", "width"]) + _update() + if Engine.is_editor_hint(): return @@ -156,3 +148,13 @@ func _draw_debug_text_gaps(): label.to_global(Vector3(offset, 0.01, 0)), Color(1, 0, 0) if i != text_handler.overflow_index else Color(0, 1, 0) ) + +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) + collision.shape.size = size + label.position = Vector3( - size.x / 2 + 0.002, 0, size.z / 2) + label.text = text_handler.get_display_text() + body.position = Vector3(0, 0, size.z / 2) \ No newline at end of file diff --git a/app/content/ui/components/input/input.tscn b/app/content/ui/components/input/input.tscn index c85e882..b6cd564 100644 --- a/app/content/ui/components/input/input.tscn +++ b/app/content/ui/components/input/input.tscn @@ -1,16 +1,32 @@ -[gd_scene load_steps=10 format=3 uid="uid://blrhy2uccrdn4"] +[gd_scene load_steps=12 format=3 uid="uid://blrhy2uccrdn4"] -[ext_resource type="Material" uid="uid://bujy3egn1oqac" path="res://assets/materials/pri-500.material" id="1_0kd7r"] [ext_resource type="Script" path="res://content/ui/components/input/input.gd" id="1_uml3t"] [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"] -[sub_resource type="BoxMesh" id="BoxMesh_kjbca"] -resource_local_to_scene = true -size = Vector3(0.15, 0.006, 0.03) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_c5qdm"] +render_priority = -1 +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/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.01 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_5rrua"] +size = Vector2(0.15, 0.03) [sub_resource type="BoxShape3D" id="BoxShape3D_x4yp8"] resource_local_to_scene = true -size = Vector3(0.15, 0.006, 0.03) +size = Vector3(0.15, 0.03, 0.01) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_x1ra7"] +shading_mode = 0 [sub_resource type="BoxMesh" id="BoxMesh_2736g"] size = Vector3(0.001, 0.02, 0.001) @@ -52,36 +68,44 @@ _data = { "blink": SubResource("Animation_8ny1h") } -[node name="Input" type="StaticBody3D" groups=["ui_focus"]] +[node name="Input" type="Node3D"] +script = ExtResource("1_uml3t") +text = "Example Text" +size = Vector3(0.15, 0.03, 0.01) + +[node name="Body" type="StaticBody3D" parent="." groups=["ui_focus"]] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) collision_layer = 6 collision_mask = 0 -script = ExtResource("1_uml3t") -text = "Example" -[node name="Box" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.003, 0) -material_override = ExtResource("1_0kd7r") -mesh = SubResource("BoxMesh_kjbca") +[node name="Box" 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") -[node name="Collision" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.003, 0) +[node name="Collision" type="CollisionShape3D" parent="Body"] shape = SubResource("BoxShape3D_x4yp8") -[node name="Label" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.073, 0.00618291, 0) +[node name="Label" type="Label3D" parent="Body"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.073, 0, 0.005) +sorting_offset = 0.1 pixel_size = 0.001 -text = "Example" +double_sided = false +alpha_cut = 2 +text = "Example Text" font = ExtResource("3_ij5fh") font_size = 18 outline_size = 0 horizontal_alignment = 0 -[node name="Caret" type="MeshInstance3D" parent="Label"] +[node name="Caret" type="MeshInstance3D" parent="Body/Label"] visible = false +material_override = SubResource("StandardMaterial3D_x1ra7") mesh = SubResource("BoxMesh_2736g") skeleton = NodePath("../..") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] +root_node = NodePath("../Body") libraries = { "": SubResource("AnimationLibrary_1sy4t") } diff --git a/app/content/ui/components/input/text_handler.gd b/app/content/ui/components/input/text_handler.gd index 9679eac..4839358 100644 --- a/app/content/ui/components/input/text_handler.gd +++ b/app/content/ui/components/input/text_handler.gd @@ -5,7 +5,12 @@ const FontTools = preload ("res://lib/utils/font_tools.gd") var label: Label3D var text: String = "" -var width: float = 0.2 +var width: float = 0.2: + set(value): + width = max(0.0, value) + gap_offsets = _calculate_text_gaps() + overflow_index = _calculate_overflow_index() + caret_position = 0 var gap_offsets = null var overflow_index: int = -1 var char_offset: int = 0 @@ -13,9 +18,6 @@ var caret_position: int = 3: set(value): caret_position = clampi(value, 0, text.length()) -func set_width(value: float): - width = value - func set_text(value: String, insert: bool=false): var old_text = text text = value diff --git a/app/content/ui/components/line_chart/line_chart.tscn b/app/content/ui/components/line_chart/line_chart.tscn index 89885c7..a8fa7a4 100644 --- a/app/content/ui/components/line_chart/line_chart.tscn +++ b/app/content/ui/components/line_chart/line_chart.tscn @@ -10,7 +10,7 @@ cull_mode = 2 shading_mode = 0 albedo_color = Color(0.109804, 0.721569, 0.262745, 1) -[sub_resource type="ArrayMesh" id="ArrayMesh_mec1l"] +[sub_resource type="ArrayMesh" id="ArrayMesh_5xylt"] _surfaces = [{ "aabb": AABB(-0.000587015, -0.000596339, 0.0005, 0.501171, 0.301189, 1e-05), "format": 34359742465, @@ -43,7 +43,7 @@ script = ExtResource("1_n7fu8") [node name="Line" type="MeshInstance3D" parent="."] material_override = SubResource("StandardMaterial3D_20gpn") -mesh = SubResource("ArrayMesh_mec1l") +mesh = SubResource("ArrayMesh_5xylt") [node name="Plane" type="MeshInstance3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 0.15, -0.001) diff --git a/app/content/ui/components/notification/notification.tscn b/app/content/ui/components/notification/notification.tscn index 50d8f07..825bfc6 100644 --- a/app/content/ui/components/notification/notification.tscn +++ b/app/content/ui/components/notification/notification.tscn @@ -197,6 +197,7 @@ libraries = { transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0.12, -0.003, -0.02) label = "close" icon = true +size = Vector3(1, 1, 1) [node name="Timer" type="Timer" parent="AnimationNode"] wait_time = 3.0 diff --git a/app/content/ui/components/slider/slider.gd b/app/content/ui/components/slider/slider.gd index 9c4969e..6984977 100644 --- a/app/content/ui/components/slider/slider.gd +++ b/app/content/ui/components/slider/slider.gd @@ -1,5 +1,5 @@ @tool -extends Node3D +extends Container3D class_name Slider3D @export var min: float = 0.0: @@ -42,32 +42,11 @@ class_name Slider3D if !is_inside_tree(): return label.text = str(value) + " " + label_unit -@export var size: Vector3 = Vector3(0.2, 0.01, 0.02): # Warning, units are in cm - set(value): - size = value - if !is_inside_tree(): return - _update_shape() -@export var cutout_border: float = 0.02: - set(value): - cutout_border = value - if !is_inside_tree(): return - _update_shape() -@export var cutout_depth: float = 0.05: - set(value): - cutout_depth = value - if !is_inside_tree(): return - _update_shape() - -@onready var outside_rod: CSGBox3D = $Rod/Outside -@onready var cutout: CSGCombiner3D = $Rod/Cutout -@onready var cutout_box: CSGBox3D = $Rod/Cutout/Length -@onready var cutout_end_left: CSGCylinder3D = $Rod/Cutout/EndLeft -@onready var cutout_end_right: CSGCylinder3D = $Rod/Cutout/EndRight @onready var label: Label3D = $Label -@onready var body_collision_shape: CollisionShape3D = $CollisionBody/CollisionShape3D +@onready var mesh: MeshInstance3D = $Body/MeshInstance3D +@onready var body_collision_shape: CollisionShape3D = $Body/CollisionShape3D @onready var area_collision_shape: CollisionShape3D = $Area3D/CollisionShape3D - @onready var slider_knob: MeshInstance3D = $Knob signal on_value_changed(value: float) @@ -78,7 +57,7 @@ func _ready(): Update.props(self, ["value", "show_label", "label_unit"]) _update_slider() - _update_shape() + _update() move_plane = Plane(Vector3.UP, Vector3(0, size.y / 200, 0)) func _on_press_down(event: EventPointer): @@ -91,9 +70,7 @@ func _on_touch_enter(event: EventTouch): _handle_touch(event) func _get_slider_min_max(): - var cutout_radius = (size.z - cutout_border * 2) / 2 - - return Vector2( - size.x / 2 + cutout_border + cutout_radius, size.x / 2 - cutout_border - cutout_radius) / 100 + return Vector2( - size.x / 2 + 0.01, size.x / 2 - 0.01) func _handle_press(event: EventPointer): var ray_pos = event.ray.global_position @@ -134,46 +111,20 @@ func _update_slider(): slider_knob.position.x = lerp(min_max.x, min_max.y, click_percent) -func _update_shape(): - outside_rod.size = size +func _update(): + _update_slider() + body_collision_shape.shape.size = size + body_collision_shape.position = Vector3(0, 0, size.z / 2) - body_collision_shape.shape.size = size * 0.01 - area_collision_shape.shape.size = Vector3(size.x, size.y * 2, size.z) * 0.01 - area_collision_shape.position = Vector3(0, size.y, 0) * 0.01 + area_collision_shape.shape.size = Vector3(size.x, size.y, 0.01) + area_collision_shape.position = Vector3(0, 0, size.z + 0.005) - var cutout_width = size.z - cutout_border * 2 + mesh.position = Vector3(0, 0, size.z) + mesh.mesh.size = Vector2(size.x, size.y) + mesh.material_override.set_shader_parameter("size", Vector2(size.x, size.y) * 10.0) - cutout_box.size = Vector3( - size.x - cutout_border * 2 - (cutout_width), - cutout_depth, - cutout_width - ) + slider_knob.position.z = size.z + 0.002 + slider_knob.mesh.size = Vector2(size.y * 0.75, size.y * 0.75) + slider_knob.material_override.set_shader_parameter("size", Vector2(size.y * 7.5, size.y * 7.5)) - cutout.position = Vector3( - 0, - size.y / 2 - cutout_depth / 2 + 0.001, - 0 - ) - - cutout_end_left.radius = cutout_box.size.z / 2 - cutout_end_right.radius = cutout_box.size.z / 2 - cutout_end_left.height = cutout_depth - cutout_end_right.height = cutout_depth - - cutout_end_left.position = Vector3( - - cutout_box.size.x / 2, - 0, - 0 - ) - - cutout_end_right.position = Vector3( - cutout_box.size.x / 2, - 0, - 0 - ) - - label.position = Vector3( - size.x / 200 + 0.005, - 0, - 0 - ) + label.position = Vector3(size.x / 2 + 0.005, 0, size.z) \ No newline at end of file diff --git a/app/content/ui/components/slider/slider.tscn b/app/content/ui/components/slider/slider.tscn index 84a9e0f..74403eb 100644 --- a/app/content/ui/components/slider/slider.tscn +++ b/app/content/ui/components/slider/slider.tscn @@ -1,92 +1,90 @@ -[gd_scene load_steps=7 format=3 uid="uid://pk5k1q8bx0rj"] +[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"] - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_eiwwn"] -albedo_color = Color(0.133333, 0.133333, 0.133333, 1) - -[sub_resource type="CylinderMesh" id="CylinderMesh_77ny1"] -material = SubResource("StandardMaterial3D_eiwwn") -top_radius = 0.008 -bottom_radius = 0.008 -height = 0.003 - -[sub_resource type="CylinderMesh" id="CylinderMesh_v34nn"] -top_radius = 0.002 -bottom_radius = 0.002 -height = 0.005 +[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="2_by0d8"] [sub_resource type="BoxShape3D" id="BoxShape3D_h1mn1"] -size = Vector3(0.2, 0.004, 0.01) +resource_local_to_scene = true +size = Vector3(0.15, 0.02, 0.01) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_vgpd3"] +resource_local_to_scene = true +render_priority = -2 +shader = ExtResource("2_by0d8") +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(1.5, 0.2) +shader_parameter/border_size = 0.005 +shader_parameter/border_fade_in = 0.04 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.12 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_k78f4"] +resource_local_to_scene = true +size = Vector2(0.15, 0.02) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_mv0la"] +resource_local_to_scene = true +render_priority = -1 +shader = ExtResource("2_by0d8") +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.15) +shader_parameter/border_size = 0.002 +shader_parameter/border_fade_in = 0.02 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.085 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_vw14o"] +resource_local_to_scene = true +size = Vector2(0.015, 0.015) [sub_resource type="BoxShape3D" id="BoxShape3D_s64dk"] -size = Vector3(0.2, 0.008, 0.01) +resource_local_to_scene = true +size = Vector3(0.15, 0.02, 0.01) [node name="Slider" type="Node3D"] script = ExtResource("1_ylune") -size = Vector3(20, 0.4, 1) -cutout_border = 0.2 -cutout_depth = 0.36 +show_label = true +size = Vector3(0.15, 0.02, 0.01) -[node name="Rod" type="CSGCombiner3D" parent="."] -transform = Transform3D(0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0, 0, 0) -snap = 0.0001 - -[node name="Outside" type="CSGBox3D" parent="Rod"] -snap = 0.0001 -size = Vector3(20, 0.4, 1) - -[node name="Cutout" type="CSGCombiner3D" parent="Rod"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.021, 0) -operation = 2 -snap = 0.0001 - -[node name="Length" type="CSGBox3D" parent="Rod/Cutout"] -snap = 0.0001 -size = Vector3(19, 0.36, 0.6) - -[node name="EndRight" type="CSGCylinder3D" parent="Rod/Cutout"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.5, 0, 0) -snap = 0.0001 -radius = 0.3 -height = 0.36 -sides = 36 - -[node name="EndLeft" type="CSGCylinder3D" parent="Rod/Cutout"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.5, 0, 0) -snap = 0.0001 -radius = 0.3 -height = 0.36 -sides = 36 - -[node name="Knob" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.057, 0.00409426, 0) -mesh = SubResource("CylinderMesh_77ny1") - -[node name="Pin" type="MeshInstance3D" parent="Knob"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.00353538, 0) -mesh = SubResource("CylinderMesh_v34nn") - -[node name="CollisionBody" type="StaticBody3D" parent="."] +[node name="Body" type="StaticBody3D" parent="."] collision_layer = 6 collision_mask = 6 -[node name="CollisionShape3D" type="CollisionShape3D" parent="CollisionBody"] +[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_h1mn1") +[node name="MeshInstance3D" type="MeshInstance3D" parent="Body"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.01) +material_override = SubResource("ShaderMaterial_vgpd3") +mesh = SubResource("QuadMesh_k78f4") + [node name="Label" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.105, 0, 0) -visible = false +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.08, 0, 0.01) pixel_size = 0.001 text = "0.2 " font_size = 10 outline_size = 4 horizontal_alignment = 0 +[node name="Knob" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.039, 0, 0.012) +material_override = SubResource("ShaderMaterial_mv0la") +mesh = SubResource("QuadMesh_vw14o") +skeleton = NodePath("../Body") + [node name="Area3D" type="Area3D" parent="."] collision_layer = 4 collision_mask = 4 [node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.004, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.015) shape = SubResource("BoxShape3D_s64dk") diff --git a/app/content/ui/components/tabs/tabs.gd b/app/content/ui/components/tabs/tabs.gd index 21c6c95..5239bd8 100644 --- a/app/content/ui/components/tabs/tabs.gd +++ b/app/content/ui/components/tabs/tabs.gd @@ -1,4 +1,5 @@ -extends Node3D +@tool +extends FlexContainer3D class_name Tabs3D signal on_select(selected: int) @@ -8,6 +9,11 @@ var selected = R.state(null) @export var initial_selected: Node3D func _ready(): + _update() + + if Engine.is_editor_hint(): + return + if initial_selected: selected.value = initial_selected diff --git a/app/content/ui/menu/edit/edit_menu.gd b/app/content/ui/menu/edit/edit_menu.gd index 7b46d7f..e9607f8 100644 --- a/app/content/ui/menu/edit/edit_menu.gd +++ b/app/content/ui/menu/edit/edit_menu.gd @@ -113,8 +113,6 @@ func render_devices(): _on_device_click(device.keys()[0]) ) devices_node.add_child(button_instance) - - devices_node._update_container() func render_entities(): var entities = get_page() @@ -134,8 +132,6 @@ func render_entities(): _on_entity_click(entity) ) devices_node.add_child(button_instance) - - devices_node._update_container() func _on_device_click(device_id): selected_device = device_id diff --git a/app/content/ui/menu/edit/edit_menu.tscn b/app/content/ui/menu/edit/edit_menu.tscn index 7be08fb..9c63361 100644 --- a/app/content/ui/menu/edit/edit_menu.tscn +++ b/app/content/ui/menu/edit/edit_menu.tscn @@ -8,26 +8,26 @@ script = ExtResource("1_34cbn") [node name="Devices" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0.01, 0.03) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.015, -0.015, 0.01) script = ExtResource("3_0xvyw") -depth_gap = 0.06 +gaps = Vector2(0.01, 0.01) size = Vector3(0.24, 0.1, 0.1) [node name="PageNumberLabel" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.26, 0.01, 0.27) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26, -0.27, 0.01) pixel_size = 0.001 text = "0 / 0" font_size = 18 outline_size = 0 [node name="Buttons" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.19, 0.01, 0.27) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16, -0.24, 0.01) [node name="NextPageButton" parent="Buttons" instance=ExtResource("4_tvimg")] label = "navigate_next" icon = true [node name="PreviousPageButton" parent="Buttons" instance=ExtResource("4_tvimg")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.08, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.07, 0, 0) label = "navigate_before" icon = true diff --git a/app/content/ui/menu/menu.gd b/app/content/ui/menu/menu.gd index 59afcc2..2cff249 100644 --- a/app/content/ui/menu/menu.gd +++ b/app/content/ui/menu/menu.gd @@ -44,6 +44,4 @@ func move_into_view(): var camera_transform = main.camera.global_transform camera_transform.origin -= camera_transform.basis.z * 0.5 - camera_transform.basis = camera_transform.basis.rotated(camera_transform.basis.x, deg_to_rad(90)) - global_transform = camera_transform \ No newline at end of file diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index b6eece1..3905c92 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://c3kdssrmv84kv"] +[gd_scene load_steps=20 format=3 uid="uid://c3kdssrmv84kv"] [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"] @@ -13,18 +13,15 @@ [ext_resource type="PackedScene" uid="uid://c6r4higceibif" path="res://content/ui/menu/settings/settings_menu.tscn" id="11_7wm6b"] [sub_resource type="BoxShape3D" id="BoxShape3D_e1esh"] -size = Vector3(0.38, 0.0128076, 0.32) +size = Vector3(0.51, 0.32, 0.013) -[sub_resource type="BoxShape3D" id="BoxShape3D_6xn1i"] -size = Vector3(0.3, 0.0264844, 0.3) - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_mhqg4"] -render_priority = 0 +[sub_resource type="ShaderMaterial" id="ShaderMaterial_du6qr"] +render_priority = -3 shader = ExtResource("3_htaoi") 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.3, 0.3) +shader_parameter/size = Vector2(0.42, 0.32) shader_parameter/border_size = 0.001 shader_parameter/border_fade_in = 0.005 shader_parameter/border_fade_out = 0.0 @@ -33,7 +30,24 @@ shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 [sub_resource type="QuadMesh" id="QuadMesh_4bh1v"] -size = Vector2(0.3, 0.3) +size = Vector2(0.42, 0.32) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_mhqg4"] +render_priority = -1 +shader = ExtResource("3_htaoi") +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.07, 0.32) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_7q1en"] +size = Vector2(0.07, 0.32) [sub_resource type="Animation" id="Animation_61md4"] length = 0.001 @@ -178,71 +192,81 @@ collision_mask = 2 script = ExtResource("1_ng4u3") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.02, -0.00286309, 1.49012e-08) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0) shape = SubResource("BoxShape3D_e1esh") [node name="Movable" type="Node" parent="."] script = ExtResource("2_8coxu") [node name="AnimationContainer" type="StaticBody3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 0, -0.15) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.15, 0) collision_layer = 6 collision_mask = 6 [node name="CollisionShape3D" type="CollisionShape3D" parent="AnimationContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.21, -0.00824219, 0.15) -shape = SubResource("BoxShape3D_6xn1i") +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.15, 0) +shape = SubResource("BoxShape3D_e1esh") [node name="Background" type="MeshInstance3D" parent="AnimationContainer"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.21, 0.01, 0.15) -material_override = SubResource("ShaderMaterial_mhqg4") +transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.23, -0.15, 0) +material_override = SubResource("ShaderMaterial_du6qr") mesh = SubResource("QuadMesh_4bh1v") skeleton = NodePath("../..") +[node name="Background2" type="MeshInstance3D" parent="AnimationContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, -0.02, -0.15, 0) +material_override = SubResource("ShaderMaterial_mhqg4") +mesh = SubResource("QuadMesh_7q1en") +skeleton = NodePath("../..") + [node name="Tabs" type="Node3D" parent="AnimationContainer" node_paths=PackedStringArray("initial_selected")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.02, -0.03, 0) script = ExtResource("4_eavfx") initial_selected = NodePath("View") +vertical = true +gap = 0.01 +size = Vector3(0.05, 0.4, 1) [node name="View" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0.03) label = "visibility" icon = true toggleable = true +disabled = true [node name="Edit" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0.09) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.06, 0) label = "widgets" icon = true toggleable = true [node name="Room" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0.15) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.12, 0) label = "view_in_ar" icon = true toggleable = true [node name="Automate" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0.21) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.18, 0) label = "schema" icon = true toggleable = true [node name="Settings" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0.27) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.24, 0) label = "settings" icon = true toggleable = true [node name="TabsContent" type="Node3D" parent="AnimationContainer" node_paths=PackedStringArray("tabs")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, 0.00999999, 0) script = ExtResource("6_7rntr") tabs = NodePath("../Tabs") [node name="ViewMenu" parent="AnimationContainer/TabsContent" instance=ExtResource("8_71pkg")] -visible = false +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, 0, 0.01) [node name="EditMenu" parent="AnimationContainer/TabsContent" instance=ExtResource("4_r2raj")] +visible = false [node name="RoomMenu" parent="AnimationContainer/TabsContent" instance=ExtResource("10_u4i1x")] visible = false @@ -254,11 +278,11 @@ visible = false visible = false [node name="NotifyPlace" type="Marker3D" parent="AnimationContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, 0, -0.05) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, 0.06, 0) gizmo_extents = 0.02 [node name="KeyboardPlace" type="Marker3D" parent="AnimationContainer"] -transform = Transform3D(0.5, 0, 0, 0, 0.353553, 0.353553, 0, -0.353553, 0.353553, 0.2, 0.130848, 0.45) +transform = Transform3D(0.5, 0, 0, 0, 0.353553, 0.353553, 0, -0.353553, 0.353553, 0.2, -0.38, 0.16) gizmo_extents = 0.02 [node name="ImmersiveHomePanels" type="MeshInstance3D" parent="."] diff --git a/app/content/ui/menu/room/room_menu.tscn b/app/content/ui/menu/room/room_menu.tscn index 81085b2..50a15ae 100644 --- a/app/content/ui/menu/room/room_menu.tscn +++ b/app/content/ui/menu/room/room_menu.tscn @@ -26,11 +26,10 @@ script = ExtResource("5_ddrep") initial_selected = NodePath("Overview") [node name="Overview" parent="Interface/Tabs3D" instance=ExtResource("4_cghmp")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0, 0.02) label = "Overview" [node name="Rooms" parent="Interface/Tabs3D" instance=ExtResource("4_cghmp")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.09, 0, 0.02) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, 0, 0) label = "Rooms" [node name="TabsContent3D" type="Node3D" parent="Interface" node_paths=PackedStringArray("tabs")] diff --git a/app/content/ui/menu/view/view_menu.tscn b/app/content/ui/menu/view/view_menu.tscn index 085c2d4..5614dda 100644 --- a/app/content/ui/menu/view/view_menu.tscn +++ b/app/content/ui/menu/view/view_menu.tscn @@ -1,108 +1,123 @@ -[gd_scene load_steps=6 format=3 uid="uid://ddpxthb414unp"] +[gd_scene load_steps=7 format=3 uid="uid://ddpxthb414unp"] [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="Material" uid="uid://bujy3egn1oqac" path="res://assets/materials/pri-500.material" id="2_se6ic"] [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"] -[sub_resource type="BoxMesh" id="BoxMesh_qr3bi"] -size = Vector3(0.3, 0.01, 0.3) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_e5hvo"] +render_priority = -3 +shader = ExtResource("5_cjxo5") +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.42, 0.32) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_1j6jf"] +size = Vector2(0.42, 0.32) [node name="ViewMenu" type="Node3D"] script = ExtResource("1_hxajx") -[node name="Background" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15, 0, 0.15) -material_override = ExtResource("2_se6ic") -mesh = SubResource("BoxMesh_qr3bi") - [node name="Content" type="Node3D" parent="."] [node name="MiniView" parent="Content" instance=ExtResource("2_qan1b")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0, 0.03) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.04, 0) label = "view_comfy" icon = true toggleable = true [node name="MiniViewLabel" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -1, 0, 0.07, 0.01, 0.03) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, -0.04, 0) pixel_size = 0.001 +double_sided = false text = "Mini View" font_size = 18 outline_size = 0 horizontal_alignment = 0 [node name="HeatMap" parent="Content" instance=ExtResource("2_qan1b")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0, 0.09) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.1, 0) label = "device_thermostat" icon = true toggleable = true [node name="HeatMapLabel" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -1, 0, 0.07, 0.01, 0.09) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, -0.1, 0) pixel_size = 0.001 +double_sided = false text = "Heat Map" font_size = 18 outline_size = 0 horizontal_alignment = 0 [node name="HumidityMap" parent="Content" instance=ExtResource("2_qan1b")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0, 0.15) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.16, 0) label = "humidity_mid" icon = true toggleable = true [node name="HumidityMapLabel" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -1, 0, 0.07, 0.01, 0.15) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, -0.16, 0) pixel_size = 0.001 +double_sided = false text = "Humidity Map" font_size = 18 outline_size = 0 horizontal_alignment = 0 [node name="MinSlider" parent="Content" instance=ExtResource("4_d3xhb")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, 0.01, 0.2) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.09, -0.21, 0) value = 0.0 step = 1.0 -show_label = true -size = Vector3(10, 0.4, 1) [node name="MinValue" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -1, 0, 0.15, 0.01, 0.2) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.21, 0) pixel_size = 0.001 +double_sided = false text = "Min Value" font_size = 18 outline_size = 0 horizontal_alignment = 0 [node name="MaxSlider" parent="Content" instance=ExtResource("4_d3xhb")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, 0.01, 0.24) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.09, -0.25, 0) value = 0.0 step = 1.0 -show_label = true -size = Vector3(10, 0.4, 1) [node name="MaxValue" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -1, 0, 0.15, 0.01, 0.24) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.25, 0) pixel_size = 0.001 +double_sided = false text = "Max Value" font_size = 18 outline_size = 0 horizontal_alignment = 0 [node name="OpacitySlider" parent="Content" instance=ExtResource("4_d3xhb")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, 0.01, 0.28) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.09, -0.29, 0) max = 100.0 value = 30.0 step = 10.0 -show_label = true label_unit = "%" -size = Vector3(10, 0.4, 1) [node name="OpacityLabel" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -1, 0, 0.15, 0.01, 0.28) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.29, 0) pixel_size = 0.001 +double_sided = false text = "Opacity" font_size = 18 outline_size = 0 horizontal_alignment = 0 + +[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_e5hvo") +mesh = SubResource("QuadMesh_1j6jf") +skeleton = NodePath("../..") From df96f4ec76002d0498e1becbff0f3925e963e3fa Mon Sep 17 00:00:00 2001 From: Nitwel Date: Wed, 24 Apr 2024 01:06:15 +0200 Subject: [PATCH 08/24] continue updating ui and start pagination --- app/content/main.tscn | 2 +- app/content/ui/components/button/button.tscn | 4 + .../ui/components/pagination/pagination.gd | 74 +++++++++++++++++++ .../ui/components/pagination/pagination.tscn | 18 +++++ app/content/ui/menu/edit/device/device.gd | 8 -- app/content/ui/menu/edit/device/device.tscn | 14 ---- app/content/ui/menu/edit/edit_menu.gd | 4 +- app/content/ui/menu/edit/edit_menu.tscn | 54 +++++++++----- app/content/ui/menu/edit/entity/entity.gd | 9 --- app/content/ui/menu/edit/entity/entity.tscn | 32 -------- app/content/ui/menu/menu.tscn | 2 +- app/content/ui/onboarding/onboarding.tscn | 4 +- app/lib/stores/devices.gd | 8 +- 13 files changed, 146 insertions(+), 87 deletions(-) create mode 100644 app/content/ui/components/pagination/pagination.gd create mode 100644 app/content/ui/components/pagination/pagination.tscn delete mode 100644 app/content/ui/menu/edit/device/device.gd delete mode 100644 app/content/ui/menu/edit/device/device.tscn delete mode 100644 app/content/ui/menu/edit/entity/entity.gd delete mode 100644 app/content/ui/menu/edit/entity/entity.tscn diff --git a/app/content/main.tscn b/app/content/main.tscn index 331c1cb..141b713 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -79,7 +79,7 @@ xr_origin = NodePath("../XROrigin3D") transform = Transform3D(0.999999, -1.39633e-11, 0, 1.60657e-10, 1, -4.54747e-13, 0, 0, 0.999999, -0.0165677, 0.766337, -0.634317) [node name="Keyboard" parent="." instance=ExtResource("9_e5n3p")] -transform = Transform3D(0.5, -0.000139169, -6.50202e-05, 5.2431e-05, 0.353553, -0.353553, 0.000144384, 0.353553, 0.353553, -0.0199266, 0.550784, -0.47368) +transform = Transform3D(0.5, 5.24309e-05, 0.000144384, -0.000139169, 0.353553, 0.353553, -6.50204e-05, -0.353553, 0.353553, -0.0199266, 0.550784, -0.47368) [node name="Rooms" type="Node3D" parent="."] diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index a597486..f2d4799 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -4,6 +4,7 @@ [ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="4_2xlpt"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_oqan0"] +resource_local_to_scene = true render_priority = -1 shader = ExtResource("4_2xlpt") shader_parameter/color = Color(1, 1, 1, 0.3) @@ -18,12 +19,15 @@ shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 [sub_resource type="QuadMesh" id="QuadMesh_bt05p"] +resource_local_to_scene = true size = Vector2(0.05, 0.05) [sub_resource type="BoxShape3D" id="BoxShape3D_xwopm"] +resource_local_to_scene = true size = Vector3(0.05, 0.05, 0.01) [sub_resource type="BoxShape3D" id="BoxShape3D_bqjii"] +resource_local_to_scene = true size = Vector3(0.05, 0.05, 0.03) [node name="Button" type="Node3D" groups=["ui_focus"]] diff --git a/app/content/ui/components/pagination/pagination.gd b/app/content/ui/components/pagination/pagination.gd new file mode 100644 index 0000000..514fc22 --- /dev/null +++ b/app/content/ui/components/pagination/pagination.gd @@ -0,0 +1,74 @@ +@tool +extends FlexContainer3D + +const ButtonScene = preload ("res://content/ui/components/button/button.tscn") + +@onready var prev_button = $Prev +@onready var next_button = $Next + +@export var page: int = 0: + set(value): + page = clamp(value, 0, pages - 1) + + if !is_inside_tree(): return + + _update() +@export var pages: int = 5: + set(value): + pages = max(1, value) + + if !is_inside_tree(): return + + _update() +@export var visible_pages: int = 5: + set(value): + visible_pages = max(1, value) + + if !is_inside_tree(): return + + _update() + +func _ready(): + _update() + +func _update(): + for child in get_children(): + if child != prev_button&&child != next_button: + print("queue_free", child) + child.queue_free() + await child.tree_exited + + var display_pages = min(pages, visible_pages) + var start_dots = pages > visible_pages&&page > visible_pages - 3 + var end_dots = pages > visible_pages&&page < pages - visible_pages + 2 + var center_pos = floor(display_pages / 2) + + prev_button.size = Vector3(size.y, size.y, size.z) + + for i in range(display_pages): + if (start_dots&&i == 1)||(end_dots&&i == display_pages - 2): + var dots = Label3D.new() + dots.text = "..." + add_child(dots) + move_child(dots, -2) + continue + + var button = ButtonScene.instantiate() + button.size = Vector3(size.y, size.y, size.z) + + if i == 0: + button.label = "1" + elif i == display_pages - 1: + button.label = str(pages) + else: + button.label = str(clamp(page - center_pos + i + 1, 2, pages - 2)) + + button.on_button_up.connect(func(_arg): + page=int(button.label) - 1 + ) + + add_child(button) + move_child(button, -2) + + 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 new file mode 100644 index 0000000..a8a4d9b --- /dev/null +++ b/app/content/ui/components/pagination/pagination.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://bef3gamrm6at2"] + +[ext_resource type="Script" path="res://content/ui/components/pagination/pagination.gd" id="1_3ylfj"] +[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="2_lsc4w"] + +[node name="Pagination" type="Node3D"] +script = ExtResource("1_3ylfj") +gap = 0.01 +size = Vector3(10, 0.05, 0.01) + +[node name="Prev" parent="." instance=ExtResource("2_lsc4w")] +label = "navigate_before" +icon = true + +[node name="Next" parent="." instance=ExtResource("2_lsc4w")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.36, 0, 0) +label = "navigate_next" +icon = true diff --git a/app/content/ui/menu/edit/device/device.gd b/app/content/ui/menu/edit/device/device.gd deleted file mode 100644 index 19c3d76..0000000 --- a/app/content/ui/menu/edit/device/device.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Node3D - -@onready var button = $Button -@export var id: String = "0" - -func set_device_name(text): - assert(button != null, "Device has to be added to the scene tree") - button.label = text diff --git a/app/content/ui/menu/edit/device/device.tscn b/app/content/ui/menu/edit/device/device.tscn deleted file mode 100644 index 9c0237a..0000000 --- a/app/content/ui/menu/edit/device/device.tscn +++ /dev/null @@ -1,14 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://dbe8slnyhro2n"] - -[ext_resource type="Script" path="res://content/ui/menu/edit/device/device.gd" id="1_rbo86"] -[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="2_go2es"] -[ext_resource type="Script" path="res://content/functions/clickable.gd" id="3_6wicx"] - -[node name="Device" type="Node3D"] -script = ExtResource("1_rbo86") - -[node name="Button" parent="." instance=ExtResource("2_go2es")] -focusable = true - -[node name="Clickable" type="Node" parent="."] -script = ExtResource("3_6wicx") diff --git a/app/content/ui/menu/edit/edit_menu.gd b/app/content/ui/menu/edit/edit_menu.gd index e9607f8..06fe58c 100644 --- a/app/content/ui/menu/edit/edit_menu.gd +++ b/app/content/ui/menu/edit/edit_menu.gd @@ -6,8 +6,8 @@ const ButtonScene = preload ("res://content/ui/components/button/button.tscn") @onready var next_page_button = $Buttons/NextPageButton @onready var previous_page_button = $Buttons/PreviousPageButton @onready var page_number_label = $PageNumberLabel -var devices = [] -var page = 0 + +var page = R.state(0) var last_device_page = 0 var page_size = 20 var pages = 0 diff --git a/app/content/ui/menu/edit/edit_menu.tscn b/app/content/ui/menu/edit/edit_menu.tscn index 9c63361..e82016a 100644 --- a/app/content/ui/menu/edit/edit_menu.tscn +++ b/app/content/ui/menu/edit/edit_menu.tscn @@ -1,33 +1,53 @@ -[gd_scene load_steps=4 format=3 uid="uid://crrb0l3ekuotj"] +[gd_scene load_steps=7 format=3 uid="uid://crrb0l3ekuotj"] [ext_resource type="Script" path="res://content/ui/menu/edit/edit_menu.gd" id="1_34cbn"] [ext_resource type="Script" path="res://content/ui/components/grid_container/grid_container.gd" id="3_0xvyw"] -[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_tvimg"] +[ext_resource type="PackedScene" uid="uid://bef3gamrm6at2" path="res://content/ui/components/pagination/pagination.tscn" id="4_4jiu6"] +[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="4_xunmy"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_hstwo"] +render_priority = -3 +shader = ExtResource("4_xunmy") +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.42, 0.32) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_4pj6f"] +size = Vector2(0.42, 0.32) [node name="EditMenu" type="Node3D"] script = ExtResource("1_34cbn") [node name="Devices" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.015, -0.015, 0.01) + +[node name="Devices" type="Node3D" parent="Devices"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.045, -0.045, 0.01) script = ExtResource("3_0xvyw") gaps = Vector2(0.01, 0.01) size = Vector3(0.24, 0.1, 0.1) -[node name="PageNumberLabel" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26, -0.27, 0.01) +[node name="Background" type="MeshInstance3D" parent="Devices"] +transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.21, -0.16, 0) +material_override = SubResource("ShaderMaterial_hstwo") +mesh = SubResource("QuadMesh_4pj6f") +skeleton = NodePath("../../..") + +[node name="Label3D" type="Label3D" parent="Devices"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.03, 0) pixel_size = 0.001 -text = "0 / 0" -font_size = 18 +text = "Devices" +font_size = 26 outline_size = 0 +horizontal_alignment = 0 -[node name="Buttons" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16, -0.24, 0.01) +[node name="Entities" type="Node3D" parent="."] -[node name="NextPageButton" parent="Buttons" instance=ExtResource("4_tvimg")] -label = "navigate_next" -icon = true - -[node name="PreviousPageButton" parent="Buttons" instance=ExtResource("4_tvimg")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.07, 0, 0) -label = "navigate_before" -icon = true +[node name="Pagination" parent="." instance=ExtResource("4_4jiu6")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.27, 0) diff --git a/app/content/ui/menu/edit/entity/entity.gd b/app/content/ui/menu/edit/entity/entity.gd deleted file mode 100644 index a4341ef..0000000 --- a/app/content/ui/menu/edit/entity/entity.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends StaticBody3D - -@onready var label: Label3D = $Label -@export var text = "Default" - -func set_entity_name(text): - assert(label != null, "Entity has to be added to the scene tree") - label.text = text.replace(".", "\n") - self.text = text diff --git a/app/content/ui/menu/edit/entity/entity.tscn b/app/content/ui/menu/edit/entity/entity.tscn deleted file mode 100644 index f969f43..0000000 --- a/app/content/ui/menu/edit/entity/entity.tscn +++ /dev/null @@ -1,32 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://xo0o5nrfjl23"] - -[ext_resource type="Script" path="res://content/ui/menu/edit/entity/entity.gd" id="1_825oj"] -[ext_resource type="Script" path="res://content/functions/clickable.gd" id="2_i054q"] - -[sub_resource type="BoxMesh" id="BoxMesh_aa3i4"] -size = Vector3(0.05, 0.01, 0.05) - -[sub_resource type="BoxShape3D" id="BoxShape3D_28fjq"] -size = Vector3(0.05, 0.01, 0.05) - -[node name="Entity" type="StaticBody3D"] -script = ExtResource("1_825oj") - -[node name="MeshInstance3D" type="MeshInstance3D" parent="."] -mesh = SubResource("BoxMesh_aa3i4") - -[node name="CollisionShape3D" type="CollisionShape3D" parent="."] -shape = SubResource("BoxShape3D_28fjq") - -[node name="Label" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.007, 0) -pixel_size = 0.001 -modulate = Color(0, 0, 0, 1) -text = "Text" -font_size = 8 -outline_size = 0 -autowrap_mode = 3 -width = 50.0 - -[node name="Clickable" type="Node" parent="."] -script = ExtResource("2_i054q") diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index 3905c92..f682992 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -258,7 +258,7 @@ icon = true toggleable = true [node name="TabsContent" type="Node3D" parent="AnimationContainer" node_paths=PackedStringArray("tabs")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, 0.00999999, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, 0.00999999, -0.01) script = ExtResource("6_7rntr") tabs = NodePath("../Tabs") diff --git a/app/content/ui/onboarding/onboarding.tscn b/app/content/ui/onboarding/onboarding.tscn index 9e2864b..2cfa3d7 100644 --- a/app/content/ui/onboarding/onboarding.tscn +++ b/app/content/ui/onboarding/onboarding.tscn @@ -63,12 +63,12 @@ autowrap_mode = 3 width = 470.0 [node name="GettingStartedButton" parent="." instance=ExtResource("3_hlpow")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.05, -0.11, 0.001) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.05, -0.11, 0.001) label = "open_in_new" icon = true [node name="CloseButton" parent="." instance=ExtResource("3_hlpow")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.21, -0.11, 0.001) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.21, -0.11, 0.001) label = "done" icon = true diff --git a/app/lib/stores/devices.gd b/app/lib/stores/devices.gd index c3bf2ab..0ee6b43 100644 --- a/app/lib/stores/devices.gd +++ b/app/lib/stores/devices.gd @@ -2,7 +2,13 @@ extends StoreClass const StoreClass = preload ("./store.gd") func _init(): - self.state = R.state({}) + self.state = R.state({ + "devices": [] + }) + + HomeApi.on_connect.connect(func(): + self.state.devices=await HomeApi.get_devices() + ) func clear(): pass \ No newline at end of file From eae0ec377a80bcea490ebed2f223a9eb18b0467b Mon Sep 17 00:00:00 2001 From: Nitwel Date: Wed, 24 Apr 2024 14:00:08 +0200 Subject: [PATCH 09/24] finish pagination component --- app/content/ui/components/button/button.tscn | 21 ++------ .../flex_container/flex_container.gd | 6 --- .../label_container/label_container.gd | 25 ++++++++++ .../label_container/label_container.tscn | 15 ++++++ .../ui/components/pagination/button.material | 3 ++ .../pagination/button_active.material | 3 ++ .../ui/components/pagination/pagination.gd | 48 ++++++++++++------- .../ui/components/pagination/pagination.tscn | 7 ++- app/lib/utils/font_tools.gd | 2 +- 9 files changed, 86 insertions(+), 44 deletions(-) create mode 100644 app/content/ui/components/label_container/label_container.gd create mode 100644 app/content/ui/components/label_container/label_container.tscn create mode 100644 app/content/ui/components/pagination/button.material create mode 100644 app/content/ui/components/pagination/button_active.material diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index f2d4799..84b26d7 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -1,22 +1,7 @@ -[gd_scene load_steps=7 format=3 uid="uid://bsjqdvkt0u87c"] +[gd_scene load_steps=6 format=3 uid="uid://bsjqdvkt0u87c"] [ext_resource type="Script" path="res://content/ui/components/button/button.gd" id="1_74x7g"] -[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="4_2xlpt"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_oqan0"] -resource_local_to_scene = true -render_priority = -1 -shader = ExtResource("4_2xlpt") -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(1, 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 +[ext_resource type="Material" uid="uid://iercgso83b0a" path="res://content/ui/components/pagination/button.material" id="2_ebyeq"] [sub_resource type="QuadMesh" id="QuadMesh_bt05p"] resource_local_to_scene = true @@ -42,7 +27,7 @@ collision_mask = 0 [node name="MeshInstance3D" type="MeshInstance3D" parent="Body"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) -material_override = SubResource("ShaderMaterial_oqan0") +material_override = ExtResource("2_ebyeq") mesh = SubResource("QuadMesh_bt05p") skeleton = NodePath("../..") diff --git a/app/content/ui/components/flex_container/flex_container.gd b/app/content/ui/components/flex_container/flex_container.gd index 45cb610..0f2e2e1 100644 --- a/app/content/ui/components/flex_container/flex_container.gd +++ b/app/content/ui/components/flex_container/flex_container.gd @@ -40,7 +40,6 @@ func _ready(): ) func _update(): - print("update") var width = size.y if vertical else size.x var child_size := Vector2(0, 0) var child_count = 0 @@ -66,9 +65,6 @@ func _update(): child_scale = child_scale.clamp(Vector2(0.001, 0.001), Vector2(1, 1)) - print(child_size) - print(child_scale) - var offset = 0.0 match justification: @@ -98,8 +94,6 @@ func _update(): child.position = Vector3(offset, 0, 0) offset += child.size.x * child_scale.x - print(offset) - match justification: Justification.START, Justification.CENTER, Justification.END: offset += gap diff --git a/app/content/ui/components/label_container/label_container.gd b/app/content/ui/components/label_container/label_container.gd new file mode 100644 index 0000000..663fa17 --- /dev/null +++ b/app/content/ui/components/label_container/label_container.gd @@ -0,0 +1,25 @@ +@tool +extends Container3D +class_name LabelContainer3D + +const FontTools = preload ("res://lib/utils/font_tools.gd") + +@onready var label: Label3D = $Label3D + +@export var text: String = "Example": + set(value): + text = value + + if !is_inside_tree(): return + + _update_text() + +func _ready(): + print("label %s enter tree" % text) + _update_text() + +func _update_text(): + label.text = text + var text_size = FontTools.get_font_size(label) + size = Vector3(text_size.x, text_size.y, 0.1) + print("label %s size %s" % [text, size]) \ No newline at end of file diff --git a/app/content/ui/components/label_container/label_container.tscn b/app/content/ui/components/label_container/label_container.tscn new file mode 100644 index 0000000..3b4b34b --- /dev/null +++ b/app/content/ui/components/label_container/label_container.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://blkfqa3ttk0d2"] + +[ext_resource type="Script" path="res://content/ui/components/label_container/label_container.gd" id="1_hqtij"] +[ext_resource type="FontVariation" uid="uid://d2ofyimg5s65q" path="res://assets/fonts/ui_font_500.tres" id="2_6y3jl"] + +[node name="LabelContainer" type="Node3D"] +script = ExtResource("1_hqtij") +size = Vector3(0.08, 0.023, 0.1) + +[node name="Label3D" type="Label3D" parent="."] +pixel_size = 0.001 +text = "Example" +font = ExtResource("2_6y3jl") +font_size = 18 +outline_size = 0 diff --git a/app/content/ui/components/pagination/button.material b/app/content/ui/components/pagination/button.material new file mode 100644 index 0000000..73b7619 --- /dev/null +++ b/app/content/ui/components/pagination/button.material @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a4d9b6aba4df0f124a285b82d6adc8b0682751d95ee946da6478ebcc3cfbd5f +size 449 diff --git a/app/content/ui/components/pagination/button_active.material b/app/content/ui/components/pagination/button_active.material new file mode 100644 index 0000000..502b5cf --- /dev/null +++ b/app/content/ui/components/pagination/button_active.material @@ -0,0 +1,3 @@ +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 514fc22..7bd8205 100644 --- a/app/content/ui/components/pagination/pagination.gd +++ b/app/content/ui/components/pagination/pagination.gd @@ -2,6 +2,10 @@ extends FlexContainer3D 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 @@ -9,48 +13,52 @@ const ButtonScene = preload ("res://content/ui/components/button/button.tscn") @export var page: int = 0: set(value): page = clamp(value, 0, pages - 1) - - if !is_inside_tree(): return - _update() @export var pages: int = 5: set(value): pages = max(1, value) - - if !is_inside_tree(): return - _update() @export var visible_pages: int = 5: set(value): - visible_pages = max(1, value) - - if !is_inside_tree(): return - + visible_pages = max(5, value) _update() func _ready(): _update() func _update(): + if !is_inside_tree(): return + for child in get_children(): if child != prev_button&&child != next_button: - print("queue_free", child) child.queue_free() await child.tree_exited var display_pages = min(pages, visible_pages) - var start_dots = pages > visible_pages&&page > visible_pages - 3 - var end_dots = pages > visible_pages&&page < pages - visible_pages + 2 var center_pos = floor(display_pages / 2) + var start_dots = pages > visible_pages&&page > visible_pages - center_pos - 1 + var end_dots = pages > visible_pages&&page < pages - visible_pages + floor((display_pages - 1) / 2) + + var at_start = page == 0 + prev_button.disabled = at_start + prev_button.mesh.visible = !at_start + + var at_end = page == pages - 1 + next_button.disabled = at_end + next_button.mesh.visible = !at_end prev_button.size = Vector3(size.y, size.y, size.z) for i in range(display_pages): if (start_dots&&i == 1)||(end_dots&&i == display_pages - 2): - var dots = Label3D.new() + var container = Container3D.new() + container.size = Vector3(size.y, size.y, size.z) + add_child(container) + move_child(container, -2) + + var dots = LabelScene.instantiate() dots.text = "..." - add_child(dots) - move_child(dots, -2) + container.add_child(dots) continue var button = ButtonScene.instantiate() @@ -60,8 +68,12 @@ func _update(): button.label = "1" elif i == display_pages - 1: button.label = str(pages) + elif pages <= visible_pages: + button.label = str(i + 1) + elif visible_pages % 2 == 1: + button.label = str(clamp(page, center_pos, pages - 1 - center_pos) - center_pos + i + 1) else: - button.label = str(clamp(page - center_pos + i + 1, 2, pages - 2)) + button.label = str(clamp(page + 1, 3, pages - 3) - center_pos + i + 1) button.on_button_up.connect(func(_arg): page=int(button.label) - 1 @@ -70,5 +82,7 @@ func _update(): add_child(button) move_child(button, -2) + button.mesh.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 a8a4d9b..0f84f79 100644 --- a/app/content/ui/components/pagination/pagination.tscn +++ b/app/content/ui/components/pagination/pagination.tscn @@ -5,14 +5,17 @@ [node name="Pagination" type="Node3D"] script = ExtResource("1_3ylfj") +page = 4 +pages = 9 +visible_pages = 6 gap = 0.01 -size = Vector3(10, 0.05, 0.01) +size = Vector3(9.92, 0.05, 0.01) [node name="Prev" parent="." instance=ExtResource("2_lsc4w")] label = "navigate_before" icon = true [node name="Next" parent="." instance=ExtResource("2_lsc4w")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.36, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.42, 0, 0) label = "navigate_next" icon = true diff --git a/app/lib/utils/font_tools.gd b/app/lib/utils/font_tools.gd index b7adc91..ff311bb 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): +static func get_font_size(label: Label3D, chars=null) -> Vector2: var font = label.font if font == null: From b2f6b707d213af2321b2b3bed47b8a3b866d8c21 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 00:22:27 +0200 Subject: [PATCH 10/24] fix ui depth, finish ui styling and finally add proper wall occlusion --- app/addons/rdot/Rdot.gd | 2 + app/addons/rdot/computed.gd | 2 +- app/content/entities/button/button.tscn | 8 +- app/content/entities/camera/camera.tscn | 8 +- app/content/entities/light/light.tscn | 13 +- .../entities/media_player/media_player.tscn | 20 +- app/content/entities/number/number.tscn | 13 +- app/content/entities/sensor/sensor.tscn | 10 +- app/content/entities/switch/switch.tscn | 6 +- app/content/main.tscn | 8 +- app/content/system/hands/hands.tscn | 8 +- app/content/system/house/room/room.tscn | 5 +- app/content/system/house/room/states/view.gd | 5 +- app/content/system/house/room/wall.tres | 6 +- app/content/system/keyboard/keyboard.gd | 1 + app/content/system/keyboard/keyboard.tscn | 5 +- app/content/ui/components/button/button.tscn | 11 +- app/content/ui/components/input/input.tscn | 8 +- .../ui/components/pagination/button.material | 4 +- .../ui/components/pagination/pagination.gd | 26 ++- .../ui/components/pagination/pagination.tscn | 10 +- app/content/ui/components/slider/slider.tscn | 6 +- app/content/ui/menu/edit/devices.gd | 47 +++++ app/content/ui/menu/edit/edit_menu.gd | 177 +++--------------- app/content/ui/menu/edit/edit_menu.tscn | 67 +++++-- app/content/ui/menu/edit/entities.gd | 55 ++++++ app/content/ui/menu/menu.tscn | 19 +- app/content/ui/menu/room/room_menu.tscn | 37 +++- app/content/ui/menu/room/views/overview.tscn | 36 +++- app/content/ui/menu/room/views/rooms.tscn | 33 +++- .../ui/menu/settings/settings_menu.tscn | 75 +++++--- app/content/ui/menu/view/view_menu.tscn | 14 +- app/content/ui/onboarding/onboarding.tscn | 8 +- app/lib/stores/devices.gd | 17 +- 34 files changed, 465 insertions(+), 305 deletions(-) create mode 100644 app/content/ui/menu/edit/devices.gd create mode 100644 app/content/ui/menu/edit/entities.gd diff --git a/app/addons/rdot/Rdot.gd b/app/addons/rdot/Rdot.gd index 6428a86..7fc8d6c 100644 --- a/app/addons/rdot/Rdot.gd +++ b/app/addons/rdot/Rdot.gd @@ -31,6 +31,8 @@ static func _bind_store(target, prop, store: RdotStore, key, watch_signal=null): return _bind_state(target, prop, store._proxied_value[key], watch_signal) static func _bind_state(target, prop, value, watch_signal=null): + assert(state != null, "target cannot be null") + var graph = RdotGraph.getInstance() var watch_c = func(new_value): diff --git a/app/addons/rdot/computed.gd b/app/addons/rdot/computed.gd index bb72b41..b6e206c 100644 --- a/app/addons/rdot/computed.gd +++ b/app/addons/rdot/computed.gd @@ -61,4 +61,4 @@ func _init(): node.value = newValue node.state = State.SET - node.version += 1 \ No newline at end of file + node.version += 1 diff --git a/app/content/entities/button/button.tscn b/app/content/entities/button/button.tscn index 02be446..f88caad 100644 --- a/app/content/entities/button/button.tscn +++ b/app/content/entities/button/button.tscn @@ -1,21 +1,17 @@ -[gd_scene load_steps=6 format=3 uid="uid://c2j7nev6qx25s"] +[gd_scene load_steps=5 format=3 uid="uid://c2j7nev6qx25s"] [ext_resource type="Script" path="res://content/entities/button/button.gd" id="1_ja7lt"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_r4tef"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="3_vrobf"] -[ext_resource type="Script" path="res://content/functions/occludable.gd" id="4_7upxo"] [sub_resource type="BoxShape3D" id="BoxShape3D_um5pa"] -size = Vector3(0.0700684, 0.011734, 0.0703125) +size = Vector3(0.07, 0.07, 0.012) [node name="Button" type="StaticBody3D"] script = ExtResource("1_ja7lt") [node name="Button" parent="." instance=ExtResource("1_r4tef")] -[node name="Occludable" type="Node" parent="."] -script = ExtResource("4_7upxo") - [node name="Movable" type="Node" parent="."] script = ExtResource("3_vrobf") diff --git a/app/content/entities/camera/camera.tscn b/app/content/entities/camera/camera.tscn index d170230..e34eaac 100644 --- a/app/content/entities/camera/camera.tscn +++ b/app/content/entities/camera/camera.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://b0nq4wjfckxsa"] +[gd_scene load_steps=5 format=3 uid="uid://b0nq4wjfckxsa"] [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="Script" path="res://content/functions/occludable.gd" id="3_jheyx"] [sub_resource type="QuadMesh" id="QuadMesh_830bv"] size = Vector2(0.15, 0.15) @@ -10,7 +9,7 @@ size = Vector2(0.15, 0.15) [sub_resource type="BoxShape3D" id="BoxShape3D_te0pn"] size = Vector3(0.15, 0.15, 0.01) -[node name="Camera" type="StaticBody3D" ] +[node name="Camera" type="StaticBody3D"] script = ExtResource("1_htxq3") [node name="View" type="Sprite3D" parent="."] @@ -26,6 +25,3 @@ shape = SubResource("BoxShape3D_te0pn") [node name="Movable" type="Node" parent="."] script = ExtResource("2_e2u6o") - -[node name="Occludable" type="Node" parent="."] -script = ExtResource("3_jheyx") diff --git a/app/content/entities/light/light.tscn b/app/content/entities/light/light.tscn index 997a50c..0e60e0e 100644 --- a/app/content/entities/light/light.tscn +++ b/app/content/entities/light/light.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=15 format=3 uid="uid://cw86rc42dv2d8"] +[gd_scene load_steps=14 format=3 uid="uid://cw86rc42dv2d8"] [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="Script" path="res://content/functions/occludable.gd" id="5_oh4jg"] [ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="6_mhjlm"] [ext_resource type="Texture2D" uid="uid://hy2f6is7qjyv" path="res://assets/canvas.png" id="7_ximu1"] [ext_resource type="Script" path="res://content/functions/clickable.gd" id="8_1sfll"] @@ -37,9 +36,6 @@ script = ExtResource("1_ykxy3") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("SphereShape3D_ukj14") -[node name="Occludable" type="Node" parent="."] -script = ExtResource("5_oh4jg") - [node name="Movable" type="Node" parent="."] script = ExtResource("4_4sfxb") @@ -59,11 +55,10 @@ height = 0.03 sides = 36 [node name="Slider" parent="." instance=ExtResource("6_mhjlm")] -transform = Transform3D(1.91069e-15, 4.37114e-08, 1, 1, -4.37114e-08, 0, 4.37114e-08, 1, -4.37114e-08, 0.08, 0, 0) +transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0.08, 0, 0) max = 100.0 value = 100.0 step = 1.0 -size = Vector3(10, 0.4, 1) [node name="ColorWheel" type="StaticBody3D" parent="."] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.15, 0, 0) @@ -95,12 +90,12 @@ mesh = SubResource("CylinderMesh_x68ys") 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, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.04, 0, 0) +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, 2.98023e-08, -1, 0, 1, 2.98023e-08, -0.1, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.1, 0, 0) label = "navigate_before" icon = true diff --git a/app/content/entities/media_player/media_player.tscn b/app/content/entities/media_player/media_player.tscn index 248a968..ab96b2c 100644 --- a/app/content/entities/media_player/media_player.tscn +++ b/app/content/entities/media_player/media_player.tscn @@ -1,16 +1,15 @@ -[gd_scene load_steps=8 format=3 uid="uid://dyktdg7ggiwl4"] +[gd_scene load_steps=7 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/movable.gd" id="3_bguto"] -[ext_resource type="Script" path="res://content/functions/occludable.gd" id="4_fnfum"] [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"] [sub_resource type="BoxShape3D" id="BoxShape3D_vi3eg"] size = Vector3(0.23, 0.142768, 0.01) -[node name="MediaPlayer" type="StaticBody3D" ] +[node name="MediaPlayer" type="StaticBody3D"] collision_mask = 0 script = ExtResource("1_ame17") @@ -19,17 +18,17 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0364514, -0.01) shape = SubResource("BoxShape3D_vi3eg") [node name="Previous" parent="." instance=ExtResource("1_8opk3")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.07, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.07, 0, 0) label = "skip_previous" icon = true [node name="Play" parent="." instance=ExtResource("1_8opk3")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -4.65661e-08, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.65661e-08, 0, 0) label = "pause" icon = true [node name="Next" parent="." instance=ExtResource("1_8opk3")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.07, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, 0, 0) label = "skip_next" icon = true @@ -60,20 +59,15 @@ pixel_size = 0.001 [node name="Movable" type="Node" parent="."] script = ExtResource("3_bguto") -[node name="Occludable" type="Node" parent="."] -script = ExtResource("4_fnfum") - [node name="Slider" parent="." instance=ExtResource("4_w73hw")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.0562844, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0562844, 0) max = 100.0 value = 30.0 step = 1.0 -show_label = true label_unit = "%" -size = Vector3(15, 0.4, 1) [node name="Label3D" type="Label3D" parent="Slider"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.088399, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.088399, 0, 0.01) pixel_size = 0.001 text = "volume_up" font = ExtResource("5_koe28") diff --git a/app/content/entities/number/number.tscn b/app/content/entities/number/number.tscn index 62ded9f..b5cb53e 100644 --- a/app/content/entities/number/number.tscn +++ b/app/content/entities/number/number.tscn @@ -1,20 +1,18 @@ -[gd_scene load_steps=6 format=3 uid="uid://bbwedgq63bj84"] +[gd_scene load_steps=5 format=3 uid="uid://bbwedgq63bj84"] [ext_resource type="Script" path="res://content/entities/number/number.gd" id="1_26xwp"] [ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="2_sninv"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="3_x8wda"] -[ext_resource type="Script" path="res://content/functions/occludable.gd" id="4_3xwop"] [sub_resource type="BoxShape3D" id="BoxShape3D_7mk8w"] -size = Vector3(0.0390625, 0.114258, 0.0142822) +size = Vector3(0.0390625, 0.150391, 0.0142822) -[node name="Number" type="StaticBody3D" ] +[node name="Number" type="StaticBody3D"] script = ExtResource("1_26xwp") [node name="Slider" parent="." instance=ExtResource("2_sninv")] -transform = Transform3D(8.74228e-08, 4.37114e-08, 1, 1, 4.37114e-08, -8.74228e-08, -4.37114e-08, 1, -4.37114e-08, 0, 0, 0) +transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0) value = 0.0 -size = Vector3(20, 0.8, 2) [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.00762939) @@ -22,6 +20,3 @@ shape = SubResource("BoxShape3D_7mk8w") [node name="Movable" type="Node" parent="."] script = ExtResource("3_x8wda") - -[node name="Occludable" type="Node" parent="."] -script = ExtResource("4_3xwop") diff --git a/app/content/entities/sensor/sensor.tscn b/app/content/entities/sensor/sensor.tscn index ecc94cd..4e5b9ba 100644 --- a/app/content/entities/sensor/sensor.tscn +++ b/app/content/entities/sensor/sensor.tscn @@ -1,16 +1,15 @@ -[gd_scene load_steps=7 format=3 uid="uid://xsiy71rsqulj"] +[gd_scene load_steps=6 format=3 uid="uid://xsiy71rsqulj"] [ext_resource type="Script" path="res://content/entities/sensor/sensor.gd" id="1_57ac8"] [ext_resource type="FontVariation" uid="uid://d2ofyimg5s65q" path="res://assets/fonts/ui_font_500.tres" id="2_4np3x"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="2_fpq5q"] -[ext_resource type="Script" path="res://content/functions/occludable.gd" id="3_l3sp5"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="5_bmtkc"] [sub_resource type="BoxShape3D" id="BoxShape3D_phuot"] resource_local_to_scene = true size = Vector3(0.18, 0.03, 0.02) -[node name="Sensor" type="StaticBody3D" ] +[node name="Sensor" type="StaticBody3D"] collision_mask = 0 script = ExtResource("1_57ac8") @@ -28,11 +27,8 @@ font_size = 80 [node name="Movable" type="Node" parent="."] script = ExtResource("2_fpq5q") -[node name="Occludable" type="Node" parent="."] -script = ExtResource("3_l3sp5") - [node name="Button" parent="." instance=ExtResource("5_bmtkc")] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.1, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0) label = "add_chart" icon = true diff --git a/app/content/entities/switch/switch.tscn b/app/content/entities/switch/switch.tscn index d143a95..0ac7162 100644 --- a/app/content/entities/switch/switch.tscn +++ b/app/content/entities/switch/switch.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=8 format=3 uid="uid://cscl5k7lhopj5"] +[gd_scene load_steps=7 format=3 uid="uid://cscl5k7lhopj5"] [ext_resource type="Script" path="res://content/entities/switch/switch.gd" id="1_8ffhi"] [ext_resource type="Texture2D" uid="uid://br3p0c2foputg" path="res://assets/materials/swich_on.png" id="1_w68gw"] [ext_resource type="Texture2D" uid="uid://co2ishj2hx57p" path="res://assets/materials/switch_off.png" id="2_86ba1"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_6xr03"] -[ext_resource type="Script" path="res://content/functions/occludable.gd" id="5_j5ucu"] [sub_resource type="SphereShape3D" id="SphereShape3D_ukj14"] radius = 0.0482081 @@ -37,6 +36,3 @@ sprite_frames = SubResource("SpriteFrames_ldpuo") [node name="Movable" type="Node" parent="."] script = ExtResource("4_6xr03") - -[node name="Occludable" type="Node" parent="."] -script = ExtResource("5_j5ucu") diff --git a/app/content/main.tscn b/app/content/main.tscn index 141b713..d49f6bc 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=17 format=3 uid="uid://eecv28y6jxk4"] +[gd_scene load_steps=18 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"] @@ -35,6 +35,8 @@ ao_enabled = true material = SubResource("StandardMaterial3D_m58yb") size = Vector3(0.01, 0.01, 0.01) +[sub_resource type="CylinderMesh" id="CylinderMesh_72c80"] + [node name="Main" type="Node3D"] transform = Transform3D(1, -0.000296142, 0.000270963, 0.000296143, 1, -4.5899e-06, -0.000270962, 4.67014e-06, 1, 0, 0, 0) script = ExtResource("1_uvrd4") @@ -88,4 +90,8 @@ transform = Transform3D(0.5, 5.24309e-05, 0.000144384, -0.000139169, 0.353553, 0 [node name="Onboarding" parent="." instance=ExtResource("12_uq2nj")] transform = Transform3D(1, -9.48098e-12, 0, 9.48098e-12, 1, 0, 0, 0, 1, -0.529594, 0.820154, -0.600147) +[node name="MeshInstance3D2" type="MeshInstance3D" parent="."] +transform = Transform3D(1, -1.39635e-11, 0, 1.02449e-10, 1, 0, 0, 0, 1, 0.327865, -9.50548e-05, 0.44448) +mesh = SubResource("CylinderMesh_72c80") + [editable path="XROrigin3D/XRControllerLeft"] diff --git a/app/content/system/hands/hands.tscn b/app/content/system/hands/hands.tscn index 5e6bf75..6cb3398 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.928487, 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.928488, 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.996576, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653567, 0.032112, 0.00654224, -0.171612) +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) 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.717078, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345978, -0.164767, -0.0355401) +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) 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.756708, 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.756709, 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/house/room/room.tscn b/app/content/system/house/room/room.tscn index e86326e..53f4771 100644 --- a/app/content/system/house/room/room.tscn +++ b/app/content/system/house/room/room.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=8 format=3 uid="uid://bswgmclohuqui"] +[gd_scene load_steps=9 format=3 uid="uid://bswgmclohuqui"] [ext_resource type="Script" path="res://content/system/house/room/room.gd" id="1_fccq0"] [ext_resource type="Script" path="res://content/functions/clickable.gd" id="1_ugebq"] +[ext_resource type="Material" uid="uid://bbx6fv7jq50tr" path="res://content/system/house/room/wall.tres" id="3_w4vos"] [ext_resource type="Script" path="res://lib/utils/state_machine/state_machine.gd" id="4_nbbo6"] [ext_resource type="Script" path="res://content/system/house/room/states/view.gd" id="6_g066t"] [ext_resource type="Script" path="res://content/system/house/room/states/edit.gd" id="7_ap14h"] @@ -25,8 +26,10 @@ shape = SubResource("WorldBoundaryShape3D_08sv0") script = ExtResource("1_ugebq") [node name="WallMesh" type="MeshInstance3D" parent="."] +material_override = ExtResource("3_w4vos") [node name="CeilingMesh" type="MeshInstance3D" parent="."] +material_override = ExtResource("3_w4vos") [node name="WallCollision" type="StaticBody3D" parent="."] collision_layer = 24 diff --git a/app/content/system/house/room/states/view.gd b/app/content/system/house/room/states/view.gd index 0bd1552..521cf36 100644 --- a/app/content/system/house/room/states/view.gd +++ b/app/content/system/house/room/states/view.gd @@ -8,9 +8,6 @@ func _on_enter(): if room_store == null||room_store.corners.size() < 3: return - room.wall_mesh.visible = false - room.ceiling_mesh.visible = false - room.wall_mesh.mesh = Room.generate_wall_mesh(room_store) if room.wall_mesh.mesh == null: @@ -38,3 +35,5 @@ func _on_leave(): room.room_floor.get_node("CollisionShape3D").disabled = true room.wall_collision.shape = null + room.wall_mesh.mesh = null + room.ceiling_mesh.mesh = null \ No newline at end of file diff --git a/app/content/system/house/room/wall.tres b/app/content/system/house/room/wall.tres index 4911d10..16a7c42 100644 --- a/app/content/system/house/room/wall.tres +++ b/app/content/system/house/room/wall.tres @@ -1,6 +1,8 @@ [gd_resource type="StandardMaterial3D" format=3 uid="uid://bbx6fv7jq50tr"] [resource] -transparency = 1 +render_priority = -100 +blend_mode = 2 cull_mode = 2 -albedo_color = Color(1, 1, 1, 0) +depth_draw_mode = 1 +shading_mode = 0 diff --git a/app/content/system/keyboard/keyboard.gd b/app/content/system/keyboard/keyboard.gd index 80afad8..59d1192 100644 --- a/app/content/system/keyboard/keyboard.gd +++ b/app/content/system/keyboard/keyboard.gd @@ -71,6 +71,7 @@ func create_key(key: Key): var key_node = button_scene.instantiate() key_node.label = EventKey.key_to_string(key, caps) + key_node.size = Vector3(0.05, 0.05, 0.01) key_node.focusable = false key_node.font_size = 32 key_node.echo = true diff --git a/app/content/system/keyboard/keyboard.tscn b/app/content/system/keyboard/keyboard.tscn index 33d2ae6..e3c86f6 100644 --- a/app/content/system/keyboard/keyboard.tscn +++ b/app/content/system/keyboard/keyboard.tscn @@ -11,7 +11,7 @@ size = Vector3(0.86, 0.27, 0.02) [sub_resource type="ShaderMaterial" id="ShaderMaterial_x72nd"] -render_priority = -1 +render_priority = 19 shader = ExtResource("5_0dbg6") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -39,6 +39,7 @@ focusable = false label = "backspace" icon = true echo = true +size = Vector3(0.05, 0.05, 0.01) metadata/key = 4194308 [node name="Caps" parent="." instance=ExtResource("1_xdpwr")] @@ -47,12 +48,14 @@ focusable = false label = "keyboard_capslock" icon = true toggleable = true +size = Vector3(0.05, 0.05, 0.01) [node name="Paste" parent="." instance=ExtResource("1_xdpwr")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.38, -0.09, 0) focusable = false label = "assignment" icon = true +size = Vector3(0.05, 0.05, 0.01) [node name="Keys" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.325, 0.09, 0) diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index 84b26d7..ece8aeb 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -5,20 +5,20 @@ [sub_resource type="QuadMesh" id="QuadMesh_bt05p"] resource_local_to_scene = true -size = Vector2(0.05, 0.05) +size = Vector2(0.04, 0.04) [sub_resource type="BoxShape3D" id="BoxShape3D_xwopm"] resource_local_to_scene = true -size = Vector3(0.05, 0.05, 0.01) +size = Vector3(0.04, 0.04, 0.01) [sub_resource type="BoxShape3D" id="BoxShape3D_bqjii"] resource_local_to_scene = true -size = Vector3(0.05, 0.05, 0.03) +size = Vector3(0.04, 0.04, 0.03) [node name="Button" type="Node3D" groups=["ui_focus"]] script = ExtResource("1_74x7g") label = "Example Text" -size = Vector3(0.05, 0.05, 0.01) +size = Vector3(0.04, 0.04, 0.01) [node name="Body" type="StaticBody3D" parent="." groups=["ui_focus_skip"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) @@ -38,11 +38,12 @@ shape = SubResource("BoxShape3D_xwopm") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.006) pixel_size = 0.001 double_sided = false +render_priority = 30 text = "Example Text" font_size = 10 outline_size = 0 autowrap_mode = 3 -width = 50.0 +width = 40.0 [node name="FingerArea" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015) diff --git a/app/content/ui/components/input/input.tscn b/app/content/ui/components/input/input.tscn index b6cd564..e6b2cf6 100644 --- a/app/content/ui/components/input/input.tscn +++ b/app/content/ui/components/input/input.tscn @@ -5,7 +5,8 @@ [ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="3_nl02b"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_c5qdm"] -render_priority = -1 +resource_local_to_scene = true +render_priority = 20 shader = ExtResource("3_nl02b") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -19,6 +20,7 @@ shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 [sub_resource type="QuadMesh" id="QuadMesh_5rrua"] +resource_local_to_scene = true size = Vector2(0.15, 0.03) [sub_resource type="BoxShape3D" id="BoxShape3D_x4yp8"] @@ -88,10 +90,10 @@ shape = SubResource("BoxShape3D_x4yp8") [node name="Label" type="Label3D" parent="Body"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.073, 0, 0.005) -sorting_offset = 0.1 pixel_size = 0.001 double_sided = false -alpha_cut = 2 +render_priority = 30 +outline_render_priority = 29 text = "Example Text" font = ExtResource("3_ij5fh") font_size = 18 diff --git a/app/content/ui/components/pagination/button.material b/app/content/ui/components/pagination/button.material index 73b7619..2a64a16 100644 --- a/app/content/ui/components/pagination/button.material +++ b/app/content/ui/components/pagination/button.material @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6a4d9b6aba4df0f124a285b82d6adc8b0682751d95ee946da6478ebcc3cfbd5f -size 449 +oid sha256:dbcd34e34bfbe649b5ee3b0c2df93869b18124ec89499cc54f9c5c287f83d0cc +size 465 diff --git a/app/content/ui/components/pagination/pagination.gd b/app/content/ui/components/pagination/pagination.gd index 7bd8205..7bc9779 100644 --- a/app/content/ui/components/pagination/pagination.gd +++ b/app/content/ui/components/pagination/pagination.gd @@ -1,5 +1,8 @@ @tool extends FlexContainer3D +class_name Pagination3D + +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") @@ -12,14 +15,20 @@ const ButtonActiveMaterial = preload ("button_active.material") @export var page: int = 0: set(value): + if page == value: return + page = clamp(value, 0, pages - 1) _update() @export var pages: int = 5: set(value): + if pages == value: return + pages = max(1, value) _update() @export var visible_pages: int = 5: set(value): + if visible_pages == value: return + visible_pages = max(5, value) _update() @@ -27,12 +36,17 @@ func _ready(): _update() func _update(): - if !is_inside_tree(): return + print("update %s %s %s %s" % [page, pages, visible_pages, get_parent()]) + if !is_node_ready(): return for child in get_children(): if child != prev_button&&child != next_button: - child.queue_free() - await child.tree_exited + remove_child(child) + child.free() + # child.queue_free() + # print("queue free", child) + # await child.tree_exited + # print("exited", child) var display_pages = min(pages, visible_pages) var center_pos = floor(display_pages / 2) @@ -48,6 +62,9 @@ func _update(): next_button.mesh.visible = !at_end prev_button.size = Vector3(size.y, size.y, size.z) + next_button.size = Vector3(size.y, size.y, size.z) + + print("A %s %s %s %s" % [display_pages, center_pos, start_dots, end_dots]) for i in range(display_pages): if (start_dots&&i == 1)||(end_dots&&i == display_pages - 2): @@ -77,12 +94,13 @@ func _update(): button.on_button_up.connect(func(_arg): page=int(button.label) - 1 + on_page_changed.emit(page) ) add_child(button) move_child(button, -2) - button.mesh.material_override = ButtonActiveMaterial if (int(button.label) - 1) == page else ButtonMaterial + 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 0f84f79..a4e2d84 100644 --- a/app/content/ui/components/pagination/pagination.tscn +++ b/app/content/ui/components/pagination/pagination.tscn @@ -5,17 +5,19 @@ [node name="Pagination" type="Node3D"] script = ExtResource("1_3ylfj") -page = 4 -pages = 9 -visible_pages = 6 +pages = 4 +visible_pages = 7 gap = 0.01 size = Vector3(9.92, 0.05, 0.01) [node name="Prev" parent="." instance=ExtResource("2_lsc4w")] 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.42, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, 0, 0) label = "navigate_next" icon = true +size = Vector3(0.05, 0.05, 0.01) diff --git a/app/content/ui/components/slider/slider.tscn b/app/content/ui/components/slider/slider.tscn index 74403eb..e3cb992 100644 --- a/app/content/ui/components/slider/slider.tscn +++ b/app/content/ui/components/slider/slider.tscn @@ -9,7 +9,7 @@ size = Vector3(0.15, 0.02, 0.01) [sub_resource type="ShaderMaterial" id="ShaderMaterial_vgpd3"] resource_local_to_scene = true -render_priority = -2 +render_priority = 20 shader = ExtResource("2_by0d8") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -28,7 +28,7 @@ size = Vector2(0.15, 0.02) [sub_resource type="ShaderMaterial" id="ShaderMaterial_mv0la"] resource_local_to_scene = true -render_priority = -1 +render_priority = 30 shader = ExtResource("2_by0d8") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -70,6 +70,8 @@ mesh = SubResource("QuadMesh_k78f4") [node name="Label" type="Label3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.08, 0, 0.01) pixel_size = 0.001 +render_priority = 30 +outline_render_priority = 29 text = "0.2 " font_size = 10 outline_size = 4 diff --git a/app/content/ui/menu/edit/devices.gd b/app/content/ui/menu/edit/devices.gd new file mode 100644 index 0000000..a657519 --- /dev/null +++ b/app/content/ui/menu/edit/devices.gd @@ -0,0 +1,47 @@ +extends Node3D + +signal on_select_device(device_id) + +const ButtonScene = preload ("res://content/ui/components/button/button.tscn") + +@onready var grid_container = $GridContainer3D +@onready var pagination = $Pagination3D + +var page = R.state(0) +var page_size = 28.0 + +func _ready(): + + var pages = R.computed(func(_arg): + var devices=Store.devices.state.devices + + print("recalc pages ", ceil(devices.size() / page_size)) + + return ceil(devices.size() / page_size) + ) + + var visible_devices = R.computed(func(_arg): + var devices=Store.devices.state.devices + + return devices.slice(page.value * page_size, page.value * page_size + page_size) + ) + + R.bind(pagination, "pages", pages) + R.bind(pagination, "page", page, pagination.on_page_changed) + + R.effect(func(_arg): + for child in grid_container.get_children(): + grid_container.remove_child(child) + child.free() + + for device in visible_devices.value: + var info=device.values()[0] + + var button_instance=ButtonScene.instantiate() + button_instance.label=info["name"] + button_instance.on_button_down.connect(func(): + on_select_device.emit(device.keys()[0]) + ) + grid_container.add_child(button_instance) + + ) diff --git a/app/content/ui/menu/edit/edit_menu.gd b/app/content/ui/menu/edit/edit_menu.gd index 06fe58c..dcc36dc 100644 --- a/app/content/ui/menu/edit/edit_menu.gd +++ b/app/content/ui/menu/edit/edit_menu.gd @@ -2,160 +2,45 @@ extends Node3D const ButtonScene = preload ("res://content/ui/components/button/button.tscn") -@onready var devices_node: GridContainer3D = $Devices -@onready var next_page_button = $Buttons/NextPageButton -@onready var previous_page_button = $Buttons/PreviousPageButton -@onready var page_number_label = $PageNumberLabel +@onready var devices_page = $Devices +@onready var entities_page = $Entities -var page = R.state(0) -var last_device_page = 0 -var page_size = 20 -var pages = 0 +var selected_device = R.state(null) -var selected_device = null -# Called when the node enters the scene tree for the first time. func _ready(): - next_page_button.on_button_down.connect(func(): - next_page() + entities_page.selected_device = selected_device + remove_child(entities_page) + + devices_page.on_select_device.connect(func(device): + selected_device.value=device + entities_page.page.value=0 ) - previous_page_button.on_button_down.connect(func(): - previous_page() + entities_page.on_select_entity.connect(func(entity_name): + AudioPlayer.play_effect("spawn") + + var entity=House.body.create_entity(entity_name, global_position) + + if entity == null: + EventSystem.notify("Entity is not in Room", EventNotify.Type.INFO) ) -func _enter_tree(): - if !HomeApi.has_connected(): await HomeApi.on_connect - - if is_node_ready(): - load_devices() - -func load_devices(): - if devices.size() == 0: - devices = await HomeApi.get_devices() - devices.sort_custom(func(a, b): - return a.values()[0]["name"].to_lower() < b.values()[0]["name"].to_lower() - ) - - for device in devices: - device.values()[0]["entities"].sort_custom(func(a, b): - return a.to_lower() < b.to_lower() - ) - - render() - - HomeApi.on_disconnect.connect(func(): - devices=[] - if is_node_ready(): - render() - ) - -func update_pages(): - if selected_device == null: - pages = ceil(float(devices.size()) / page_size) - else: - for device in devices: - if device.keys()[0] == selected_device: - pages = ceil(float(device.values()[0]["entities"].size()) / page_size) - -func get_page(): - if selected_device == null: - return devices.slice(page * page_size, page * page_size + page_size) - else: - for device in devices: - if device.keys()[0] == selected_device: - return device.values()[0]["entities"].slice(page * page_size, page * page_size + page_size) - -func next_page(): - if page >= pages - 1: - return - page += 1 - render() - -func previous_page(): - if page <= 0: - return - - page -= 1 - render() - -func render(): - if devices.size() == 0: - return - - update_pages() - page_number_label.set_text(str(page + 1) + " / " + str(pages)) - - var has_prev_page = page > 0 - var has_next_page = page < pages - 1 - - previous_page_button.visible = has_prev_page - previous_page_button.disabled = !has_prev_page - previous_page_button.body.get_node("CollisionShape3D").disabled = !has_prev_page - next_page_button.visible = has_next_page - next_page_button.disabled = !has_next_page - next_page_button.body.get_node("CollisionShape3D").disabled = !has_next_page - - clear_menu() - if selected_device == null: - render_devices() - else: - render_entities() - -func render_devices(): - var page_devices = get_page() - - for device in page_devices: - var info = device.values()[0] - - var button_instance = ButtonScene.instantiate() - button_instance.label = info["name"] - button_instance.on_button_down.connect(func(): - _on_device_click(device.keys()[0]) - ) - devices_node.add_child(button_instance) - -func render_entities(): - var entities = get_page() - - var back_button = ButtonScene.instantiate() - back_button.label = "arrow_back" - back_button.icon = true - back_button.on_button_down.connect(func(): - _on_entity_click("#back") + entities_page.on_back.connect(func(): + selected_device.value=null ) - devices_node.add_child(back_button) - - for entity in entities: - var button_instance = ButtonScene.instantiate() - button_instance.label = entity - button_instance.on_button_down.connect(func(): - _on_entity_click(entity) - ) - devices_node.add_child(button_instance) - -func _on_device_click(device_id): - selected_device = device_id - last_device_page = page - page = 0 - - render() -func _on_entity_click(entity_name): - if entity_name == "#back": - selected_device = null - page = last_device_page - AudioPlayer.play_effect("click") - render() - return + R.effect(func(_arg): + if selected_device.value == null: + if devices_page.is_inside_tree() == false: + add_child(devices_page) - AudioPlayer.play_effect("spawn") + if entities_page.is_inside_tree(): + remove_child(entities_page) - var entity = House.body.create_entity(entity_name, global_position) - - if entity == null: - EventSystem.notify("Entity is not in Room", EventNotify.Type.INFO) - -func clear_menu(): - for child in devices_node.get_children(): - devices_node.remove_child(child) - child.queue_free() + if selected_device.value != null: + if entities_page.is_inside_tree() == false: + add_child(entities_page) + + if devices_page.is_inside_tree(): + remove_child(devices_page) + ) diff --git a/app/content/ui/menu/edit/edit_menu.tscn b/app/content/ui/menu/edit/edit_menu.tscn index e82016a..bf746a5 100644 --- a/app/content/ui/menu/edit/edit_menu.tscn +++ b/app/content/ui/menu/edit/edit_menu.tscn @@ -1,9 +1,12 @@ -[gd_scene load_steps=7 format=3 uid="uid://crrb0l3ekuotj"] +[gd_scene load_steps=10 format=3 uid="uid://crrb0l3ekuotj"] [ext_resource type="Script" path="res://content/ui/menu/edit/edit_menu.gd" id="1_34cbn"] +[ext_resource type="Script" path="res://content/ui/menu/edit/devices.gd" id="2_rkvf4"] [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="Script" path="res://content/ui/menu/edit/entities.gd" id="5_t34xe"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_hstwo"] render_priority = -3 @@ -26,28 +29,64 @@ size = Vector2(0.42, 0.32) script = ExtResource("1_34cbn") [node name="Devices" type="Node3D" parent="."] +script = ExtResource("2_rkvf4") -[node name="Devices" type="Node3D" parent="Devices"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.045, -0.045, 0.01) +[node name="GridContainer3D" type="Node3D" parent="Devices"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, -0.08, 0) script = ExtResource("3_0xvyw") +columns = 7 gaps = Vector2(0.01, 0.01) -size = Vector3(0.24, 0.1, 0.1) - -[node name="Background" type="MeshInstance3D" parent="Devices"] -transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.21, -0.16, 0) -material_override = SubResource("ShaderMaterial_hstwo") -mesh = SubResource("QuadMesh_4pj6f") -skeleton = NodePath("../../..") +size = Vector3(0.28, 0.1, 0.1) [node name="Label3D" type="Label3D" parent="Devices"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.03, 0) pixel_size = 0.001 +double_sided = false +render_priority = 15 +outline_render_priority = 14 text = "Devices" -font_size = 26 +font_size = 24 outline_size = 0 horizontal_alignment = 0 -[node name="Entities" type="Node3D" parent="."] +[node name="Pagination3D" parent="Devices" instance=ExtResource("4_4jiu6")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.29, 0) +size = Vector3(9.92, 0.03, 0.01) -[node name="Pagination" parent="." instance=ExtResource("4_4jiu6")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.27, 0) +[node name="Entities" type="Node3D" parent="."] +script = ExtResource("5_t34xe") + +[node name="GridContainer3D" type="Node3D" parent="Entities"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, -0.08, 0) +script = ExtResource("3_0xvyw") +columns = 7 +gaps = Vector2(0.01, 0.01) +size = Vector3(0.28, 0.1, 0.1) + +[node name="Pagination3D" parent="Entities" instance=ExtResource("4_4jiu6")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.29, 0) +size = Vector3(9.92, 0.03, 0.01) + +[node name="Label3D" type="Label3D" parent="Entities"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, -0.03, 0) +pixel_size = 0.001 +double_sided = false +render_priority = 15 +outline_render_priority = 14 +text = "My Entity" +font_size = 24 +outline_size = 0 +horizontal_alignment = 0 + +[node name="Button" parent="Entities" instance=ExtResource("4_lpv7m")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.03, 0) +label = "arrow_back" +icon = true +size = Vector3(0.03, 0.03, 0.01) + +[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) +visible = false +material_override = SubResource("ShaderMaterial_hstwo") +mesh = SubResource("QuadMesh_4pj6f") +skeleton = NodePath("../..") diff --git a/app/content/ui/menu/edit/entities.gd b/app/content/ui/menu/edit/entities.gd new file mode 100644 index 0000000..0bc81e8 --- /dev/null +++ b/app/content/ui/menu/edit/entities.gd @@ -0,0 +1,55 @@ +extends Node3D + +signal on_select_entity(entity_id) +signal on_back() + +const ButtonScene = preload ("res://content/ui/components/button/button.tscn") + +@onready var grid_container = $GridContainer3D +@onready var pagination = $Pagination3D +@onready var back_button = $Button + +var page = R.state(0) +var page_size = 28.0 +var selected_device = R.state(null) + +func _ready(): + var entities = R.computed(func(_arg): + var devices=Store.devices.state.devices + + for device in devices: + if device.keys()[0] == selected_device.value: + return device.values()[0]["entities"] + + return [] + ) + + var pages = R.computed(func(_arg): + return ceil(entities.value.size() / page_size) + ) + + var visible_entities = R.computed(func(_arg): + return entities.value.slice(page.value * page_size, page.value * page_size + page_size) + ) + + R.bind(pagination, "pages", pages) + R.bind(pagination, "page", page, pagination.on_page_changed) + + back_button.on_button_up.connect(func(): + on_back.emit() + ) + + R.effect(func(_arg): + for child in grid_container.get_children(): + grid_container.remove_child(child) + child.free() + + for entity in visible_entities.value: + var button_instance=ButtonScene.instantiate() + button_instance.label=entity + button_instance.on_button_down.connect(func(): + on_select_entity.emit(entity) + ) + grid_container.add_child(button_instance) + + ) diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index f682992..006a0bc 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -16,7 +16,7 @@ size = Vector3(0.51, 0.32, 0.013) [sub_resource type="ShaderMaterial" id="ShaderMaterial_du6qr"] -render_priority = -3 +render_priority = 0 shader = ExtResource("3_htaoi") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -30,10 +30,11 @@ shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 [sub_resource type="QuadMesh" id="QuadMesh_4bh1v"] +lightmap_size_hint = Vector2i(4, 3) size = Vector2(0.42, 0.32) [sub_resource type="ShaderMaterial" id="ShaderMaterial_mhqg4"] -render_priority = -1 +render_priority = 0 shader = ExtResource("3_htaoi") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -192,7 +193,7 @@ collision_mask = 2 script = ExtResource("1_ng4u3") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, -0.005) shape = SubResource("BoxShape3D_e1esh") [node name="Movable" type="Node" parent="."] @@ -204,7 +205,7 @@ collision_layer = 6 collision_mask = 6 [node name="CollisionShape3D" type="CollisionShape3D" parent="AnimationContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.15, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.15, -0.005) shape = SubResource("BoxShape3D_e1esh") [node name="Background" type="MeshInstance3D" parent="AnimationContainer"] @@ -232,41 +233,45 @@ label = "visibility" icon = true toggleable = true disabled = true +size = Vector3(0.05, 0.05, 0.01) [node name="Edit" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.06, 0) label = "widgets" icon = true toggleable = true +size = Vector3(0.05, 0.05, 0.01) [node name="Room" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.12, 0) label = "view_in_ar" icon = true toggleable = true +size = Vector3(0.05, 0.05, 0.01) [node name="Automate" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.18, 0) label = "schema" icon = true toggleable = true +size = Vector3(0.05, 0.05, 0.01) [node name="Settings" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.24, 0) label = "settings" icon = true toggleable = true +size = Vector3(0.05, 0.05, 0.01) [node name="TabsContent" type="Node3D" parent="AnimationContainer" node_paths=PackedStringArray("tabs")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, 0.00999999, -0.01) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, 0.00999999, 0) script = ExtResource("6_7rntr") tabs = NodePath("../Tabs") [node name="ViewMenu" parent="AnimationContainer/TabsContent" instance=ExtResource("8_71pkg")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, 0, 0.01) +visible = false [node name="EditMenu" parent="AnimationContainer/TabsContent" instance=ExtResource("4_r2raj")] -visible = false [node name="RoomMenu" parent="AnimationContainer/TabsContent" instance=ExtResource("10_u4i1x")] visible = false diff --git a/app/content/ui/menu/room/room_menu.tscn b/app/content/ui/menu/room/room_menu.tscn index 50a15ae..7a3596a 100644 --- a/app/content/ui/menu/room/room_menu.tscn +++ b/app/content/ui/menu/room/room_menu.tscn @@ -1,29 +1,40 @@ -[gd_scene load_steps=9 format=3 uid="uid://c01gkeldvjwtr"] +[gd_scene load_steps=10 format=3 uid="uid://c01gkeldvjwtr"] [ext_resource type="Script" path="res://content/ui/menu/room/room_menu.gd" id="1_ch4jb"] -[ext_resource type="Material" uid="uid://bujy3egn1oqac" path="res://assets/materials/pri-500.material" id="2_7m4yn"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_cghmp"] [ext_resource type="Script" path="res://content/ui/components/tabs/tabs.gd" id="5_ddrep"] [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"] -[sub_resource type="BoxMesh" id="BoxMesh_e37nn"] -size = Vector3(0.3, 0.01, 0.3) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_2asng"] +render_priority = -3 +shader = ExtResource("7_bxp1w") +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.42, 0.32) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_16sg5"] +size = Vector2(0.42, 0.32) [node name="RoomMenu" type="Node3D"] script = ExtResource("1_ch4jb") -[node name="Background" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15, 0, 0.15) -material_override = ExtResource("2_7m4yn") -mesh = SubResource("BoxMesh_e37nn") - [node name="Interface" type="Node3D" parent="."] [node name="Tabs3D" type="Node3D" parent="Interface" node_paths=PackedStringArray("initial_selected")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.04, 0) script = ExtResource("5_ddrep") initial_selected = NodePath("Overview") +gap = 0.01 [node name="Overview" parent="Interface/Tabs3D" instance=ExtResource("4_cghmp")] label = "Overview" @@ -37,6 +48,12 @@ script = ExtResource("6_ba00g") tabs = NodePath("../Tabs3D") [node name="Overview" parent="Interface/TabsContent3D" instance=ExtResource("6_206ad")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.04) [node name="Rooms" parent="Interface/TabsContent3D" instance=ExtResource("7_2f8e0")] + +[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) +visible = false +material_override = SubResource("ShaderMaterial_2asng") +mesh = SubResource("QuadMesh_16sg5") +skeleton = NodePath("../..") diff --git a/app/content/ui/menu/room/views/overview.tscn b/app/content/ui/menu/room/views/overview.tscn index d158f91..6abd572 100644 --- a/app/content/ui/menu/room/views/overview.tscn +++ b/app/content/ui/menu/room/views/overview.tscn @@ -1,24 +1,52 @@ -[gd_scene load_steps=3 format=3 uid="uid://dd71loi64gnmp"] +[gd_scene load_steps=6 format=3 uid="uid://dd71loi64gnmp"] [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"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_n3lbn"] +render_priority = -3 +shader = ExtResource("3_2yl2s") +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.42, 0.32) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_l1dos"] +size = Vector2(0.42, 0.32) [node name="Overview" type="Node3D"] script = ExtResource("1_jesad") [node name="EditButton" parent="." instance=ExtResource("1_fteh8")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, 0, 0.07) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.12, 0) label = "edit" icon = true [node name="FixButton" parent="." instance=ExtResource("1_fteh8")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1, 0, 0.07) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1, -0.12, 0) label = "healing" icon = true [node name="Label3D" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.06, 0.01, 0.02) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.08, 0.01) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "Reference" font_size = 18 outline_size = 0 +horizontal_alignment = 0 + +[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) +visible = false +material_override = SubResource("ShaderMaterial_n3lbn") +mesh = SubResource("QuadMesh_l1dos") +skeleton = NodePath("../..") diff --git a/app/content/ui/menu/room/views/rooms.tscn b/app/content/ui/menu/room/views/rooms.tscn index c215f74..b9f58a8 100644 --- a/app/content/ui/menu/room/views/rooms.tscn +++ b/app/content/ui/menu/room/views/rooms.tscn @@ -1,21 +1,46 @@ -[gd_scene load_steps=4 format=3 uid="uid://bpta22fahai46"] +[gd_scene load_steps=7 format=3 uid="uid://bpta22fahai46"] [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"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_dah0r"] +render_priority = -3 +shader = ExtResource("4_jx6i3") +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.42, 0.32) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_fq44b"] +size = Vector2(0.42, 0.32) [node name="Rooms" type="Node3D"] script = ExtResource("1_3a1oa") [node name="Rooms" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15, 0.01, 0.17) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.14, -0.13, 0) [node name="Button" parent="." instance=ExtResource("1_y3lty")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.27, 0, 0.27) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.28, 0) label = "add" icon = true [node name="Input" parent="." instance=ExtResource("2_hstw7")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.12, 0.005, 0.27) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.09, -0.28, 0) text = "Room 1" disabled = true + +[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) +visible = false +material_override = SubResource("ShaderMaterial_dah0r") +mesh = SubResource("QuadMesh_fq44b") +skeleton = NodePath("../..") diff --git a/app/content/ui/menu/settings/settings_menu.tscn b/app/content/ui/menu/settings/settings_menu.tscn index 7e45261..729f996 100644 --- a/app/content/ui/menu/settings/settings_menu.tscn +++ b/app/content/ui/menu/settings/settings_menu.tscn @@ -1,38 +1,47 @@ -[gd_scene load_steps=9 format=3 uid="uid://c6r4higceibif"] +[gd_scene load_steps=10 format=3 uid="uid://c6r4higceibif"] [ext_resource type="Script" path="res://content/ui/menu/settings/settings_menu.gd" id="1_0lte6"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_faxng"] -[ext_resource type="Material" uid="uid://bujy3egn1oqac" path="res://assets/materials/pri-500.material" id="2_6lhhi"] [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"] - -[sub_resource type="BoxMesh" id="BoxMesh_e51x8"] -size = Vector3(0.3, 0.01, 0.3) +[ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="6_mubnp"] [sub_resource type="BoxShape3D" id="BoxShape3D_3qdps"] -size = Vector3(0.08, 0.01, 0.02) +size = Vector3(0.07, 0.02, 0.01) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_3iv64"] +render_priority = -3 +shader = ExtResource("6_mubnp") +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.42, 0.32) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.02 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_d0l0p"] +size = Vector2(0.42, 0.32) [node name="SettingsMenu" type="Node3D"] script = ExtResource("1_0lte6") -[node name="Background" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15, 0, 0.15) -material_override = ExtResource("2_6lhhi") -mesh = SubResource("BoxMesh_e51x8") - [node name="Content" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.007, 0) [node name="ConnectionStatus" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.250698, 0, 0.151303) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.251, -0.151, 0) pixel_size = 0.001 text = "Disconnected" font_size = 8 outline_size = 0 [node name="LabelURL" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.01, 0, 0.03) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.03, 0) pixel_size = 0.001 text = "url: " @@ -41,11 +50,12 @@ outline_size = 0 horizontal_alignment = 0 [node name="InputURL" parent="Content" instance=ExtResource("4_q3x6k")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.18, 0, 0.03) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.18, -0.03, 0) text = "ws://192.168.0.1:8123" +size = Vector3(0.2, 0.03, 0.01) [node name="LabelToken" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.01, 0, 0.07) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.07, 0) pixel_size = 0.001 text = "token:" font_size = 18 @@ -53,11 +63,12 @@ outline_size = 0 horizontal_alignment = 0 [node name="InputToken" parent="Content" instance=ExtResource("4_q3x6k")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.18, 0, 0.07) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.18, -0.07, 0) text = "..." +size = Vector3(0.2, 0.03, 0.01) [node name="LabelConnect" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.14, 0, 0.12) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.14, -0.12, 0) pixel_size = 0.001 text = "Connect" font_size = 18 @@ -65,26 +76,26 @@ outline_size = 0 horizontal_alignment = 0 [node name="Connect" parent="Content" instance=ExtResource("1_faxng")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 0, 0.12) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, -0.12, 0) label = "login" icon = true [node name="Credits" type="StaticBody3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0102286, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.37, -0.300229, 0) [node name="CollisionShape3D" type="CollisionShape3D" parent="Content/Credits"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26, 0.005, 0.29) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.005, 0, 0) shape = SubResource("BoxShape3D_3qdps") [node name="Label" type="Label3D" parent="Content/Credits"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.26, 0.0102286, 0.29) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.98023e-08, 0, 0) pixel_size = 0.001 text = "credits" font_size = 12 outline_size = 0 [node name="Hearth" type="Label3D" parent="Content/Credits"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.29, 0.0102286, 0.29) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0, 0) pixel_size = 0.001 modulate = Color(0.584314, 0, 0, 1) text = "favorite" @@ -96,7 +107,7 @@ outline_size = 0 script = ExtResource("3_qmg6q") [node name="SaveLabel" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.01, 0, 0.21) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.21, 0) pixel_size = 0.001 text = "Manual Save:" font_size = 18 @@ -104,12 +115,12 @@ outline_size = 0 horizontal_alignment = 0 [node name="Save" parent="Content" instance=ExtResource("1_faxng")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.17, 0, 0.21) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.17, -0.21, 0) label = "save" icon = true [node name="clearSaveLabel" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.01, 0, 0.26) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.26, 0) pixel_size = 0.001 text = "Clear Save:" font_size = 18 @@ -117,12 +128,12 @@ outline_size = 0 horizontal_alignment = 0 [node name="ClearSave" parent="Content" instance=ExtResource("1_faxng")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.17, 0, 0.27) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.17, -0.27, 0) label = "close" icon = true [node name="clearSaveWarning" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.01, 0, 0.28) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.28, 0) pixel_size = 0.001 modulate = Color(1, 0, 0, 1) text = "Caution! This will delete all your rooms and placed devices." @@ -133,16 +144,22 @@ autowrap_mode = 3 width = 150.0 [node name="VoiceAssist" parent="Content" instance=ExtResource("1_faxng")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1, 0, 0.12) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1, -0.12, 0) label = "mic_off" icon = true toggleable = true [node name="LabelVoiceAssist" type="Label3D" parent="Content"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.01, 0, 0.12) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.12, 0) pixel_size = 0.001 text = "Voice- Assist:" font_size = 18 outline_size = 0 horizontal_alignment = 0 + +[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") +mesh = SubResource("QuadMesh_d0l0p") +skeleton = NodePath("../..") diff --git a/app/content/ui/menu/view/view_menu.tscn b/app/content/ui/menu/view/view_menu.tscn index 5614dda..4a6699e 100644 --- a/app/content/ui/menu/view/view_menu.tscn +++ b/app/content/ui/menu/view/view_menu.tscn @@ -6,7 +6,7 @@ [ext_resource type="Shader" path="res://assets/materials/glass.gdshader" id="5_cjxo5"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_e5hvo"] -render_priority = -3 +render_priority = 10 shader = ExtResource("5_cjxo5") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -37,6 +37,8 @@ toggleable = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, -0.04, 0) pixel_size = 0.001 double_sided = false +render_priority = 15 +outline_render_priority = 14 text = "Mini View" font_size = 18 outline_size = 0 @@ -52,6 +54,8 @@ toggleable = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, -0.1, 0) pixel_size = 0.001 double_sided = false +render_priority = 15 +outline_render_priority = 14 text = "Heat Map" font_size = 18 outline_size = 0 @@ -67,6 +71,8 @@ toggleable = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, -0.16, 0) pixel_size = 0.001 double_sided = false +render_priority = 15 +outline_render_priority = 14 text = "Humidity Map" font_size = 18 outline_size = 0 @@ -81,6 +87,8 @@ step = 1.0 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.21, 0) pixel_size = 0.001 double_sided = false +render_priority = 15 +outline_render_priority = 14 text = "Min Value" font_size = 18 outline_size = 0 @@ -95,6 +103,8 @@ step = 1.0 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.25, 0) pixel_size = 0.001 double_sided = false +render_priority = 15 +outline_render_priority = 14 text = "Max Value" font_size = 18 outline_size = 0 @@ -111,6 +121,8 @@ label_unit = "%" transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.29, 0) pixel_size = 0.001 double_sided = false +render_priority = 15 +outline_render_priority = 14 text = "Opacity" font_size = 18 outline_size = 0 diff --git a/app/content/ui/onboarding/onboarding.tscn b/app/content/ui/onboarding/onboarding.tscn index 2cfa3d7..443783c 100644 --- a/app/content/ui/onboarding/onboarding.tscn +++ b/app/content/ui/onboarding/onboarding.tscn @@ -8,7 +8,7 @@ size = Vector3(0.5, 0.3, 0.01) [sub_resource type="ShaderMaterial" id="ShaderMaterial_d2ck8"] -render_priority = -1 +render_priority = 10 shader = ExtResource("2_87aan") shader_parameter/color = Color(1, 1, 1, 0.3) shader_parameter/border_color = Color(1, 1, 1, 1) @@ -32,6 +32,8 @@ script = ExtResource("1_k4yvw") [node name="Label3D2" type="Label3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, -0.1, 0.001) pixel_size = 0.001 +render_priority = 30 +outline_render_priority = 29 text = "Getting Started" font_size = 18 outline_size = 0 @@ -50,6 +52,8 @@ mesh = SubResource("QuadMesh_ij2lj") [node name="GettingStartedLabel" type="Label3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.13, 0.001) pixel_size = 0.001 +render_priority = 30 +outline_render_priority = 29 text = "Hey! This app is still early in development and still has a lot of rough edges. Things might break or are sometimes difficult to use, this will improve the more polished the app becomes. @@ -75,6 +79,8 @@ icon = true [node name="CloseLabel" type="Label3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, -0.1, 0.001) pixel_size = 0.001 +render_priority = 30 +outline_render_priority = 29 text = "Understood" font_size = 18 outline_size = 0 diff --git a/app/lib/stores/devices.gd b/app/lib/stores/devices.gd index 0ee6b43..0eb1917 100644 --- a/app/lib/stores/devices.gd +++ b/app/lib/stores/devices.gd @@ -7,7 +7,22 @@ func _init(): }) HomeApi.on_connect.connect(func(): - self.state.devices=await HomeApi.get_devices() + var devices=await HomeApi.get_devices() + + devices.sort_custom(func(a, b): + return a.values()[0]["name"].to_lower() < b.values()[0]["name"].to_lower() + ) + + for device in devices: + device.values()[0]["entities"].sort_custom(func(a, b): + return a.to_lower() < b.to_lower() + ) + + self.state.devices=devices + ) + + HomeApi.on_disconnect.connect(func(): + self.state.devices=[] ) func clear(): From 0745cdf99cafb7d2e2ad480e526130ee2f89626d Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 11:45:14 +0200 Subject: [PATCH 11/24] fix rooms and input focus --- app/content/system/hands/hands.tscn | 8 ++++---- app/content/system/raycast/raycast.tscn | 1 + app/content/ui/components/button/button.tscn | 2 +- app/content/ui/components/input/input.gd | 6 +++--- app/content/ui/components/input/input.tscn | 6 +++--- app/content/ui/menu/room/views/rooms.gd | 5 +++-- app/content/ui/menu/room/views/rooms.tscn | 3 +-- .../ui/menu/settings/settings_menu.tscn | 20 +++++++++++++++++++ app/lib/events/event_focus.gd | 4 +--- app/lib/globals/event_system.gd | 2 ++ 10 files changed, 39 insertions(+), 18 deletions(-) diff --git a/app/content/system/hands/hands.tscn b/app/content/system/hands/hands.tscn index 6cb3398..5e6bf75 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/raycast/raycast.tscn b/app/content/system/raycast/raycast.tscn index 3ac7fe6..af14d31 100644 --- a/app/content/system/raycast/raycast.tscn +++ b/app/content/system/raycast/raycast.tscn @@ -31,6 +31,7 @@ lower_fade = 0.000919435 [node name="CursorSprite" type="Sprite3D" parent="Cursor"] transform = Transform3D(0.03, 2.71051e-20, 0, -5.42101e-20, 0.03, -2.03288e-21, -2.46521e-33, 2.5411e-21, 0.03, 0, 0, 0) pixel_size = 0.001 +render_priority = 90 texture = ExtResource("1_2f2iv") [node name="Ray" type="MeshInstance3D" parent="."] diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index ece8aeb..8ad6e89 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -43,7 +43,7 @@ text = "Example Text" font_size = 10 outline_size = 0 autowrap_mode = 3 -width = 40.0 +width = 50.0 [node name="FingerArea" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015) diff --git a/app/content/ui/components/input/input.gd b/app/content/ui/components/input/input.gd index 21f2942..7c4860b 100644 --- a/app/content/ui/components/input/input.gd +++ b/app/content/ui/components/input/input.gd @@ -29,7 +29,7 @@ var text_handler = preload ("res://content/ui/components/input/text_handler.gd") label.modulate = Color(0.7, 0.7, 0.7) add_to_group("ui_focus_skip") animation.stop() - caret.hide() + caret.visible = false else: label.modulate = Color(1, 1, 1) remove_from_group("ui_focus_skip") @@ -110,7 +110,7 @@ func _on_focus_in(_event): caret.position.x = text_handler.get_caret_position() label.text = text_handler.get_display_text() - caret.show() + caret.visible = true animation.play("blink") func update_caret_position(event): @@ -135,7 +135,7 @@ func _on_focus_out(_event): return animation.stop() - caret.hide() + caret.visible = false func _draw_debug_text_gaps(): if text_handler.gap_offsets == null: diff --git a/app/content/ui/components/input/input.tscn b/app/content/ui/components/input/input.tscn index e6b2cf6..c047dcd 100644 --- a/app/content/ui/components/input/input.tscn +++ b/app/content/ui/components/input/input.tscn @@ -70,15 +70,15 @@ _data = { "blink": SubResource("Animation_8ny1h") } -[node name="Input" type="Node3D"] +[node name="Input" type="Node3D" groups=["ui_focus"]] script = ExtResource("1_uml3t") text = "Example Text" size = Vector3(0.15, 0.03, 0.01) -[node name="Body" type="StaticBody3D" parent="." groups=["ui_focus"]] +[node name="Body" type="StaticBody3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) collision_layer = 6 -collision_mask = 0 +collision_mask = 6 [node name="Box" type="MeshInstance3D" parent="Body"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005) diff --git a/app/content/ui/menu/room/views/rooms.gd b/app/content/ui/menu/room/views/rooms.gd index 803f87c..a583489 100644 --- a/app/content/ui/menu/room/views/rooms.gd +++ b/app/content/ui/menu/room/views/rooms.gd @@ -104,7 +104,7 @@ func _on_click(event: EventPointer): func _generate_room_map(): var rooms = Store.house.state.rooms - var target_size = Vector2(0.2, 0.24) + var target_size = Vector2(0.2, 0.2) var target_offset = Vector2(0, 0.05) for old_room in rooms_map.get_children(): @@ -156,6 +156,7 @@ func _generate_room_map(): var scale_value = min(target_scale.x, target_scale.y) rooms_map.position.x = -current_min.x * scale_value + target_offset.x - rooms_map.position.z = -current_min.y * scale_value + target_offset.y + rooms_map.position.y = current_min.y * scale_value - target_offset.y + rooms_map.position.z = 0.002 rooms_map.scale = Vector3(scale_value, scale_value, scale_value) diff --git a/app/content/ui/menu/room/views/rooms.tscn b/app/content/ui/menu/room/views/rooms.tscn index b9f58a8..b735a42 100644 --- a/app/content/ui/menu/room/views/rooms.tscn +++ b/app/content/ui/menu/room/views/rooms.tscn @@ -26,7 +26,7 @@ size = Vector2(0.42, 0.32) script = ExtResource("1_3a1oa") [node name="Rooms" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.14, -0.13, 0) +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.14, -0.15, 0) [node name="Button" parent="." instance=ExtResource("1_y3lty")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.28, 0) @@ -40,7 +40,6 @@ disabled = true [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) -visible = false material_override = SubResource("ShaderMaterial_dah0r") mesh = SubResource("QuadMesh_fq44b") skeleton = NodePath("../..") diff --git a/app/content/ui/menu/settings/settings_menu.tscn b/app/content/ui/menu/settings/settings_menu.tscn index 729f996..4bf6853 100644 --- a/app/content/ui/menu/settings/settings_menu.tscn +++ b/app/content/ui/menu/settings/settings_menu.tscn @@ -36,6 +36,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.007, 0) [node name="ConnectionStatus" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.251, -0.151, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "Disconnected" font_size = 8 outline_size = 0 @@ -43,6 +45,8 @@ outline_size = 0 [node name="LabelURL" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.03, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "url: " font_size = 18 @@ -57,6 +61,8 @@ size = Vector3(0.2, 0.03, 0.01) [node name="LabelToken" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.07, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "token:" font_size = 18 outline_size = 0 @@ -70,6 +76,8 @@ size = Vector3(0.2, 0.03, 0.01) [node name="LabelConnect" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.14, -0.12, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "Connect" font_size = 18 outline_size = 0 @@ -90,6 +98,8 @@ shape = SubResource("BoxShape3D_3qdps") [node name="Label" type="Label3D" parent="Content/Credits"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.98023e-08, 0, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "credits" font_size = 12 outline_size = 0 @@ -97,6 +107,8 @@ outline_size = 0 [node name="Hearth" type="Label3D" parent="Content/Credits"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 modulate = Color(0.584314, 0, 0, 1) text = "favorite" font = ExtResource("5_eiwd4") @@ -109,6 +121,8 @@ script = ExtResource("3_qmg6q") [node name="SaveLabel" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.21, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "Manual Save:" font_size = 18 outline_size = 0 @@ -122,6 +136,8 @@ icon = true [node name="clearSaveLabel" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.26, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "Clear Save:" font_size = 18 outline_size = 0 @@ -135,6 +151,8 @@ icon = true [node name="clearSaveWarning" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.28, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 modulate = Color(1, 0, 0, 1) text = "Caution! This will delete all your rooms and placed devices." font_size = 8 @@ -152,6 +170,8 @@ toggleable = true [node name="LabelVoiceAssist" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.01, -0.12, 0) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "Voice- Assist:" font_size = 18 diff --git a/app/lib/events/event_focus.gd b/app/lib/events/event_focus.gd index 35f9858..39e4127 100644 --- a/app/lib/events/event_focus.gd +++ b/app/lib/events/event_focus.gd @@ -1,8 +1,6 @@ -extends Event +extends EventBubble ## Emitted when a Node with the `ui_focus` group is focused or unfocused. class_name EventFocus -## The Node that is being focused or unfocused. -var target: Node ## The Node that was previously focused or unfocused. var previous_target: Node \ No newline at end of file diff --git a/app/lib/globals/event_system.gd b/app/lib/globals/event_system.gd index 31c5c6e..dbf1747 100644 --- a/app/lib/globals/event_system.gd +++ b/app/lib/globals/event_system.gd @@ -96,8 +96,10 @@ func _handle_focus(target: Variant, event: EventBubble): var event_focus = EventFocus.new() event_focus.previous_target = _active_node event_focus.target = target + event_focus.bubbling = false if _active_node != null&&_active_node.has_method(FN_PREFIX + "focus_out"): + emit("focus_out", event_focus) _active_node.call(FN_PREFIX + "focus_out", event_focus) on_focus_out.emit(event_focus) From 2a78e0b33a9255393a057cce6c0f73e987da3108 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 13:19:12 +0200 Subject: [PATCH 12/24] fix and improve devices page --- app/content/ui/components/button/button.gd | 5 +- app/content/ui/components/button/button.tscn | 2 +- .../flex_container/flex_container.gd | 58 +++++++++---------- .../label_container/label_container.gd | 9 +++ .../label_container/label_container.tscn | 2 + .../ui/components/pagination/pagination.gd | 22 ++++--- app/content/ui/menu/edit/devices.gd | 1 + app/content/ui/menu/edit/edit_menu.tscn | 21 ++++--- app/content/ui/menu/edit/entities.gd | 23 ++++---- app/content/ui/menu/edit/entity.gd | 32 ++++++++++ app/content/ui/menu/edit/entity.tscn | 22 +++++++ app/content/ui/menu/menu.tscn | 11 ++-- app/content/ui/menu/room/room_menu.tscn | 7 ++- app/lib/utils/entity_factory.gd | 23 +++++++- 14 files changed, 168 insertions(+), 70 deletions(-) create mode 100644 app/content/ui/menu/edit/entity.gd create mode 100644 app/content/ui/menu/edit/entity.tscn diff --git a/app/content/ui/components/button/button.gd b/app/content/ui/components/button/button.gd index 0c9e639..36d4f6d 100644 --- a/app/content/ui/components/button/button.gd +++ b/app/content/ui/components/button/button.gd @@ -47,13 +47,13 @@ const ECHO_WAIT_REPEAT = 0.1 if icon: label_node.font = IconFont - label_node.font_size = 36 + label_node.font_size = size.x / 0.05 * 36 label_node.width = 1000 label_node.autowrap_mode = TextServer.AUTOWRAP_OFF else: label_node.font = null label_node.font_size = font_size - label_node.width = 50 + label_node.width = size.x / label_node.pixel_size label_node.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART @export var toggleable: bool = false @@ -204,6 +204,7 @@ func _update(): 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) 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) diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index 8ad6e89..ece8aeb 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -43,7 +43,7 @@ text = "Example Text" font_size = 10 outline_size = 0 autowrap_mode = 3 -width = 50.0 +width = 40.0 [node name="FingerArea" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015) diff --git a/app/content/ui/components/flex_container/flex_container.gd b/app/content/ui/components/flex_container/flex_container.gd index 0f2e2e1..85b7015 100644 --- a/app/content/ui/components/flex_container/flex_container.gd +++ b/app/content/ui/components/flex_container/flex_container.gd @@ -27,21 +27,9 @@ enum Justification { func _ready(): _update() - child_entered_tree.connect(func(_arg): - _update() - ) - - child_exiting_tree.connect(func(_arg): - _update() - ) - - child_order_changed.connect(func(): - _update() - ) - func _update(): var width = size.y if vertical else size.x - var child_size := Vector2(0, 0) + var children_size := Vector2(0, 0) var child_count = 0 for child in get_children(): @@ -49,58 +37,64 @@ func _update(): continue if vertical: - child_size.x = max(child.size.x, child_size.x) - child_size.y += child.size.y + gap + children_size.x = max(child.size.x, children_size.x) + children_size.y += child.size.y + gap else: - child_size.x += child.size.x + gap - child_size.y = max(child.size.y, child_size.y) + children_size.x += child.size.x + gap + children_size.y = max(child.size.y, children_size.y) child_count += 1 if child_count == 0: return - var child_scale = Vector2(size.x, size.y) / child_size - child_size.clamp(Vector2(0, 0), Vector2(size.x, size.y)) + var children_scale = Vector2(size.x, size.y) / children_size + children_size.clamp(Vector2(0, 0), Vector2(size.x, size.y)) - child_scale = child_scale.clamp(Vector2(0.001, 0.001), Vector2(1, 1)) + children_scale = children_scale.clamp(Vector2(0.001, 0.001), Vector2(1, 1)) var offset = 0.0 + var children_width = children_size.y if vertical else children_size.x + match justification: Justification.START: offset = 0.0 Justification.CENTER: - offset = (width - child_size) / 2 + offset = (width - children_width) / 2.0 Justification.END: - offset = width - child_size + offset = width - children_width Justification.SPACE_BETWEEN: offset = 0.0 Justification.SPACE_AROUND: - offset = (width - child_size) / child_count / 2 + offset = (width - children_width) / child_count / 2.0 Justification.SPACE_EVENLY: - offset = (width - child_size) / (child_count + 1) + offset = (width - children_width) / (child_count + 1) for child in get_children(): if child is Container3D == false: continue - child.scale = Vector3(child_scale.x, child_scale.y, 1) + child.scale = Vector3(children_scale.x, children_scale.y, 1) if vertical: - child.position = Vector3(0, -offset, 0) - offset += child.size.y * child_scale.y + var child_width = child.size.y * children_scale.y + + child.position = Vector3(0, -offset - child_width / 2.0, 0) + offset += child.size.y * children_scale.y else: - child.position = Vector3(offset, 0, 0) - offset += child.size.x * child_scale.x + var child_width = child.size.x * children_scale.x + + child.position = Vector3(offset + child_width / 2.0, 0, 0) + offset += child.size.x * children_scale.x match justification: Justification.START, Justification.CENTER, Justification.END: offset += gap Justification.SPACE_BETWEEN: - offset += (width - child_size) / (child_count - 1) + offset += (width - children_width) / (child_count - 1) Justification.SPACE_AROUND: - offset += (width - child_size) / child_count + offset += (width - children_width) / child_count Justification.SPACE_EVENLY: - offset += (width - child_size) / (child_count + 1) + offset += (width - children_width) / (child_count + 1) \ No newline at end of file diff --git a/app/content/ui/components/label_container/label_container.gd b/app/content/ui/components/label_container/label_container.gd index 663fa17..f357c4f 100644 --- a/app/content/ui/components/label_container/label_container.gd +++ b/app/content/ui/components/label_container/label_container.gd @@ -14,11 +14,20 @@ const FontTools = preload ("res://lib/utils/font_tools.gd") _update_text() +@export var font_size: int = 18: + set(value): + font_size = value + + if !is_inside_tree(): return + + _update_text() + func _ready(): print("label %s enter tree" % text) _update_text() func _update_text(): + label.font_size = font_size label.text = text var text_size = FontTools.get_font_size(label) size = Vector3(text_size.x, text_size.y, 0.1) diff --git a/app/content/ui/components/label_container/label_container.tscn b/app/content/ui/components/label_container/label_container.tscn index 3b4b34b..2e245ad 100644 --- a/app/content/ui/components/label_container/label_container.tscn +++ b/app/content/ui/components/label_container/label_container.tscn @@ -9,6 +9,8 @@ size = Vector3(0.08, 0.023, 0.1) [node name="Label3D" type="Label3D" parent="."] pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "Example" font = ExtResource("2_6y3jl") font_size = 18 diff --git a/app/content/ui/components/pagination/pagination.gd b/app/content/ui/components/pagination/pagination.gd index 7bc9779..479edfc 100644 --- a/app/content/ui/components/pagination/pagination.gd +++ b/app/content/ui/components/pagination/pagination.gd @@ -35,6 +35,16 @@ const ButtonActiveMaterial = preload ("button_active.material") func _ready(): _update() + prev_button.on_button_up.connect(func(): + page -= 1 + on_page_changed.emit(page) + ) + + next_button.on_button_up.connect(func(): + page += 1 + on_page_changed.emit(page) + ) + func _update(): print("update %s %s %s %s" % [page, pages, visible_pages, get_parent()]) if !is_node_ready(): return @@ -42,11 +52,7 @@ func _update(): for child in get_children(): if child != prev_button&&child != next_button: remove_child(child) - child.free() - # child.queue_free() - # print("queue free", child) - # await child.tree_exited - # print("exited", child) + child.queue_free() var display_pages = min(pages, visible_pages) var center_pos = floor(display_pages / 2) @@ -55,11 +61,11 @@ func _update(): var at_start = page == 0 prev_button.disabled = at_start - prev_button.mesh.visible = !at_start + prev_button.visible = !at_start var at_end = page == pages - 1 next_button.disabled = at_end - next_button.mesh.visible = !at_end + next_button.visible = !at_end prev_button.size = Vector3(size.y, size.y, size.z) next_button.size = Vector3(size.y, size.y, size.z) @@ -92,7 +98,7 @@ func _update(): else: button.label = str(clamp(page + 1, 3, pages - 3) - center_pos + i + 1) - button.on_button_up.connect(func(_arg): + button.on_button_up.connect(func(): page=int(button.label) - 1 on_page_changed.emit(page) ) diff --git a/app/content/ui/menu/edit/devices.gd b/app/content/ui/menu/edit/devices.gd index a657519..1a6defe 100644 --- a/app/content/ui/menu/edit/devices.gd +++ b/app/content/ui/menu/edit/devices.gd @@ -39,6 +39,7 @@ func _ready(): var button_instance=ButtonScene.instantiate() button_instance.label=info["name"] + button_instance.font_size=8 button_instance.on_button_down.connect(func(): on_select_device.emit(device.keys()[0]) ) diff --git a/app/content/ui/menu/edit/edit_menu.tscn b/app/content/ui/menu/edit/edit_menu.tscn index bf746a5..68979c1 100644 --- a/app/content/ui/menu/edit/edit_menu.tscn +++ b/app/content/ui/menu/edit/edit_menu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://crrb0l3ekuotj"] +[gd_scene load_steps=11 format=3 uid="uid://crrb0l3ekuotj"] [ext_resource type="Script" path="res://content/ui/menu/edit/edit_menu.gd" id="1_34cbn"] [ext_resource type="Script" path="res://content/ui/menu/edit/devices.gd" id="2_rkvf4"] @@ -7,6 +7,7 @@ [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="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"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_hstwo"] render_priority = -3 @@ -50,21 +51,23 @@ outline_size = 0 horizontal_alignment = 0 [node name="Pagination3D" parent="Devices" instance=ExtResource("4_4jiu6")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.29, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.29, 0) +pages = 10 size = Vector3(9.92, 0.03, 0.01) [node name="Entities" type="Node3D" parent="."] script = ExtResource("5_t34xe") -[node name="GridContainer3D" type="Node3D" parent="Entities"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, -0.08, 0) -script = ExtResource("3_0xvyw") -columns = 7 -gaps = Vector2(0.01, 0.01) -size = Vector3(0.28, 0.1, 0.1) +[node name="FlexContainer3D" type="Node3D" parent="Entities"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.06, 0) +script = ExtResource("6_cr6p6") +vertical = true +gap = 0.01 +size = Vector3(1, 0.2, 1) [node name="Pagination3D" parent="Entities" instance=ExtResource("4_4jiu6")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, -0.29, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.29, 0) +pages = 10 size = Vector3(9.92, 0.03, 0.01) [node name="Label3D" type="Label3D" parent="Entities"] diff --git a/app/content/ui/menu/edit/entities.gd b/app/content/ui/menu/edit/entities.gd index 0bc81e8..d659fb6 100644 --- a/app/content/ui/menu/edit/entities.gd +++ b/app/content/ui/menu/edit/entities.gd @@ -3,14 +3,14 @@ extends Node3D signal on_select_entity(entity_id) signal on_back() -const ButtonScene = preload ("res://content/ui/components/button/button.tscn") +const EntityScene = preload ("entity.tscn") -@onready var grid_container = $GridContainer3D +@onready var entity_container = $FlexContainer3D @onready var pagination = $Pagination3D @onready var back_button = $Button var page = R.state(0) -var page_size = 28.0 +var page_size = 5.0 var selected_device = R.state(null) func _ready(): @@ -40,16 +40,19 @@ func _ready(): ) R.effect(func(_arg): - for child in grid_container.get_children(): - grid_container.remove_child(child) - child.free() + for child in entity_container.get_children(): + entity_container.remove_child(child) + child.queue_free() for entity in visible_entities.value: - var button_instance=ButtonScene.instantiate() - button_instance.label=entity - button_instance.on_button_down.connect(func(): + var entity_node=EntityScene.instantiate() + entity_node.icon=EntityFactory.get_entity_icon(entity.split(".")[0]) + entity_node.text=entity + entity_node.on_select.connect(func(): on_select_entity.emit(entity) ) - grid_container.add_child(button_instance) + entity_container.add_child(entity_node) + + entity_container._update() ) diff --git a/app/content/ui/menu/edit/entity.gd b/app/content/ui/menu/edit/entity.gd new file mode 100644 index 0000000..6f86d33 --- /dev/null +++ b/app/content/ui/menu/edit/entity.gd @@ -0,0 +1,32 @@ +@tool +extends FlexContainer3D + +signal on_select() + +@onready var button = $Button +@onready var label = $LabelContainer + +@export var icon: String = "question_mark": + set(value): + icon = value + _update() + +@export var text: String = "Button": + set(value): + text = value + _update() + +func _ready(): + super._ready() + + button.on_button_up.connect(func(): + on_select.emit() + ) + +func _update(): + if !is_node_ready(): return + + button.label = icon + label.text = text + + super._update() diff --git a/app/content/ui/menu/edit/entity.tscn b/app/content/ui/menu/edit/entity.tscn new file mode 100644 index 0000000..d41222a --- /dev/null +++ b/app/content/ui/menu/edit/entity.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://uogsamyglyw5"] + +[ext_resource type="Script" path="res://content/ui/menu/edit/entity.gd" id="1_d4c6l"] +[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="2_gi1de"] +[ext_resource type="PackedScene" uid="uid://blkfqa3ttk0d2" path="res://content/ui/components/label_container/label_container.tscn" id="3_vva3t"] + +[node name="Entity" type="Node3D"] +script = ExtResource("1_d4c6l") +gap = 0.01 +size = Vector3(0.35, 0.03, 1) + +[node name="Button" parent="." instance=ExtResource("2_gi1de")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.015, 0, 0) +label = "question_mark" +icon = true +size = Vector3(0.03, 0.03, 0.01) + +[node name="LabelContainer" parent="." instance=ExtResource("3_vva3t")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0615, 0, 0) +text = "Button" +font_size = 12 +size = Vector3(0.043, 0.015, 0.1) diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index 006a0bc..fb9e111 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -221,7 +221,7 @@ mesh = SubResource("QuadMesh_7q1en") skeleton = NodePath("../..") [node name="Tabs" type="Node3D" parent="AnimationContainer" node_paths=PackedStringArray("initial_selected")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.02, -0.03, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.02, -0.005, 0) script = ExtResource("4_eavfx") initial_selected = NodePath("View") vertical = true @@ -229,6 +229,7 @@ gap = 0.01 size = Vector3(0.05, 0.4, 1) [node name="View" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.025, 0) label = "visibility" icon = true toggleable = true @@ -236,28 +237,28 @@ disabled = true size = Vector3(0.05, 0.05, 0.01) [node name="Edit" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.06, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.085, 0) label = "widgets" icon = true toggleable = true size = Vector3(0.05, 0.05, 0.01) [node name="Room" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.12, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.145, 0) label = "view_in_ar" icon = true toggleable = true size = Vector3(0.05, 0.05, 0.01) [node name="Automate" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.18, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.205, 0) label = "schema" icon = true toggleable = true size = Vector3(0.05, 0.05, 0.01) [node name="Settings" parent="AnimationContainer/Tabs" instance=ExtResource("5_w4i01")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.24, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.265, 0) label = "settings" icon = true toggleable = true diff --git a/app/content/ui/menu/room/room_menu.tscn b/app/content/ui/menu/room/room_menu.tscn index 7a3596a..fb961f8 100644 --- a/app/content/ui/menu/room/room_menu.tscn +++ b/app/content/ui/menu/room/room_menu.tscn @@ -31,17 +31,20 @@ script = ExtResource("1_ch4jb") [node name="Interface" type="Node3D" parent="."] [node name="Tabs3D" type="Node3D" parent="Interface" node_paths=PackedStringArray("initial_selected")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.04, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.04, 0) script = ExtResource("5_ddrep") initial_selected = NodePath("Overview") gap = 0.01 [node name="Overview" parent="Interface/Tabs3D" instance=ExtResource("4_cghmp")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03, 0, 0) label = "Overview" +size = Vector3(0.06, 0.04, 0.01) [node name="Rooms" parent="Interface/Tabs3D" instance=ExtResource("4_cghmp")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, 0, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1, 0, 0) label = "Rooms" +size = Vector3(0.06, 0.04, 0.01) [node name="TabsContent3D" type="Node3D" parent="Interface" node_paths=PackedStringArray("tabs")] script = ExtResource("6_ba00g") diff --git a/app/lib/utils/entity_factory.gd b/app/lib/utils/entity_factory.gd index 3608632..e1aa5dc 100644 --- a/app/lib/utils/entity_factory.gd +++ b/app/lib/utils/entity_factory.gd @@ -38,4 +38,25 @@ static func create_entity(id: String, type=null): return null entity.entity_id = id - return entity \ No newline at end of file + return entity + +static func get_entity_icon(type: String) -> String: + match type: + "switch": + return "toggle_on" + "light": + return "lightbulb" + "sensor": + return "sensors" + "media_player": + return "play_circle" + "camera": + return "photo_camera" + "button": + return "radio_button_checked" + "number": + return "sliders" + "line_chart": + return "finance" + _: + return "question_mark" \ No newline at end of file From 8bbeeb49a9a0c73bc370891e51df5feb28f19525 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 15:40:56 +0200 Subject: [PATCH 13/24] update hands and fix mini view z-fighting --- app/content/main.tscn | 4 +-- app/content/system/hands/hands.gd | 25 +++++++++++++------ app/content/system/hands/hands.tscn | 10 ++++---- app/content/system/house/mini/mini_wall.tres | 2 +- .../house/mini/mini_wall_shader.gdshader | 3 ++- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/content/main.tscn b/app/content/main.tscn index d49f6bc..baa8410 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -18,13 +18,11 @@ sky_material = ExtResource("5_wgwf8") [sub_resource type="Environment" id="Environment_7ghp0"] background_mode = 1 -background_color = Color(1, 1, 1, 0) +background_color = Color(0, 0, 0, 0) background_energy_multiplier = 0.0 sky = SubResource("Sky_vhymk") ambient_light_source = 2 ambient_light_color = Color(1, 1, 1, 1) -ambient_light_energy = 0.5 -reflected_light_source = 1 ssao_radius = 6.52 ssao_intensity = 5.68 diff --git a/app/content/system/hands/hands.gd b/app/content/system/hands/hands.gd index 33d3dae..fe208a5 100644 --- a/app/content/system/hands/hands.gd +++ b/app/content/system/hands/hands.gd @@ -17,10 +17,12 @@ const Miniature = preload ("res://content/system/house/mini/miniature.gd") @onready var humidity_button = $XRHandLeft/Palm/QuickActions/Humidity @export var ray_left: RayCast3D @export var ray_right: RayCast3D -var initiator: Initiator = Initiator.new() +var left_initiator: Initiator = Initiator.new() +var right_initiator: Initiator = Initiator.new() var touch: Touch var collide: Collide -var pointer: Pointer +var left_pointer: Pointer +var right_pointer: Pointer var press_distance = 0.03 var grip_distance = 0.03 var close_distance = 0.1 @@ -43,7 +45,7 @@ func _ready(): add_child(touch) add_child(collide) - _ready_hand(hand_right) + _ready_hand() mini_view_button.on_button_up.connect(func(): House.body.mini_view.small.value=!House.body.mini_view.small.value @@ -63,12 +65,18 @@ func _ready(): House.body.mini_view.heatmap_type.value=Miniature.HeatmapType.HUMIDITY ) -func _ready_hand(hand: OpenXRHand): - initiator.type = Initiator.Type.HAND_RIGHT if hand == hand_right else Initiator.Type.HAND_LEFT - initiator.node = ray_left.get_parent() if hand == hand_left else ray_right.get_parent() +func _ready_hand(): + left_initiator.type = Initiator.Type.HAND_LEFT + left_initiator.node = ray_left.get_parent() - pointer = Pointer.new(initiator, ray_left if hand == hand_left else ray_right) - add_child(pointer) + left_pointer = Pointer.new(left_initiator, ray_left) + add_child(left_pointer) + + right_initiator.type = Initiator.Type.HAND_RIGHT + right_initiator.node = ray_right.get_parent() + + right_pointer = Pointer.new(right_initiator, ray_right) + add_child(right_pointer) func _process(_delta): if main.camera.global_transform.basis.z.dot(palm.global_transform.basis.y) > 0.85: @@ -86,6 +94,7 @@ func _process_hand(hand: OpenXRHand): var middle_tip = hand.get_node("MiddleTip/Marker3D") var _ray = ray_left if hand == hand_left else ray_right + var initiator = left_initiator if hand == hand_left else right_initiator var distance_trigger = index_tip.global_position.distance_to(thumb_tip.global_position) var distance_grab = middle_tip.global_position.distance_to(thumb_tip.global_position) diff --git a/app/content/system/hands/hands.tscn b/app/content/system/hands/hands.tscn index 5e6bf75..517a26b 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.928487, 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.928488, 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.996576, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653567, 0.032112, 0.00654224, -0.171612) +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) bone_name = "Middle_Tip_L" bone_idx = 14 use_external_skeleton = true @@ -84,7 +84,7 @@ shape = SubResource("CapsuleShape3D_dopke") transform = Transform3D(-0.707107, -8.74228e-08, -0.707107, 6.18173e-08, -1, 6.18173e-08, -0.707107, -8.29045e-24, 0.707107, 0.01, -0.04, -5.58794e-09) [node name="QuickActions" type="Node3D" parent="XRHandLeft/Palm"] -transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) +transform = Transform3D(0.5, -4.47035e-08, -4.37114e-08, 4.37114e-08, -2.18557e-08, 0.5, -4.47035e-08, -0.5, -2.18557e-08, 0.005, 0, 0.005) [node name="MiniView" parent="XRHandLeft/Palm/QuickActions" instance=ExtResource("3_te2p8")] transform = Transform3D(1, -3.55271e-15, -4.33681e-19, 3.55271e-15, 1, 3.5525e-15, -4.33681e-19, -3.55291e-15, 1, -0.0600001, 0, 0) @@ -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.717078, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345978, -0.164767, -0.0355401) +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) 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.756708, 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.756709, 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/house/mini/mini_wall.tres b/app/content/system/house/mini/mini_wall.tres index 20f7c8e..efe68d9 100644 --- a/app/content/system/house/mini/mini_wall.tres +++ b/app/content/system/house/mini/mini_wall.tres @@ -4,7 +4,7 @@ [ext_resource type="Texture2D" uid="uid://bbuq4wn7e5o2q" path="res://content/system/house/mini/temp_gradient.tres" id="2_3lwi8"] [resource] -render_priority = -2 +render_priority = 0 shader = ExtResource("1_sbr3e") shader_parameter/data = PackedFloat32Array() shader_parameter/data_size = 0 diff --git a/app/content/system/house/mini/mini_wall_shader.gdshader b/app/content/system/house/mini/mini_wall_shader.gdshader index 7ae17f2..e7dd184 100644 --- a/app/content/system/house/mini/mini_wall_shader.gdshader +++ b/app/content/system/house/mini/mini_wall_shader.gdshader @@ -79,4 +79,5 @@ void fragment() { ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO, a); ROUGHNESS = roughness; SPECULAR = 0.5 * inversesqrt(ALPHA); -} + DEPTH = FRAGCOORD.z - 0.00001; +} \ No newline at end of file From 570dda3791f2b6a88326810fee73f607d9c370da Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 16:05:52 +0200 Subject: [PATCH 14/24] more fixes --- app/content/system/assist/assist.gd | 7 +++ app/content/system/house/mini/miniature.tscn | 1 + .../label_container/label_container.gd | 4 +- .../components/notification/notification.tscn | 45 +++++++++++++------ .../ui/components/pagination/pagination.gd | 3 -- app/content/ui/menu/edit/devices.gd | 2 - app/content/ui/menu/menu.gd | 2 +- app/content/ui/menu/room/views/rooms.tscn | 1 + .../ui/menu/settings/settings_menu.tscn | 2 + 9 files changed, 45 insertions(+), 22 deletions(-) diff --git a/app/content/system/assist/assist.gd b/app/content/system/assist/assist.gd index 4188991..71959ec 100644 --- a/app/content/system/assist/assist.gd +++ b/app/content/system/assist/assist.gd @@ -26,6 +26,10 @@ func _ready(): var index = AudioServer.get_bus_index("Record") effect = AudioServer.get_bus_effect(index, 0) + chat_assistant.visible = false + chat_user.visible = false + loader.visible = false + if !HomeApi.has_connected(): await HomeApi.on_connect @@ -91,6 +95,9 @@ func finish(): loader.visible = false func _process(_delta): + if voice_assistant == null: + return + var sterioData: PackedVector2Array = effect.get_buffer(effect.get_frames_available()) if sterioData.size() == 0: diff --git a/app/content/system/house/mini/miniature.tscn b/app/content/system/house/mini/miniature.tscn index be396af..f89f869 100644 --- a/app/content/system/house/mini/miniature.tscn +++ b/app/content/system/house/mini/miniature.tscn @@ -13,6 +13,7 @@ script = ExtResource("1_b53yn") [node name="CollisionShape3D" type="CollisionShape3D" parent="Body"] shape = SubResource("BoxShape3D_bckw3") +disabled = true [node name="Movable" type="Node" parent="Body"] script = ExtResource("2_x7oed") diff --git a/app/content/ui/components/label_container/label_container.gd b/app/content/ui/components/label_container/label_container.gd index f357c4f..601c983 100644 --- a/app/content/ui/components/label_container/label_container.gd +++ b/app/content/ui/components/label_container/label_container.gd @@ -23,12 +23,10 @@ const FontTools = preload ("res://lib/utils/font_tools.gd") _update_text() func _ready(): - print("label %s enter tree" % text) _update_text() func _update_text(): label.font_size = font_size label.text = text var text_size = FontTools.get_font_size(label) - size = Vector3(text_size.x, text_size.y, 0.1) - print("label %s size %s" % [text, size]) \ No newline at end of file + size = Vector3(text_size.x, text_size.y, 0.1) \ No newline at end of file diff --git a/app/content/ui/components/notification/notification.tscn b/app/content/ui/components/notification/notification.tscn index 825bfc6..ebf6457 100644 --- a/app/content/ui/components/notification/notification.tscn +++ b/app/content/ui/components/notification/notification.tscn @@ -1,15 +1,29 @@ -[gd_scene load_steps=10 format=3 uid="uid://bqj7qwj5mgd30"] +[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="Material" uid="uid://bujy3egn1oqac" path="res://assets/materials/pri-500.material" id="2_5b8oo"] +[ext_resource type="Shader" path="res://assets/materials/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"] -[sub_resource type="BoxMesh" id="BoxMesh_s37oj"] -size = Vector3(0.25, 0.01, 0.05) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0ktvn"] +render_priority = 10 +shader = ExtResource("2_b68od") +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.25, 0.05) +shader_parameter/border_size = 0.001 +shader_parameter/border_fade_in = 0.005 +shader_parameter/border_fade_out = 0.0 +shader_parameter/corner_radius = 0.025 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_dx2yp"] +size = Vector2(0.25, 0.05) [sub_resource type="BoxShape3D" id="BoxShape3D_m4d21"] -size = Vector3(0.25, 0.01, 0.05) +size = Vector3(0.25, 0.05, 0.01) [sub_resource type="Animation" id="Animation_bkual"] length = 0.001 @@ -164,25 +178,31 @@ script = ExtResource("1_yw3yb") collision_layer = 6 collision_mask = 0 -[node name="MeshInstance3D" type="MeshInstance3D" parent="AnimationNode"] -material_override = ExtResource("2_5b8oo") -mesh = SubResource("BoxMesh_s37oj") +[node name="MeshInstance3D2" type="MeshInstance3D" parent="AnimationNode"] +material_override = SubResource("ShaderMaterial_0ktvn") +mesh = SubResource("QuadMesh_dx2yp") [node name="CollisionShape3D" type="CollisionShape3D" parent="AnimationNode"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.005) shape = SubResource("BoxShape3D_m4d21") [node name="Text" type="Label3D" parent="AnimationNode"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.08, 0.006, 0) +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 autowrap_mode = 3 -width = 190.0 +width = 170.0 [node name="Icon" type="Label3D" parent="AnimationNode"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.1, 0.006, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.1, 0, 0.001) pixel_size = 0.001 +render_priority = 15 +outline_render_priority = 14 text = "info" font = ExtResource("3_1ljpc") font_size = 24 @@ -194,10 +214,9 @@ libraries = { } [node name="Button" parent="AnimationNode" instance=ExtResource("4_ocg5j")] -transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0.12, -0.003, -0.02) +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0.1, 0, 0) label = "close" icon = true -size = Vector3(1, 1, 1) [node name="Timer" type="Timer" parent="AnimationNode"] wait_time = 3.0 diff --git a/app/content/ui/components/pagination/pagination.gd b/app/content/ui/components/pagination/pagination.gd index 479edfc..4ec7733 100644 --- a/app/content/ui/components/pagination/pagination.gd +++ b/app/content/ui/components/pagination/pagination.gd @@ -46,7 +46,6 @@ func _ready(): ) func _update(): - print("update %s %s %s %s" % [page, pages, visible_pages, get_parent()]) if !is_node_ready(): return for child in get_children(): @@ -70,8 +69,6 @@ func _update(): prev_button.size = Vector3(size.y, size.y, size.z) next_button.size = Vector3(size.y, size.y, size.z) - print("A %s %s %s %s" % [display_pages, center_pos, start_dots, end_dots]) - for i in range(display_pages): if (start_dots&&i == 1)||(end_dots&&i == display_pages - 2): var container = Container3D.new() diff --git a/app/content/ui/menu/edit/devices.gd b/app/content/ui/menu/edit/devices.gd index 1a6defe..ac6d257 100644 --- a/app/content/ui/menu/edit/devices.gd +++ b/app/content/ui/menu/edit/devices.gd @@ -14,8 +14,6 @@ func _ready(): var pages = R.computed(func(_arg): var devices=Store.devices.state.devices - - print("recalc pages ", ceil(devices.size() / page_size)) return ceil(devices.size() / page_size) ) diff --git a/app/content/ui/menu/menu.gd b/app/content/ui/menu/menu.gd index 2cff249..bb0c8b6 100644 --- a/app/content/ui/menu/menu.gd +++ b/app/content/ui/menu/menu.gd @@ -35,7 +35,7 @@ func _ready(): notification_node.type=event.type for child in notify_place.get_children(): - child.position += Vector3(0, 0, -0.06) + child.position += Vector3(0, 0.06, 0) notify_place.add_child(notification_node) ) diff --git a/app/content/ui/menu/room/views/rooms.tscn b/app/content/ui/menu/room/views/rooms.tscn index b735a42..ecac368 100644 --- a/app/content/ui/menu/room/views/rooms.tscn +++ b/app/content/ui/menu/room/views/rooms.tscn @@ -40,6 +40,7 @@ disabled = true [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) +visible = false material_override = SubResource("ShaderMaterial_dah0r") mesh = SubResource("QuadMesh_fq44b") skeleton = NodePath("../..") diff --git a/app/content/ui/menu/settings/settings_menu.tscn b/app/content/ui/menu/settings/settings_menu.tscn index 4bf6853..2844629 100644 --- a/app/content/ui/menu/settings/settings_menu.tscn +++ b/app/content/ui/menu/settings/settings_menu.tscn @@ -90,10 +90,12 @@ icon = true [node name="Credits" type="StaticBody3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.37, -0.300229, 0) +visible = false [node name="CollisionShape3D" type="CollisionShape3D" parent="Content/Credits"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.005, 0, 0) shape = SubResource("BoxShape3D_3qdps") +disabled = true [node name="Label" type="Label3D" parent="Content/Credits"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.98023e-08, 0, 0) From 96a42dcb8acec80de4dfcdb005a2330db122d33e Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 16:16:14 +0200 Subject: [PATCH 15/24] fix hand drag --- app/content/main.tscn | 8 +------- app/content/system/controller_left/controller_left.tscn | 1 + app/content/system/keyboard/keyboard.tscn | 6 +----- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/content/main.tscn b/app/content/main.tscn index baa8410..45bb435 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://eecv28y6jxk4"] +[gd_scene load_steps=17 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"] @@ -33,8 +33,6 @@ ao_enabled = true material = SubResource("StandardMaterial3D_m58yb") size = Vector3(0.01, 0.01, 0.01) -[sub_resource type="CylinderMesh" id="CylinderMesh_72c80"] - [node name="Main" type="Node3D"] transform = Transform3D(1, -0.000296142, 0.000270963, 0.000296143, 1, -4.5899e-06, -0.000270962, 4.67014e-06, 1, 0, 0, 0) script = ExtResource("1_uvrd4") @@ -88,8 +86,4 @@ transform = Transform3D(0.5, 5.24309e-05, 0.000144384, -0.000139169, 0.353553, 0 [node name="Onboarding" parent="." instance=ExtResource("12_uq2nj")] transform = Transform3D(1, -9.48098e-12, 0, 9.48098e-12, 1, 0, 0, 0, 1, -0.529594, 0.820154, -0.600147) -[node name="MeshInstance3D2" type="MeshInstance3D" parent="."] -transform = Transform3D(1, -1.39635e-11, 0, 1.02449e-10, 1, 0, 0, 0, 1, 0.327865, -9.50548e-05, 0.44448) -mesh = SubResource("CylinderMesh_72c80") - [editable path="XROrigin3D/XRControllerLeft"] diff --git a/app/content/system/controller_left/controller_left.tscn b/app/content/system/controller_left/controller_left.tscn index a18969b..2b5adba 100644 --- a/app/content/system/controller_left/controller_left.tscn +++ b/app/content/system/controller_left/controller_left.tscn @@ -119,3 +119,4 @@ libraries = { } [node name="Raycast" parent="." instance=ExtResource("4_n7lao")] +is_right = false diff --git a/app/content/system/keyboard/keyboard.tscn b/app/content/system/keyboard/keyboard.tscn index e3c86f6..d83d06b 100644 --- a/app/content/system/keyboard/keyboard.tscn +++ b/app/content/system/keyboard/keyboard.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=10 format=3 uid="uid://lrehk38exd5n"] +[gd_scene load_steps=9 format=3 uid="uid://lrehk38exd5n"] [ext_resource type="Script" path="res://content/system/keyboard/keyboard.gd" id="1_maojw"] [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="Script" path="res://content/functions/occludable.gd" id="6_y4sdl"] [sub_resource type="BoxShape3D" id="BoxShape3D_k5ib7"] size = Vector3(0.86, 0.27, 0.02) @@ -73,6 +72,3 @@ shape = SubResource("BoxShape3D_k5ib7") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] material_override = SubResource("ShaderMaterial_x72nd") mesh = SubResource("QuadMesh_88pdc") - -[node name="Occludable" type="Node" parent="."] -script = ExtResource("6_y4sdl") From 8441eac8f2193859a39a1a302e6919923612d92b Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 16:31:55 +0200 Subject: [PATCH 16/24] fix touching devices menu --- app/content/ui/menu/edit/devices.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/content/ui/menu/edit/devices.gd b/app/content/ui/menu/edit/devices.gd index ac6d257..86e4947 100644 --- a/app/content/ui/menu/edit/devices.gd +++ b/app/content/ui/menu/edit/devices.gd @@ -38,7 +38,7 @@ func _ready(): var button_instance=ButtonScene.instantiate() button_instance.label=info["name"] button_instance.font_size=8 - button_instance.on_button_down.connect(func(): + button_instance.on_button_up.connect(func(): on_select_device.emit(device.keys()[0]) ) grid_container.add_child(button_instance) From c7958d82fa16b6809f987a99ec245b320ab4e4fb Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 17:15:01 +0200 Subject: [PATCH 17/24] update onboarding --- app/content/main.tscn | 2 +- app/content/system/house/mini/mini_wall.tres | 2 +- app/content/ui/onboarding/onboarding.tscn | 14 ++++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/content/main.tscn b/app/content/main.tscn index 45bb435..47079ed 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -84,6 +84,6 @@ transform = Transform3D(0.5, 5.24309e-05, 0.000144384, -0.000139169, 0.353553, 0 [node name="House" parent="." instance=ExtResource("9_np6mw")] [node name="Onboarding" parent="." instance=ExtResource("12_uq2nj")] -transform = Transform3D(1, -9.48098e-12, 0, 9.48098e-12, 1, 0, 0, 0, 1, -0.529594, 0.820154, -0.600147) +transform = Transform3D(1, -1.39636e-11, 0, 4.42413e-11, 1, 0, 0, 0, 1, -0.576793, 0.820168, -0.60016) [editable path="XROrigin3D/XRControllerLeft"] diff --git a/app/content/system/house/mini/mini_wall.tres b/app/content/system/house/mini/mini_wall.tres index efe68d9..c2f5e4d 100644 --- a/app/content/system/house/mini/mini_wall.tres +++ b/app/content/system/house/mini/mini_wall.tres @@ -4,7 +4,7 @@ [ext_resource type="Texture2D" uid="uid://bbuq4wn7e5o2q" path="res://content/system/house/mini/temp_gradient.tres" id="2_3lwi8"] [resource] -render_priority = 0 +render_priority = 10 shader = ExtResource("1_sbr3e") shader_parameter/data = PackedFloat32Array() shader_parameter/data_size = 0 diff --git a/app/content/ui/onboarding/onboarding.tscn b/app/content/ui/onboarding/onboarding.tscn index 443783c..a6d12e1 100644 --- a/app/content/ui/onboarding/onboarding.tscn +++ b/app/content/ui/onboarding/onboarding.tscn @@ -13,11 +13,11 @@ shader = ExtResource("2_87aan") 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(1, 1) +shader_parameter/size = Vector2(0.5, 0.3) shader_parameter/border_size = 0.001 shader_parameter/border_fade_in = 0.005 shader_parameter/border_fade_out = 0.0 -shader_parameter/corner_radius = 0.04 +shader_parameter/corner_radius = 0.02 shader_parameter/roughness = 0.3 shader_parameter/grain_amount = 0.02 @@ -30,7 +30,7 @@ collision_mask = 0 script = ExtResource("1_k4yvw") [node name="Label3D2" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, -0.1, 0.001) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, -0.11, 0.001) pixel_size = 0.001 render_priority = 30 outline_render_priority = 29 @@ -38,7 +38,6 @@ text = "Getting Started" font_size = 18 outline_size = 0 horizontal_alignment = 0 -vertical_alignment = 0 autowrap_mode = 3 width = 470.0 @@ -67,7 +66,7 @@ autowrap_mode = 3 width = 470.0 [node name="GettingStartedButton" parent="." instance=ExtResource("3_hlpow")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.05, -0.11, 0.001) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, -0.11, 0.001) label = "open_in_new" icon = true @@ -77,14 +76,13 @@ label = "done" icon = true [node name="CloseLabel" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, -0.1, 0.001) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.18, -0.11, 0.001) pixel_size = 0.001 render_priority = 30 outline_render_priority = 29 text = "Understood" font_size = 18 outline_size = 0 -horizontal_alignment = 0 -vertical_alignment = 0 +horizontal_alignment = 2 autowrap_mode = 3 width = 470.0 From de9a6a21be8c7eaaf07fbb844022fe2360e7f32a Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 17:27:17 +0200 Subject: [PATCH 18/24] fix lights --- app/content/entities/light/light.gd | 7 +------ app/content/entities/light/light_on.tres | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/content/entities/light/light.gd b/app/content/entities/light/light.gd index 7335c40..c14c9d9 100644 --- a/app/content/entities/light/light.gd +++ b/app/content/entities/light/light.gd @@ -126,9 +126,4 @@ func quick_action(): _toggle() func _toggle(): - var attributes = {} - - if !active.value&&brightness.value != null: - attributes["brightness"] = int(brightness.value) - - HomeApi.set_state(entity_id, "off" if active.value else "on", attributes) \ No newline at end of file + HomeApi.set_state(entity_id, "off" if active.value else "on") \ No newline at end of file diff --git a/app/content/entities/light/light_on.tres b/app/content/entities/light/light_on.tres index e590915..03bfde0 100644 --- a/app/content/entities/light/light_on.tres +++ b/app/content/entities/light/light_on.tres @@ -2,5 +2,6 @@ [resource] resource_local_to_scene = true +albedo_color = Color(0.231373, 0.231373, 0.231373, 1) emission = Color(1, 0.65098, 0, 1) emission_energy_multiplier = 0.0 From 5605934e03b7d3b23a6882ec4e262ff96b245594 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 17:28:17 +0200 Subject: [PATCH 19/24] delete occludable --- app/content/functions/occludable.gd | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 app/content/functions/occludable.gd diff --git a/app/content/functions/occludable.gd b/app/content/functions/occludable.gd deleted file mode 100644 index 432b004..0000000 --- a/app/content/functions/occludable.gd +++ /dev/null @@ -1,20 +0,0 @@ -extends Function -class_name Occludable - -var ray := RayCast3D.new() -@onready var player_camera: XRCamera3D = get_node("/root/Main/XROrigin3D/XRCamera3D") - -func _ready(): - ray.set_collision_mask_value(1, false) - ray.set_collision_mask_value(5, true) - get_parent().add_child.call_deferred(ray) - - EventSystem.on_slow_tick.connect(_slow_tick) - -func _slow_tick(_delta): - if player_camera.is_inside_tree() == false||ray.is_inside_tree() == false: - return - - ray.target_position = get_parent().to_local(player_camera.global_position) - - get_parent().visible = ray.is_colliding() == false From 0433331e2b7016c2e2f4266d85003e27cd523112 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 19:09:52 +0200 Subject: [PATCH 20/24] fix movable and menu --- app/content/functions/movable.gd | 25 ++++++++++++++++---- app/content/system/hands/hands.gd | 8 +++---- app/content/ui/components/button/button.tscn | 2 +- app/content/ui/menu/menu.tscn | 12 +++------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/content/functions/movable.gd b/app/content/functions/movable.gd index 1937512..4447883 100644 --- a/app/content/functions/movable.gd +++ b/app/content/functions/movable.gd @@ -9,17 +9,26 @@ signal on_moved() @export var restrict_movement: Callable @export var lock_rotation: bool = false var hit_node := Node3D.new() +var initiator = null func _on_grab_down(event: EventPointer): - if restricted && event.target != get_parent(): + if restricted&&event.target != get_parent(): return - event.initiator.node.add_child(hit_node) + initiator = event.initiator + + if hit_node.get_parent() != null: + hit_node.get_parent().remove_child(hit_node) + + initiator.node.add_child(hit_node) hit_node.global_transform = get_parent().global_transform -func _on_grab_move(_event: EventPointer): +func _on_grab_move(event: EventPointer): if hit_node.get_parent() == null: return + + if event.initiator != initiator: + return if restrict_movement: get_parent().global_position = restrict_movement.call(hit_node.global_position) @@ -33,7 +42,14 @@ func _on_grab_move(_event: EventPointer): on_move.emit(get_parent().global_position, Vector3(0, 0, 0)) func _on_grab_up(event: EventPointer): - event.initiator.node.remove_child(hit_node) + if event.initiator != initiator: + return + + if hit_node.get_parent() == null: + return + + initiator = null + hit_node.get_parent().remove_child(hit_node) on_moved.emit() func _get_configuration_warnings() -> PackedStringArray: @@ -41,6 +57,5 @@ func _get_configuration_warnings() -> PackedStringArray: if get_parent() is StaticBody3D == false: warnings.append("Movable requires a StaticBody3D as parent.") - return warnings diff --git a/app/content/system/hands/hands.gd b/app/content/system/hands/hands.gd index fe208a5..26e378a 100644 --- a/app/content/system/hands/hands.gd +++ b/app/content/system/hands/hands.gd @@ -122,12 +122,12 @@ func _process_hand(hand: OpenXRHand): initiator.on_release.emit(Initiator.EventType.GRIP) grabbed_left = false else: - if trigger_close&&!grabbed_right: + if trigger_close&&!grabbed_left: initiator.on_press.emit(Initiator.EventType.GRIP) - grabbed_right = true - elif !trigger_close&&grabbed_right: + grabbed_left = true + elif !trigger_close&&grabbed_left: initiator.on_release.emit(Initiator.EventType.GRIP) - grabbed_right = false + grabbed_left = false else: if !distance_close: if trigger_close&&!pressed_right: diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index ece8aeb..881bb56 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -45,7 +45,7 @@ outline_size = 0 autowrap_mode = 3 width = 40.0 -[node name="FingerArea" type="Area3D" parent="."] +[node name="FingerArea" type="Area3D" parent="." groups=["ui_focus_skip"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015) collision_layer = 4 collision_mask = 0 diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index fb9e111..b0ab2de 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -188,8 +188,8 @@ _data = { } [node name="Menu" type="StaticBody3D"] -collision_layer = 2 -collision_mask = 2 +collision_layer = 6 +collision_mask = 6 script = ExtResource("1_ng4u3") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] @@ -199,14 +199,8 @@ shape = SubResource("BoxShape3D_e1esh") [node name="Movable" type="Node" parent="."] script = ExtResource("2_8coxu") -[node name="AnimationContainer" type="StaticBody3D" parent="."] +[node name="AnimationContainer" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.15, 0) -collision_layer = 6 -collision_mask = 6 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="AnimationContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.15, -0.005) -shape = SubResource("BoxShape3D_e1esh") [node name="Background" type="MeshInstance3D" parent="AnimationContainer"] transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.23, -0.15, 0) From 5ba67029c7eca6691652f4ea5979af066333f82d Mon Sep 17 00:00:00 2001 From: Nitwel Date: Fri, 26 Apr 2024 13:30:11 +0200 Subject: [PATCH 21/24] 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="" From b25cc8c08db3dd89aed34d81e46fbc6389ba2711 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Fri, 26 Apr 2024 13:58:20 +0200 Subject: [PATCH 22/24] fix rotation and entity in mini view --- app/content/functions/movable.gd | 4 ++++ app/content/system/house/mini/Entity.gd | 9 +++++++-- app/content/system/house/mini/miniature.gd | 2 ++ app/content/system/house/mini/miniature.tscn | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/content/functions/movable.gd b/app/content/functions/movable.gd index 4447883..8d3c33a 100644 --- a/app/content/functions/movable.gd +++ b/app/content/functions/movable.gd @@ -8,10 +8,14 @@ signal on_moved() @export var restricted: bool = false @export var restrict_movement: Callable @export var lock_rotation: bool = false +@export var disabled: bool = false var hit_node := Node3D.new() var initiator = null func _on_grab_down(event: EventPointer): + if disabled: + return + if restricted&&event.target != get_parent(): return diff --git a/app/content/system/house/mini/Entity.gd b/app/content/system/house/mini/Entity.gd index 67ee467..7f5671a 100644 --- a/app/content/system/house/mini/Entity.gd +++ b/app/content/system/house/mini/Entity.gd @@ -4,17 +4,20 @@ const DotScene = preload ("res://content/system/dot/dot.tscn") const Entity = preload ("res://content/entities/entity.gd") @onready var dots = $"../Small/Dots" +@onready var main = $"/root/Main" var active_type = null var editing = R.state([]) var group_entity = null +var house_small = null + func _ready(): await House.body.ready # Update Group Entity R.effect(func(_arg): - if editing.value.size() == 0: + if house_small.value == false||editing.value.size() == 0: if group_entity != null: group_entity.queue_free() group_entity=null @@ -23,7 +26,9 @@ func _ready(): group_entity=EntityFactory.create_entity(id, active_type) for entity_node in group_entity.get_children(): if entity_node is Movable: - group_entity.remove_child(entity_node) + entity_node.disabled=true + + group_entity.transform=Transform3D().looking_at(to_local((main.camera.global_position)), Vector3.UP, true) add_child(group_entity) else: HomeApi.groups.update_entities(group_entity.entity_id, editing.value.map(func(entity): return entity.entity_id)) diff --git a/app/content/system/house/mini/miniature.gd b/app/content/system/house/mini/miniature.gd index 9dccb84..724da7b 100644 --- a/app/content/system/house/mini/miniature.gd +++ b/app/content/system/house/mini/miniature.gd @@ -38,6 +38,8 @@ func _ready(): wall_material.set_shader_parameter("data", []) wall_material.set_shader_parameter("data_size", 0) + entity_select.house_small = small + if Store.house.is_loaded() == false: await Store.house.on_loaded diff --git a/app/content/system/house/mini/miniature.tscn b/app/content/system/house/mini/miniature.tscn index f89f869..f462726 100644 --- a/app/content/system/house/mini/miniature.tscn +++ b/app/content/system/house/mini/miniature.tscn @@ -18,6 +18,7 @@ disabled = true [node name="Movable" type="Node" parent="Body"] script = ExtResource("2_x7oed") restricted = true +disabled = null [node name="Small" type="Node3D" parent="Body"] From 08de973e96d661e9deda3ecdbd10092891c29052 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Fri, 26 Apr 2024 14:42:30 +0200 Subject: [PATCH 23/24] small fixes --- app/content/system/house/align_reference.gd | 3 +++ app/content/system/house/mini/miniature.gd | 1 - app/content/system/house/mini/miniature.tscn | 1 - app/content/ui/components/button/button.tscn | 25 +++++++++++++++---- app/content/ui/components/input/input.tscn | 8 +++--- app/content/ui/components/panel/panel.tscn | 25 +++++++++++++++---- .../ui/components/tabs/tabs_content.gd | 2 +- app/content/ui/onboarding/onboarding.gd | 3 ++- 8 files changed, 50 insertions(+), 18 deletions(-) diff --git a/app/content/system/house/align_reference.gd b/app/content/system/house/align_reference.gd index c4e1242..23c9f28 100644 --- a/app/content/system/house/align_reference.gd +++ b/app/content/system/house/align_reference.gd @@ -50,6 +50,9 @@ func get_new_transform(): func update_align_reference(): corner1.global_position = Store.house.state.align_position1 corner2.global_position = Store.house.state.align_position2 + + if corner1.global_position == corner2.global_position: + corner2.global_position = corner1.global_position + Vector3(1, 0, 0) corner2.look_at(corner1.global_position, Vector3.UP) corner2.rotate(Vector3.UP, deg_to_rad( - 90)) diff --git a/app/content/system/house/mini/miniature.gd b/app/content/system/house/mini/miniature.gd index 724da7b..77eedba 100644 --- a/app/content/system/house/mini/miniature.gd +++ b/app/content/system/house/mini/miniature.gd @@ -9,7 +9,6 @@ const temperature_gradient = preload ("./temp_gradient.tres") @onready var small_node = $Body/Small @onready var model = $Body/Small/Model @onready var collision_shape = $Body/CollisionShape3D -@onready var toggle_heatmap = $Body/HeatmapButton @onready var entity_select = $Body/EntitySelect enum HeatmapType { diff --git a/app/content/system/house/mini/miniature.tscn b/app/content/system/house/mini/miniature.tscn index f462726..f89f869 100644 --- a/app/content/system/house/mini/miniature.tscn +++ b/app/content/system/house/mini/miniature.tscn @@ -18,7 +18,6 @@ disabled = true [node name="Movable" type="Node" parent="Body"] script = ExtResource("2_x7oed") restricted = true -disabled = null [node name="Small" type="Node3D" parent="Body"] diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index 9000ad3..0570053 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -1,10 +1,25 @@ -[gd_scene load_steps=7 format=3 uid="uid://bsjqdvkt0u87c"] +[gd_scene load_steps=8 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://crycqex1ucj04" path="res://content/ui/components/panel/panel.material" id="2_28wsr"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="2_db5by"] [ext_resource type="Script" path="res://content/ui/components/panel/panel.gd" id="3_skm86"] -[sub_resource type="QuadMesh" id="QuadMesh_bu2il"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_tulmb"] +resource_local_to_scene = true +render_priority = 10 +shader = ExtResource("2_db5by") +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(1, 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_hvywi"] size = Vector2(0.04, 0.04) [sub_resource type="BoxShape3D" id="BoxShape3D_xwopm"] @@ -27,8 +42,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 = ExtResource("2_28wsr") -mesh = SubResource("QuadMesh_bu2il") +material_override = SubResource("ShaderMaterial_tulmb") +mesh = SubResource("QuadMesh_hvywi") 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 d135253..039908c 100644 --- a/app/content/ui/components/input/input.tscn +++ b/app/content/ui/components/input/input.tscn @@ -5,7 +5,7 @@ [ext_resource type="FontVariation" uid="uid://d2ofyimg5s65q" path="res://assets/fonts/ui_font_500.tres" id="3_ij5fh"] [ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_nl02b"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_ioqea"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_exbug"] 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_qgsvu"] +[sub_resource type="QuadMesh" id="QuadMesh_lemta"] size = Vector2(0.15, 0.03) [sub_resource type="BoxShape3D" id="BoxShape3D_x4yp8"] @@ -82,8 +82,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_ioqea") -mesh = SubResource("QuadMesh_qgsvu") +material_override = SubResource("ShaderMaterial_exbug") +mesh = SubResource("QuadMesh_lemta") script = ExtResource("3_3bvrj") size = Vector2(0.15, 0.03) diff --git a/app/content/ui/components/panel/panel.tscn b/app/content/ui/components/panel/panel.tscn index 5dcc34a..ecf1008 100644 --- a/app/content/ui/components/panel/panel.tscn +++ b/app/content/ui/components/panel/panel.tscn @@ -1,14 +1,29 @@ -[gd_scene load_steps=4 format=3 uid="uid://dnam3fe36gg62"] +[gd_scene load_steps=5 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"] +[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="1_mpdsy"] -[sub_resource type="QuadMesh" id="QuadMesh_vflbj"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_jbi6t"] +resource_local_to_scene = true +render_priority = 10 +shader = ExtResource("1_mpdsy") +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(1, 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.04 +shader_parameter/roughness = 0.3 +shader_parameter/grain_amount = 0.02 + +[sub_resource type="QuadMesh" id="QuadMesh_vcnnc"] size = Vector2(0.04, 0.04) [node name="Panel" type="MeshInstance3D"] -material_override = ExtResource("1_8jj0l") -mesh = SubResource("QuadMesh_vflbj") +material_override = SubResource("ShaderMaterial_jbi6t") +mesh = SubResource("QuadMesh_vcnnc") script = ExtResource("1_2jq4a") size = Vector2(0.04, 0.04) corner_radius = null diff --git a/app/content/ui/components/tabs/tabs_content.gd b/app/content/ui/components/tabs/tabs_content.gd index 181d298..1dd6b5d 100644 --- a/app/content/ui/components/tabs/tabs_content.gd +++ b/app/content/ui/components/tabs/tabs_content.gd @@ -16,6 +16,6 @@ func _ready(): R.effect(func(_arg): if tabs.selected.value.get_index() == i: add_child(child) - else: + elif child.get_parent() == self: remove_child(child) ) diff --git a/app/content/ui/onboarding/onboarding.gd b/app/content/ui/onboarding/onboarding.gd index d917341..7aac25e 100644 --- a/app/content/ui/onboarding/onboarding.gd +++ b/app/content/ui/onboarding/onboarding.gd @@ -3,9 +3,10 @@ extends Node3D @onready var getting_started_button = $GettingStartedButton @onready var close_button = $CloseButton @onready var camera = $"/root/Main/XROrigin3D/XRCamera3D" -var next_new_position = global_position +var next_new_position = null func _ready(): + next_new_position = global_position if Store.settings.is_loaded() == false: await Store.settings.on_loaded From c74845df501126f59ebe5e7b956915fd9c6d6d5c Mon Sep 17 00:00:00 2001 From: Nitwel Date: Fri, 26 Apr 2024 14:53:40 +0200 Subject: [PATCH 24/24] fix keyboard collision --- app/content/system/keyboard/keyboard.tscn | 1 + 1 file changed, 1 insertion(+) diff --git a/app/content/system/keyboard/keyboard.tscn b/app/content/system/keyboard/keyboard.tscn index 94318be..5f761e0 100644 --- a/app/content/system/keyboard/keyboard.tscn +++ b/app/content/system/keyboard/keyboard.tscn @@ -67,6 +67,7 @@ size = Vector3(0.6, 0.15, 1) script = ExtResource("4_86fct") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.01) shape = SubResource("BoxShape3D_k5ib7") [node name="MeshInstance3D" type="MeshInstance3D" parent="."]