From 71b669eb447d609b59c2a4c9e3479664e497ed8d Mon Sep 17 00:00:00 2001 From: Techwizz Date: Sat, 25 Feb 2023 15:21:18 -0700 Subject: [PATCH] Added name label above player #4 --- characters/teddy/Teddy.gd | 1 + scenes/Teddy.tscn | 4 ++++ scenes/hostmenu.tscn | 14 ++++++++++++++ scripts/host.gd | 7 ++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/characters/teddy/Teddy.gd b/characters/teddy/Teddy.gd index cc1c0e6..9d738f7 100644 --- a/characters/teddy/Teddy.gd +++ b/characters/teddy/Teddy.gd @@ -23,6 +23,7 @@ func _ready(): selfTeddy = self.get_path() teddyParent = get_node(selfTeddy).get_parent() Global.teddyAuthorityID = teddyAuthority + Global.playerName = $nameLabel func _unhandled_input(event): Global.selfTeddy = selfTeddy diff --git a/scenes/Teddy.tscn b/scenes/Teddy.tscn index 493bc86..184fa0c 100644 --- a/scenes/Teddy.tscn +++ b/scenes/Teddy.tscn @@ -26,3 +26,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.859224, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.104801, -0.858231) [node name="sound" type="AudioStreamPlayer3D" parent="."] + +[node name="nameLabel" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.60152, 0) +text = "Un-named Player" diff --git a/scenes/hostmenu.tscn b/scenes/hostmenu.tscn index ceb8194..3dd3e49 100644 --- a/scenes/hostmenu.tscn +++ b/scenes/hostmenu.tscn @@ -131,7 +131,21 @@ offset_right = 620.0 offset_bottom = 187.0 text = "Host Game" +[node name="playerNameBox" type="LineEdit" parent="."] +offset_left = 392.0 +offset_top = 527.0 +offset_right = 559.0 +offset_bottom = 570.0 + +[node name="playerLabel" type="Label" parent="."] +offset_left = 269.0 +offset_top = 536.0 +offset_right = 377.0 +offset_bottom = 562.0 +text = "Player Name: " + [connection signal="pressed" from="close" to="." method="_on_close_pressed"] [connection signal="pressed" from="playground" to="." method="_on_playground_pressed"] [connection signal="pressed" from="startButton" to="." method="_on_start_button_pressed"] [connection signal="pressed" from="joinButton" to="." method="_on_join_button_pressed"] +[connection signal="text_changed" from="playerNameBox" to="." method="_on_player_name_box_text_changed"] diff --git a/scripts/host.gd b/scripts/host.gd index a18ce6a..728b361 100644 --- a/scripts/host.gd +++ b/scripts/host.gd @@ -3,7 +3,7 @@ extends Node var SCENE func _ready(): - pass + $playerNameBox.text = Global.playerName func _process(delta): @@ -55,3 +55,8 @@ func _on_join_button_pressed(): var scene=scene_trs.instantiate() get_parent().add_child(scene) self.queue_free() + + +func _on_player_name_box_text_changed(new_text): + $playerNameBox.text = Global.playerName + SettingsFile.save_data(Global.mouseSensitivity, Global.playerName)