InputPrompt has optional `hold` param

This commit is contained in:
Rob Kelly 2024-12-30 18:00:38 -07:00
parent 495e29c487
commit 9d730a6730
5 changed files with 63 additions and 105 deletions

View File

@ -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="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="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"] [node name="FreeCamera" type="CharacterBody3D"]
process_mode = 3 process_mode = 3
collision_layer = 0 collision_layer = 0
@ -53,42 +16,3 @@ shape = SubResource("SphereShape3D_wmusx")
[node name="Camera3D" type="Camera3D" parent="."] [node name="Camera3D" type="Camera3D" parent="."]
current = true current = true
far = 8192.0 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"

View File

@ -3,14 +3,22 @@ extends Label
## A prompt with the input symbol bound to the given action. ## A prompt with the input symbol bound to the given action.
const PROMPT_FORMAT := "{0} - {1}" const PROMPT_FORMAT := "{0} - {1}"
const HOLD_FORMAT := "{0} {1}"
const UNKNOWN_LABEL_SYM := "[unknown]" const UNKNOWN_LABEL_SYM := "[unknown]"
const ACTION_HOLD_KEY := "ACTION_HOLD_MODIFIER"
@export var action: StringName: @export var action: StringName:
set(value): set(value):
action = value action = value
_update() _update()
@export var hold := false:
set(value):
hold = value
_update()
@export var show_name := true: @export var show_name := true:
set(value): set(value):
show_name = value show_name = value
@ -37,12 +45,19 @@ func _update() -> void:
if not input_symbol: if not input_symbol:
input_symbol = str(PromptMap.UNKNOWN_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: if show_name:
text = PROMPT_FORMAT.format( text = (
[ PROMPT_FORMAT
input_symbol if input_symbol else str(PromptMap.UNKNOWN_INPUT_SYMBOL), . format(
loc_action if loc_action else str(action) [
] input_symbol,
loc_action if loc_action else str(action),
]
)
) )
else: else:
text = input_symbol text = input_symbol

View File

@ -11,3 +11,4 @@ grow_vertical = 2
theme_type_variation = &"InputPrompt" theme_type_variation = &"InputPrompt"
text = "❓ - ACTION_" text = "❓ - ACTION_"
script = ExtResource("1_qq6w5") script = ExtResource("1_qq6w5")
hold = null

View File

@ -846,6 +846,7 @@ layout_mode = 2
text = "❓ - ACTION_shot_reset" text = "❓ - ACTION_shot_reset"
uppercase = true uppercase = true
action = &"shot_reset" action = &"shot_reset"
hold = false
[node name="Glint" type="TextureRect" parent="Prompts/ResetPrompt/ResetInputPrompt"] [node name="Glint" type="TextureRect" parent="Prompts/ResetPrompt/ResetInputPrompt"]
layout_mode = 1 layout_mode = 1
@ -906,6 +907,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"club_next" action = &"club_next"
hold = false
show_name = false show_name = false
[node name="InputPrompt2" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeClubPrompt/ClubControlFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt2" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeClubPrompt/ClubControlFader" instance=ExtResource("14_ik4gg")]
@ -920,6 +922,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"club_previous" action = &"club_previous"
hold = false
show_name = false show_name = false
[node name="Label" type="Label" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeClubPrompt"] [node name="Label" type="Label" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeClubPrompt"]
@ -956,6 +959,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"ball_next" action = &"ball_next"
hold = false
show_name = false show_name = false
[node name="InputPrompt2" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeBallPrompt/BallControlFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt2" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeBallPrompt/BallControlFader" instance=ExtResource("14_ik4gg")]
@ -970,6 +974,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"ball_previous" action = &"ball_previous"
hold = false
show_name = false show_name = false
[node name="Label" type="Label" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeBallPrompt"] [node name="Label" type="Label" parent="Prompts/AimEquipPrompts/HBoxContainer/ChangeBallPrompt"]
@ -1010,6 +1015,7 @@ theme_override_constants/separation = 64
layout_mode = 2 layout_mode = 2
text = "❓ - ACTION_shot_accept" text = "❓ - ACTION_shot_accept"
action = &"shot_accept" action = &"shot_accept"
hold = false
[node name="FreeCameraPrompt" type="HBoxContainer" parent="Prompts/AimPrompts/HBoxContainer"] [node name="FreeCameraPrompt" type="HBoxContainer" parent="Prompts/AimPrompts/HBoxContainer"]
layout_mode = 2 layout_mode = 2
@ -1035,6 +1041,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_forward" action = &"camera_forward"
hold = false
show_name = false show_name = false
[node name="InputPrompt2" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt2" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")]
@ -1049,6 +1056,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_left" action = &"camera_left"
hold = false
show_name = false show_name = false
[node name="InputPrompt3" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt3" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")]
@ -1063,6 +1071,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_back" action = &"camera_back"
hold = false
show_name = false show_name = false
[node name="InputPrompt4" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt4" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt/FreeCamControlFader" instance=ExtResource("14_ik4gg")]
@ -1077,6 +1086,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_right" action = &"camera_right"
hold = false
show_name = false show_name = false
[node name="Label" type="Label" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt"] [node name="Label" type="Label" parent="Prompts/AimPrompts/HBoxContainer/FreeCameraPrompt"]
@ -1113,6 +1123,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"shot_zoom_in" action = &"shot_zoom_in"
hold = false
show_name = false show_name = false
[node name="InputPrompt2" parent="Prompts/AimPrompts/HBoxContainer/ZoomPrompt/ZoomControlFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt2" parent="Prompts/AimPrompts/HBoxContainer/ZoomPrompt/ZoomControlFader" instance=ExtResource("14_ik4gg")]
@ -1127,6 +1138,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"shot_zoom_out" action = &"shot_zoom_out"
hold = false
show_name = false show_name = false
[node name="Label" type="Label" parent="Prompts/AimPrompts/HBoxContainer/ZoomPrompt"] [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")] [node name="InputPrompt" parent="Prompts/PowerPrompt/HBoxContainer" instance=ExtResource("14_ik4gg")]
layout_mode = 2 layout_mode = 2
text = "❓" text = "❓ ACTION_HOLD_MODIFIER"
action = &"shot_accept" action = &"shot_accept"
hold = true
show_name = false 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"] [node name="Label2" type="Label" parent="Prompts/PowerPrompt/HBoxContainer"]
layout_mode = 2 layout_mode = 2
theme_type_variation = &"InputPrompt" theme_type_variation = &"InputPrompt"
@ -1224,6 +1232,7 @@ theme_type_variation = &"InputPromptContainer"
layout_mode = 2 layout_mode = 2
text = "❓" text = "❓"
action = &"shot_accept" action = &"shot_accept"
hold = false
show_name = false show_name = false
[node name="Label2" type="Label" parent="Prompts/CurvePrompt/HBoxContainer"] [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")] [node name="InputPrompt" parent="Prompts/ShotPrompt" instance=ExtResource("14_ik4gg")]
layout_mode = 2 layout_mode = 2
text = "❓ - ACTION_fast_forward" text = "❓ ACTION_HOLD_MODIFIER - ACTION_fast_forward"
action = &"fast_forward" action = &"fast_forward"
hold = true
[node name="ShotPromptAnimation" type="AnimationPlayer" parent="Prompts/ShotPrompt"] [node name="ShotPromptAnimation" type="AnimationPlayer" parent="Prompts/ShotPrompt"]
unique_name_in_owner = true 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")] [node name="InputPrompt" parent="Prompts/FreeCamUtilPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")]
layout_mode = 2 layout_mode = 2
text = "❓ - ACTION_camera_sprint" text = "❓ ACTION_HOLD_MODIFIER - ACTION_camera_sprint"
action = &"camera_sprint" action = &"camera_sprint"
hold = true
[node name="InputPrompt2" parent="Prompts/FreeCamUtilPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")] [node name="InputPrompt2" parent="Prompts/FreeCamUtilPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")]
layout_mode = 2 layout_mode = 2
text = "❓ - ACTION_camera_cancel" text = "❓ - ACTION_camera_cancel"
action = &"camera_cancel" action = &"camera_cancel"
hold = false
[node name="FreeCamUtilPromptAnimation" type="AnimationPlayer" parent="Prompts/FreeCamUtilPrompts"] [node name="FreeCamUtilPromptAnimation" type="AnimationPlayer" parent="Prompts/FreeCamUtilPrompts"]
unique_name_in_owner = true unique_name_in_owner = true
@ -1339,6 +1351,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_forward" action = &"camera_forward"
hold = false
show_name = false show_name = false
[node name="InputPrompt2" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt2" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")]
@ -1353,6 +1366,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_left" action = &"camera_left"
hold = false
show_name = false show_name = false
[node name="InputPrompt3" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt3" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")]
@ -1367,6 +1381,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_back" action = &"camera_back"
hold = false
show_name = false show_name = false
[node name="InputPrompt4" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")] [node name="InputPrompt4" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt/WASDFader" instance=ExtResource("14_ik4gg")]
@ -1381,6 +1396,7 @@ offset_bottom = 19.5
grow_horizontal = 0 grow_horizontal = 0
text = "❓" text = "❓"
action = &"camera_right" action = &"camera_right"
hold = false
show_name = false show_name = false
[node name="Label" type="Label" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt"] [node name="Label" type="Label" parent="Prompts/FreeCamMotionPrompts/HBoxContainer/WASDPrompt"]
@ -1397,11 +1413,13 @@ text = "ACTION_FREE_CAM_MOVE"
layout_mode = 2 layout_mode = 2
text = "❓ - ACTION_camera_up" text = "❓ - ACTION_camera_up"
action = &"camera_up" action = &"camera_up"
hold = false
[node name="InputPrompt2" parent="Prompts/FreeCamMotionPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")] [node name="InputPrompt2" parent="Prompts/FreeCamMotionPrompts/HBoxContainer" instance=ExtResource("14_ik4gg")]
layout_mode = 2 layout_mode = 2
text = "❓ - ACTION_camera_down" text = "❓ - ACTION_camera_down"
action = &"camera_down" action = &"camera_down"
hold = false
[node name="FreeCamMotionPromptAnimation" type="AnimationPlayer" parent="Prompts/FreeCamMotionPrompts"] [node name="FreeCamMotionPromptAnimation" type="AnimationPlayer" parent="Prompts/FreeCamMotionPrompts"]
unique_name_in_owner = true unique_name_in_owner = true

View File

@ -28,6 +28,21 @@ _balls = {
script = ExtResource("5_h6mje") script = ExtResource("5_h6mje")
players = Array[ExtResource("2_e743i")]([ExtResource("3_pyw81"), SubResource("Resource_mbhdy")]) 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"] [sub_resource type="Animation" id="Animation_xfpfm"]
resource_name = "blink" resource_name = "blink"
loop_mode = 1 loop_mode = 1
@ -44,21 +59,6 @@ tracks/0/keys = {
"values": [true, false] "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"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_7gn8c"]
_data = { _data = {
"RESET": SubResource("Animation_6350f"), "RESET": SubResource("Animation_6350f"),