QodotPlugin / qodot-plugin

(LEGACY) Quake .map support for Godot 3.x
MIT License
960 stars 70 forks source link

Hotkey Support #111

Open keyle opened 3 years ago

keyle commented 3 years ago

Hi there

I'm constantly iterating and having to find "QodotMap" in the scene tree to click Full Build many times. I'm trying to automate this but no luck so far (I tried with _notification NOTIFICATION_WM_FOCUS_IN as bruteforce, no luck)

Godot can see the resource has changed upon editor focus, is there a way to either automate this or set a keyboard shortcut from Project/Tools?

Ideally there would be a checkbox in the Qodot Map panel saying "Auto full build on map changed" or an editor keyboard shortcut...

Thanks

keyle commented 3 years ago

Ok I mate a simple plugin that will regen from anywhere in the editor via CTRL_R.

I think this should be part of the functionality though, if possible.

ref.

func _unhandled_key_input(event: InputEventKey) -> void:
    if event.is_pressed() and event.scancode == KEY_R and event.control:
        var qodot = get_tree().get_edited_scene_root().find_node("QodotMap")
        if not qodot:
            print("no qodot")
            return
        if qodot.has_method("build_map"):
            qodot.build_map()
        else:
            print("could not find build_map method")
Pio64 commented 3 years ago

Related to https://github.com/Shfty/qodot-plugin/issues/91.

Shfty commented 3 years ago

As pio mentioned, resource-based auto reloading is already covered by #91. A hotkey for invoking a full rebuild is a good idea though, so I'll rename this issue to cover that.

In terms of an official implementation, hooking directly into _unhandled_key_input with a hardcoded check doesn't seem like the best approach, since the editor already has a hotkey system that will probably conflict with or execute alongside the plugin-side Control+R if some existing binding is registered with the editor.

A brief sweep of the docs doesn't reveal any obvious API for manipulating editor shortcuts, but EditorSettings is probably a good next place to look. Worst-case, the hotkey can be stored in a regular Qodot EditorSettings section and handled manually.

There's also the ShortCut resource type that can couple a key combination to a UI control, which could be a usable entrypoint if applied to the Full Build button in the top bar.

Will need to do some more research and see what the best approach is.