22 lines
648 B
GDScript
22 lines
648 B
GDScript
extends Control
|
|
|
|
|
|
export var action: String
|
|
|
|
|
|
onready var keyboard_button: Label = $KeyboardButton
|
|
onready var gamepad_button: TextureRect = $GamepadButton
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
if SceneManager.last_input_gamepad:
|
|
keyboard_button.visible = false
|
|
gamepad_button.visible = true
|
|
var button = Controls.get_button(action)
|
|
if button >= 0:
|
|
gamepad_button.texture.region.position.x = float(button % 8) * 12.0
|
|
gamepad_button.texture.region.position.y = float(button / 8) * 10.0
|
|
else:
|
|
keyboard_button.visible = true
|
|
gamepad_button.visible = false
|
|
keyboard_button.text = OS.get_scancode_string(Controls.get_key(action))
|