From 9bab4348aff7d77f21df0607120c6af539877a93 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Sun, 26 Nov 2023 03:06:31 +0100 Subject: [PATCH] bug fixes for exporting to android --- content/ui/components/button/button.gd | 21 +++++++++++++++------ content/ui/components/input/input.gd | 12 +++++++++--- content/ui/menu/edit/device/device.gd | 6 +++--- content/ui/menu/edit/device/device.tscn | 9 --------- content/ui/menu/edit/edit_menu.gd | 4 ++-- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/content/ui/components/button/button.gd b/content/ui/components/button/button.gd index bd48488..a16b3a5 100644 --- a/content/ui/components/button/button.gd +++ b/content/ui/components/button/button.gd @@ -12,17 +12,23 @@ const IconFont = preload("res://assets/icons/icons.tres") @export var label: String = "": set(value): - if !is_inside_tree(): await ready + label = value + if label_node == null: + return label_node.text = value - get: - return label_node.text @export var icon: bool = false: set(value): icon = value - if !is_inside_tree(): await ready - label_node.font = IconFont if value else null - label_node.font_size = 48 if value else 10 + if label_node == null: + return + + if value: + label_node.font = IconFont + label_node.font_size = 48 + label_node.width = 1000 + label_node.autowrap_mode = TextServer.AUTOWRAP_OFF + @export var toggleable: bool = false @export var disabled: bool = false @@ -44,6 +50,9 @@ var active: bool = false : @onready var animation_player: AnimationPlayer = $AnimationPlayer func _ready(): + label = label + icon = icon + if initial_active: active = true diff --git a/content/ui/components/input/input.gd b/content/ui/components/input/input.gd index 97dc833..2230348 100644 --- a/content/ui/components/input/input.gd +++ b/content/ui/components/input/input.gd @@ -13,9 +13,11 @@ var text_handler = preload("res://content/ui/components/input/text_handler.gd"). get: return text_handler.width set(value): + width = value text_handler.width = value - if !is_inside_tree(): await ready + if mesh_box == null: + return mesh_box.mesh.size.x = value collision.shape.size.x = value @@ -25,10 +27,12 @@ var text_handler = preload("res://content/ui/components/input/text_handler.gd"). get: return text_handler.text set(value): + text = value var focused = Engine.is_editor_hint() == false && EventSystem.is_focused(self) == false - text_handler.set_text(value, focused) + if label == null: + return - if !is_inside_tree(): await ready + text_handler.set_text(value, focused) label.text = text_handler.get_display_text() var keyboard_input: bool = false @@ -37,6 +41,8 @@ var input_plane = Plane(Vector3.UP, Vector3.ZERO) func _ready(): text_handler.label = label + width = width + text = text if Engine.is_editor_hint(): return diff --git a/content/ui/menu/edit/device/device.gd b/content/ui/menu/edit/device/device.gd index 1ec8175..19c3d76 100644 --- a/content/ui/menu/edit/device/device.gd +++ b/content/ui/menu/edit/device/device.gd @@ -1,8 +1,8 @@ extends Node3D -@onready var label: Label3D = $Button/Label +@onready var button = $Button @export var id: String = "0" func set_device_name(text): - assert(label != null, "Device has to be added to the scene tree") - label.text = text + assert(button != null, "Device has to be added to the scene tree") + button.label = text diff --git a/content/ui/menu/edit/device/device.tscn b/content/ui/menu/edit/device/device.tscn index 22373f1..12fdd5c 100644 --- a/content/ui/menu/edit/device/device.tscn +++ b/content/ui/menu/edit/device/device.tscn @@ -9,14 +9,5 @@ script = ExtResource("1_rbo86") [node name="Button" parent="." instance=ExtResource("2_go2es")] -[node name="Label" type="Label3D" parent="Button"] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.0142873, 0) -pixel_size = 0.001 -text = "Texttexttexttexttexttextext" -font_size = 7 -outline_size = 0 -autowrap_mode = 3 -width = 50.0 - [node name="Clickable" type="Node" parent="."] script = ExtResource("3_6wicx") diff --git a/content/ui/menu/edit/edit_menu.gd b/content/ui/menu/edit/edit_menu.gd index c34537a..8676d09 100644 --- a/content/ui/menu/edit/edit_menu.gd +++ b/content/ui/menu/edit/edit_menu.gd @@ -31,7 +31,7 @@ func _enter_tree(): load_devices() else: HomeApi.on_connect.connect(func(): - if is_inside_tree(): + if is_node_ready(): load_devices() ) @@ -42,7 +42,7 @@ func load_devices(): HomeApi.on_disconnect.connect(func(): devices = [] - if is_inside_tree(): + if is_node_ready(): render() )