mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
testing dynamic keys (:
This commit is contained in:
parent
2eb63be2ca
commit
49f6a2e58d
4 changed files with 75 additions and 41 deletions
|
|
@ -186,54 +186,29 @@ right={
|
|||
}
|
||||
jump={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":75,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
action={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":74,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777238,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
reset={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
debug_spawn_box={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
window_shrink={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":45,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
window_expand={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":61,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
dev_console={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":96,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
pause={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":10,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
screenshot={
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ margin_top = 1.0
|
|||
margin_right = 9.0
|
||||
margin_bottom = 10.0
|
||||
rect_min_size = Vector2( 9, 9 )
|
||||
action = "action"
|
||||
text = "c"
|
||||
|
||||
[node name="Desc" type="Label" parent="Center/Control/List/C"]
|
||||
|
|
@ -283,20 +284,21 @@ custom_constants/separation = 0
|
|||
alignment = 2
|
||||
|
||||
[node name="P" type="HBoxContainer" parent="Center/Control/Top"]
|
||||
margin_left = 157.0
|
||||
margin_left = 169.0
|
||||
margin_right = 218.0
|
||||
margin_bottom = 12.0
|
||||
custom_constants/separation = 4
|
||||
|
||||
[node name="Key" parent="Center/Control/Top/P" instance=ExtResource( 7 )]
|
||||
margin_top = 1.0
|
||||
margin_right = 33.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 10.0
|
||||
action = "pause"
|
||||
|
||||
[node name="Desc" type="Label" parent="Center/Control/Top/P"]
|
||||
margin_left = 37.0
|
||||
margin_left = 25.0
|
||||
margin_top = 3.0
|
||||
margin_right = 61.0
|
||||
margin_right = 49.0
|
||||
margin_bottom = 8.0
|
||||
custom_fonts/font = SubResource( 3 )
|
||||
text = "menu"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,38 @@
|
|||
tool
|
||||
extends Control
|
||||
|
||||
export var action := "" setget set_action
|
||||
export var text := "key" setget set_text
|
||||
|
||||
onready var white := $White
|
||||
onready var black := $Black
|
||||
onready var label := $Label
|
||||
|
||||
var is_gamepad := false
|
||||
|
||||
var swap := {"control" : "ctrl",
|
||||
"quoteleft" : "~",
|
||||
"capslock" : "caps",
|
||||
"escape" : "esc",
|
||||
"equal" : "=",
|
||||
"minus" : "-",
|
||||
"bracketleft" : "[",
|
||||
"bracketright" : "]",
|
||||
"apostrophe" : "'",
|
||||
"semicolon" : ";",
|
||||
"comma" : ",",
|
||||
"period" : ".",
|
||||
"slash" : "/",
|
||||
"backslash" : "\\",
|
||||
"insert" : "ins",
|
||||
"delete" : "del",
|
||||
"pageup" : "pgup",
|
||||
"pagedown" : "pgdn",
|
||||
}
|
||||
|
||||
|
||||
func _ready():
|
||||
set_text()
|
||||
set_action()
|
||||
if Engine.editor_hint: return
|
||||
|
||||
func set_text(arg := text):
|
||||
|
|
@ -27,3 +51,36 @@ func set_text(arg := text):
|
|||
black.rect_size = Vector2(l + 1, 7)
|
||||
|
||||
update()
|
||||
|
||||
func set_action(arg := action):
|
||||
action = arg
|
||||
print("set_action = ", action, " ", InputMap.get_action_list(action))
|
||||
|
||||
|
||||
if action != "" and InputMap.has_action(action):
|
||||
var l = InputMap.get_action_list(action)
|
||||
print("l")
|
||||
var e = null
|
||||
|
||||
for i in l:
|
||||
if is_type(i):
|
||||
e = i
|
||||
|
||||
if e:
|
||||
parse_event(e)
|
||||
|
||||
func is_type(event):
|
||||
var test = !is_gamepad and event is InputEventKey
|
||||
if !test:
|
||||
test = is_gamepad and (event is InputEventJoypadButton or event is InputEventJoypadMotion)
|
||||
|
||||
return test
|
||||
|
||||
func parse_event(event : InputEvent):
|
||||
var s = str(event.as_text().to_lower())
|
||||
|
||||
if swap.has(s):
|
||||
s = swap[s]
|
||||
|
||||
self.text = s
|
||||
update()
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ font_data = ExtResource( 1 )
|
|||
[node name="Key" type="Control"]
|
||||
margin_right = 8.0
|
||||
margin_bottom = 8.0
|
||||
rect_min_size = Vector2( 33, 9 )
|
||||
rect_min_size = Vector2( 21, 9 )
|
||||
size_flags_vertical = 4
|
||||
script = ExtResource( 2 )
|
||||
text = "enter"
|
||||
action = "jump"
|
||||
|
||||
[node name="White" type="ColorRect" parent="."]
|
||||
margin_right = 33.0
|
||||
margin_right = 21.0
|
||||
margin_bottom = 9.0
|
||||
rect_min_size = Vector2( 8, 8 )
|
||||
|
||||
|
|
@ -28,14 +28,14 @@ rect_min_size = Vector2( 8, 8 )
|
|||
modulate = Color( 0, 0, 0, 1 )
|
||||
margin_left = 1.0
|
||||
margin_top = 1.0
|
||||
margin_right = 32.0
|
||||
margin_right = 20.0
|
||||
margin_bottom = 8.0
|
||||
rect_min_size = Vector2( 7, 7 )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
margin_left = 2.0
|
||||
margin_top = 2.0
|
||||
margin_right = 26.0
|
||||
margin_right = 20.0
|
||||
margin_bottom = 7.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "enter"
|
||||
text = "key"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue