ajout de panneaux de contrôles, de paramètres et refactorisation de la gestion de l'audio
This commit is contained in:
38
gui/menu/controls/scripts/input_group.gd
Normal file
38
gui/menu/controls/scripts/input_group.gd
Normal file
@@ -0,0 +1,38 @@
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
class_name InputGroup
|
||||
|
||||
const MAX_INPUT_NAME = 30
|
||||
|
||||
var event : InputEvent = null
|
||||
var is_remapping := false
|
||||
|
||||
@export var action_name : String :
|
||||
set(v):
|
||||
action_name = v
|
||||
var events : Array[InputEvent] = InputMap.action_get_events(action_name)
|
||||
event = null if events.size() == 0 else events[0]
|
||||
update()
|
||||
|
||||
func update():
|
||||
%Text.text = action_name.to_upper()
|
||||
var input_name = "UNASSIGNED" if event == null else event.as_text()
|
||||
if input_name.length() > MAX_INPUT_NAME:
|
||||
input_name = input_name.substr(0,MAX_INPUT_NAME) + "..."
|
||||
%Button.text = input_name
|
||||
# (%Button as Button).add_theme_color_override("font_color", Color.RED if )
|
||||
|
||||
func _input(new_event):
|
||||
if is_remapping:
|
||||
if (
|
||||
new_event is InputEventKey or (new_event is InputEventMouseButton and new_event.is_pressed())
|
||||
):
|
||||
is_remapping = false
|
||||
GameInfo.update_input(action_name, event, new_event)
|
||||
event = new_event
|
||||
update()
|
||||
|
||||
func _on_button_button_down():
|
||||
if !is_remapping:
|
||||
is_remapping = true
|
||||
%Button.text = "PRESS_KEY"
|
||||
Reference in New Issue
Block a user