finish input, fix menu, implement conn config

This commit is contained in:
Nitwel 2023-11-23 03:41:13 +01:00
parent 2433845df7
commit f8033e7e06
17 changed files with 179 additions and 93 deletions

View File

@ -12,6 +12,7 @@ var sky_passthrough = preload("res://assets/materials/sky_passthrough.material")
func _ready(): func _ready():
# In case we're running on the headset, use the passthrough sky # In case we're running on the headset, use the passthrough sky
if OS.get_name() == "Android": if OS.get_name() == "Android":
OS.request_permissions()
environment.environment.sky.set_material(sky_passthrough) environment.environment.sky.set_material(sky_passthrough)
house.visible = false house.visible = false
else: else:

View File

@ -6,9 +6,9 @@
[ext_resource type="Script" path="res://content/functions/movable.gd" id="4_86fct"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_86fct"]
[sub_resource type="BoxShape3D" id="BoxShape3D_k5ib7"] [sub_resource type="BoxShape3D" id="BoxShape3D_k5ib7"]
size = Vector3(0.744504, 0.0402036, 0.296009) size = Vector3(0.84, 0.0402036, 0.296009)
[node name="Keyboard" type="StaticBody3D"] [node name="Keyboard" type="StaticBody3D" groups=["ui_focus_skip"]]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
script = ExtResource("1_maojw") script = ExtResource("1_maojw")
@ -48,5 +48,5 @@ size = Vector3(0.6, 1, 1)
script = ExtResource("4_86fct") script = ExtResource("4_86fct")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.276719, -0.025645, 0.0928761) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.296719, -0.025645, 0.0928761)
shape = SubResource("BoxShape3D_k5ib7") shape = SubResource("BoxShape3D_k5ib7")

View File

@ -6,6 +6,7 @@ signal on_button_up()
@export var toggleable: bool = false @export var toggleable: bool = false
@export var disabled: bool = false @export var disabled: bool = false
@export var external_state: bool = false
@export var initial_active: bool = false @export var initial_active: bool = false
var active: bool = false : var active: bool = false :
set(value): set(value):
@ -31,13 +32,14 @@ func _on_press_down(event):
event.bubbling = false event.bubbling = false
return return
if toggleable: AudioPlayer.play_effect("click")
if external_state || toggleable:
return return
active = true active = true
on_button_down.emit() on_button_down.emit()
AudioPlayer.play_effect("click")
func _on_press_up(event): func _on_press_up(event):
@ -45,8 +47,12 @@ func _on_press_up(event):
event.bubbling = false event.bubbling = false
return return
if external_state:
return
if toggleable: if toggleable:
active = !active active = !active
if active: if active:
on_button_down.emit() on_button_down.emit()
else: else:

View File

@ -1,16 +1,26 @@
@tool
extends StaticBody3D extends StaticBody3D
@onready var caret: MeshInstance3D = $Label/Caret
@onready var label: Label3D = $Label @onready var label: Label3D = $Label
@onready var animation: AnimationPlayer = $AnimationPlayer @export var text: String = "Hello World":
var text: String = "Hello World":
set(value): set(value):
var old_text = text var old_text = text
text = value text = value
if label == null:
return
label.text = value label.text = value
if Engine.is_editor_hint():
return
gap_offsets = _calculate_text_gaps() gap_offsets = _calculate_text_gaps()
caret_position += text.length() - old_text.length() caret_position += text.length() - old_text.length()
text_changed.emit(value)
@onready var caret: MeshInstance3D = $Label/Caret
@onready var animation: AnimationPlayer = $AnimationPlayer
signal text_changed(text: String)
var keyboard_input: bool = false var keyboard_input: bool = false
var gap_offsets = [] var gap_offsets = []
@ -20,6 +30,11 @@ var caret_position: int = 3:
caret.position.x = gap_offsets[caret_position] caret.position.x = gap_offsets[caret_position]
func _ready(): func _ready():
text = text # So @tool works
if Engine.is_editor_hint():
return
EventSystem.on_key_down.connect(func(event): EventSystem.on_key_down.connect(func(event):
if EventSystem.is_focused(self) == false: if EventSystem.is_focused(self) == false:
return return
@ -37,6 +52,9 @@ func _input(event):
text = EventKey.key_to_string(event.keycode, event.shift_pressed, text.substr(0, caret_position)) + text.substr(caret_position, text.length()) text = EventKey.key_to_string(event.keycode, event.shift_pressed, text.substr(0, caret_position)) + text.substr(caret_position, text.length())
func _process(_delta): func _process(_delta):
if Engine.is_editor_hint():
return
if get_tree().debug_collisions_hint && OS.get_name() != "Android": if get_tree().debug_collisions_hint && OS.get_name() != "Android":
_draw_debug_text_gaps() _draw_debug_text_gaps()

View File

@ -26,7 +26,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0), "times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1), "transitions": PackedFloat32Array(1),
"update": 0, "update": 0,
"values": [true] "values": [false]
} }
[sub_resource type="Animation" id="Animation_8ny1h"] [sub_resource type="Animation" id="Animation_8ny1h"]
@ -71,6 +71,7 @@ font = SubResource("SystemFont_nbea0")
horizontal_alignment = 0 horizontal_alignment = 0
[node name="Caret" type="MeshInstance3D" parent="Label"] [node name="Caret" type="MeshInstance3D" parent="Label"]
visible = false
mesh = SubResource("BoxMesh_2736g") mesh = SubResource("BoxMesh_2736g")
skeleton = NodePath("../..") skeleton = NodePath("../..")

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://dbe8slnyhro2n"] [gd_scene load_steps=4 format=3 uid="uid://dbe8slnyhro2n"]
[ext_resource type="Script" path="res://content/ui/device/device.gd" id="1_rbo86"] [ext_resource type="Script" path="res://content/ui/device/device.gd" id="1_rbo86"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/button/button.tscn" id="2_go2es"] [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"] [ext_resource type="Script" path="res://content/functions/clickable.gd" id="3_6wicx"]
[node name="Device" type="Node3D"] [node name="Device" type="Node3D"]

View File

@ -10,7 +10,7 @@ const Sensor = preload("res://content/entities/sensor/sensor.tscn")
@onready var next_page_button = $Buttons/NextPageButton @onready var next_page_button = $Buttons/NextPageButton
@onready var previous_page_button = $Buttons/PreviousPageButton @onready var previous_page_button = $Buttons/PreviousPageButton
@onready var page_number_label = $PageNumberLabel @onready var page_number_label = $PageNumberLabel
var devices var devices = []
var page = 0 var page = 0
var last_device_page = 0 var last_device_page = 0
var page_size = 20 var page_size = 20
@ -19,7 +19,10 @@ var pages = 0
var selected_device = null var selected_device = null
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
HomeAdapters.adapter.adapter.on_connect.connect(func():
devices = await HomeAdapters.adapter.get_devices() devices = await HomeAdapters.adapter.get_devices()
render()
)
next_page_button.get_node("Clickable").on_click.connect(func(_event): next_page_button.get_node("Clickable").on_click.connect(func(_event):
print("next page") print("next page")
@ -30,8 +33,6 @@ func _ready():
previous_page() previous_page()
) )
render()
func update_pages(): func update_pages():
if selected_device == null: if selected_device == null:
pages = ceil(float(devices.size()) / page_size) pages = ceil(float(devices.size()) / page_size)
@ -62,6 +63,9 @@ func previous_page():
render() render()
func render(): func render():
if devices.size() == 0:
return
update_pages() update_pages()
page_number_label.set_text(str(page + 1) + " / " + str(pages)) page_number_label.set_text(str(page + 1) + " / " + str(pages))
@ -91,7 +95,7 @@ func render_devices():
_on_device_click(device_instance.id) _on_device_click(device_instance.id)
) )
devices_node.add_child(device_instance) devices_node.add_child(device_instance)
device_instance.set_device_name(info["name"]) device_instance.set_device_name.call_deferred(info["name"])
devices_node._update_container() devices_node._update_container()
@ -158,6 +162,7 @@ func _on_entity_click(entity_name):
func clear_menu(): func clear_menu():
for child in devices_node.get_children(): for child in devices_node.get_children():
devices_node.remove_child(child) devices_node.remove_child(child)
child.queue_free()
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):

View File

@ -16,18 +16,9 @@ extends Node3D
@onready var nav = $AnimationContainer/Navigation @onready var nav = $AnimationContainer/Navigation
@onready var animation_player = $AnimationPlayer @onready var animation_player = $AnimationPlayer
enum Menu { var selected_nav = null
VIEW,
EDIT,
ROOM,
AUTOMATE,
SETTINGS
}
var selected_menu := Menu.EDIT
var show_menu := true: var show_menu := true:
get:
return show_menu
set(value): set(value):
show_menu = value show_menu = value
if value: if value:
@ -39,67 +30,47 @@ var show_menu := true:
func _ready(): func _ready():
_controller.button_pressed.connect(func(button): _controller.button_pressed.connect(func(button):
print(button)
if button == "by_button": if button == "by_button":
show_menu = !show_menu show_menu = !show_menu
) )
select_menu(selected_menu) select_menu(nav_edit)
func _on_click(event): func _on_click(event):
if event.target == nav_view: select_menu(event.target)
select_menu(Menu.VIEW)
elif event.target == nav_edit: func select_menu(nav):
select_menu(Menu.EDIT) if _is_valid_nav(nav) == false || selected_nav == nav:
elif event.target == nav_room: return
select_menu(Menu.ROOM)
elif event.target == nav_automate:
select_menu(Menu.AUTOMATE)
elif event.target == nav_settings:
select_menu(Menu.SETTINGS)
func select_menu(menu: Menu):
selected_menu = menu
for child in content.get_children(): for child in content.get_children():
content.remove_child(child) content.remove_child(child)
var menu_node = enum_to_menu(menu) if selected_nav != null:
var nav_node = enum_to_nav(menu) selected_nav.active = false
if nav_node != null: selected_nav = nav
nav_node.disabled = true
if menu_node != null: if selected_nav != null:
menu_node.visible = true selected_nav.active = true
content.add_child(menu_node) var menu = _nav_to_menu(selected_nav)
if menu != null:
content.add_child(menu)
menu.visible = true
for child in nav.get_children(): func _is_valid_nav(nav):
if child.active && child != nav_node: return nav == nav_view || nav == nav_edit || nav == nav_room || nav == nav_automate || nav == nav_settings
child.active = false
child.disabled = false
func enum_to_nav(menu: Menu): func _nav_to_menu(nav):
match menu: match nav:
Menu.VIEW: nav_view:
return nav_view
Menu.EDIT:
return nav_edit
Menu.ROOM:
return nav_room
Menu.AUTOMATE:
return nav_automate
Menu.SETTINGS:
return nav_settings
func enum_to_menu(menu: Menu):
match menu:
Menu.VIEW:
return null return null
Menu.EDIT: nav_edit:
return menu_edit return menu_edit
Menu.ROOM: nav_room:
return menu_room return menu_room
Menu.AUTOMATE: nav_automate:
return null return null
Menu.SETTINGS: nav_settings:
return menu_settings return menu_settings
return null

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=3 uid="uid://c3kdssrmv84kv"] [gd_scene load_steps=16 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/ui/menu/menu.gd" id="1_ng4u3"]
[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://crrb0l3ekuotj" path="res://content/ui/menu/edit/edit_menu.tscn" id="4_r2raj"]
@ -11,7 +11,6 @@
[ext_resource type="Texture2D" uid="uid://dyh0ax51xqp8n" path="res://assets/icons/settings_white_24dp.svg" id="9_mel13"] [ext_resource type="Texture2D" uid="uid://dyh0ax51xqp8n" path="res://assets/icons/settings_white_24dp.svg" id="9_mel13"]
[ext_resource type="PackedScene" uid="uid://c01gkeldvjwtr" path="res://content/ui/menu/room/room_menu.tscn" id="10_u4i1x"] [ext_resource type="PackedScene" uid="uid://c01gkeldvjwtr" path="res://content/ui/menu/room/room_menu.tscn" id="10_u4i1x"]
[ext_resource type="PackedScene" uid="uid://c6r4higceibif" path="res://content/ui/menu/settings/settings_menu.tscn" id="11_7wm6b"] [ext_resource type="PackedScene" uid="uid://c6r4higceibif" path="res://content/ui/menu/settings/settings_menu.tscn" id="11_7wm6b"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="12_ov3em"]
[sub_resource type="BoxMesh" id="BoxMesh_08du6"] [sub_resource type="BoxMesh" id="BoxMesh_08du6"]
size = Vector3(0.3, 0.01, 0.3) size = Vector3(0.3, 0.01, 0.3)
@ -169,6 +168,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06, 0, 0)
[node name="View" parent="AnimationContainer/Navigation" instance=ExtResource("5_w4i01")] [node name="View" parent="AnimationContainer/Navigation" instance=ExtResource("5_w4i01")]
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.03, 0, 0.03)
toggleable = true toggleable = true
external_state = true
[node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/View"] [node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/View"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0)
@ -179,7 +179,7 @@ texture = ExtResource("5_8o1rb")
[node name="Edit" parent="AnimationContainer/Navigation" instance=ExtResource("5_w4i01")] [node name="Edit" parent="AnimationContainer/Navigation" 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.03, 0, 0.09)
toggleable = true toggleable = true
initial_active = true external_state = true
[node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Edit"] [node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Edit"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0)
@ -190,6 +190,7 @@ texture = ExtResource("6_344ot")
[node name="Room" parent="AnimationContainer/Navigation" instance=ExtResource("5_w4i01")] [node name="Room" parent="AnimationContainer/Navigation" 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.03, 0, 0.15)
toggleable = true toggleable = true
external_state = true
[node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Room"] [node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Room"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0)
@ -200,6 +201,7 @@ texture = ExtResource("7_wvovx")
[node name="Automate" parent="AnimationContainer/Navigation" instance=ExtResource("5_w4i01")] [node name="Automate" parent="AnimationContainer/Navigation" 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.03, 0, 0.21)
toggleable = true toggleable = true
external_state = true
[node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Automate"] [node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Automate"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0)
@ -210,6 +212,7 @@ texture = ExtResource("8_3d082")
[node name="Settings" parent="AnimationContainer/Navigation" instance=ExtResource("5_w4i01")] [node name="Settings" parent="AnimationContainer/Navigation" 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.03, 0, 0.27)
toggleable = true toggleable = true
external_state = true
[node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Settings"] [node name="Sprite3D" type="Sprite3D" parent="AnimationContainer/Navigation/Settings"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0)
@ -221,12 +224,12 @@ texture = ExtResource("9_mel13")
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.06, 0, 0)
[node name="EditMenu" parent="AnimationContainer/Content" instance=ExtResource("4_r2raj")] [node name="EditMenu" parent="AnimationContainer/Content" instance=ExtResource("4_r2raj")]
visible = false
[node name="RoomMenu" parent="AnimationContainer/Content" instance=ExtResource("10_u4i1x")] [node name="RoomMenu" parent="AnimationContainer/Content" instance=ExtResource("10_u4i1x")]
visible = false visible = false
[node name="SettingsMenu" parent="AnimationContainer/Content" instance=ExtResource("11_7wm6b")] [node name="SettingsMenu" parent="AnimationContainer/Content" instance=ExtResource("11_7wm6b")]
visible = false
[node name="ImmersiveHomePanels" type="MeshInstance3D" parent="."] [node name="ImmersiveHomePanels" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-10, 0, 0.01, 0, 0.01, 0, -0.01, 0, -4.37114e-10, 0.32, 0, -0.0500001) transform = Transform3D(-4.37114e-10, 0, 0.01, 0, 0.01, 0, -0.01, 0, -4.37114e-10, 0.32, 0, -0.0500001)
@ -237,6 +240,3 @@ mesh = ExtResource("7_f4u4o")
libraries = { libraries = {
"": SubResource("AnimationLibrary_s30cd") "": SubResource("AnimationLibrary_s30cd")
} }
[node name="Input" parent="." instance=ExtResource("12_ov3em")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.19, 0, -0.04)

View File

@ -5,6 +5,10 @@ const ball_scene = preload("res://content/ui/menu/settings/ball.tscn")
@onready var clickable = $Content/Button/Clickable @onready var clickable = $Content/Button/Clickable
@onready var connection_status = $Content/ConnectionStatus @onready var connection_status = $Content/ConnectionStatus
@onready var input_url = $Content/InputURL
@onready var input_token = $Content/InputToken
@onready var button_connect = $Content/Connect
func _ready(): func _ready():
clickable.on_click.connect(func(event): clickable.on_click.connect(func(event):
var ball = ball_scene.instantiate() var ball = ball_scene.instantiate()
@ -13,6 +17,25 @@ func _ready():
get_tree().root.add_child(ball) get_tree().root.add_child(ball)
) )
var config = ConfigData.load_config()
if config.has("url"):
input_url.text = config["url"]
if config.has("token"):
input_token.text = config["token"]
button_connect.on_button_down.connect(func():
HomeAdapters.adapter.adapter.url = input_url.text + "/api/websocket"
HomeAdapters.adapter.adapter.token = input_token.text
HomeAdapters.adapter.adapter.retries = 5
HomeAdapters.adapter.adapter.connect_ws()
ConfigData.save_config({
"url": input_url.text,
"token": input_token.text
})
)
HomeAdapters.adapter.adapter.on_connect.connect(func(): HomeAdapters.adapter.adapter.on_connect.connect(func():
connection_status.text = "Connected" connection_status.text = "Connected"
) )

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://c6r4higceibif"] [gd_scene load_steps=6 format=3 uid="uid://c6r4higceibif"]
[ext_resource type="Script" path="res://content/ui/menu/settings/settings_menu.gd" id="1_0lte6"] [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="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_faxng"]
[ext_resource type="Script" path="res://content/functions/clickable.gd" id="3_qmg6q"] [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"]
[sub_resource type="BoxMesh" id="BoxMesh_e51x8"] [sub_resource type="BoxMesh" id="BoxMesh_e51x8"]
size = Vector3(0.3, 0.01, 0.3) size = Vector3(0.3, 0.01, 0.3)
@ -18,12 +19,12 @@ mesh = SubResource("BoxMesh_e51x8")
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, 0.0102286, 0)
[node name="Label3D" type="Label3D" parent="Content"] [node name="Label3D" type="Label3D" parent="Content"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.184377, 0, 0.0435752) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.184377, 0, 0.253575)
pixel_size = 0.001 pixel_size = 0.001
text = "Spawn Ball" text = "Spawn Ball"
[node name="Button" parent="Content" instance=ExtResource("1_faxng")] [node name="Button" parent="Content" instance=ExtResource("1_faxng")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0458097, 0, 0.0435752) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0458097, 0, 0.253575)
[node name="Clickable" type="Node" parent="Content/Button"] [node name="Clickable" type="Node" parent="Content/Button"]
script = ExtResource("3_qmg6q") script = ExtResource("3_qmg6q")
@ -32,3 +33,35 @@ script = ExtResource("3_qmg6q")
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.26, 0, 0.29) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.26, 0, 0.29)
pixel_size = 0.0003 pixel_size = 0.0003
text = "Disconnected" text = "Disconnected"
[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)
pixel_size = 0.0005
text = "URL"
font_size = 36
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)
text = "ws://192.168.33.33:8123"
[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)
pixel_size = 0.0005
text = "TOKEN"
font_size = 36
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)
text = "paste token here"
[node name="LabelConnect" type="Label3D" parent="Content"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.15, 0, 0.12)
pixel_size = 0.0005
text = "TOKEN"
font_size = 36
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)

View File

@ -142,7 +142,7 @@ permissions/process_outgoing_calls=false
permissions/read_calendar=false permissions/read_calendar=false
permissions/read_call_log=false permissions/read_call_log=false
permissions/read_contacts=false permissions/read_contacts=false
permissions/read_external_storage=false permissions/read_external_storage=true
permissions/read_frame_buffer=false permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false permissions/read_history_bookmarks=false
permissions/read_input_state=false permissions/read_input_state=false
@ -193,7 +193,7 @@ permissions/write_apn_settings=false
permissions/write_calendar=false permissions/write_calendar=false
permissions/write_call_log=false permissions/write_call_log=false
permissions/write_contacts=false permissions/write_contacts=false
permissions/write_external_storage=false permissions/write_external_storage=true
permissions/write_gservices=false permissions/write_gservices=false
permissions/write_history_bookmarks=false permissions/write_history_bookmarks=false
permissions/write_profile=false permissions/write_profile=false

View File

@ -142,7 +142,7 @@ permissions/process_outgoing_calls=false
permissions/read_calendar=false permissions/read_calendar=false
permissions/read_call_log=false permissions/read_call_log=false
permissions/read_contacts=false permissions/read_contacts=false
permissions/read_external_storage=false permissions/read_external_storage=true
permissions/read_frame_buffer=false permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false permissions/read_history_bookmarks=false
permissions/read_input_state=false permissions/read_input_state=false
@ -193,7 +193,7 @@ permissions/write_apn_settings=false
permissions/write_calendar=false permissions/write_calendar=false
permissions/write_call_log=false permissions/write_call_log=false
permissions/write_contacts=false permissions/write_contacts=false
permissions/write_external_storage=false permissions/write_external_storage=true
permissions/write_gservices=false permissions/write_gservices=false
permissions/write_history_bookmarks=false permissions/write_history_bookmarks=false
permissions/write_profile=false permissions/write_profile=false

View File

@ -0,0 +1,23 @@
extends Node
var file_url: String = "user://config.json"
func save_config(data: Dictionary):
var file := FileAccess.open(file_url, FileAccess.WRITE)
if file == null:
return
var json_data := JSON.stringify(data)
file.store_string(json_data)
func load_config():
var file := FileAccess.open(file_url, FileAccess.READ)
if file == null:
return {}
var json_data := file.get_as_text()
var data = JSON.parse_string(json_data)
return data

View File

@ -25,15 +25,16 @@ var adapter: Node
func _init(type: ADAPTER_TYPES): func _init(type: ADAPTER_TYPES):
var clipboard := DisplayServer.clipboard_get() var url = ""
var token = ""
var config = ConfigData.load_config()
if clipboard != null && clipboard.find(" ") != -1: if config.has("url"):
var clip_url = clipboard.split(" ")[0] url = config["url"] + "/api/websocket"
var clip_token = clipboard.split(" ")[1] if config.has("token"):
adapter = adapters[type].new(clip_url, clip_token) token = config["token"]
else:
adapter = adapters[type].new()
adapter = adapters[type].new(url, token)
add_child(adapter) add_child(adapter)
for method in methods: for method in methods:

View File

@ -32,6 +32,9 @@ func _init(url := self.url, token := self.token):
connect_ws() connect_ws()
func connect_ws(): func connect_ws():
if url == "" || token == "":
return
retries -= 1 retries -= 1
if retries < 0: if retries < 0:
print("Failed to connect to %s" % self.url) print("Failed to connect to %s" % self.url)

View File

@ -18,6 +18,7 @@ config/icon="res://assets/logo.png"
[autoload] [autoload]
XRToolsUserSettings="*res://addons/godot-xr-tools/user_settings/user_settings.gd" XRToolsUserSettings="*res://addons/godot-xr-tools/user_settings/user_settings.gd"
ConfigData="*res://lib/globals/config_data.gd"
Request="*res://lib/globals/request.gd" Request="*res://lib/globals/request.gd"
HomeAdapters="*res://lib/globals/home_adapters.gd" HomeAdapters="*res://lib/globals/home_adapters.gd"
AudioPlayer="*res://lib/globals/audio_player.gd" AudioPlayer="*res://lib/globals/audio_player.gd"