godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 97 forks source link

Interactive Plugins: let our plugins listen to mouse and keyboard input and then exit. #2528

Open atursams opened 3 years ago

atursams commented 3 years ago

Describe the project you are working on

A plugin that speeds up level editing when tiles are not suitable.

Describe the problem or limitation you are having in your project

Unable to run a plugin that will listen to user input and perform mundane routine tasks like a simple interactive macro. This question describes it.

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

Allowing plugins to launch and listen to keyboard and mouse input and perform routine tasks within the editor.

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

This will work like a Godot game with access to the scene node. You "run" this "game". Within the "game" (plugin) , the plugin's creator has "full" control over the scene tree. You can have mouse clicks and keyboard input create and edit exiting nodes as you desire. When you exit the game (interactive plugin) , you store your (state) creation into the scene tree as nodes with export attributes.

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

I think I can write an actual Godot game and have it store it's state as a text file and then copy paste that text file into a Godot tool or a Godot EditorScript and then hope for the best. What I'm looking for is something that directly allows full interactivity with the editor without writing new Engine code.

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

This a feature proposal for add-on assets

atursams commented 3 years ago

This is the closest I found. It seems that this is possible but clunky? Perhaps the enhancement should be in the documentation to properly guide users on how to make interactive plugins that use the mouse and keyboard input to manipulate the editor? listening to mouse

Again it might be that beginner knowledge is so widely available and searched that this advanced topic isn't covered right.

YuriSizov commented 3 years ago

For keyboard you can create shortcuts as normal. Mouse events are propagated, so to capture all of them you can create an overlay control over the top of the editor window. But if you only want to interact with the 2d or 3d viewports, there is a specific API for that already.

So I don't see from your description what the limitation you experience is.

atursams commented 3 years ago

@pycbouh Unless I miss something, I don't think creating shortcuts is an alternative. The issue is that this is supposed to be a tool you can step into and out of. If I understand correctly shortcuts remain the same? So this keyboard input should only be triggering a specific behavior within the scope of the tool.

Also, I linked to a question about this suggesting that listening to mouse behavior like this doesn't really provide the needed result because it ignores the editor state like zoom and such. Like I said, I might be looking for something trivial but from what I know so far it is not designed to create a new interactive editing experience within the editor.

atursams commented 3 years ago

Maybe I should better explain one of my use cases and there is a specific simple solution for this. One of my issues is relationships between nodes. Currently if there is a relationship between two nodes in a game or a level (eg. power moving between structures or a monster assigned to protect a moving or stationary object) I add an export var and select the target.

However, these are simple examples and in actuality I'm dealing with a complex directional relationship graph between platforms (monster can jump from platform A to platform B) and doing the assignment by hand during level editing is tedious. Having an option to write a tool where I could simply left click to select an item and then right click to select the item it relates to would be beautiful, simple and quick. This is of course just one example of free form editing scenario that could be facilitated with this when in actuality this could be used to extend the editing capabilities in any non-tile based scenario.

YuriSizov commented 3 years ago

The plugin API I've linked can be used for that.

As for shortcuts, yes, they are static, but I fail to see what good capturing an arbitrary keyboard input would be in this particular case. Maybe though what you imagine is closer to the command palette proposal and the way it can be integrated into the plugin API (https://github.com/godotengine/godot-proposals/issues/70, https://github.com/godotengine/godot-proposals/issues/1444, https://github.com/godotengine/godot-proposals/issues/2105).

atursams commented 3 years ago

@pycbouh

  1. It would allow better handling of Ctrl+Click and Shift+Click which I'm guessing aren't supported?
  2. It is good because it would allow to create an interactive editing experience that is specifically suited for a scenario.
  3. Click on a tree or a shrub within the tool and replace it with a bigger (pre-modeled) one by pressing up.
  4. Click on some monster and make it follow another monster by pressing 'F' and clicking on the other monster.

It would provide a freedom to create an editing experience that is fast and natural and feels like a game, avoiding many clicks. I really don't see how tool specific behavior and static shortcuts are on the same playing field when it comes to designing an additional interactive editing experience on top of the existing Godot Editor.

Are you a level designer? Do you not want custom specific keyboard shortcuts for different editing situations? Do you know this guy? Some people just appreciate having context specific shortcuts during editing more than others. That is why a lot of people use this device for things other than streaming.

Customizing your editing experience might be a form of procrastination but it is definitely popular and a lot of productive people use it ardently.

Is there a demo tut for that plugin API? Thanks. Like I said, I read that it has problems with zoom, offsets and general window navigation. Wouldn't mind diving into it if it can solve 99% of the problem I'm having. :D

YuriSizov commented 3 years ago

Click on some monster and make it follow another monster by pressing 'F' and clicking on the other monster.

That's still a static shortcut bound to the key F, and you can already do that. What you described initially sounded like you want to capture all the keyboard input as if you were making a text editor. But if you want to create custom shortcuts for custom plugin actions, you can already.

As for using mouse for shortcuts, it's not possible in 3.x, but it is possible in 4.x.

Is there a demo tut for that plugin API? Thanks.

Not sure, but you can probably look at other plugins that work with the viewport space, or ask for help on Discord.

atursams commented 3 years ago

Thanks! I admit these details are not heavily documented and shared. So it basically means that all the stuff I asked for already exists but it not terribly well taught through tutorials and such?

If so would is moving this to the documentation area and suggesting I prepare some tutorial on this a good suggestion?

YuriSizov commented 3 years ago

I don't think this all is badly documented, but maybe it's an angle-that-you-look-at-it kind of issue.

You can make a tutorial on the matter from your perspective, but I can't guarantee we will include it in the official docs, as we are currently trying to trim the docs down and would prefer tutorials and guides, unless essential, to be hosted outside of the docs themselves. If it's turns to be a good doc we can link to it directly from the class reference though.

So it basically means that all the stuff I asked for already exists

And yes, I think so. Or it's covered by other proposals such as the editor actions one and its satellites that I've linked before.