godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 93 forks source link

Add an ability to copy and paste signal connections #3775

Open me2beats opened 2 years ago

me2beats commented 2 years ago

Describe the project you are working on

A plugin that has UI scenes with many connections. Signals are connected mainly with editor (Node-Signals tab)

Describe the problem or limitation you are having in your project

connection_example

I created a connection for signal item_selected of node OptionButton so that when the signal is emmited, the root node (AnyAll) update_title() method called.

Now I want to create the same connection but for node OptionButton2 (and maybe OptionButton3 if I will create it).

If I do this from Editor, I would create these connections "from scratch", there is no way to copy a signal connection from one node to another.

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

An ability to copy/paste signal connections would solve the problem

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

2 buttons - copy connection and paste connection could be added to connections right-click context menus

copy_connection

Edit Go to Method Disconnect Copy Connection

paste_connection

Connect Disconnect All Paste Connection

All connections settings (deferred, oneshot, arguments etc) could be copied too

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

options could be

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

I don's see an easy way implementing this as a plugin. There is a lack of exposed API for that

Zireael07 commented 2 years ago

I had the same use case problem recently. Another solution would be to allow adding a Node (or NodePath) parameter from the GUI, this would let you reuse the same signal connection for different nodes.

me2beats commented 2 years ago

made it as a plugin https://github.com/me2beats/copy-paste-connections

rossunger commented 2 years ago

made it as a plugin https://github.com/me2beats/copy-paste-connections

This is great! I think this should be core? any reason this shouldn't be core? can someone C++ this please? :)