diff options
Diffstat (limited to 'tools/editor/connections_dialog.cpp')
-rw-r--r-- | tools/editor/connections_dialog.cpp | 156 |
1 files changed, 106 insertions, 50 deletions
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index cf4b21510a..b0bacdae61 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -172,7 +172,7 @@ void ConnectDialog::ok_pressed() { if (dst_method->get_text()=="") { error->set_text("Method in target Node must be specified!"); - error->popup_centered(Size2(300,80)); + error->popup_centered_minsize(); return; } emit_signal("connected"); @@ -530,7 +530,7 @@ void ConnectionsDialog::ok_pressed() { get_ok()->set_disabled(true); return; } - if (item->get_parent()==tree->get_root()) { + 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 signalname=signal; @@ -632,74 +632,130 @@ void ConnectionsDialog::update_tree() { node->get_signal_list(&node_signals); //node_signals.sort_custom<_ConnectionsDialogMethodInfoSort>(); + bool did_script=false; + StringName base = node->get_type(); - for(List<MethodInfo>::Element *E=node_signals.front();E;E=E->next()) { - + while(base) { + + List<MethodInfo> node_signals; + Ref<Texture> icon; + String name; - MethodInfo &mi =E->get(); + if (!did_script) { - String signaldesc; - signaldesc=mi.name+"("; - StringArray argnames; - if (mi.arguments.size()) { - signaldesc+=" "; - for(int i=0;i<mi.arguments.size();i++) { + Ref<Script> scr = node->get_script(); + if (scr.is_valid()) { + scr->get_script_signal_list(&node_signals); + if (scr->get_path().is_resource_file()) + name=scr->get_path().get_file(); + else + name=scr->get_type(); - PropertyInfo &pi = mi.arguments[i]; + if (has_icon(scr->get_type(),"EditorIcons")) { + icon=get_icon(scr->get_type(),"EditorIcons"); + } + } - if (i>0) - signaldesc+=", "; - signaldesc+=Variant::get_type_name(pi.type)+" "+(pi.name==""?String("arg "+itos(i)):pi.name); - argnames.push_back(pi.name); + } else { + ObjectTypeDB::get_signal_list(base,&node_signals,true); + if (has_icon(base,"EditorIcons")) { + icon=get_icon(base,"EditorIcons"); } - signaldesc+=" "; + name=base; } - signaldesc+=")"; - - TreeItem *item=tree->create_item(root); - item->set_text(0,signaldesc); - Dictionary sinfo; - sinfo["name"]=mi.name; - sinfo["args"]=argnames; - item->set_metadata(0,sinfo); - item->set_icon(0,get_icon("Signal","EditorIcons")); - List<Object::Connection> connections; - node->get_signal_connection_list(mi.name,&connections); + TreeItem *pitem = NULL; + + if (node_signals.size()) { + pitem=tree->create_item(root); + pitem->set_text(0,name); + pitem->set_icon(0,icon); + pitem->set_selectable(0,false); + pitem->set_editable(0,false); + pitem->set_custom_bg_color(0,get_color("prop_subsection","Editor")); + node_signals.sort(); + } - for(List<Object::Connection>::Element *F=connections.front();F;F=F->next()) { + for(List<MethodInfo>::Element *E=node_signals.front();E;E=E->next()) { - Object::Connection&c = F->get(); - if (!(c.flags&CONNECT_PERSIST)) - continue; - Node *target = c.target->cast_to<Node>(); - if (!target) - continue; + MethodInfo &mi =E->get(); - String path = String(node->get_path_to(target))+" :: "+c.method+"()"; - if (c.flags&CONNECT_DEFERRED) - path+=" (deferred)"; - if (c.binds.size()) { + String signaldesc; + signaldesc=mi.name+"("; + StringArray argnames; + if (mi.arguments.size()) { + signaldesc+=" "; + for(int i=0;i<mi.arguments.size();i++) { - path+=" binds( "; - for(int i=0;i<c.binds.size();i++) { + PropertyInfo &pi = mi.arguments[i]; if (i>0) - path+=", "; - path+=c.binds[i].operator String(); + signaldesc+=", "; + String tname="var"; + if (pi.type!=Variant::NIL) { + tname=Variant::get_type_name(pi.type); + } + signaldesc+=tname+" "+(pi.name==""?String("arg "+itos(i)):pi.name); + argnames.push_back(pi.name); + } - path+=" )"; + signaldesc+=" "; } - TreeItem *item2=tree->create_item(item); - item2->set_text(0,path); - item2->set_metadata(0,c); - item2->set_icon(0,get_icon("Slot","EditorIcons")); + signaldesc+=")"; + + TreeItem *item=tree->create_item(pitem); + item->set_text(0,signaldesc); + Dictionary sinfo; + sinfo["name"]=mi.name; + sinfo["args"]=argnames; + item->set_metadata(0,sinfo); + item->set_icon(0,get_icon("Signal","EditorIcons")); + + List<Object::Connection> connections; + node->get_signal_connection_list(mi.name,&connections); + for(List<Object::Connection>::Element *F=connections.front();F;F=F->next()) { + + Object::Connection&c = F->get(); + if (!(c.flags&CONNECT_PERSIST)) + continue; + + Node *target = c.target->cast_to<Node>(); + if (!target) + continue; + + String path = String(node->get_path_to(target))+" :: "+c.method+"()"; + if (c.flags&CONNECT_DEFERRED) + path+=" (deferred)"; + if (c.binds.size()) { + + path+=" binds( "; + for(int i=0;i<c.binds.size();i++) { + + if (i>0) + path+=", "; + path+=c.binds[i].operator String(); + } + path+=" )"; + } + + TreeItem *item2=tree->create_item(item); + item2->set_text(0,path); + item2->set_metadata(0,c); + item2->set_icon(0,get_icon("Slot","EditorIcons")); + + + } + } + if (!did_script) { + did_script=true; + } else { + base=ObjectTypeDB::type_inherits_from(base); } } @@ -722,7 +778,7 @@ void ConnectionsDialog::_something_selected() { get_ok()->set_text("Connect.."); get_ok()->set_disabled(true); - } else if (item->get_parent()==tree->get_root()) { + } else if (item->get_parent()==tree->get_root() || item->get_parent()->get_parent()==tree->get_root()) { //a signal - connect get_ok()->set_text("Connect.."); get_ok()->set_disabled(false); |