summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-08-02 20:28:10 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-08-02 20:28:10 -0300
commitcbee679bd78c1b3317db1ea4e349f278576304a1 (patch)
tree862e1d13df996bd0d06fc2e97073e74ea78ec284 /scene/main
parent59961c99144523d7cc2881a4abe6d0a319a975df (diff)
live debug fixes
removing node in live debugging fixed
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/node.cpp9
-rw-r--r--scene/main/scene_main_loop.cpp77
-rw-r--r--scene/main/scene_main_loop.h5
3 files changed, 86 insertions, 5 deletions
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: