live debug fixes

removing node in live debugging fixed
This commit is contained in:
Juan Linietsky 2015-08-02 20:28:10 -03:00
parent 59961c9914
commit cbee679bd7
8 changed files with 105 additions and 23 deletions

View File

@ -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 {

View File

@ -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);
};

View File

@ -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++;

View File

@ -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);
}
}

View File

@ -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:

View File

@ -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);

View File

@ -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);
}

View File

@ -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();