mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Update Keychain
This commit is contained in:
parent
970d1d3c23
commit
d7f6432bb7
|
@ -9,7 +9,7 @@
|
||||||
## Keychain
|
## Keychain
|
||||||
|
|
||||||
- Upstream: https://github.com/Orama-Interactive/Keychain
|
- Upstream: https://github.com/Orama-Interactive/Keychain
|
||||||
- Version: 4a08d6b380929031b2c9202811ae0a65d850a5ac
|
- Version: [5031af557efcff4eb1ae77550e91868ab57cb1c0](https://github.com/Orama-Interactive/Keychain/commit/5031af557efcff4eb1ae77550e91868ab57cb1c0)
|
||||||
- License: [MIT](https://github.com/Orama-Interactive/Keychain/blob/main/LICENSE)
|
- License: [MIT](https://github.com/Orama-Interactive/Keychain/blob/main/LICENSE)
|
||||||
|
|
||||||
## gdgifexporter
|
## gdgifexporter
|
||||||
|
|
|
@ -2,19 +2,28 @@ extends Node
|
||||||
|
|
||||||
const PROFILES_PATH := "user://shortcut_profiles"
|
const PROFILES_PATH := "user://shortcut_profiles"
|
||||||
|
|
||||||
## Change these settings
|
## [Array] of [ShortcutProfile]s.
|
||||||
var profiles: Array[ShortcutProfile] = [preload("profiles/default.tres")]
|
var profiles: Array[ShortcutProfile] = [preload("profiles/default.tres")]
|
||||||
var selected_profile := profiles[0]
|
var selected_profile := profiles[0] ## The currently selected [ShortcutProfile].
|
||||||
var profile_index := 0
|
var profile_index := 0 ## The index of the currently selected [ShortcutProfile].
|
||||||
|
## [Dictionary] of [String] and [InputAction].
|
||||||
## Syntax: "action_name": InputAction.new("Action Display Name", "Group", true)
|
## Syntax: "action_name": InputAction.new("Action Display Name", "Group", true)
|
||||||
## Note that "action_name" must already exist in the Project's Input Map.
|
## Note that "action_name" must already exist in the Project's Input Map.
|
||||||
var actions := {}
|
var actions := {}
|
||||||
|
## [Dictionary] of [String] and [InputGroup].
|
||||||
## Syntax: "Group Name": InputGroup.new("Parent Group Name")
|
## Syntax: "Group Name": InputGroup.new("Parent Group Name")
|
||||||
var groups := {}
|
var groups := {}
|
||||||
var ignore_actions := []
|
var ignore_actions: Array[StringName] = [] ## [Array] of [StringName] input map actions to ignore.
|
||||||
|
## If [code]true[/code], ignore Godot's default "ui_" input map actions.
|
||||||
var ignore_ui_actions := true
|
var ignore_ui_actions := true
|
||||||
var changeable_types := [true, true, true, true]
|
## A [PackedByteArray] of [bool]s with a fixed length of 4. Used for developers to allow or
|
||||||
|
## forbid setting certain types of InputEvents. The first element is for [InputEventKey]s,
|
||||||
|
## the second for [InputEventMouseButton]s, the third for [InputEventJoypadButton]s
|
||||||
|
## and the fourth for [InputEventJoypadMotion]s.
|
||||||
|
var changeable_types: PackedByteArray = [true, true, true, true]
|
||||||
|
## The file path of the [code]config_file[/code].
|
||||||
var config_path := "user://cache.ini"
|
var config_path := "user://cache.ini"
|
||||||
|
## Used to store the settings to the filesystem.
|
||||||
var config_file: ConfigFile
|
var config_file: ConfigFile
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,15 +94,15 @@ func change_profile(index: int) -> void:
|
||||||
action_add_event(action, event)
|
action_add_event(action, event)
|
||||||
|
|
||||||
|
|
||||||
func action_add_event(action: String, event: InputEvent) -> void:
|
func action_add_event(action: StringName, event: InputEvent) -> void:
|
||||||
InputMap.action_add_event(action, event)
|
InputMap.action_add_event(action, event)
|
||||||
|
|
||||||
|
|
||||||
func action_erase_event(action: String, event: InputEvent) -> void:
|
func action_erase_event(action: StringName, event: InputEvent) -> void:
|
||||||
InputMap.action_erase_event(action, event)
|
InputMap.action_erase_event(action, event)
|
||||||
|
|
||||||
|
|
||||||
func action_erase_events(action: String) -> void:
|
func action_erase_events(action: StringName) -> void:
|
||||||
InputMap.action_erase_events(action)
|
InputMap.action_erase_events(action)
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,3 +110,19 @@ func load_translation(locale: String) -> void:
|
||||||
var translation = load("res://addons/keychain/translations".path_join(locale + ".po"))
|
var translation = load("res://addons/keychain/translations".path_join(locale + ".po"))
|
||||||
if is_instance_valid(translation) and translation is Translation:
|
if is_instance_valid(translation) and translation is Translation:
|
||||||
TranslationServer.add_translation(translation)
|
TranslationServer.add_translation(translation)
|
||||||
|
|
||||||
|
|
||||||
|
## Converts a [param text] with snake case to a more readable format, by replacing
|
||||||
|
## underscores with spaces. If [param capitalize_first_letter] is [code]true[/code],
|
||||||
|
## the first letter of the text is capitalized.
|
||||||
|
## E.g, "snake_case" would be converted to "Snake case" if
|
||||||
|
## [param capitalize_first_letter] is [code]true[/code], else it would be converted to
|
||||||
|
## "snake case".
|
||||||
|
func humanize_snake_case(text: String, capitalize_first_letter := true) -> String:
|
||||||
|
text = text.replace("_", " ")
|
||||||
|
if capitalize_first_letter:
|
||||||
|
var first_letter := text.left(1)
|
||||||
|
first_letter = first_letter.capitalize()
|
||||||
|
text = text.right(-1)
|
||||||
|
text = text.insert(0, first_letter)
|
||||||
|
return text
|
||||||
|
|
|
@ -199,19 +199,10 @@ func get_action_name(action: String) -> String:
|
||||||
display_name = Keychain.actions[action].display_name
|
display_name = Keychain.actions[action].display_name
|
||||||
|
|
||||||
if display_name.is_empty():
|
if display_name.is_empty():
|
||||||
display_name = _humanize_snake_case(action)
|
display_name = Keychain.humanize_snake_case(action)
|
||||||
return display_name
|
return display_name
|
||||||
|
|
||||||
|
|
||||||
func _humanize_snake_case(text: String) -> String:
|
|
||||||
text = text.replace("_", " ")
|
|
||||||
var first_letter := text.left(1)
|
|
||||||
first_letter = first_letter.capitalize()
|
|
||||||
text = text.right(-1)
|
|
||||||
text = text.insert(0, first_letter)
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
func add_event_tree_item(event: InputEvent, action_tree_item: TreeItem) -> void:
|
func add_event_tree_item(event: InputEvent, action_tree_item: TreeItem) -> void:
|
||||||
var event_class := event.get_class()
|
var event_class := event.get_class()
|
||||||
match event_class:
|
match event_class:
|
||||||
|
|
Loading…
Reference in a new issue