2018-07-25 07:36:19 +00:00
|
|
|
extends MarginContainer
|
|
|
|
|
|
|
|
# class member variables go here, for example:
|
|
|
|
# var a = 2
|
|
|
|
# var b = "textvar"
|
|
|
|
|
2018-08-13 14:48:22 +00:00
|
|
|
const ACTION_LIST = [ "ui_debug_window", "ui_music_controls", "hide_char", "ui_hide_all", "move_up", "move_down", "move_left", "move_right", "fly_up", "fly_down","game_flashlight", "ui_pause", "ui_reload", "ui_free_cursor", "ui_quit", "test_change_map_1", "test_change_map_2" ]
|
|
|
|
const ACTION_TEXT = [ "show/hide debug", "show/hide music", "Hide/show character", "hide/show UI", "move up", "move down", "move left", "move right", "fly up", "fly down", "on/off flashlight", "pause/play", "reload the scene", "free/capture mouse cursor", "quit", "test scene", "test grid map" ]
|
2018-07-25 07:36:19 +00:00
|
|
|
|
|
|
|
func _ready():
|
2018-08-03 12:58:20 +00:00
|
|
|
_on_Refresh_pressed()
|
|
|
|
|
2018-07-25 07:36:19 +00:00
|
|
|
|
|
|
|
func _on_Refresh_pressed():
|
2018-08-03 10:02:46 +00:00
|
|
|
var index = 0
|
2018-07-25 07:36:19 +00:00
|
|
|
for action_name in ACTION_LIST:
|
2018-08-03 12:58:20 +00:00
|
|
|
var event_index = 0
|
2018-07-25 07:36:19 +00:00
|
|
|
for event in InputMap.get_action_list( action_name ):
|
|
|
|
if event is InputEventKey:
|
2018-08-03 12:58:20 +00:00
|
|
|
if get_node( "ScrollContainer/MarginContainer/VBoxContainer" ).has_node( action_name+str(event_index) ):
|
|
|
|
get_node( "ScrollContainer/MarginContainer/VBoxContainer" ).remove_child( get_node( "ScrollContainer/MarginContainer/VBoxContainer" ).get_node( action_name+str(event_index) ) )
|
2018-08-03 10:02:46 +00:00
|
|
|
|
|
|
|
var label = Label.new()
|
2018-08-03 12:58:20 +00:00
|
|
|
label.name = action_name+str(event_index)
|
2018-08-03 10:02:46 +00:00
|
|
|
label.text = ACTION_TEXT[ index ] + ": " + OS.get_scancode_string( event.get_scancode_with_modifiers() )
|
2018-08-03 12:58:20 +00:00
|
|
|
$ScrollContainer/MarginContainer/VBoxContainer.add_child( label )
|
|
|
|
label.set_owner( $ScrollContainer/MarginContainer/VBoxContainer )
|
|
|
|
elif event is InputEventJoypadButton:
|
|
|
|
if get_node( "ScrollContainer/MarginContainer/VBoxContainer" ).has_node( action_name+str(event_index) ):
|
|
|
|
get_node( "ScrollContainer/MarginContainer/VBoxContainer" ).remove_child( get_node( "ScrollContainer/MarginContainer/VBoxContainer" ).get_node( action_name+str(event_index) ) )
|
|
|
|
|
|
|
|
var label = Label.new()
|
|
|
|
label.name = action_name+str(event_index)
|
|
|
|
label.text = ACTION_TEXT[ index ] + ": " + Input.get_joy_button_string( event.button_index )
|
|
|
|
$ScrollContainer/MarginContainer/VBoxContainer.add_child( label )
|
|
|
|
label.set_owner( $ScrollContainer/MarginContainer/VBoxContainer )
|
|
|
|
event_index += 1
|
2018-08-03 10:02:46 +00:00
|
|
|
index += 1
|
2018-07-25 07:36:19 +00:00
|
|
|
|
|
|
|
func _input( event ):
|
|
|
|
if event.is_action_pressed( "ui_debug_window" ):
|
|
|
|
self.visible = not self.visible
|