-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
primitive config with custom shortcuts #159
Conversation
Thank you for your contribution, but custom keyboard shortcuts are already beeing worked on by @MrApplejuice. See: #144. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! Wow, handy to have this actually. I did not tackle persisting of keyboard shortcuts yet, at all. And this comes in just handy. Seems pretty compatible with what I am doing as well, except for the "multiple bindings" per action thing that I commented on.
If that is not fixed now, I will need to do this later, and that would probably be a bit annoying because the config-file syntax needs to be changed again and might require backwards incompatible changes.
I would suggest, taking the current implementation and wrapping the serialization of scancodes in an Array and set that value - that should work right? ConfigFile seems to support "Variants", I would assume that would include Arrays of serializable values. Then we would be done with this for good. (If arrays cannot be written directly, just JSONify the array and save/load that one).
That would be my 2-cents to this. Looks good otherwise :-) I leave the final decision to @mbrlabs .
Hey @MrApplejuice, you were right, ConfigFile supports Arrays so I fixed that, and now multiple bindings per action work. I had to add a prefix to every shortcut: Edit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, looks good to me! Have tow nit-picky suggestions, but in no way necessary :-)
I am also only contributing ;-) @mbrlabs what do you think?
'_setup_shortcuts' function now creates binding if it is not present in settings new function 'set_default_shortcut' allows you to restore default values for a shortcut
I think this is everything for now. I hope you find this useful. Thank you for your suggestions, godot is totally new for me so I appreciate every help :-) |
Persistence-wise i probably would have done it the same: Shortcuts section in
As for how to serialize the key combinantions: just let Godot do it (InputEvent is a Resource, so that should be no problem). It's less readable then a custom format, but it's still possible if you want to debug/check something by reading or changing the file directly. For example a single-event action would look like this:
In order to save it like this you can just pass in the array of InputEvents into the set_value method of the ConfigFile. Serialization & deserialization is automatic. |
Thanks! |
This is just a simple/primitive implementation of custom shortcuts. For now, editing shortcuts can be made only via settings.cfg file.
There is problem with some combination of shortucts (like Control+[key] and Control+Shift+[key]), because godot don't check other shortcuts if overlap. I found this about possible solution.
(I know almost nothing about godot so I am really sorry if I did something wrong.)