test-client-godot/scenes/GUI/Help/Help.gd

42 lines
2.5 KiB
GDScript3
Raw Normal View History

2018-07-25 07:36:19 +00:00
extends MarginContainer
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
2018-07-31 08:26:45 +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" ]
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" ]
2018-07-25 07:36:19 +00:00
func _ready():
_on_Refresh_pressed()
2018-07-25 07:36:19 +00:00
func _on_Refresh_pressed():
var index = 0
2018-07-25 07:36:19 +00:00
for action_name in ACTION_LIST:
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:
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 ] + ": " + OS.get_scancode_string( event.get_scancode_with_modifiers() )
$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
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