gd: added input addon

This commit is contained in:
2025-05-27 19:20:46 +02:00
parent d8a1604af9
commit c8d8c7ec25
683 changed files with 21608 additions and 2 deletions

View File

@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://cwtdxy3gy7kud"]
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_jeypp"]
[resource]
script = ExtResource("1_jeypp")
name = &""
action_value_type = 0
block_lower_priority_actions = true
emit_as_godot_actions = false
is_remappable = false
display_name = ""
display_category = ""

View File

@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://bcumfh8j6k1ln"]
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_25sbb"]
[resource]
script = ExtResource("1_25sbb")
name = &""
action_value_type = 2
block_lower_priority_actions = true
emit_as_godot_actions = false
is_remappable = false
display_name = ""
display_category = ""

View File

@ -0,0 +1,80 @@
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=22 format=3 uid="uid://b4tn11iq7uvr7"]
[ext_resource type="Resource" uid="uid://bcumfh8j6k1ln" path="res://guide_examples/virtual_cursor/mapping_contexts/actions/cursor_2d.tres" id="1_0amnw"]
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="1_0ixy4"]
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="1_hs8l5"]
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_joy_axis_2d.gd" id="2_6ps54"]
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_deadzone.gd" id="3_jknka"]
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_virtual_cursor.gd" id="3_smvwl"]
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_canvas_coordinates.gd" id="4_w4o86"]
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="5_ucwra"]
[ext_resource type="Resource" uid="uid://cwtdxy3gy7kud" path="res://guide_examples/virtual_cursor/mapping_contexts/actions/click.tres" id="8_2fjde"]
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_joy_button.gd" id="9_15a8y"]
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_pressed.gd" id="10_caax3"]
[sub_resource type="Resource" id="Resource_51lnp"]
script = ExtResource("2_6ps54")
x = 0
y = 1
joy_index = 0
[sub_resource type="Resource" id="Resource_vtltt"]
script = ExtResource("3_jknka")
lower_threshold = 0.2
upper_threshold = 1.0
[sub_resource type="Resource" id="Resource_tn5ov"]
script = ExtResource("3_smvwl")
initial_position = Vector2(0.5, 0.5)
speed = Vector3(1, 1, 1)
screen_scale = 1
apply_delta_time = true
scale = Vector3(1, 1, 1)
[sub_resource type="Resource" id="Resource_r6xcs"]
script = ExtResource("4_w4o86")
relative_input = false
[sub_resource type="Resource" id="Resource_jede7"]
script = ExtResource("5_ucwra")
override_action_settings = false
is_remappable = false
display_name = ""
display_category = ""
input = SubResource("Resource_51lnp")
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_vtltt"), SubResource("Resource_tn5ov"), SubResource("Resource_r6xcs")])
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
[sub_resource type="Resource" id="Resource_phyr3"]
script = ExtResource("1_0ixy4")
action = ExtResource("1_0amnw")
input_mappings = Array[ExtResource("5_ucwra")]([SubResource("Resource_jede7")])
[sub_resource type="Resource" id="Resource_5fidk"]
script = ExtResource("9_15a8y")
button = 0
joy_index = 0
[sub_resource type="Resource" id="Resource_m13js"]
script = ExtResource("10_caax3")
actuation_threshold = 0.5
[sub_resource type="Resource" id="Resource_mnbnv"]
script = ExtResource("5_ucwra")
override_action_settings = false
is_remappable = false
display_name = ""
display_category = ""
input = SubResource("Resource_5fidk")
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_m13js")])
[sub_resource type="Resource" id="Resource_7601p"]
script = ExtResource("1_0ixy4")
action = ExtResource("8_2fjde")
input_mappings = Array[ExtResource("5_ucwra")]([SubResource("Resource_mnbnv")])
[resource]
script = ExtResource("1_hs8l5")
display_name = ""
mappings = Array[ExtResource("1_0ixy4")]([SubResource("Resource_phyr3"), SubResource("Resource_7601p")])

View File

@ -0,0 +1,15 @@
extends Area2D
var _is_spinning:bool = false
func spin():
if _is_spinning:
return
_is_spinning = true
var tween := create_tween()
tween.tween_property(self, "rotation_degrees", 360, 0.5)
await tween.finished
rotation_degrees = 0
_is_spinning = false

View File

@ -0,0 +1 @@
uid://dghhpx6mxb4lr

View File

@ -0,0 +1,17 @@
[gd_scene load_steps=4 format=3 uid="uid://ca51sup6v0qr1"]
[ext_resource type="Script" path="res://guide_examples/virtual_cursor/pointable/pointable.gd" id="1_ujxlw"]
[ext_resource type="Texture2D" uid="uid://byjxtsekdl8t2" path="res://guide_examples/shared/godot_logo.svg" id="2_i12oa"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_cccqq"]
size = Vector2(128, 128)
[node name="Pointable" type="Area2D"]
monitoring = false
script = ExtResource("1_ujxlw")
[node name="GodotLogo" type="Sprite2D" parent="."]
texture = ExtResource("2_i12oa")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_cccqq")

View File

@ -0,0 +1,17 @@
extends Area2D
@export var cursor_2d:GUIDEAction
@export var click:GUIDEAction
func _ready():
click.triggered.connect(_click)
func _process(delta):
global_position = cursor_2d.value_axis_2d
func _click():
for clickable in get_overlapping_areas():
if clickable.has_method("spin"):
clickable.spin()

View File

@ -0,0 +1 @@
uid://cyhgr4oiher4l

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
<g transform="matrix(1.25048,1.25048,-0.676025,0.676025,2.92124,-72.712)">
<path d="M64.746,66.841L64.746,81.618L29.548,55.905L64.746,30.192L64.746,44.969L117.949,44.969L117.949,66.841L64.746,66.841Z" style="fill:url(#_Linear1);stroke:black;stroke-width:1.3px;"/>
</g>
<defs>
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(88.4011,0,0,51.4261,29.5478,55.905)"><stop offset="0" style="stop-color:white;stop-opacity:1"/><stop offset="0.4" style="stop-color:rgb(242,242,242);stop-opacity:1"/><stop offset="0.85" style="stop-color:rgb(156,156,156);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(145,145,145);stop-opacity:1"/></linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ntkhw87eedc0"
path="res://.godot/imported/pointer.svg-2068835178847b731dd1d6754048fd27.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://guide_examples/virtual_cursor/pointer.svg"
dest_files=["res://.godot/imported/pointer.svg-2068835178847b731dd1d6754048fd27.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@ -0,0 +1,7 @@
extends Node2D
@export var mapping_context:GUIDEMappingContext
func _ready():
GUIDE.enable_mapping_context(mapping_context)

View File

@ -0,0 +1 @@
uid://dvv04npvyv3mh

View File

@ -0,0 +1,80 @@
[gd_scene load_steps=12 format=3 uid="uid://b1f0bnaomla7u"]
[ext_resource type="Script" path="res://guide_examples/virtual_cursor/virtual_cursor.gd" id="1_g0bre"]
[ext_resource type="Resource" uid="uid://b4tn11iq7uvr7" path="res://guide_examples/virtual_cursor/mapping_contexts/virtual_cursor.tres" id="2_4xju7"]
[ext_resource type="Texture2D" uid="uid://ntkhw87eedc0" path="res://guide_examples/virtual_cursor/pointer.svg" id="2_mxnae"]
[ext_resource type="Script" path="res://guide_examples/virtual_cursor/pointer.gd" id="3_dw1p5"]
[ext_resource type="PackedScene" uid="uid://ca51sup6v0qr1" path="res://guide_examples/virtual_cursor/pointable/pointable.tscn" id="3_uy61q"]
[ext_resource type="Resource" uid="uid://bcumfh8j6k1ln" path="res://guide_examples/virtual_cursor/mapping_contexts/actions/cursor_2d.tres" id="5_tj3fv"]
[ext_resource type="Resource" uid="uid://cwtdxy3gy7kud" path="res://guide_examples/virtual_cursor/mapping_contexts/actions/click.tres" id="6_1ffq2"]
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="6_hfxka"]
[ext_resource type="Theme" uid="uid://dot0gi1yoqmrl" path="res://guide_examples/shared/ui_theme.tres" id="7_bh7yl"]
[ext_resource type="Script" path="res://guide_examples/shared/instructions_label.gd" id="7_udsq5"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ltt1b"]
radius = 32.95
[node name="VirtualCursor" type="Node2D"]
script = ExtResource("1_g0bre")
mapping_context = ExtResource("2_4xju7")
[node name="Pointable" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(358, 282)
[node name="Pointable2" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(915, 209)
[node name="Pointable3" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(1177, 621)
[node name="Pointable4" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(338, 859)
[node name="Pointable5" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(1476, 274)
[node name="Pointable6" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(791, 808)
[node name="Pointable7" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(605, 499)
[node name="Pointable8" parent="." instance=ExtResource("3_uy61q")]
position = Vector2(1515, 845)
[node name="Pointer" type="Area2D" parent="."]
position = Vector2(813, 485)
script = ExtResource("3_dw1p5")
cursor_2d = ExtResource("5_tj3fv")
click = ExtResource("6_1ffq2")
[node name="PointerVisual" type="Sprite2D" parent="Pointer"]
texture = ExtResource("2_mxnae")
centered = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Pointer"]
shape = SubResource("CircleShape2D_ltt1b")
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="GuideDebugger" parent="CanvasLayer" instance=ExtResource("6_hfxka")]
theme = ExtResource("7_bh7yl")
[node name="UILayer" type="CanvasLayer" parent="."]
[node name="RichTextLabel" type="RichTextLabel" parent="UILayer"]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -104.0
offset_top = 56.0
offset_right = -64.0
offset_bottom = 96.0
grow_horizontal = 0
theme = ExtResource("7_bh7yl")
script = ExtResource("7_udsq5")
instructions_text = "This shows how to use a controller stick to control a virtual cursor.
%s to move the the cursor
%s to \"click\""
actions = Array[Resource("res://addons/guide/guide_action.gd")]([ExtResource("5_tj3fv"), ExtResource("6_1ffq2")])