@@ -2,19 +2,28 @@ extends Node
22
33const PROFILES_PATH := "user://shortcut_profiles"
44
5- ## Change these settings
5+ ## [Array] of [ShortcutProfile]s.
66var profiles : Array [ShortcutProfile ] = [preload ("profiles/default.tres" )]
7- var selected_profile := profiles [0 ]
8- var profile_index := 0
7+ var selected_profile := profiles [0 ] ## The currently selected [ShortcutProfile].
8+ var profile_index := 0 ## The index of the currently selected [ShortcutProfile].
9+ ## [Dictionary] of [String] and [InputAction].
910## Syntax: "action_name": InputAction.new("Action Display Name", "Group", true)
1011## Note that "action_name" must already exist in the Project's Input Map.
1112var actions := {}
13+ ## [Dictionary] of [String] and [InputGroup].
1214## Syntax: "Group Name": InputGroup.new("Parent Group Name")
1315var groups := {}
14- var ignore_actions := []
16+ var ignore_actions : Array [StringName ] = [] ## [Array] of [StringName] input map actions to ignore.
17+ ## If [code]true[/code], ignore Godot's default "ui_" input map actions.
1518var ignore_ui_actions := true
16- var changeable_types := [true , true , true , true ]
19+ ## A [PackedByteArray] of [bool]s with a fixed length of 4. Used for developers to allow or
20+ ## forbid setting certain types of InputEvents. The first element is for [InputEventKey]s,
21+ ## the second for [InputEventMouseButton]s, the third for [InputEventJoypadButton]s
22+ ## and the fourth for [InputEventJoypadMotion]s.
23+ var changeable_types : PackedByteArray = [true , true , true , true ]
24+ ## The file path of the [code]config_file[/code].
1725var config_path := "user://cache.ini"
26+ ## Used to store the settings to the filesystem.
1827var config_file : ConfigFile
1928
2029
@@ -85,19 +94,35 @@ func change_profile(index: int) -> void:
8594 action_add_event (action , event )
8695
8796
88- func action_add_event (action : String , event : InputEvent ) -> void :
97+ func action_add_event (action : StringName , event : InputEvent ) -> void :
8998 InputMap .action_add_event (action , event )
9099
91100
92- func action_erase_event (action : String , event : InputEvent ) -> void :
101+ func action_erase_event (action : StringName , event : InputEvent ) -> void :
93102 InputMap .action_erase_event (action , event )
94103
95104
96- func action_erase_events (action : String ) -> void :
105+ func action_erase_events (action : StringName ) -> void :
97106 InputMap .action_erase_events (action )
98107
99108
100109func load_translation (locale : String ) -> void :
101110 var translation = load ("res://addons/keychain/translations" .path_join (locale + ".po" ))
102111 if is_instance_valid (translation ) and translation is Translation :
103112 TranslationServer .add_translation (translation )
113+
114+
115+ ## Converts a [param text] with snake case to a more readable format, by replacing
116+ ## underscores with spaces. If [param capitalize_first_letter] is [code]true[/code],
117+ ## the first letter of the text is capitalized.
118+ ## E.g, "snake_case" would be converted to "Snake case" if
119+ ## [param capitalize_first_letter] is [code]true[/code], else it would be converted to
120+ ## "snake case".
121+ func humanize_snake_case (text : String , capitalize_first_letter := true ) -> String :
122+ text = text .replace ("_" , " " )
123+ if capitalize_first_letter :
124+ var first_letter := text .left (1 )
125+ first_letter = first_letter .capitalize ()
126+ text = text .right (- 1 )
127+ text = text .insert (0 , first_letter )
128+ return text
0 commit comments