Bladeren bron

:tada: Remove movement input prompt when every command has been pressed

DricomDragon 2 weken geleden
bovenliggende
commit
b9496ddd9a

+ 103 - 0
godot/component/ui/input_prompts/move/move_container.tscn

@@ -0,0 +1,103 @@
+[gd_scene load_steps=15 format=3 uid="uid://y4gc5uinkcqj"]
+
+[ext_resource type="Script" path="res://component/ui/input_prompts/move/move_prompt.gd" id="1_b1cf6"]
+[ext_resource type="Texture2D" uid="uid://cah6r1q5x2lte" path="res://addons/input_prompts/icons/generic/left_stick_left.png" id="1_lp1l5"]
+[ext_resource type="Script" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="2_hmylp"]
+[ext_resource type="Texture2D" uid="uid://c03r3n0nfrjck" path="res://addons/input_prompts/icons/generic/left_stick_right.png" id="3_l042n"]
+[ext_resource type="Texture2D" uid="uid://bntsrcd3hjcex" path="res://addons/input_prompts/icons/generic/left_stick_up.png" id="4_e345q"]
+[ext_resource type="Texture2D" uid="uid://dreirjfpqj40a" path="res://addons/input_prompts/icons/generic/left_stick_down.png" id="5_vrthb"]
+
+[sub_resource type="InputEventKey" id="InputEventKey_5ba2r"]
+device = -1
+physical_keycode = 65
+unicode = 97
+
+[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_2p15s"]
+device = -1
+axis_value = -1.0
+
+[sub_resource type="InputEventKey" id="InputEventKey_vmcvq"]
+device = -1
+physical_keycode = 68
+unicode = 101
+
+[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_auo40"]
+device = -1
+axis_value = 1.0
+
+[sub_resource type="InputEventKey" id="InputEventKey_urkwk"]
+device = -1
+physical_keycode = 87
+unicode = 44
+
+[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_sgel0"]
+device = -1
+axis = 1
+axis_value = -1.0
+
+[sub_resource type="InputEventKey" id="InputEventKey_3sn2y"]
+device = -1
+physical_keycode = 83
+unicode = 111
+
+[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_kmldo"]
+device = -1
+axis = 1
+axis_value = 1.0
+
+[node name="MoveContainer" type="HBoxContainer"]
+script = ExtResource("1_b1cf6")
+
+[node name="MoveLabel" type="Label" parent="."]
+layout_mode = 2
+theme_override_font_sizes/font_size = 34
+text = "Move"
+
+[node name="MoveLeftActionPrompt" type="TextureRect" parent="."]
+custom_minimum_size = Vector2(100, 100)
+layout_mode = 2
+texture = ExtResource("1_lp1l5")
+stretch_mode = 5
+script = ExtResource("2_hmylp")
+action = "move_left"
+icon = 0
+events = Array[InputEvent]([SubResource("InputEventKey_5ba2r"), SubResource("InputEventJoypadMotion_2p15s")])
+
+[node name="MoveRightActionPrompt" type="TextureRect" parent="."]
+custom_minimum_size = Vector2(100, 100)
+layout_mode = 2
+texture = ExtResource("3_l042n")
+stretch_mode = 5
+script = ExtResource("2_hmylp")
+action = "move_right"
+icon = 0
+events = Array[InputEvent]([SubResource("InputEventKey_vmcvq"), SubResource("InputEventJoypadMotion_auo40")])
+
+[node name="MoveForwardActionPrompt" type="TextureRect" parent="."]
+custom_minimum_size = Vector2(100, 100)
+layout_mode = 2
+texture = ExtResource("4_e345q")
+stretch_mode = 5
+script = ExtResource("2_hmylp")
+action = "move_forward"
+icon = 0
+events = Array[InputEvent]([SubResource("InputEventKey_urkwk"), SubResource("InputEventJoypadMotion_sgel0")])
+
+[node name="MoveBackActionPrompt" type="TextureRect" parent="."]
+custom_minimum_size = Vector2(100, 100)
+layout_mode = 2
+texture = ExtResource("5_vrthb")
+stretch_mode = 5
+script = ExtResource("2_hmylp")
+action = "move_back"
+icon = 0
+events = Array[InputEvent]([SubResource("InputEventKey_3sn2y"), SubResource("InputEventJoypadMotion_kmldo")])
+
+[connection signal="pressed" from="MoveLeftActionPrompt" to="MoveLeftActionPrompt" method="queue_free"]
+[connection signal="tree_exited" from="MoveLeftActionPrompt" to="." method="_on_child_exited_tree"]
+[connection signal="pressed" from="MoveRightActionPrompt" to="MoveRightActionPrompt" method="queue_free"]
+[connection signal="tree_exited" from="MoveRightActionPrompt" to="." method="_on_child_exited_tree"]
+[connection signal="pressed" from="MoveForwardActionPrompt" to="MoveForwardActionPrompt" method="queue_free"]
+[connection signal="tree_exited" from="MoveForwardActionPrompt" to="." method="_on_child_exited_tree"]
+[connection signal="pressed" from="MoveBackActionPrompt" to="MoveBackActionPrompt" method="queue_free"]
+[connection signal="tree_exited" from="MoveBackActionPrompt" to="." method="_on_child_exited_tree"]

+ 14 - 0
godot/component/ui/input_prompts/move/move_prompt.gd

@@ -0,0 +1,14 @@
+extends Control
+## Show basic movements
+
+
+func remove_if_no_more_prompt():
+	print(get_children().size(), " remaining children")
+	if get_children().size() <= 1:
+		# Only label remaining
+		print("Destruction !")
+		queue_free()
+
+
+func _on_child_exited_tree() -> void:
+	remove_if_no_more_prompt()

+ 3 - 90
godot/run/levels/infinite_level.tscn

@@ -1,4 +1,4 @@
-[gd_scene load_steps=40 format=3 uid="uid://7ivipmwaw24t"]
+[gd_scene load_steps=28 format=3 uid="uid://7ivipmwaw24t"]
 
 [ext_resource type="Texture2D" uid="uid://cgwafs6ukpm7y" path="res://component/entity/ground/ground051.jpg" id="1_3ytcp"]
 [ext_resource type="Script" path="res://run/levels/camera_tracker.gd" id="1_qdm47"]
@@ -16,14 +16,10 @@
 [ext_resource type="PackedScene" uid="uid://da7q7i7pqa5pw" path="res://component/entity/primitives/long_bridge.tscn" id="13_06kfi"]
 [ext_resource type="PackedScene" uid="uid://bohus0ptrc77h" path="res://component/entity/buildings/summit_gate/summit_gate.tscn" id="14_ky6m3"]
 [ext_resource type="Texture2D" uid="uid://daewyr44tkkm0" path="res://effect/sky/sky_stk.jpg" id="15_5bqty"]
-[ext_resource type="Texture2D" uid="uid://cah6r1q5x2lte" path="res://addons/input_prompts/icons/generic/left_stick_left.png" id="15_qlnnx"]
-[ext_resource type="Script" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="16_h2at1"]
+[ext_resource type="PackedScene" uid="uid://y4gc5uinkcqj" path="res://component/ui/input_prompts/move/move_container.tscn" id="15_wc547"]
 [ext_resource type="PackedScene" uid="uid://c68bdcjpdm1y2" path="res://component/ui/pause/pause_menu.tscn" id="16_orqqe"]
 [ext_resource type="PackedScene" uid="uid://bmgwhm6ejsden" path="res://component/ui/victory/victory_menu.tscn" id="17_1u7wg"]
-[ext_resource type="Texture2D" uid="uid://c03r3n0nfrjck" path="res://addons/input_prompts/icons/generic/left_stick_right.png" id="17_wvmbu"]
-[ext_resource type="Texture2D" uid="uid://bntsrcd3hjcex" path="res://addons/input_prompts/icons/generic/left_stick_up.png" id="18_anatf"]
 [ext_resource type="Script" path="res://flow/signal_wire/space_limit.gd" id="19_3qyrt"]
-[ext_resource type="Texture2D" uid="uid://dreirjfpqj40a" path="res://addons/input_prompts/icons/generic/left_stick_down.png" id="19_18en6"]
 
 [sub_resource type="BoxShape3D" id="BoxShape3D_ctk0t"]
 size = Vector3(500, 10, 500)
@@ -40,44 +36,6 @@ material = SubResource("StandardMaterial3D_ot7iy")
 size = Vector2(500, 500)
 orientation = 1
 
-[sub_resource type="InputEventKey" id="InputEventKey_5ba2r"]
-device = -1
-physical_keycode = 65
-unicode = 97
-
-[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_2p15s"]
-device = -1
-axis_value = -1.0
-
-[sub_resource type="InputEventKey" id="InputEventKey_vmcvq"]
-device = -1
-physical_keycode = 68
-unicode = 101
-
-[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_auo40"]
-device = -1
-axis_value = 1.0
-
-[sub_resource type="InputEventKey" id="InputEventKey_urkwk"]
-device = -1
-physical_keycode = 87
-unicode = 44
-
-[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_sgel0"]
-device = -1
-axis = 1
-axis_value = -1.0
-
-[sub_resource type="InputEventKey" id="InputEventKey_3sn2y"]
-device = -1
-physical_keycode = 83
-unicode = 111
-
-[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_kmldo"]
-device = -1
-axis = 1
-axis_value = 1.0
-
 [sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_me3fv"]
 panorama = ExtResource("15_5bqty")
 filter = false
@@ -447,53 +405,8 @@ anchor_bottom = 1.0
 grow_horizontal = 2
 grow_vertical = 2
 
-[node name="MoveContainer" type="HBoxContainer" parent="UI/InputPrompts"]
-layout_mode = 2
-
-[node name="MoveLabel" type="Label" parent="UI/InputPrompts/MoveContainer"]
-layout_mode = 2
-theme_override_font_sizes/font_size = 34
-text = "Move"
-
-[node name="MoveLeftActionPrompt" type="TextureRect" parent="UI/InputPrompts/MoveContainer"]
-custom_minimum_size = Vector2(100, 100)
-layout_mode = 2
-texture = ExtResource("15_qlnnx")
-stretch_mode = 5
-script = ExtResource("16_h2at1")
-action = "move_left"
-icon = 0
-events = Array[InputEvent]([SubResource("InputEventKey_5ba2r"), SubResource("InputEventJoypadMotion_2p15s")])
-
-[node name="MoveRightActionPrompt" type="TextureRect" parent="UI/InputPrompts/MoveContainer"]
-custom_minimum_size = Vector2(100, 100)
-layout_mode = 2
-texture = ExtResource("17_wvmbu")
-stretch_mode = 5
-script = ExtResource("16_h2at1")
-action = "move_right"
-icon = 0
-events = Array[InputEvent]([SubResource("InputEventKey_vmcvq"), SubResource("InputEventJoypadMotion_auo40")])
-
-[node name="MoveForwardActionPrompt" type="TextureRect" parent="UI/InputPrompts/MoveContainer"]
-custom_minimum_size = Vector2(100, 100)
-layout_mode = 2
-texture = ExtResource("18_anatf")
-stretch_mode = 5
-script = ExtResource("16_h2at1")
-action = "move_forward"
-icon = 0
-events = Array[InputEvent]([SubResource("InputEventKey_urkwk"), SubResource("InputEventJoypadMotion_sgel0")])
-
-[node name="MoveBackActionPrompt" type="TextureRect" parent="UI/InputPrompts/MoveContainer"]
-custom_minimum_size = Vector2(100, 100)
+[node name="MoveContainer" parent="UI/InputPrompts" instance=ExtResource("15_wc547")]
 layout_mode = 2
-texture = ExtResource("19_18en6")
-stretch_mode = 5
-script = ExtResource("16_h2at1")
-action = "move_back"
-icon = 0
-events = Array[InputEvent]([SubResource("InputEventKey_3sn2y"), SubResource("InputEventJoypadMotion_kmldo")])
 
 [node name="TitleScreen" parent="UI" instance=ExtResource("13_2xijd")]