-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebindable Inputs: - This should now work! (please report any issues) - When you first try this, you'll get an error that now keybindings are found in your config file, this is to be expected. - Once you save your keybindings (press "Apply" in the options menu), this error should no longer occur. - This was only tested with the standard button sets. Special buttons for individual gamepads (like Playstations touchpad button) have not been tested and might display the wrong icon when used. - Be aware that these bindings get saved/loaded on runtime, so they will not show up as changed in the Godot Editor input map! - If you own a PS5 gamepad and would like to contribute, please let me know (open a thread or issue), thanks!
- Loading branch information
1 parent
bbe1575
commit 1f960d7
Showing
13 changed files
with
179 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://cbv85ok0isnb3"] | ||
|
||
[ext_resource type="Script" path="res://addons/cogito/EasyMenus/Components/menu_separator.gd" id="1_6oy01"] | ||
|
||
[node name="MenuSeparator" type="HBoxContainer"] | ||
alignment = 1 | ||
script = ExtResource("1_6oy01") | ||
|
||
[node name="HSeparator" type="HSeparator" parent="."] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
|
||
[node name="Label" type="Label" parent="."] | ||
layout_mode = 2 | ||
text = "Input Bindings (WIP!)" | ||
horizontal_alignment = 1 | ||
|
||
[node name="HSeparator2" type="HSeparator" parent="."] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,72 @@ | ||
extends Node | ||
|
||
@export var remap_entry: PackedScene | ||
@export var separator_entry: PackedScene | ||
|
||
@onready var bindings_container: VBoxContainer = %BindingsContainer | ||
|
||
var config = ConfigFile.new() | ||
|
||
|
||
var input_actions = { | ||
"separator_movement": "MOVEMENT", | ||
"forward": "Move forward", | ||
"back": "Move back", | ||
"left": "Move left", | ||
"right": "Move right", | ||
"jump": "Jump", | ||
"crouch": "Crouch", | ||
"separator_actions": "ACTIONS", | ||
"action_primary": "Primary Action", | ||
"action_secondary": "Secondary Action", | ||
"interact": "Interact 1", | ||
"interact2": "Interact 2", | ||
"menu": "Pause", | ||
"inventory": "Inventory", | ||
"reload": "Reload", | ||
"quickslot_1": "Quickslot 1", | ||
"quickslot_2": "Quickslot 2", | ||
"quickslot_3": "Quickslot 3", | ||
"quickslot_4": "Quickslot 4", | ||
"separator_inventory": "MENUS", | ||
"menu": "Pause", | ||
"inventory": "Inventory", | ||
"inventory_drop_item": "Quick Drop Item", | ||
"inventory_move_item": "Move Item", | ||
"inventory_use_item": "Use Item", | ||
} | ||
|
||
func _ready() -> void: | ||
load_keybindings_from_config() | ||
create_action_remap_items() | ||
|
||
|
||
|
||
func load_keybindings_from_config(): | ||
var err = config.load(OptionsConstants.config_file_name) | ||
if err != 0: | ||
print("Keybindings: Loading options config failed.") | ||
#save_keybindings_to_config() | ||
|
||
var serialized_inputs = config.get_value(OptionsConstants.key_binds, OptionsConstants.input_helper_string) | ||
if serialized_inputs: | ||
InputHelper.deserialize_inputs_for_actions(serialized_inputs) | ||
else: | ||
print("Keybindings: No saved bindings found.") | ||
|
||
|
||
|
||
func save_keybindings_to_config(): | ||
var serialized_inputs = InputHelper.serialize_inputs_for_actions() | ||
config.set_value(OptionsConstants.key_binds, OptionsConstants.input_helper_string, serialized_inputs) | ||
config.save(OptionsConstants.config_file_name) | ||
|
||
|
||
func create_action_remap_items() -> void: | ||
for action in input_actions: | ||
var input_entry = remap_entry.instantiate() | ||
input_entry.action = action | ||
bindings_container.add_child(input_entry) | ||
input_entry.label.text = input_actions[action] | ||
if action.contains("separator"): | ||
var separator = separator_entry.instantiate() | ||
bindings_container.add_child(separator) | ||
separator.separator_text = input_actions[action] | ||
else: | ||
var input_entry = remap_entry.instantiate() | ||
input_entry.action = action | ||
bindings_container.add_child(input_entry) | ||
input_entry.label.text = input_actions[action] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends HBoxContainer | ||
@onready var label: Label = $Label | ||
|
||
var separator_text: String = "Section": | ||
set(value): | ||
separator_text = value | ||
label.text = separator_text |
Oops, something went wrong.