From 9d730a67306ed6a007db6100d2159fecb86a897e Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Mon, 30 Dec 2024 18:00:38 -0700 Subject: [PATCH] InputPrompt has optional `hold` param --- src/ui/camera/free_camera/free_camera.tscn | 78 +------------------ src/ui/elements/input_prompt/input_prompt.gd | 25 ++++-- .../elements/input_prompt/input_prompt.tscn | 1 + src/ui/shot_hud/shot_hud.tscn | 34 ++++++-- src/world/world.tscn | 30 +++---- 5 files changed, 63 insertions(+), 105 deletions(-) diff --git a/src/ui/camera/free_camera/free_camera.tscn b/src/ui/camera/free_camera/free_camera.tscn index 78c8a99..6db7a28 100644 --- a/src/ui/camera/free_camera/free_camera.tscn +++ b/src/ui/camera/free_camera/free_camera.tscn @@ -1,46 +1,9 @@ -[gd_scene load_steps=7 format=3 uid="uid://dd17ce110sw6p"] +[gd_scene load_steps=3 format=3 uid="uid://dd17ce110sw6p"] [ext_resource type="Script" path="res://src/ui/camera/free_camera/free_camera.gd" id="1_3gm3q"] -[ext_resource type="PackedScene" uid="uid://b47goj32i6sdh" path="res://src/ui/elements/input_prompt/input_prompt.tscn" id="2_6hucw"] [sub_resource type="SphereShape3D" id="SphereShape3D_wmusx"] -[sub_resource type="Animation" id="Animation_vc2i5"] -resource_name = "RESET" -length = 0.001 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:offset_bottom") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0, -0.2, 0, 0.2, 0), -"times": PackedFloat32Array(0) -} - -[sub_resource type="Animation" id="Animation_8gctc"] -resource_name = "show" -length = 0.4 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:offset_bottom") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0, 0), -"points": PackedFloat32Array(0, -0.2, 0, 0.2, 0, 55, -0.2, 0, 0.2, 0), -"times": PackedFloat32Array(0, 0.4) -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_fk25i"] -_data = { -"RESET": SubResource("Animation_vc2i5"), -"show": SubResource("Animation_8gctc") -} - [node name="FreeCamera" type="CharacterBody3D"] process_mode = 3 collision_layer = 0 @@ -53,42 +16,3 @@ shape = SubResource("SphereShape3D_wmusx") [node name="Camera3D" type="Camera3D" parent="."] current = true far = 8192.0 - -[node name="FreeCamHUD" type="Control" parent="."] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="UtilityPrompts" type="MarginContainer" parent="FreeCamHUD"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.5 -anchor_right = 0.5 -grow_horizontal = 2 -grow_vertical = 0 -theme_override_constants/margin_top = 16 -theme_override_constants/margin_right = 16 - -[node name="HBoxContainer" type="HBoxContainer" parent="FreeCamHUD/UtilityPrompts"] -layout_mode = 2 -theme_override_constants/separation = 64 - -[node name="InputPrompt" parent="FreeCamHUD/UtilityPrompts/HBoxContainer" instance=ExtResource("2_6hucw")] -layout_mode = 2 -text = "❓ - ACTION_camera_sprint" -action = &"camera_sprint" - -[node name="InputPrompt2" parent="FreeCamHUD/UtilityPrompts/HBoxContainer" instance=ExtResource("2_6hucw")] -layout_mode = 2 -text = "❓ - ACTION_camera_cancel" -action = &"camera_cancel" - -[node name="AimEquipPromptAnimation" type="AnimationPlayer" parent="FreeCamHUD/UtilityPrompts"] -unique_name_in_owner = true -libraries = { -"": SubResource("AnimationLibrary_fk25i") -} -autoplay = "show" diff --git a/src/ui/elements/input_prompt/input_prompt.gd b/src/ui/elements/input_prompt/input_prompt.gd index 9243d03..358e827 100644 --- a/src/ui/elements/input_prompt/input_prompt.gd +++ b/src/ui/elements/input_prompt/input_prompt.gd @@ -3,14 +3,22 @@ extends Label ## A prompt with the input symbol bound to the given action. const PROMPT_FORMAT := "{0} - {1}" +const HOLD_FORMAT := "{0} {1}" const UNKNOWN_LABEL_SYM := "[unknown]" +const ACTION_HOLD_KEY := "ACTION_HOLD_MODIFIER" + @export var action: StringName: set(value): action = value _update() +@export var hold := false: + set(value): + hold = value + _update() + @export var show_name := true: set(value): show_name = value @@ -37,12 +45,19 @@ func _update() -> void: if not input_symbol: input_symbol = str(PromptMap.UNKNOWN_INPUT_SYMBOL) + + if hold: + input_symbol = HOLD_FORMAT.format([input_symbol, tr(ACTION_HOLD_KEY)]) + if show_name: - text = PROMPT_FORMAT.format( - [ - input_symbol if input_symbol else str(PromptMap.UNKNOWN_INPUT_SYMBOL), - loc_action if loc_action else str(action) - ] + text = ( + PROMPT_FORMAT + . format( + [ + input_symbol, + loc_action if loc_action else str(action), + ] + ) ) else: text = input_symbol diff --git a/src/ui/elements/input_prompt/input_prompt.tscn b/src/ui/elements/input_prompt/input_prompt.tscn index 4e1c191..b7d4945 100644 --- a/src/ui/elements/input_prompt/input_prompt.tscn +++ b/src/ui/elements/input_prompt/input_prompt.tscn @@ -11,3 +11,4 @@ grow_vertical = 2 theme_type_variation = &"InputPrompt" text = "❓ - ACTION_" script = ExtResource("1_qq6w5") +hold = null diff --git a/src/ui/shot_hud/shot_hud.tscn b/src/ui/shot_hud/shot_hud.tscn index f1f7ebb..5ee4530 100644 --- a/src/ui/shot_hud/shot_hud.tscn +++ b/src/ui/shot_hud/shot_hud.tscn @@ -846,6 +846,7 @@ layout_mode = 2 text = "❓ - ACTION_shot_reset" uppercase = true action = &"shot_reset" +hold = false [node name="Glint" type="TextureRect" parent="Prompts/ResetPrompt/ResetInputPrompt"] layout_mode = 1 @@ -906,6 +907,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"club_next" +hold = false show_name = false [node name="InputPrompt2" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeClubPrompt/ClubControlFader" instance=ExtResource("14_ik4gg")] @@ -920,6 +922,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"club_previous" +hold = false show_name = false [node name="Label" type="Label" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeClubPrompt"] @@ -956,6 +959,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"ball_next" +hold = false show_name = false [node name="InputPrompt2" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeBallPrompt/BallControlFader" instance=ExtResource("14_ik4gg")] @@ -970,6 +974,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"ball_previous" +hold = false show_name = false [node name="Label" type="Label" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeBallPrompt"] @@ -1010,6 +1015,7 @@ theme_override_constants/separation = 64 layout_mode = 2 text = "❓ - ACTION_shot_accept" action = &"shot_accept" +hold = false [node name="FreeCameraPrompt" type="HBoxContainer" parent="Prompts/AimPrompts/HBoxContainer"] layout_mode = 2 @@ -1035,6 +1041,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_forward" +hold = false show_name = false [node name="InputPrompt2" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")] @@ -1049,6 +1056,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_left" +hold = false show_name = false [node name="InputPrompt3" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")] @@ -1063,6 +1071,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_back" +hold = false show_name = false [node name="InputPrompt4" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")] @@ -1077,6 +1086,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_right" +hold = false show_name = false [node name="Label" type="Label" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt"] @@ -1113,6 +1123,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"shot_zoom_in" +hold = false show_name = false [node name="InputPrompt2" parent="Prompts/AimPrompts/HBoxContainer/ZoomPrompt/ZoomControlFader" instance=ExtResource("14_ik4gg")] @@ -1127,6 +1138,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"shot_zoom_out" +hold = false show_name = false [node name="Label" type="Label" parent="Prompts/AimPrompts/HBoxContainer/ZoomPrompt"] @@ -1178,15 +1190,11 @@ theme_type_variation = &"InputPromptContainer" [node name="InputPrompt" parent="Prompts/PowerPrompt/HBoxContainer" instance=ExtResource("14_ik4gg")] layout_mode = 2 -text = "❓" +text = "❓ ACTION_HOLD_MODIFIER" action = &"shot_accept" +hold = true show_name = false -[node name="Label" type="Label" parent="Prompts/PowerPrompt/HBoxContainer"] -layout_mode = 2 -theme_type_variation = &"InputPrompt" -text = "ACTION_HOLD_MODIFIER" - [node name="Label2" type="Label" parent="Prompts/PowerPrompt/HBoxContainer"] layout_mode = 2 theme_type_variation = &"InputPrompt" @@ -1224,6 +1232,7 @@ theme_type_variation = &"InputPromptContainer" layout_mode = 2 text = "❓" action = &"shot_accept" +hold = false show_name = false [node name="Label2" type="Label" parent="Prompts/CurvePrompt/HBoxContainer"] @@ -1257,8 +1266,9 @@ theme_override_constants/margin_bottom = 16 [node name="InputPrompt" parent="Prompts/ShotPrompt" instance=ExtResource("14_ik4gg")] layout_mode = 2 -text = "❓ - ACTION_fast_forward" +text = "❓ ACTION_HOLD_MODIFIER - ACTION_fast_forward" action = &"fast_forward" +hold = true [node name="ShotPromptAnimation" type="AnimationPlayer" parent="Prompts/ShotPrompt"] unique_name_in_owner = true @@ -1282,13 +1292,15 @@ theme_override_constants/separation = 64 [node name="InputPrompt" parent="Prompts/FreeCamUtilPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")] layout_mode = 2 -text = "❓ - ACTION_camera_sprint" +text = "❓ ACTION_HOLD_MODIFIER - ACTION_camera_sprint" action = &"camera_sprint" +hold = true [node name="InputPrompt2" parent="Prompts/FreeCamUtilPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")] layout_mode = 2 text = "❓ - ACTION_camera_cancel" action = &"camera_cancel" +hold = false [node name="FreeCamUtilPromptAnimation" type="AnimationPlayer" parent="Prompts/FreeCamUtilPrompts"] unique_name_in_owner = true @@ -1339,6 +1351,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_forward" +hold = false show_name = false [node name="InputPrompt2" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")] @@ -1353,6 +1366,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_left" +hold = false show_name = false [node name="InputPrompt3" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")] @@ -1367,6 +1381,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_back" +hold = false show_name = false [node name="InputPrompt4" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")] @@ -1381,6 +1396,7 @@ offset_bottom = 19.5 grow_horizontal = 0 text = "❓" action = &"camera_right" +hold = false show_name = false [node name="Label" type="Label" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt"] @@ -1397,11 +1413,13 @@ text = "ACTION_FREE_CAM_MOVE" layout_mode = 2 text = "❓ - ACTION_camera_up" action = &"camera_up" +hold = false [node name="InputPrompt2" parent="Prompts/FreeCamMotionPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")] layout_mode = 2 text = "❓ - ACTION_camera_down" action = &"camera_down" +hold = false [node name="FreeCamMotionPromptAnimation" type="AnimationPlayer" parent="Prompts/FreeCamMotionPrompts"] unique_name_in_owner = true diff --git a/src/world/world.tscn b/src/world/world.tscn index 162e5eb..07081d4 100644 --- a/src/world/world.tscn +++ b/src/world/world.tscn @@ -28,6 +28,21 @@ _balls = { script = ExtResource("5_h6mje") players = Array[ExtResource("2_e743i")]([ExtResource("3_pyw81"), SubResource("Resource_mbhdy")]) +[sub_resource type="Animation" id="Animation_6350f"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} + [sub_resource type="Animation" id="Animation_xfpfm"] resource_name = "blink" loop_mode = 1 @@ -44,21 +59,6 @@ tracks/0/keys = { "values": [true, false] } -[sub_resource type="Animation" id="Animation_6350f"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [true] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_7gn8c"] _data = { "RESET": SubResource("Animation_6350f"),