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

Add a signal connection dialog for autoloads/singletons #1694

Open
kodkuce opened this issue Oct 20, 2020 · 3 comments
Open

Add a signal connection dialog for autoloads/singletons #1694

kodkuce opened this issue Oct 20, 2020 · 3 comments

Comments

@kodkuce
Copy link

kodkuce commented Oct 20, 2020

Describe the project you are working on:
Project with singletons and signals

Describe the problem or limitation you are having in your project:
I can not connect an signal to Singleton node mothod

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
So limitation is for each button i would now need to make a script and in script a method
that will call that signal/delagate on Singleton instance...

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Hmm my proposal would work this way, we add a TextField named oweridePath
that will be empty by default and ignored, but if you put text in it it will be used similar as connect
method "<source_node>.connect(<signal_name>, <target_node>, <target_function_name>)".
So this way i when i click on button_up() signal i can in oweridePath type /root/MySingleton/method
and it will work np :)

If this enhancement will not be used often, can it be worked around with a few lines of script?:
My issue is i think this enchantment will be used a lot, cuz you can have a lot of signal connections,
but ye you can create a class for each button just to connect it to SIngleton

Is there a reason why this should be core and not an add-on in the asset library?:
Because adding one TextField in dialog has no bad effect

@Calinou Calinou changed the title Signal dialog with Singleton Add a signal connection dialogs for autoloads/singletons Oct 20, 2020
@Calinou Calinou changed the title Add a signal connection dialogs for autoloads/singletons Add a signal connection dialog for autoloads/singletons Oct 20, 2020
@KoBeWi
Copy link
Member

KoBeWi commented Oct 20, 2020

Other way around could be useful too, i.e. connecting autoload signal to a node.

@kodkuce
Copy link
Author

kodkuce commented Oct 29, 2020

For anyone looking for simple workaround, i made class you can attach to any node
and just type path. it uses an array so you can connect multiple stuff, i use this mainly
on buttons to connect to Singleton but can be used for anything i guess

Example on slider:
Image of script in editor

using Godot;
using System;

public class CustomNodeSignals : Node
{
    [Export]
    public string[] connections;

    public override void _Ready()
    {
        foreach( string c in connections)
        {
            string[] parts = c.Split(';');
            if( parts.Length == 3)
            {
                Node n = GetNode(parts[1]);
                Connect( parts[0], n, parts[2] );
            }
        }
    }
}

I tried to chop C++ source but from what i see, possible i got it wrong, but there
connection is somehow attached prestart and i don't have ref to Singleton until runtime :(

@cgbeutler
Copy link

cgbeutler commented Nov 21, 2020

I imagine this could also be expanded to cover a few other popups, like the "NodePath" popup dialog, though maybe each dialog with the missing singletons would need its own issue.

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

No branches or pull requests

4 participants