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

42 lines
No EOL
2.6 KiB
GDScript

extends MarginContainer
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
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", "test_change_map_3" ]
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", "main test scene" ]
func _ready():
_on_Refresh_pressed()
func _on_Refresh_pressed():
var index = 0
for action_name in ACTION_LIST:
var event_index = 0
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
func _input( event ):
if event.is_action_pressed( "ui_debug_window" ):
self.visible = not self.visible