Skip to content

Commit

Permalink
Merge pull request #708 from voylin/Fix_GUI_Input_Mapping_Demo_4.0-dev
Browse files Browse the repository at this point in the history
Fixed Script Errors for GUI Input Mapping Demo - 4.0-dev
  • Loading branch information
aaronfranke authored Apr 3, 2022
2 parents e5ceb2d + 85e7aee commit 6ac2aee
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 56 deletions.
10 changes: 5 additions & 5 deletions gui/input_mapping/ActionRemapButton.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ func _ready():
display_current_key()


func _toggled(button_pressed):
set_process_unhandled_key_input(button_pressed)
if button_pressed:
func _toggled(is_button_pressed):
set_process_unhandled_key_input(is_button_pressed)
if is_button_pressed:
text = "... Key"
release_focus()
else:
Expand All @@ -21,7 +21,7 @@ func _unhandled_key_input(event):
# Note that you can use the _input callback instead, especially if
# you want to work with gamepads.
remap_action_to(event)
pressed = false
button_pressed = false


func remap_action_to(event):
Expand All @@ -31,5 +31,5 @@ func remap_action_to(event):


func display_current_key():
var current_key = InputMap.get_action_list(action)[0].as_text()
var current_key = InputMap.action_get_events(action)[0].as_text()
text = "%s Key" % current_key
34 changes: 7 additions & 27 deletions gui/input_mapping/InputRemapMenu.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=3 uid="uid://bjdgwg23lm1d4"]

[ext_resource path="res://ActionRemapButton.tscn" type="PackedScene" id=1]

[sub_resource type="ButtonGroup" id=1]
[ext_resource type="PackedScene" path="res://ActionRemapButton.tscn" id="1"]

[node name="InputRemapMenu" type="Control"]
anchor_right = 1.0
Expand All @@ -13,8 +11,6 @@ anchor_right = 1.0
offset_top = 24.0
offset_bottom = 55.0
text = "Click on a button to reassign its action key."
align = 1
autowrap = true
__meta__ = {
"_edit_use_anchors_": false
}
Expand All @@ -29,7 +25,6 @@ offset_top = -144.0
offset_right = 160.0
offset_bottom = 144.0
disabled = true
group = SubResource( 1 )
flat = true
__meta__ = {
"_edit_use_anchors_": false
Expand Down Expand Up @@ -60,16 +55,13 @@ offset_bottom = 52.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Move Left"
align = 1
valign = 1

[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow" instance=ExtResource( 1 )]
[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow" instance=ExtResource( "1" )]
offset_left = 162.0
offset_right = 320.0
offset_bottom = 52.0
size_flags_horizontal = 3
size_flags_vertical = 3
group = SubResource( 1 )
action = "move_left"

[node name="ActionRemapRow2" type="HBoxContainer" parent="RemapButtonGroup/ActionsList"]
Expand All @@ -85,16 +77,13 @@ offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Move Right"
align = 1
valign = 1

[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow2" instance=ExtResource( 1 )]
[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow2" instance=ExtResource( "1" )]
offset_left = 162.0
offset_right = 320.0
offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
group = SubResource( 1 )
action = "move_right"

[node name="ActionRemapRow3" type="HBoxContainer" parent="RemapButtonGroup/ActionsList"]
Expand All @@ -110,16 +99,13 @@ offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Look Up"
align = 1
valign = 1

[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow3" instance=ExtResource( 1 )]
[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow3" instance=ExtResource( "1" )]
offset_left = 162.0
offset_right = 320.0
offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
group = SubResource( 1 )
action = "look_up"

[node name="ActionRemapRow4" type="HBoxContainer" parent="RemapButtonGroup/ActionsList"]
Expand All @@ -135,16 +121,13 @@ offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Crouch"
align = 1
valign = 1

[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow4" instance=ExtResource( 1 )]
[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow4" instance=ExtResource( "1" )]
offset_left = 162.0
offset_right = 320.0
offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
group = SubResource( 1 )
action = "crouch"

[node name="ActionRemapRow5" type="HBoxContainer" parent="RemapButtonGroup/ActionsList"]
Expand All @@ -160,14 +143,11 @@ offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Dash"
align = 1
valign = 1

[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow5" instance=ExtResource( 1 )]
[node name="RemapButton" parent="RemapButtonGroup/ActionsList/ActionRemapRow5" instance=ExtResource( "1" )]
offset_left = 162.0
offset_right = 320.0
offset_bottom = 53.0
size_flags_horizontal = 3
size_flags_vertical = 3
group = SubResource( 1 )
action = "dash"
2 changes: 1 addition & 1 deletion gui/input_mapping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A demo showing how to build an input key remapping screen.

Language: GDScript

Renderer: GLES 2
Renderer: Vulkan Mobile

Check out this demo on the asset library: https://godotengine.org/asset-library/asset/131

Expand Down
28 changes: 13 additions & 15 deletions gui/input_mapping/icon.png.import
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
[remap]

importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://bn2conid84pie"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
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/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1
14 changes: 6 additions & 8 deletions gui/input_mapping/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4
config_version=5

[application]

Expand All @@ -18,13 +18,13 @@ config/description="A demo showing how to build an input key remapping screen.
after the project is restarted."
run/main_scene="res://InputRemapMenu.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")

[display]

window/size/width=640
window/size/height=480
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/size/viewport_width=640
window/size/viewport_height=480
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"

[gdnative]
Expand Down Expand Up @@ -61,6 +61,4 @@ dash={

[rendering]

quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
vulkan/rendering/back_end=1

0 comments on commit 6ac2aee

Please sign in to comment.