From 10881802bab109e076577edda3b9a86226367cda Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Sun, 12 Jun 2016 01:01:17 +0200 Subject: ConnectionsDock: Double click to create and go to signal connection --- tools/editor/connections_dialog.cpp | 49 +++++++++++++++++++++++++++ tools/editor/connections_dialog.h | 1 + tools/editor/plugins/script_editor_plugin.cpp | 45 ++++++++++++++++++++++++ tools/editor/plugins/script_editor_plugin.h | 2 ++ 4 files changed, 97 insertions(+) (limited to 'tools') diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index e2b8f2884f..d2d5c0b542 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -35,6 +35,7 @@ #include "print_string.h" #include "editor_settings.h" #include "editor_node.h" +#include "plugins/script_editor_plugin.h" class ConnectDialogBinds : public Object { @@ -808,11 +809,58 @@ void ConnectionsDock::_something_selected() { } +void ConnectionsDock::_something_activated() { + + TreeItem *item = tree->get_selected(); + + if (!item) + return; + + if (item->get_parent()==tree->get_root() || item->get_parent()->get_parent()==tree->get_root()) { + // a signal - connect + String signal=item->get_metadata(0).operator Dictionary()["name"]; + String midname=node->get_name(); + for(int i=0;i='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_') { + //all good + } else if (c==' ') { + c='_'; + } else { + midname.remove(i); + i--; + continue; + } + + midname[i]=c; + } + + connect_dialog->edit(node); + connect_dialog->popup_centered_ratio(); + connect_dialog->set_dst_method("_on_"+midname+"_"+signal); + connect_dialog->set_dst_node(node->get_owner()?node->get_owner():node); + } else { + // a slot - go to target method + Connection c=item->get_metadata(0); + ERR_FAIL_COND(c.source!=node); //shouldn't happen but...bugcheck + + if (!c.target) + return; + + Ref