Skip to content
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

Expose EditorSettings shortcut related functions #4112

Open
AnidemDex opened this issue Feb 24, 2022 · 1 comment · May be fixed by godotengine/godot#58585
Open

Expose EditorSettings shortcut related functions #4112

AnidemDex opened this issue Feb 24, 2022 · 1 comment · May be fixed by godotengine/godot#58585

Comments

@AnidemDex
Copy link

Describe the project you are working on

EditorPlugins, mainly Textalog (a dialog node implementation) and Event System (a plugin to execute pieces of code in sequence according to the scenario)

Describe the problem or limitation you are having in your project

Event system plugin adds a bottom dock panel to edit a custom resource. Some operations that can be applied in that resource can be made through shortcuts:
image
Those shortcuts were hardcoded replicating what I saw in editor settings.

Trying to get default shortcuts through EditorSettings.get_setting(path/to/shortcut) doesn't works.

I'm going to add more actions, and I don't want to keep myself hardcoding things, I want to use the editor ones.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Exposing get_shortcut method from EditorSettings could help me in this situation.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Basically, expose EditorSettings::get_shortcut():

In EditorSettings or inside EditorPlugin or EditorInterface, I don't know.

extends EditorPlugin
func _ready():
    # In EditorPlugin
    get_shortcut(shortcut_path:String) <- Option A

    # or in editor interface
    get_editor_interface().get_shortcut(shortcut_path:String) <- Option B

    # or in editor settings
    get_editor_interface().get_editor_settings().get_shortcut(shortcut_path:String) <- Option C
    

But now that I want to expose some methods, why not exposing every method related to shortcuts, in order to give those tools to plugin makers (no idea why someone would use EditorSettings in a game), that means exposing:

And maybe:

https://github.com/godotengine/godot/blob/cfc7c78732198a7ebc43b92ed24e7025fdf4bc11/editor/editor_settings.cpp#L1359-L1410

If this enhancement will not be used often, can it be worked around with a few lines of script?

A few lines? No, you'll need to create the whole shortcut by hand, and nothing ensures that will be the same as the editor uses:
image
because this will not work:

var settings:EditorSettings = plugin.get_editor_interface().get_editor_settings()
var shortcut = settings.get("scene_tree/duplicate") as ShortCut

Is there a reason why this should be core and not an add-on in the asset library?

I had no idea if that is something possible using GDNative/GDExtension, always wanted to make a plugin with that, don't know where to start.

EditorSettings.call() does not work, so I think need to be exposed somehow from core.

@YuriSizov
Copy link
Contributor

But now that I want to expose some methods, why not exposing every method related to shortcuts

Yeah, all 4 of them can be exposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants