From 9c6175db11ff72603ae58789a462b33ec1e910f8 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 25 Aug 2016 17:45:20 -0300 Subject: More visual script work -Block switches to 2d/3d editor if editing visual script -Added cast node in flow control -Added ability to do RPC in visual script -Comment nodes -Fix bug with inverted cable in connecting backwards -Copy and paste nodes, including from different scripts --- core/object.cpp | 121 +++- core/object.h | 8 + core/object_type_db.cpp | 2 +- core/script_language.cpp | 1 + core/script_language.h | 6 + modules/gdscript/gd_script.cpp | 9 + modules/gdscript/gd_script.h | 2 + modules/visual_script/register_types.cpp | 8 +- modules/visual_script/visual_script.cpp | 67 +- modules/visual_script/visual_script.h | 3 + modules/visual_script/visual_script_editor.cpp | 205 +++++- modules/visual_script/visual_script_editor.h | 14 + .../visual_script/visual_script_flow_control.cpp | 193 +++++ modules/visual_script/visual_script_flow_control.h | 47 ++ modules/visual_script/visual_script_func_nodes.cpp | 806 ++++++++++++++++----- modules/visual_script/visual_script_func_nodes.h | 50 +- modules/visual_script/visual_script_nodes.cpp | 171 +++++ modules/visual_script/visual_script_nodes.h | 49 ++ .../visual_script/visual_script_yield_nodes.cpp | 15 +- modules/visual_script/visual_script_yield_nodes.h | 1 + scene/gui/control.cpp | 9 +- scene/gui/control.h | 6 + scene/gui/graph_edit.cpp | 12 + scene/gui/graph_edit.h | 2 + scene/gui/graph_node.cpp | 77 +- scene/gui/graph_node.h | 14 + scene/resources/default_theme/default_theme.cpp | 3 + .../resources/default_theme/graph_node_comment.png | Bin 0 -> 506 bytes scene/resources/default_theme/theme_data.h | 10 + scene/resources/default_theme/window_resizer.png | Bin 0 -> 181 bytes tools/editor/editor_node.cpp | 2 +- tools/editor/plugins/script_editor_plugin.cpp | 29 +- tools/editor/plugins/script_editor_plugin.h | 7 +- tools/editor/property_editor.cpp | 1 + tools/editor/property_selector.cpp | 1 + 35 files changed, 1703 insertions(+), 248 deletions(-) create mode 100644 scene/resources/default_theme/graph_node_comment.png create mode 100644 scene/resources/default_theme/window_resizer.png diff --git a/core/object.cpp b/core/object.cpp index 26319d42dd..b036efa501 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -59,30 +59,112 @@ struct _ObjectDebugLock { #endif + +PropertyInfo::operator Dictionary() const { + + Dictionary d; + d["name"]=name; + d["type"]=type; + d["hint"]=hint; + d["hint_string"]=hint_string; + d["usage"]=usage; + return d; + +} + +PropertyInfo PropertyInfo::from_dict(const Dictionary& p_dict) { + + PropertyInfo pi; + + if (p_dict.has("type")) + pi.type=Variant::Type(int(p_dict["type"])); + + if (p_dict.has("name")) + pi.name=p_dict["name"]; + + if (p_dict.has("hint")) + pi.hint=PropertyHint(int(p_dict["hint"])); + + if (p_dict.has("hint_string")) + + pi.hint_string=p_dict["hint_string"]; + + if (p_dict.has("usage")) + pi.usage=p_dict["usage"]; + + return pi; +} + + Array convert_property_list(const List * p_list) { Array va; for (const List::Element *E=p_list->front();E;E=E->next()) { - const PropertyInfo &pi = E->get(); - Dictionary d; - d["name"]=pi.name; - d["type"]=pi.type; - d["hint"]=pi.hint; - d["hint_string"]=pi.hint_string; - d["usage"]=pi.usage; - va.push_back(d); + + va.push_back(Dictionary(E->get())); } return va; } +MethodInfo::operator Dictionary() const { + + + Dictionary d; + d["name"]=name; + d["args"]=convert_property_list(&arguments); + Array da; + for(int i=0;i::Element *E=ml.front();E;E=E->next()) { - Dictionary d = _get_dict_from_method(E->get()); + Dictionary d = E->get(); //va.push_back(d); ret.push_back(d); } @@ -1305,7 +1368,7 @@ Array Object::_get_signal_list() const{ Array ret; for (List::Element *E=signal_list.front();E;E=E->next()) { - ret.push_back(_get_dict_from_method(E->get())); + ret.push_back(Dictionary(E->get())); } return ret; diff --git a/core/object.h b/core/object.h index 6ea794ec71..ac3fc51b3e 100644 --- a/core/object.h +++ b/core/object.h @@ -126,6 +126,11 @@ struct PropertyInfo { _FORCE_INLINE_ PropertyInfo added_usage(int p_fl) const { PropertyInfo pi=*this; pi.usage|=p_fl; return pi; } + + operator Dictionary() const; + + static PropertyInfo from_dict(const Dictionary& p_dict); + PropertyInfo() { type=Variant::NIL; hint=PROPERTY_HINT_NONE; usage = PROPERTY_USAGE_DEFAULT; } PropertyInfo( Variant::Type p_type, const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_string="",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) { type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage; @@ -150,6 +155,9 @@ struct MethodInfo { inline bool operator<(const MethodInfo& p_method) const { return id==p_method.id?(name < p_method.name):(id *p_li TypeInfo *check=type; while(check) { - for(List::Element *E=type->property_list.front();E;E=E->next()) { + for(List::Element *E=check->property_list.front();E;E=E->next()) { if (p_validator) { diff --git a/core/script_language.cpp b/core/script_language.cpp index 75d8b6d285..fa1d01d3eb 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -33,6 +33,7 @@ int ScriptServer::_language_count=0; bool ScriptServer::scripting_enabled=true; bool ScriptServer::reload_scripts_on_save=false; +ScriptEditRequestFunction ScriptServer::edit_request_func=NULL; void Script::_notification( int p_what) { diff --git a/core/script_language.h b/core/script_language.h index 36ed11efec..1b037e908c 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -38,6 +38,8 @@ class ScriptLanguage; +typedef void (*ScriptEditRequestFunction)(const String& p_path); + class ScriptServer { enum { @@ -50,6 +52,8 @@ class ScriptServer { static bool reload_scripts_on_save; public: + static ScriptEditRequestFunction edit_request_func; + static void set_scripting_enabled(bool p_enabled); static bool is_scripting_enabled(); static int get_language_count(); @@ -88,6 +92,8 @@ public: virtual bool can_instance() const=0; + virtual Ref