Update controlsUI
This commit is contained in:
parent
1cec50f4f6
commit
8cc69e99da
@ -74,7 +74,7 @@ func _unhandled_input(event):
|
|||||||
if event.is_action_pressed("pause"):
|
if event.is_action_pressed("pause"):
|
||||||
if playing:
|
if playing:
|
||||||
pause($controls_ui)
|
pause($controls_ui)
|
||||||
elif $controls_ui.enable_resume:
|
else:
|
||||||
resume()
|
resume()
|
||||||
if event.is_action_pressed("toggle_fullscreen"):
|
if event.is_action_pressed("toggle_fullscreen"):
|
||||||
OS.window_fullscreen = not OS.window_fullscreen
|
OS.window_fullscreen = not OS.window_fullscreen
|
||||||
|
@ -229,7 +229,7 @@ extra_spacing_bottom = 5
|
|||||||
font_data = ExtResource( 12 )
|
font_data = ExtResource( 12 )
|
||||||
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
|
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
|
||||||
|
|
||||||
[node name="Main" type="WorldEnvironment" index="0"]
|
[node name="Main" type="WorldEnvironment"]
|
||||||
|
|
||||||
environment = SubResource( 2 )
|
environment = SubResource( 2 )
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
@ -1,17 +1,5 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
# Note for the reader:
|
|
||||||
#
|
|
||||||
# This demo conveniently uses the same names for actions and for the container nodes
|
|
||||||
# that hold each remapping button. This allow to get back to the button based simply
|
|
||||||
# on the name of the corresponding action, but it might not be so simple in your project.
|
|
||||||
#
|
|
||||||
# A better approach for large-scale input remapping might be to do the connections between
|
|
||||||
# buttons and wait_for_input through the code, passing as arguments both the name of the
|
|
||||||
# action and the node, e.g.:
|
|
||||||
# button.connect("pressed", self, "wait_for_input", [ button, action ])
|
|
||||||
|
|
||||||
# Constants
|
|
||||||
const INPUT_ACTIONS = [
|
const INPUT_ACTIONS = [
|
||||||
"move_left",
|
"move_left",
|
||||||
"move_right",
|
"move_right",
|
||||||
@ -24,11 +12,8 @@ const INPUT_ACTIONS = [
|
|||||||
]
|
]
|
||||||
const CONFIG_FILE = "user://input.cfg"
|
const CONFIG_FILE = "user://input.cfg"
|
||||||
|
|
||||||
# Member variables
|
|
||||||
var action # To register the action the UI is currently handling
|
var action # To register the action the UI is currently handling
|
||||||
var button # Button node corresponding to the above action
|
var button # Button node corresponding to the above action
|
||||||
var enable_resume = true
|
|
||||||
|
|
||||||
|
|
||||||
# Load/save input mapping to a config file
|
# Load/save input mapping to a config file
|
||||||
# Changes done while testing the demo will be persistent, saved to CONFIG_FILE
|
# Changes done while testing the demo will be persistent, saved to CONFIG_FILE
|
||||||
@ -74,8 +59,7 @@ func wait_for_input(action_bind):
|
|||||||
action = action_bind
|
action = action_bind
|
||||||
# See note at the beginning of the script
|
# See note at the beginning of the script
|
||||||
button = get_node("bindings").get_node(action).get_node("Button")
|
button = get_node("bindings").get_node(action).get_node("Button")
|
||||||
#get_node("contextual_help").text = "Press a key to assign to the '" + action + "' action."
|
button.text = "Press key"
|
||||||
enable_resume = false
|
|
||||||
set_process_input(true)
|
set_process_input(true)
|
||||||
|
|
||||||
|
|
||||||
@ -85,9 +69,7 @@ func _input(event):
|
|||||||
# Register the event as handled and stop polling
|
# Register the event as handled and stop polling
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
set_process_input(false)
|
set_process_input(false)
|
||||||
# Reinitialise the contextual help label
|
|
||||||
#get_node("contextual_help").text = "Click a key binding to reassign it, or press the Cancel action."
|
|
||||||
|
|
||||||
# Display the string corresponding to the pressed key
|
# Display the string corresponding to the pressed key
|
||||||
var scancode = OS.get_scancode_string(event.scancode)
|
var scancode = OS.get_scancode_string(event.scancode)
|
||||||
button.text = scancode
|
button.text = scancode
|
||||||
@ -97,8 +79,6 @@ func _input(event):
|
|||||||
# Add the new key binding
|
# Add the new key binding
|
||||||
InputMap.action_add_event(action, event)
|
InputMap.action_add_event(action, event)
|
||||||
save_to_config("input", action, scancode)
|
save_to_config("input", action, scancode)
|
||||||
enable_resume = true
|
|
||||||
|
|
||||||
hint_text()
|
hint_text()
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
[ext_resource path="res://icons/hold.png" type="Texture" id=10]
|
[ext_resource path="res://icons/hold.png" type="Texture" id=10]
|
||||||
[ext_resource path="res://icons/pause.png" type="Texture" id=11]
|
[ext_resource path="res://icons/pause.png" type="Texture" id=11]
|
||||||
|
|
||||||
[node name="controls_ui" type="Control"]
|
[node name="controls_ui" type="Control" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
@ -83,9 +83,9 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 50.0
|
margin_left = 20.0
|
||||||
margin_top = 65.0
|
margin_top = 65.0
|
||||||
margin_right = 90.0
|
margin_right = 60.0
|
||||||
margin_bottom = 105.0
|
margin_bottom = 105.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -101,7 +101,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 80.0
|
margin_left = 80.0
|
||||||
margin_right = 155.0
|
margin_right = 174.0
|
||||||
margin_bottom = 37.0
|
margin_bottom = 37.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -115,6 +115,7 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
@ -131,10 +132,10 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 226.0
|
margin_left = 220.0
|
||||||
margin_top = 66.0
|
margin_top = 65.0
|
||||||
margin_right = 266.0
|
margin_right = 260.0
|
||||||
margin_bottom = 106.0
|
margin_bottom = 105.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
@ -150,7 +151,7 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 84.0
|
margin_left = 84.0
|
||||||
margin_top = -1.0
|
margin_top = -1.0
|
||||||
margin_right = 159.0
|
margin_right = 178.0
|
||||||
margin_bottom = 36.0
|
margin_bottom = 36.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -164,8 +165,10 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
|
_sections_unfolded = [ "custom_fonts" ]
|
||||||
|
|
||||||
[node name="arrowRight" type="Sprite" parent="bindings/move_right" index="1"]
|
[node name="arrowRight" type="Sprite" parent="bindings/move_right" index="1"]
|
||||||
|
|
||||||
@ -180,10 +183,10 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 230.0
|
margin_left = 224.0
|
||||||
margin_top = 115.0
|
margin_top = 114.0
|
||||||
margin_right = 270.0
|
margin_right = 264.0
|
||||||
margin_bottom = 155.0
|
margin_bottom = 154.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
@ -198,7 +201,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 80.0
|
margin_left = 80.0
|
||||||
margin_right = 155.0
|
margin_right = 174.0
|
||||||
margin_bottom = 37.0
|
margin_bottom = 37.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -212,9 +215,10 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
_sections_unfolded = [ "custom_fonts" ]
|
_sections_unfolded = [ "Rect", "custom_fonts" ]
|
||||||
|
|
||||||
[node name="clockwise" type="Sprite" parent="bindings/rotate_clockwise" index="1"]
|
[node name="clockwise" type="Sprite" parent="bindings/rotate_clockwise" index="1"]
|
||||||
|
|
||||||
@ -228,9 +232,9 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 45.0
|
margin_left = 15.0
|
||||||
margin_top = 115.0
|
margin_top = 115.0
|
||||||
margin_right = 85.0
|
margin_right = 55.0
|
||||||
margin_bottom = 155.0
|
margin_bottom = 155.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -247,7 +251,7 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 84.0
|
margin_left = 84.0
|
||||||
margin_top = -1.0
|
margin_top = -1.0
|
||||||
margin_right = 159.0
|
margin_right = 178.0
|
||||||
margin_bottom = 36.0
|
margin_bottom = 36.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -261,6 +265,7 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
@ -277,9 +282,9 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 50.0
|
margin_left = 20.0
|
||||||
margin_top = 165.0
|
margin_top = 165.0
|
||||||
margin_right = 90.0
|
margin_right = 60.0
|
||||||
margin_bottom = 205.0
|
margin_bottom = 205.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -295,7 +300,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 80.0
|
margin_left = 80.0
|
||||||
margin_right = 155.0
|
margin_right = 174.0
|
||||||
margin_bottom = 37.0
|
margin_bottom = 37.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -309,6 +314,7 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
@ -325,10 +331,10 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 226.0
|
margin_left = 220.0
|
||||||
margin_top = 166.0
|
margin_top = 165.0
|
||||||
margin_right = 266.0
|
margin_right = 260.0
|
||||||
margin_bottom = 206.0
|
margin_bottom = 205.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
@ -344,7 +350,7 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 84.0
|
margin_left = 84.0
|
||||||
margin_top = -1.0
|
margin_top = -1.0
|
||||||
margin_right = 159.0
|
margin_right = 178.0
|
||||||
margin_bottom = 36.0
|
margin_bottom = 36.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -358,6 +364,7 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
@ -374,9 +381,9 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 50.0
|
margin_left = 20.0
|
||||||
margin_top = 215.0
|
margin_top = 215.0
|
||||||
margin_right = 90.0
|
margin_right = 60.0
|
||||||
margin_bottom = 255.0
|
margin_bottom = 255.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -392,7 +399,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 80.0
|
margin_left = 80.0
|
||||||
margin_right = 155.0
|
margin_right = 174.0
|
||||||
margin_bottom = 37.0
|
margin_bottom = 37.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -406,6 +413,7 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
@ -421,10 +429,10 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 226.0
|
margin_left = 220.0
|
||||||
margin_top = 216.0
|
margin_top = 215.0
|
||||||
margin_right = 266.0
|
margin_right = 260.0
|
||||||
margin_bottom = 256.0
|
margin_bottom = 255.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
@ -440,7 +448,7 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 84.0
|
margin_left = 84.0
|
||||||
margin_top = -1.0
|
margin_top = -1.0
|
||||||
margin_right = 159.0
|
margin_right = 178.0
|
||||||
margin_bottom = 36.0
|
margin_bottom = 36.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -454,6 +462,7 @@ toggle_mode = false
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
|
text = "Press key"
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user