Exemplo n.º 1
0
void ScenesDock::_favorites_pressed() {

	TreeItem *sel = tree->get_selected();
	if (!sel)
		return ;
	String dir = sel->get_metadata(0);

	int idx = -1;
	Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
	for(int i=0;i<favorites.size();i++) {

		if (favorites[i]==dir) {
			idx=i;
			break;
		}
	}

	if (button_favorite->is_pressed() && idx==-1) {
		favorites.push_back(dir);
		EditorSettings::get_singleton()->set_favorite_dirs(favorites);
		_update_tree();
	} else if (!button_favorite->is_pressed() && idx!=-1) {
		favorites.remove(idx);
		EditorSettings::get_singleton()->set_favorite_dirs(favorites);
		_update_tree();
	}

}
Exemplo n.º 2
0
void SceneTreeEditor::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {

			get_tree()->connect("tree_changed", this, "_tree_changed");
			get_tree()->connect("node_removed", this, "_node_removed");
			get_tree()->connect("node_configuration_warning_changed", this, "_warning_changed");

			tree->connect("item_collapsed", this, "_cell_collapsed");

			_update_tree();
		} break;
		case NOTIFICATION_EXIT_TREE: {

			get_tree()->disconnect("tree_changed", this, "_tree_changed");
			get_tree()->disconnect("node_removed", this, "_node_removed");
			tree->disconnect("item_collapsed", this, "_cell_collapsed");
			get_tree()->disconnect("node_configuration_warning_changed", this, "_warning_changed");
		} break;
		case NOTIFICATION_THEME_CHANGED: {

			_update_tree();
		} break;
	}
}
Exemplo n.º 3
0
void SceneTreeEditor::set_selected(Node *p_node,bool p_emit_selected) {

	ERR_FAIL_COND(blocked>0);

	if (pending_test_update)
		_test_update_tree();
	if (tree_dirty)
		_update_tree();

	if (selected==p_node)
		return;


	TreeItem* item=p_node?_find(tree->get_root(),p_node->get_path()):NULL;

	if (item) {
		item->select(0);
		item->set_as_cursor(0);
		selected=p_node;
		tree->ensure_cursor_is_visible();
	} else {
		if (!p_node)
			selected=NULL;
		_update_tree();
		selected=p_node;
		if (p_emit_selected)
			emit_signal("node_selected");
	}

}
Exemplo n.º 4
0
void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {

	ERR_FAIL_COND(blocked > 0);

	if (pending_test_update)
		_test_update_tree();
	if (tree_dirty)
		_update_tree();

	if (selected == p_node)
		return;

	TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : NULL;

	if (item) {
		// make visible when it's collapsed
		TreeItem *node = item->get_parent();
		while (node && node != tree->get_root()) {
			node->set_collapsed(false);
			node = node->get_parent();
		}
		item->select(0);
		item->set_as_cursor(0);
		selected = p_node;
		tree->ensure_cursor_is_visible();
	} else {
		if (!p_node)
			selected = NULL;
		_update_tree();
		selected = p_node;
		if (p_emit_selected)
			emit_signal("node_selected");
	}
}
Exemplo n.º 5
0
void SceneTreeEditor::set_marked(const Set<Node*>& p_marked,bool p_selectable,bool p_children_selectable) {

	if (tree_dirty)
		_update_tree();
	marked=p_marked;
	marked_selectable=p_selectable;
	marked_children_selectable=p_children_selectable;
	_update_tree();
}
Exemplo n.º 6
0
void SceneTreeEditor::_notification(int p_what) {

	if (p_what==NOTIFICATION_ENTER_TREE) {

		get_tree()->connect("tree_changed",this,"_tree_changed");
		get_tree()->connect("node_removed",this,"_node_removed");
		get_tree()->connect("node_configuration_warning_changed",this,"_warning_changed");

		instance_menu->set_item_icon(5,get_icon("Load","EditorIcons"));
		tree->connect("item_collapsed",this,"_cell_collapsed");
		inheritance_menu->set_item_icon(2,get_icon("Load","EditorIcons"));
		clear_inherit_confirm->connect("confirmed",this,"_subscene_option",varray(SCENE_MENU_CLEAR_INHERITANCE_CONFIRM));

		EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");


//		get_scene()->connect("tree_changed",this,"_tree_changed",Vector<Variant>(),CONNECT_DEFERRED);
//		get_scene()->connect("node_removed",this,"_node_removed",Vector<Variant>(),CONNECT_DEFERRED);
		_update_tree();
	}
	if (p_what==NOTIFICATION_EXIT_TREE) {

		get_tree()->disconnect("tree_changed",this,"_tree_changed");
		get_tree()->disconnect("node_removed",this,"_node_removed");
		tree->disconnect("item_collapsed",this,"_cell_collapsed");
		clear_inherit_confirm->disconnect("confirmed",this,"_subscene_option");
		get_tree()->disconnect("node_configuration_warning_changed",this,"_warning_changed");
		EditorSettings::get_singleton()->disconnect("settings_changed",this,"_editor_settings_changed");
	}

}
Exemplo n.º 7
0
void ScenesDock::open(const String& p_path) {


	String npath;
	String nfile;

	if (p_path.ends_with("/")) {

		if (p_path!="res://")
			npath=p_path.substr(0,p_path.length()-1);
		else
			npath="res://";
	} else {
		nfile=p_path.get_file();
		npath=p_path.get_base_dir();
	}

	path=npath;

	if (tree_mode && nfile=="") {
		_update_tree();
		tree->grab_focus();
		tree->call_deferred("ensure_cursor_is_visible");
		_push_to_history();
		return;
	} else if (tree_mode){
		_update_tree();
		tree->grab_focus();
		tree->ensure_cursor_is_visible();
		_open_pressed();
		current_path->set_text(path);
	} else {
		_update_files(false);
		_push_to_history();
	}

	for(int i=0;i<files->get_item_count();i++) {

		String md = files->get_item_metadata(i);
		if (md==p_path) {
			files->select(i,true);
			files->ensure_current_is_visible();
			break;
		}
	}

}
Exemplo n.º 8
0
void ScenesDock::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {

			if (initialized)
				return;
			initialized=true;

			EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed");

			button_reload->set_icon( get_icon("Reload","EditorIcons"));
			button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
			button_fav_up->set_icon( get_icon("MoveUp","EditorIcons"));
			button_fav_down->set_icon( get_icon("MoveDown","EditorIcons"));
			button_instance->set_icon( get_icon("Add","EditorIcons"));
			button_open->set_icon( get_icon("Folder","EditorIcons"));
			button_back->set_icon( get_icon("Filesystem","EditorIcons"));
			display_mode->set_icon( get_icon("FileList","EditorIcons"));
			display_mode->connect("pressed",this,"_change_file_display");
			file_options->set_icon( get_icon("Tools","EditorIcons"));
			files->connect("item_activated",this,"_select_file");
			button_hist_next->connect("pressed",this,"_fw_history");
			button_hist_prev->connect("pressed",this,"_bw_history");

			button_hist_next->set_icon( get_icon("Forward","EditorIcons"));
			button_hist_prev->set_icon( get_icon("Back","EditorIcons"));
			file_options->get_popup()->connect("item_pressed",this,"_file_option");


			button_back->connect("pressed",this,"_go_to_tree",varray(),CONNECT_DEFERRED);
			current_path->connect("text_entered",this,"_go_to_dir");
			_update_tree(); //maybe it finished already

			if (EditorFileSystem::get_singleton()->is_scanning()) {
				_set_scannig_mode();
			}

		} break;
		case NOTIFICATION_PROCESS: {
			if (EditorFileSystem::get_singleton()->is_scanning()) {
				scanning_progress->set_val(EditorFileSystem::get_singleton()->get_scanning_progress()*100);
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {

		} break;
		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {

			display_mode->set_pressed(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_LIST);

			_change_file_display();
		} break;
	}

}
Exemplo n.º 9
0
void ScenesDock::_go_to_tree() {

	tree->show();
	file_list_vb->hide();
	_update_tree();
	tree->grab_focus();
	tree->ensure_cursor_is_visible();
	button_favorite->show();
	//button_open->hide();
	//file_options->hide();
}
void
dmz::MBRAPluginFaultTreeAutoLayout::_update_tree (
      const Handle SuperHandle,
      const Handle SubHandle,
      const Int32 Column,
      Int32 &count) {

   ObjectModule *objMod (get_object_module ());

   if (objMod && SuperHandle && SubHandle) {

      Vector rootPos (0.0, 0.0, 0.0);

      Vector superPos;
      objMod->lookup_position (SuperHandle, _defaultAttrHandle, superPos);

      Vector offset ((Column * _hOffset), 0.0, (count * _vOffset));
      Vector topPos (rootPos + offset);

      HandleContainer children;
      objMod->lookup_sub_links (SubHandle, _linkAttrHandle, children);

      if (children.get_count ()) {

         Int32 startCount (count);

         Handle current (children.get_first ());

         while (current) {

            _update_tree (SubHandle, current, Column + 1, count);

            current = children.get_next ();
         }

         Int32 endCount (count);

         offset.set_xyz (0.0, 0.0, ((endCount - startCount - 1) * 0.5f * _vOffset));
         objMod->store_position (SubHandle, _defaultAttrHandle, topPos + offset);

         _update_logic (SubHandle);

         _update_path (SubHandle);
      }
      else {

         offset.set_xyz ((Column * _hOffset), 0.0, (count * _vOffset));
         objMod->store_position (SubHandle, _defaultAttrHandle, rootPos + offset);

         count++;
      }
   }
}
Exemplo n.º 11
0
void ScenesDock::_go_to_tree() {

	tree->show();
	files->hide();
	path_hb->hide();
	_update_tree();
	tree->grab_focus();
	tree->ensure_cursor_is_visible();
	button_favorite->show();
	button_fav_up->show();
	button_fav_down->show();
	button_open->hide();
	button_instance->hide();
	button_open->hide();
	file_options->hide();
	tree_mode=true;
}
void
dmz::MBRAPluginFaultTreeAutoLayout::_update_tree () {

   ObjectModule *objMod (get_object_module ());

   if (objMod && _root) {

      HandleContainer children;

      objMod->lookup_sub_links (_root, _linkAttrHandle, children);

      _path = QPainterPath ();

      Int32 count (0);

      Handle current (children.get_first ());

      while (current) {

         _update_tree (_root, current, 1, count);

         current = children.get_next ();
      }

      Vector offset (0.0, 0.0, 0.0);

      if (count) {

         offset.set_z ((count - 1) * 0.5f * _vOffset);
      }

      objMod->store_position (_root, _defaultAttrHandle, offset);

      _update_logic (_root);

      if (children.get_count ()) {

         _update_path (_root);
      }

      if (_pathItem) { _pathItem->setPath (_path); }
   }
}
void
dmz::MBRAPluginFaultTreeAutoLayout::update_object_flag (
      const UUID &Identity,
      const Handle ObjectHandle,
      const Handle AttributeHandle,
      const Boolean Value,
      const Boolean *PreviousValue) {

   if (Value) { _root = ObjectHandle; }

   ObjectModule *objMod = get_object_module ();

   if (objMod) {

      _set_component_hide_state (ObjectHandle, Value ? False : True, *objMod);
   }

   _update_tree ();
}
Exemplo n.º 14
0
void EditorFileSystem::scan() {

    if (bool(Globals::get_singleton()->get("debug/disable_scan")))
           return;

	if (scanning || scanning_sources|| thread)
		return;


	abort_scan=false;
	if (!use_threads) {
		scanning=true;
		_scan_scenes();
		if (rootdir)
			memdelete(rootdir);
		rootdir=scandir;
		if (filesystem)
			memdelete(filesystem);
//		file_type_cache.clear();
		filesystem=_update_tree(rootdir);

		if (rootdir)
			memdelete(rootdir);
		rootdir=NULL;
		scanning=false;
		emit_signal("filesystem_changed");
		emit_signal("sources_changed",sources_changed.size()>0);

	} else {

		ERR_FAIL_COND(thread);
		set_process(true);
		Thread::Settings s;
		scanning=true;
		s.priority=Thread::PRIORITY_LOW;
		thread = Thread::create(_thread_func,this,s);
		//tree->hide();
		//progress->show();
	}



}
Exemplo n.º 15
0
void SceneTreeEditor::_node_script_changed(Node *p_node) {

	_update_tree();
	/*
	changes the order :|
	TreeItem* item=p_node?_find(tree->get_root(),p_node->get_path()):NULL;
	if (p_node->get_script().is_null()) {

		int idx=item->get_button_by_id(0,2);
		if (idx>=0)
			item->erase_button(0,idx);
	} else {

		int idx=item->get_button_by_id(0,2);
		if (idx<0)
			item->add_button(0,get_icon("Script","EditorIcons"),2);

	}*/
}
Exemplo n.º 16
0
void ScenesDock::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_SCENE: {


			EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_update_tree");

			button_reload->set_icon( get_icon("Reload","EditorIcons"));
			button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
			button_instance->set_icon( get_icon("Add","EditorIcons"));
			button_open->set_icon( get_icon("Folder","EditorIcons"));

			String path = Globals::get_singleton()->get_resource_path()+"/favorites.cfg";
			FileAccess *f=FileAccess::open(path,FileAccess::READ);
			if (f) {

				String l = f->get_line();

				while(l!="") {
					favorites.insert(l);
					l = f->get_line();

				}

				f->close();
				memdelete(f);
			}



			_update_tree(); //maybe it finished already
		} break;
		case NOTIFICATION_EXIT_SCENE: {

		} break;
		case NOTIFICATION_PROCESS: {

		} break;
	}

}
Exemplo n.º 17
0
void ScenesDock::_bw_history() {

	if (history_pos>0)
		history_pos--;

	path=history[history_pos];

	if (tree_mode) {
		_update_tree();
		tree->grab_focus();
		tree->ensure_cursor_is_visible();
	} else {
		_update_files(false);
		current_path->set_text(path);
	}

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());

}
Exemplo n.º 18
0
void ScenesDock::_fs_changed() {

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());
	scanning_vb->hide();
	split_box->show();

	if (!tree->is_hidden()) {
		button_favorite->show();
		_update_tree();

	}

	if (!file_list_vb->is_hidden()) {

		_update_files(true);
	}

	set_process(false);
}
Exemplo n.º 19
0
void ScenesDock::_fav_down_pressed() {

	TreeItem *sel = tree->get_selected();
	if (!sel)
		return ;

	if (!sel->get_next())
		return;

	String sw = sel->get_next()->get_metadata(0);
	String txt = sel->get_metadata(0);

	Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();

	int a_idx=favorited.find(sw);
	int b_idx=favorited.find(txt);

	if (a_idx==-1 || b_idx==-1)
		return;
	SWAP(favorited[a_idx],favorited[b_idx]);

	EditorSettings::get_singleton()->set_favorite_dirs(favorited);

	_update_tree();

	if (!tree->get_root() || !tree->get_root()->get_children() || !tree->get_root()->get_children()->get_children())
		return;
	sel = tree->get_root()->get_children()->get_children();
	while(sel) {

		String t = sel->get_metadata(0);
		if (t==txt) {
			sel->select(0);
			return;
		}
		sel=sel->get_next();
	}
}
Exemplo n.º 20
0
EditorFileSystemDirectory* EditorFileSystem::_update_tree(DirItem *p_item) {

	EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );

	if (!p_item)
		return efd; //empty likely
	efd->name=p_item->name;

	for(int i=0;i<p_item->files.size();i++) {

		String s = p_item->files[i]->type;
		//if (p_item->files[i]->meta)
		//	s="*"+s;

//		file_type_cache[p_item->files[i]->path]=s;
		if (p_item->files[i]->type=="")
			continue; //ignore because it's invalid
		EditorFileSystemDirectory::FileInfo fi;
		fi.file=p_item->files[i]->file;
		fi.type=p_item->files[i]->type;
		fi.meta=p_item->files[i]->meta;
		fi.modified_time=p_item->files[i]->modified_time;

		efd->files.push_back(fi);

	}

	for(int i=0;i<p_item->dirs.size();i++) {

		EditorFileSystemDirectory *efsd =_update_tree(p_item->dirs[i]);
		efsd->parent=efd;
		efd->subdirs.push_back( efsd );

	}


	return efd;
}
Exemplo n.º 21
0
void ScenesDock::_fw_history() {

	if (history_pos<history.size()-1)
		history_pos++;

	path=history[history_pos];

	if (!tree->is_hidden()) {
		_update_tree();
		tree->grab_focus();
		tree->ensure_cursor_is_visible();

	}

	if (!file_list_vb->is_hidden()) {
		_update_files(false);
		current_path->set_text(path);
	}

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());

}
// TimeSlice Interface
void
dmz::MBRAPluginFaultTreeAutoLayout::update_time_slice (const Float64 TimeDelta) {

   if (_doTreeUpdate) {

      _update_tree ();

      _doTreeUpdate = False;
      _doZoomUpdate = True;
   }
   else if (_doZoomUpdate && _canvasModule) {

      if (_subHandle) {

         _canvasModule->center_on (_subHandle);
         _subHandle = 0;
      }
      
//      _canvasModule->zoom_extents ();

      _doZoomUpdate = False;
   }
}
Exemplo n.º 23
0
void ScenesDock::_fs_changed() {

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());
	scanning_vb->hide();

	if (tree_mode) {

		tree->show();
		button_favorite->show();
		button_fav_up->show();
		button_fav_down->show();
		_update_tree();
	} else {
		files->show();
		path_hb->show();
		button_instance->show();
		button_open->show();
		file_options->show();
		_update_files(true);
	}

	set_process(false);
}
Exemplo n.º 24
0
void ScenesDock::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_RESIZED: {


			bool new_mode = get_size().height < get_viewport_rect().size.height*3/4;

			if (new_mode != split_mode ) {

				split_mode=new_mode;

				//print_line("SPLIT MODE? "+itos(split_mode));
				if (split_mode) {

					file_list_vb->hide();
					tree->set_v_size_flags(SIZE_EXPAND_FILL);
					button_back->show();
				} else {

					tree->show();
					file_list_vb->show();
					tree->set_v_size_flags(SIZE_FILL);
					button_back->hide();
					if (!EditorFileSystem::get_singleton()->is_scanning()) {
						_fs_changed();
					}
				}
			}


		} break;
		case NOTIFICATION_ENTER_TREE: {

			if (initialized)
				return;
			initialized=true;

			EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed");

			button_reload->set_icon( get_icon("Reload","EditorIcons"));
			button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
			button_fav_up->set_icon( get_icon("MoveUp","EditorIcons"));
			button_fav_down->set_icon( get_icon("MoveDown","EditorIcons"));
			//button_instance->set_icon( get_icon("Add","EditorIcons"));
			//button_open->set_icon( get_icon("Folder","EditorIcons"));
			button_back->set_icon( get_icon("Filesystem","EditorIcons"));
			display_mode->set_icon( get_icon("FileList","EditorIcons"));
			display_mode->connect("pressed",this,"_change_file_display");
			//file_options->set_icon( get_icon("Tools","EditorIcons"));
			files->connect("item_activated",this,"_select_file");
			button_hist_next->connect("pressed",this,"_fw_history");
			button_hist_prev->connect("pressed",this,"_bw_history");
			search_button->set_icon( get_icon("Zoom","EditorIcons"));

			button_hist_next->set_icon( get_icon("Forward","EditorIcons"));
			button_hist_prev->set_icon( get_icon("Back","EditorIcons"));
			file_options->connect("item_pressed",this,"_file_option");


			button_back->connect("pressed",this,"_go_to_tree",varray(),CONNECT_DEFERRED);
			current_path->connect("text_entered",this,"_go_to_dir");
			_update_tree(); //maybe it finished already

			if (EditorFileSystem::get_singleton()->is_scanning()) {
				_set_scannig_mode();
			}

		} break;
		case NOTIFICATION_PROCESS: {
			if (EditorFileSystem::get_singleton()->is_scanning()) {
				scanning_progress->set_val(EditorFileSystem::get_singleton()->get_scanning_progress()*100);
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {

		} break;
		case NOTIFICATION_DRAG_BEGIN: {

			Dictionary dd = get_viewport()->gui_get_drag_data();
			if (tree->is_visible() && dd.has("type") && (
						(String(dd["type"])=="files") || (String(dd["type"])=="files_and_dirs") || (String(dd["type"])=="resource"))) {
				tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
			}
		} break;
		case NOTIFICATION_DRAG_END: {

			tree->set_drop_mode_flags(0);

		} break;
		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {

			display_mode->set_pressed(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_LIST);

			_change_file_display();
		} break;
	}

}
Exemplo n.º 25
0
void SceneTreeEditor::set_display_foreign_nodes(bool p_display) {

	display_foreign=p_display;
	_update_tree();
}
Exemplo n.º 26
0
void SceneTreeEditor::set_filter(const String& p_filter) {

	filter=p_filter;
	_update_tree();
}
Exemplo n.º 27
0
void SceneTreeEditor::_subscene_option(int p_idx) {

	Object *obj = ObjectDB::get_instance(instance_node);
	if (!obj)
		return;
	Node *node = obj->cast_to<Node>();
	if (!node)
		return;

	switch(p_idx) {

		case SCENE_MENU_EDITABLE_CHILDREN: {

			bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node);
			editable = !editable;

			//node->set_instance_children_editable(editable);
			EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node,editable);
			instance_menu->set_item_checked(0,editable);
			if (editable) {
				node->set_scene_instance_load_placeholder(false);
				instance_menu->set_item_checked(1,false);
			}

			_update_tree();

		} break;
		case SCENE_MENU_USE_PLACEHOLDER: {

			bool placeholder = node->get_scene_instance_load_placeholder();
			placeholder = !placeholder;

			//node->set_instance_children_editable(editable);
			if (placeholder) {
				EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node,false);
			}
			node->set_scene_instance_load_placeholder(placeholder);
			instance_menu->set_item_checked(0,false);
			instance_menu->set_item_checked(1,placeholder);

			_update_tree();

		} break;
		case SCENE_MENU_OPEN: {

			emit_signal("open",node->get_filename());
		} break;
		case SCENE_MENU_CLEAR_INHERITANCE: {
			clear_inherit_confirm->popup_centered_minsize();
		} break;
		case SCENE_MENU_CLEAR_INSTANCING: {

			Node*root=EditorNode::get_singleton()->get_edited_scene();
			if (!root)
				break;


			ERR_FAIL_COND(node->get_filename()==String());

			undo_redo->create_action("Discard Instancing");

			undo_redo->add_do_method(node,"set_filename","");
			undo_redo->add_undo_method(node,"set_filename",node->get_filename());

			_node_replace_owner(node,node,root);

			undo_redo->add_do_method(this,"update_tree");
			undo_redo->add_undo_method(this,"update_tree");

			undo_redo->commit_action();


		} break;
		case SCENE_MENU_OPEN_INHERITED: {
			if (node && node->get_scene_inherited_state().is_valid()) {
				emit_signal("open",node->get_scene_inherited_state()->get_path());
			}
		} break;
		case SCENE_MENU_CLEAR_INHERITANCE_CONFIRM: {
			if (node && node->get_scene_inherited_state().is_valid()) {
				node->set_scene_inherited_state(Ref<SceneState>());
				update_tree();
				EditorNode::get_singleton()->get_property_editor()->update_tree();
			}

		} break;


	}

}
Exemplo n.º 28
0
void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) {

	TreeItem *item=p_item->cast_to<TreeItem>();
	ERR_FAIL_COND(!item);

	NodePath np = item->get_metadata(0);

	Node *n=get_node(np);
	ERR_FAIL_COND(!n);

	if (p_id==BUTTON_SUBSCENE) {
		//open scene request
		Rect2 item_rect = tree->get_item_rect(item,0);
		item_rect.pos.y-=tree->get_scroll().y;
		item_rect.pos+=tree->get_global_pos();

		if (n==get_scene_node()) {
			inheritance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y));
			inheritance_menu->set_size(Vector2(item_rect.size.x,0));
			inheritance_menu->popup();
			instance_node=n->get_instance_ID();

		} else {
			instance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y));
			instance_menu->set_size(Vector2(item_rect.size.x,0));
			if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(n))
				instance_menu->set_item_checked(0,true);
			else
				instance_menu->set_item_checked(0,false);

			if (n->get_owner()==get_scene_node()) {
				instance_menu->set_item_checked(1,n->get_scene_instance_load_placeholder());
				instance_menu->set_item_disabled(1,false);
			} else {

				instance_menu->set_item_checked(1,false);
				instance_menu->set_item_disabled(1,true);
			}

			instance_menu->popup();
			instance_node=n->get_instance_ID();
		}
		//emit_signal("open",n->get_filename());
	} else if (p_id==BUTTON_SCRIPT) {
		RefPtr script=n->get_script();
		if (!script.is_null())
			emit_signal("open_script",script);

	} else if (p_id==BUTTON_VISIBILITY) {


		if (n->is_type("Spatial")) {

			Spatial *ci = n->cast_to<Spatial>();
			if (!ci->is_visible() && ci->get_parent_spatial() && !ci->get_parent_spatial()->is_visible()) {
				error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first."));
				error->popup_centered_minsize();
				return;
			}

			bool v = !bool(n->call("is_hidden"));
			undo_redo->create_action(TTR("Toggle Spatial Visible"));
			undo_redo->add_do_method(n,"_set_visible_",!v);
			undo_redo->add_undo_method(n,"_set_visible_",v);
			undo_redo->commit_action();
		} else if (n->is_type("CanvasItem")) {

			CanvasItem *ci = n->cast_to<CanvasItem>();
			if (!ci->is_visible() && ci->get_parent_item() && !ci->get_parent_item()->is_visible()) {
				error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first."));
				error->popup_centered_minsize();
				return;
			}
			bool v = !bool(n->call("is_hidden"));
			undo_redo->create_action(TTR("Toggle CanvasItem Visible"));
			undo_redo->add_do_method(n,v?"hide":"show");
			undo_redo->add_undo_method(n,v?"show":"hide");
			undo_redo->commit_action();
		}

	} else if (p_id==BUTTON_LOCK) {

		if (n->is_type("CanvasItem")) {
			n->set_meta("_edit_lock_", Variant());
			_update_tree();
			emit_signal("node_changed");
		}

	} else if (p_id==BUTTON_GROUP) {
		if (n->is_type("CanvasItem")) {
			n->set_meta("_edit_group_", Variant());
			_update_tree();
			emit_signal("node_changed");
		}
	} else if (p_id==BUTTON_WARNING) {

		String config_err = n->get_configuration_warning();
		if (config_err==String())
			return;
		config_err=config_err.word_wrap(80);
		warning->set_text(config_err);
		warning->popup_centered_minsize();

	} else if (p_id==BUTTON_SIGNALS) {

		editor_selection->clear();
		editor_selection->add_node(n);

		set_selected(n);

		NodeDock::singleton->get_parent()->call("set_current_tab",NodeDock::singleton->get_index());
		NodeDock::singleton->show_connections();

	} else if (p_id==BUTTON_GROUPS) {

		editor_selection->clear();
		editor_selection->add_node(n);

		set_selected(n);

		NodeDock::singleton->get_parent()->call("set_current_tab",NodeDock::singleton->get_index());
		NodeDock::singleton->show_groups();
	}
}
Exemplo n.º 29
0
void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {

	if (connect_to_script_mode) {
		return; //don't do anything in this mode
	}
	TreeItem *item = Object::cast_to<TreeItem>(p_item);
	ERR_FAIL_COND(!item);

	NodePath np = item->get_metadata(0);

	Node *n = get_node(np);
	ERR_FAIL_COND(!n);

	if (p_id == BUTTON_SUBSCENE) {
		if (n == get_scene_node()) {
			if (n && n->get_scene_inherited_state().is_valid()) {
				emit_signal("open", n->get_scene_inherited_state()->get_path());
			}
		} else {
			emit_signal("open", n->get_filename());
		}
	} else if (p_id == BUTTON_SCRIPT) {
		RefPtr script = n->get_script();
		if (!script.is_null())
			emit_signal("open_script", script);

	} else if (p_id == BUTTON_VISIBILITY) {
		undo_redo->create_action(TTR("Toggle Visible"));
		_toggle_visible(n);
		List<Node *> selection = editor_selection->get_selected_node_list();
		if (selection.size() > 1 && selection.find(n) != NULL) {
			for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
				Node *nv = E->get();
				ERR_FAIL_COND(!nv);
				if (nv == n) {
					continue;
				}
				_toggle_visible(nv);
			}
		}
		undo_redo->commit_action();
	} else if (p_id == BUTTON_LOCK) {
		undo_redo->create_action(TTR("Unlock Node"));

		if (n->is_class("CanvasItem") || n->is_class("Spatial")) {

			undo_redo->add_do_method(n, "remove_meta", "_edit_lock_");
			undo_redo->add_undo_method(n, "set_meta", "_edit_lock_", true);
			undo_redo->add_do_method(this, "_update_tree", Variant());
			undo_redo->add_undo_method(this, "_update_tree", Variant());
			undo_redo->add_do_method(this, "emit_signal", "node_changed");
			undo_redo->add_undo_method(this, "emit_signal", "node_changed");
		}
		undo_redo->commit_action();
	} else if (p_id == BUTTON_PIN) {

		if (n->is_class("AnimationPlayer")) {
			AnimationPlayerEditor::singleton->unpin();
			_update_tree();
		}

	} else if (p_id == BUTTON_GROUP) {
		undo_redo->create_action(TTR("Button Group"));

		if (n->is_class("CanvasItem") || n->is_class("Spatial")) {

			undo_redo->add_do_method(n, "remove_meta", "_edit_group_");
			undo_redo->add_undo_method(n, "set_meta", "_edit_group_", true);
			undo_redo->add_do_method(this, "_update_tree", Variant());
			undo_redo->add_undo_method(this, "_update_tree", Variant());
			undo_redo->add_do_method(this, "emit_signal", "node_changed");
			undo_redo->add_undo_method(this, "emit_signal", "node_changed");
		}
		undo_redo->commit_action();
	} else if (p_id == BUTTON_WARNING) {

		String config_err = n->get_configuration_warning();
		if (config_err == String())
			return;
		config_err = config_err.word_wrap(80);
		warning->set_text(config_err);
		warning->popup_centered_minsize();

	} else if (p_id == BUTTON_SIGNALS) {

		editor_selection->clear();
		editor_selection->add_node(n);

		set_selected(n);

		NodeDock::singleton->get_parent()->call("set_current_tab", NodeDock::singleton->get_index());
		NodeDock::singleton->show_connections();

	} else if (p_id == BUTTON_GROUPS) {

		editor_selection->clear();
		editor_selection->add_node(n);

		set_selected(n);

		NodeDock::singleton->get_parent()->call("set_current_tab", NodeDock::singleton->get_index());
		NodeDock::singleton->show_groups();
	}
}
Exemplo n.º 30
0
void ScenesDock::_favorites_toggled(bool p_toggled) {

	_update_tree();
}