diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-08-02 20:28:10 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-08-02 20:28:10 -0300 |
commit | cbee679bd78c1b3317db1ea4e349f278576304a1 (patch) | |
tree | 862e1d13df996bd0d06fc2e97073e74ea78ec284 | |
parent | 59961c99144523d7cc2881a4abe6d0a319a975df (diff) |
live debug fixes
removing node in live debugging fixed
-rw-r--r-- | core/script_debugger_remote.cpp | 8 | ||||
-rw-r--r-- | core/script_language.h | 2 | ||||
-rw-r--r-- | scene/main/node.cpp | 9 | ||||
-rw-r--r-- | scene/main/scene_main_loop.cpp | 77 | ||||
-rw-r--r-- | scene/main/scene_main_loop.h | 5 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 6 | ||||
-rw-r--r-- | tools/editor/script_editor_debugger.cpp | 19 | ||||
-rw-r--r-- | tools/editor/script_editor_debugger.h | 2 |
8 files changed, 105 insertions, 23 deletions
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 15861ed4a1..15be8b1d00 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -310,19 +310,19 @@ bool ScriptDebuggerRemote::_parse_live_edit(const Array& cmd) { return false; - print_line(Variant(cmd).get_construct_string()); + //print_line(Variant(cmd).get_construct_string()); if (cmdstr=="live_set_root") { if (!live_edit_funcs->root_func) return true; - print_line("root: "+Variant(cmd).get_construct_string()); + //print_line("root: "+Variant(cmd).get_construct_string()); live_edit_funcs->root_func(live_edit_funcs->udata,cmd[1],cmd[2]); } else if (cmdstr=="live_node_path") { if (!live_edit_funcs->node_path_func) return true; - print_line("path: "+Variant(cmd).get_construct_string()); + //print_line("path: "+Variant(cmd).get_construct_string()); live_edit_funcs->node_path_func(live_edit_funcs->udata,cmd[1],cmd[2]); @@ -392,7 +392,7 @@ bool ScriptDebuggerRemote::_parse_live_edit(const Array& cmd) { live_edit_funcs->tree_duplicate_node_func(live_edit_funcs->udata,cmd[1],cmd[2]); } else if (cmdstr=="live_reparent_node") { - live_edit_funcs->tree_reparent_node_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]); + live_edit_funcs->tree_reparent_node_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3],cmd[4]); } else { diff --git a/core/script_language.h b/core/script_language.h index 8b0ed2c33b..d5fb83deb1 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -258,7 +258,7 @@ public: void (*tree_remove_and_keep_node_func)(void*,const NodePath& p_at,ObjectID p_keep_id); void (*tree_restore_node_func)(void*,ObjectID p_id,const NodePath& p_at,int p_at_pos); void (*tree_duplicate_node_func)(void*,const NodePath& p_at,const String& p_new_name); - void (*tree_reparent_node_func)(void*,const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name); + void (*tree_reparent_node_func)(void*,const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos); }; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 5e0faae0a2..8336ce35f6 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -224,6 +224,15 @@ void Node::_propagate_exit_tree() { data.tree->live_scene_edit_cache.erase(E); } } + + Map<Node*,Map<ObjectID,Node*> >::Element *F=data.tree->live_edit_remove_list.find(this); + if (F) { + for (Map<ObjectID,Node*>::Element*G=F->get().front();G;G=G->next()) { + + memdelete(G->get()); + } + data.tree->live_edit_remove_list.erase(F); + } } #endif data.blocked++; diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index 9a05d6d4d0..45e3d92ece 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -1203,7 +1203,7 @@ void SceneTree::_live_edit_create_node_func(const NodePath& p_parent,const Strin void SceneTree::_live_edit_instance_node_func(const NodePath& p_parent,const String& p_path,const String& p_name){ Ref<PackedScene> ps = ResourceLoader::load(p_path); - print_line("instance node?"); + if (!ps.is_valid()) return; @@ -1265,11 +1265,81 @@ void SceneTree::_live_edit_remove_node_func(const NodePath& p_at){ } void SceneTree::_live_edit_remove_and_keep_node_func(const NodePath& p_at,ObjectID p_keep_id){ + Node *base = NULL; + if (root->has_node(live_edit_root)) + base = root->get_node(live_edit_root); + + Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene); + if (!E) + return; //scene not editable + + + for(Set<Node*>::Element *F=E->get().front();F;) { + + Set<Node*>::Element *N=F->next(); + + Node *n=F->get(); + if (base && !base->is_a_parent_of(n)) + continue; + + if (!n->has_node(p_at)) + continue; + + Node *n2 = n->get_node(p_at); + + n2->get_parent()->remove_child(n2); + + live_edit_remove_list[n][p_keep_id]=n2; + + F=N; + + } } void SceneTree::_live_edit_restore_node_func(ObjectID p_id,const NodePath& p_at,int p_at_pos){ + Node *base = NULL; + if (root->has_node(live_edit_root)) + base = root->get_node(live_edit_root); + + Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene); + if (!E) + return; //scene not editable + + for(Set<Node*>::Element *F=E->get().front();F;) { + + Set<Node*>::Element *N=F->next(); + + Node *n=F->get(); + + if (base && !base->is_a_parent_of(n)) + continue; + + if (!n->has_node(p_at)) + continue; + Node *n2 = n->get_node(p_at); + + Map<Node*,Map<ObjectID,Node*> >::Element *EN=live_edit_remove_list.find(n); + + if (!EN) + continue; + + Map<ObjectID,Node*>::Element *FN=EN->get().find(p_id); + + if (!FN) + continue; + n2->add_child(FN->get()); + + EN->get().erase(FN); + + if (EN->get().size()==0) { + live_edit_remove_list.erase(EN); + } + + F=N; + + } } void SceneTree::_live_edit_duplicate_node_func(const NodePath& p_at,const String& p_new_name){ @@ -1298,12 +1368,11 @@ void SceneTree::_live_edit_duplicate_node_func(const NodePath& p_at,const String continue; dup->set_name(p_new_name); - n2->get_parent()->add_child(dup); } } -void SceneTree::_live_edit_reparent_node_func(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name){ +void SceneTree::_live_edit_reparent_node_func(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos){ Node *base = NULL; if (root->has_node(live_edit_root)) @@ -1332,6 +1401,8 @@ void SceneTree::_live_edit_reparent_node_func(const NodePath& p_at,const NodePat nfrom->set_name(p_new_name); nto->add_child(nfrom); + if (p_at_pos>=0) + nto->move_child(nfrom,p_at_pos); } } diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h index 94d0abe50f..1f09d9c546 100644 --- a/scene/main/scene_main_loop.h +++ b/scene/main/scene_main_loop.h @@ -173,6 +173,7 @@ friend class Viewport; String live_edit_scene; Map<String,Set<Node*> > live_scene_edit_cache; + Map<Node*,Map<ObjectID,Node*> > live_edit_remove_list; ScriptDebugger::LiveEditFuncs live_edit_funcs; @@ -193,7 +194,7 @@ friend class Viewport; void _live_edit_remove_and_keep_node_func(const NodePath& p_at,ObjectID p_keep_id); void _live_edit_restore_node_func(ObjectID p_id,const NodePath& p_at,int p_at_pos); void _live_edit_duplicate_node_func(const NodePath& p_at,const String& p_new_name); - void _live_edit_reparent_node_func(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name); + void _live_edit_reparent_node_func(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos); static void _live_edit_node_path_funcs(void *self,const NodePath &p_path,int p_id) { reinterpret_cast<SceneTree*>(self)->_live_edit_node_path_func(p_path,p_id); } static void _live_edit_res_path_funcs(void *self,const String &p_path,int p_id) { reinterpret_cast<SceneTree*>(self)->_live_edit_res_path_func(p_path,p_id); } @@ -212,7 +213,7 @@ friend class Viewport; static void _live_edit_remove_and_keep_node_funcs(void* self,const NodePath& p_at,ObjectID p_keep_id) { reinterpret_cast<SceneTree*>(self)->_live_edit_remove_and_keep_node_func(p_at,p_keep_id); } static void _live_edit_restore_node_funcs(void* self,ObjectID p_id,const NodePath& p_at,int p_at_pos) { reinterpret_cast<SceneTree*>(self)->_live_edit_restore_node_func(p_id,p_at,p_at_pos); } static void _live_edit_duplicate_node_funcs(void* self,const NodePath& p_at,const String& p_new_name) { reinterpret_cast<SceneTree*>(self)->_live_edit_duplicate_node_func(p_at,p_new_name); } - static void _live_edit_reparent_node_funcs(void* self,const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name) { reinterpret_cast<SceneTree*>(self)->_live_edit_reparent_node_func(p_at,p_new_place,p_new_name); } + static void _live_edit_reparent_node_funcs(void* self,const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos) { reinterpret_cast<SceneTree*>(self)->_live_edit_reparent_node_func(p_at,p_new_place,p_new_name,p_at_pos); } #endif protected: diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 111d307b8e..ae0b58a665 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -402,7 +402,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); - editor_data->get_undo_redo().add_do_method(sed,"live_debug_duplicate_node",edited_scene->get_path_to(node),edited_scene->get_path_to(parent),attempt); + editor_data->get_undo_redo().add_do_method(sed,"live_debug_duplicate_node",edited_scene->get_path_to(node),attempt); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+attempt)); //parent->add_child(dup); @@ -919,8 +919,8 @@ void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) { ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); String new_name = new_parent->validate_child_name(node->get_name()); - editor_data->get_undo_redo().add_do_method(sed,"live_debug_reparent_node",edited_scene->get_path_to(node),edited_scene->get_path_to(new_parent),new_name); - editor_data->get_undo_redo().add_undo_method(sed,"live_debug_reparent_node",NodePath(String(edited_scene->get_path_to(new_parent))+"/"+new_name),node->get_parent(),node->get_name()); + editor_data->get_undo_redo().add_do_method(sed,"live_debug_reparent_node",edited_scene->get_path_to(node),edited_scene->get_path_to(new_parent),new_name,-1); + editor_data->get_undo_redo().add_undo_method(sed,"live_debug_reparent_node",NodePath(String(edited_scene->get_path_to(new_parent))+"/"+new_name),edited_scene->get_path_to(node->get_parent()),node->get_name(),node->get_index()); editor_data->get_undo_redo().add_do_method(this,"_set_owners",edited_scene,owners); diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index a0ff55e845..a4bd8f3bd7 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -927,7 +927,7 @@ void ScriptEditorDebugger::update_live_edit_root() { void ScriptEditorDebugger::live_debug_create_node(const NodePath& p_parent,const String& p_type,const String& p_name) { - if (connection.is_valid()) { + if (live_debug && connection.is_valid()) { Array msg; msg.push_back("live_create_node"); msg.push_back(p_parent); @@ -939,7 +939,7 @@ void ScriptEditorDebugger::live_debug_create_node(const NodePath& p_parent,const void ScriptEditorDebugger::live_debug_instance_node(const NodePath& p_parent,const String& p_path,const String& p_name){ - if (connection.is_valid()) { + if (live_debug && connection.is_valid()) { Array msg; msg.push_back("live_instance_node"); msg.push_back(p_parent); @@ -951,7 +951,7 @@ void ScriptEditorDebugger::live_debug_instance_node(const NodePath& p_parent,con } void ScriptEditorDebugger::live_debug_remove_node(const NodePath& p_at){ - if (connection.is_valid()) { + if (live_debug && connection.is_valid()) { Array msg; msg.push_back("live_remove_node"); msg.push_back(p_at); @@ -961,9 +961,9 @@ void ScriptEditorDebugger::live_debug_remove_node(const NodePath& p_at){ } void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath& p_at,ObjectID p_keep_id) { - if (connection.is_valid()) { + if (live_debug && connection.is_valid()) { Array msg; - msg.push_back("live_remove_and_keep_mode"); + msg.push_back("live_remove_and_keep_node"); msg.push_back(p_at); msg.push_back(p_keep_id); ppeer->put_var(msg); @@ -972,7 +972,7 @@ void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath& p_at, } void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath& p_at, int p_at_pos){ - if (connection.is_valid()) { + if (live_debug && connection.is_valid()) { Array msg; msg.push_back("live_restore_node"); msg.push_back(p_id); @@ -984,7 +984,7 @@ void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath } void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath& p_at,const String& p_new_name){ - if (connection.is_valid()) { + if (live_debug && connection.is_valid()) { Array msg; msg.push_back("live_duplicate_node"); msg.push_back(p_at); @@ -993,14 +993,15 @@ void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath& p_at,const } } -void ScriptEditorDebugger::live_debug_reparent_node(const NodePath& p_at, const NodePath& p_new_place, const String &p_new_name){ +void ScriptEditorDebugger::live_debug_reparent_node(const NodePath& p_at, const NodePath& p_new_place, const String &p_new_name, int p_at_pos){ - if (connection.is_valid()) { + if (live_debug && connection.is_valid()) { Array msg; msg.push_back("live_reparent_node"); msg.push_back(p_at); msg.push_back(p_new_place); msg.push_back(p_new_name); + msg.push_back(p_at_pos); ppeer->put_var(msg); } diff --git a/tools/editor/script_editor_debugger.h b/tools/editor/script_editor_debugger.h index e8ac0fddb3..cad41ce8a7 100644 --- a/tools/editor/script_editor_debugger.h +++ b/tools/editor/script_editor_debugger.h @@ -159,7 +159,7 @@ public: void live_debug_remove_and_keep_node(const NodePath& p_at,ObjectID p_keep_id); void live_debug_restore_node(ObjectID p_id,const NodePath& p_at,int p_at_pos); void live_debug_duplicate_node(const NodePath& p_at,const String& p_new_name); - void live_debug_reparent_node(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name); + void live_debug_reparent_node(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos); void update_live_edit_root(); |