diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index a620dc0feff..0544fd6ba8b 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -2175,6 +2175,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ if (takeover_paths) { r->set_path(p_path+"::"+itos(r->get_subindex()),true); } +#ifdef TOOLS_ENABLED + r->set_edited(false); +#endif } else { save_unicode_string(r->get_path()); //actual external } diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 0d545b16f58..44fbaf02acc 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -2800,6 +2800,10 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res if (takeover_paths) { res->set_path(p_path+"::"+itos(idx),true); } +#ifdef TOOLS_ENABLED + res->set_edited(false); +#endif + } write_string("\n",false); diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index b55ebf2ffcf..58afeef3e37 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -117,6 +117,9 @@ void unregister_visual_script_types() { ScriptServer::unregister_language(visual_script_language); +#ifdef TOOLS_ENABLED + VisualScriptEditor::free_clipboard(); +#endif if (visual_script_language) memdelete( visual_script_language ); diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 312abdf39bc..aa09e7f0053 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -907,6 +907,9 @@ void VisualScript::_update_placeholders() { for (Map::Element *E=variables.front();E;E=E->next()) { + if (!E->get()._export) + continue; + PropertyInfo p = E->get().info; p.name=SCRIPT_VARIABLES_PREFIX+String(E->key()); pinfo.push_back(p); @@ -940,6 +943,9 @@ ScriptInstance* VisualScript::instance_create(Object *p_this) { for (Map::Element *E=variables.front();E;E=E->next()) { + if (!E->get()._export) + continue; + PropertyInfo p = E->get().info; p.name=SCRIPT_VARIABLES_PREFIX+String(E->key()); pinfo.push_back(p); @@ -1110,6 +1116,20 @@ void VisualScript::get_script_property_list(List *p_list) const { } } +bool VisualScript::are_subnodes_edited() const { + + for(const Map::Element *E=functions.front();E;E=E->next()) { + + for (const Map::Element *F=E->get().nodes.front();F;F=F->next()) { + if (F->get().node->is_edited()) { + return true; + } + } + } + + return false; +} + void VisualScript::_set_data(const Dictionary& p_data) { diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 8f541a367bf..9e96967c6f2 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -342,6 +342,7 @@ public: virtual void get_script_property_list(List *p_list) const; + virtual bool are_subnodes_edited() const; VisualScript(); ~VisualScript(); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 01e26a66280..7f09a265fba 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2127,7 +2127,8 @@ Ref VisualScriptEditor::get_icon(){ bool VisualScriptEditor::is_unsaved(){ #ifdef TOOLS_ENABLED - return script->is_edited(); + + return script->is_edited() || script->are_subnodes_edited(); #else return false; #endif @@ -2722,9 +2723,9 @@ void VisualScriptEditor::_menu_option(int p_what) { if (!script->has_function(edited_func)) break; - clipboard.nodes.clear(); - clipboard.data_connections.clear(); - clipboard.sequence_connections.clear(); + clipboard->nodes.clear(); + clipboard->data_connections.clear(); + clipboard->sequence_connections.clear(); for(int i=0;iget_child_count();i++) { GraphNode *gn = graph->get_child(i)->cast_to(); @@ -2738,15 +2739,15 @@ void VisualScriptEditor::_menu_option(int p_what) { return; } if (node.is_valid()) { - clipboard.nodes[id]=node->duplicate(); - clipboard.nodes_positions[id]=script->get_node_pos(edited_func,id); + clipboard->nodes[id]=node->duplicate(); + clipboard->nodes_positions[id]=script->get_node_pos(edited_func,id); } } } } - if (clipboard.nodes.empty()) + if (clipboard->nodes.empty()) break; List sequence_connections; @@ -2755,9 +2756,9 @@ void VisualScriptEditor::_menu_option(int p_what) { for (List::Element *E=sequence_connections.front();E;E=E->next()) { - if (clipboard.nodes.has(E->get().from_node) && clipboard.nodes.has(E->get().to_node)) { + if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard.sequence_connections.insert(E->get()); + clipboard->sequence_connections.insert(E->get()); } } @@ -2767,9 +2768,9 @@ void VisualScriptEditor::_menu_option(int p_what) { for (List::Element *E=data_connections.front();E;E=E->next()) { - if (clipboard.nodes.has(E->get().from_node) && clipboard.nodes.has(E->get().to_node)) { + if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard.data_connections.insert(E->get()); + clipboard->data_connections.insert(E->get()); } } @@ -2783,7 +2784,7 @@ void VisualScriptEditor::_menu_option(int p_what) { if (!script->has_function(edited_func)) break; - if (clipboard.nodes.empty()) { + if (clipboard->nodes.empty()) { EditorNode::get_singleton()->show_warning("Clipboard is empty!"); break; } @@ -2806,7 +2807,7 @@ void VisualScriptEditor::_menu_option(int p_what) { } } - for (Map >::Element *E=clipboard.nodes.front();E;E=E->next()) { + for (Map >::Element *E=clipboard->nodes.front();E;E=E->next()) { Ref node = E->get()->duplicate(); @@ -2816,7 +2817,7 @@ void VisualScriptEditor::_menu_option(int p_what) { remap[E->key()]=new_id; - Vector2 paste_pos = clipboard.nodes_positions[E->key()]; + Vector2 paste_pos = clipboard->nodes_positions[E->key()]; while(existing_positions.has(paste_pos.snapped(Vector2(2,2)))) { paste_pos+=Vector2(20,20)*EDSCALE; @@ -2828,7 +2829,7 @@ void VisualScriptEditor::_menu_option(int p_what) { } - for (Set::Element *E=clipboard.sequence_connections.front();E;E=E->next()) { + for (Set::Element *E=clipboard->sequence_connections.front();E;E=E->next()) { undo_redo->add_do_method(script.ptr(),"sequence_connect",edited_func,remap[E->get().from_node],E->get().from_output,remap[E->get().to_node]); @@ -2836,7 +2837,7 @@ void VisualScriptEditor::_menu_option(int p_what) { } - for (Set::Element *E=clipboard.data_connections.front();E;E=E->next()) { + for (Set::Element *E=clipboard->data_connections.front();E;E=E->next()) { undo_redo->add_do_method(script.ptr(),"data_connect",edited_func,remap[E->get().from_node],E->get().from_port,remap[E->get().to_node],E->get().to_port); @@ -2921,6 +2922,9 @@ void VisualScriptEditor::_bind_methods() { VisualScriptEditor::VisualScriptEditor() { + if (!clipboard) { + clipboard = memnew( Clipboard ); + } updating_graph=false; edit_menu = memnew( MenuButton ); @@ -3107,6 +3111,14 @@ static ScriptEditorBase * create_editor(const Ref