1
0
Fork 0
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:
Emmanouil Papadeas 2022-05-29 12:51:56 +03:00
parent c3d56ee547
commit 9135caabbe
3 changed files with 36 additions and 20 deletions

View file

@ -3,13 +3,13 @@
## Keychain
- Upstream: https://github.com/Orama-Interactive/Keychain
- Version: Based on git commit 29e80383e46acb5478696d40990bc3624a6920c4 with slight modifications in Keychain.gd and ShortcutEdit.tscn.
- Version: Based on git commit 22539c2b9b9e781c0cd54f32d92c77b6f36837e0 with slight modifications in Keychain.gd and ShortcutEdit.tscn.
- License: [MIT](https://github.com/Orama-Interactive/Keychain/blob/main/LICENSE)
## gdgifexporter
- Upstream: https://github.com/jegor377/godot-gdgifexporter
- Version: git (b6a6628dc253acb5c2955bc9ca5c8eaa2eaf2e1a, 2021)
- Version: custom
- License: [MIT](https://github.com/jegor377/godot-gdgifexporter/blob/master/LICENSE)
Files extracted from source:

View file

@ -11,9 +11,14 @@ func _init() -> void:
func fill_bindings() -> void:
var unnecessary_actions = bindings.duplicate() # Checks if the profile has any unused actions
for action in InputMap.get_actions():
if not action in bindings:
bindings[action] = InputMap.get_action_list(action)
unnecessary_actions.erase(action)
for action in unnecessary_actions:
bindings.erase(action)
save()
func change_action(action: String) -> void:
@ -24,6 +29,8 @@ func change_action(action: String) -> void:
func save() -> bool:
if !customizable:
return false
var err := ResourceSaver.save(resource_path, self)
if err != OK:
print("Error saving shortcut profile %s. Error code: %s" % [resource_path, err])

View file

@ -97,12 +97,7 @@ func _set_shortcut(action: String, old_event: InputEvent, new_event: InputEvent)
if metadata is InputEvent:
if input_to_replace.shortcut_match(metadata):
var map_action: String = tree_item.get_parent().get_metadata(0)
if map_action in Keychain.actions:
# If it's local, check if it's the same group, otherwise ignore
if !Keychain.actions[map_action].global:
if Keychain.actions[map_action].group != group:
tree_item = _get_next_tree_item(tree_item)
continue
if map_action == action_to_replace:
tree_item.free()
break
@ -138,10 +133,12 @@ func _find_matching_event_in_map(action: String, event: InputEvent) -> Array:
if Keychain.ignore_ui_actions and map_action.begins_with("ui_"):
continue
for map_event in InputMap.get_action_list(map_action):
if event.shortcut_match(map_event):
if !event.shortcut_match(map_event):
continue
if map_action in Keychain.actions:
# If it's local, check if it's the same group, otherwise ignore
if !Keychain.actions[map_action].global:
if !Keychain.actions[action].global or !Keychain.actions[map_action].global:
if Keychain.actions[map_action].group != group:
continue
@ -158,10 +155,22 @@ func _on_ShortcutSelectorDialog_about_to_show() -> void:
yield(get_tree(), "idle_frame")
entered_shortcut.grab_focus()
else:
if !listened_input:
var metadata = root.currently_editing_tree_item.get_metadata(0)
if metadata is InputEvent: # Editing an input event
var index := 0
if metadata is InputEventMouseButton:
index = metadata.button_index - 1
elif metadata is InputEventJoypadButton:
index = metadata.button_index
elif metadata is InputEventJoypadMotion:
index = metadata.axis * 2
index += round(metadata.axis_value) / 2.0 + 0.5
option_button.select(index)
_on_OptionButton_item_selected(index)
elif metadata is String: # Adding a new input event to an action
option_button.select(0)
_on_OptionButton_item_selected(0)
else:
_show_assigned_state(listened_input)
func _on_ShortcutSelectorDialog_popup_hide() -> void: