Ejemplo n.º 1
0
void OrphanResourcesDialog::refresh() {
	HashMap<String,int> refs;
	_fill_owners(EditorFileSystem::get_singleton()->get_filesystem(),refs,NULL);
	files->clear();
	TreeItem *root=files->create_item();
	_fill_owners(EditorFileSystem::get_singleton()->get_filesystem(),refs,root);
}
Ejemplo n.º 2
0
void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {

	if (!efsd)
		return;

	for (int i = 0; i < efsd->get_subdir_count(); i++) {
		_fill_owners(efsd->get_subdir(i));
	}

	for (int i = 0; i < efsd->get_file_count(); i++) {

		Vector<String> deps = efsd->get_file_deps(i);
		bool found = false;
		for (int j = 0; j < deps.size(); j++) {
			if (deps[j] == editing) {
				found = true;
				break;
			}
		}
		if (!found)
			continue;

		Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i));

		owners->add_item(efsd->get_file_path(i), icon);
	}
}
Ejemplo n.º 3
0
void DependencyEditorOwners::show(const String &p_path) {

	editing = p_path;
	owners->clear();
	_fill_owners(EditorFileSystem::get_singleton()->get_filesystem());
	popup_centered_ratio();

	set_title(TTR("Owners Of:") + " " + p_path.get_file());
}
Ejemplo n.º 4
0
void DependencyRemoveDialog::_fill_owners(EditorFileSystemDirectory *efsd) {

	if (!efsd)
		return;

	for(int i=0;i<efsd->get_subdir_count();i++) {
		_fill_owners(efsd->get_subdir(i));
	}

	for(int i=0;i<efsd->get_file_count();i++) {

		Vector<String> deps = efsd->get_file_deps(i);
		//print_line(":::"+efsd->get_file_path(i));
		Set<String> met;
		for(int j=0;j<deps.size();j++) {
			if (files.has(deps[j])) {
				met.insert(deps[j]);
			}
		}
		if (!met.size())
			continue;

		exist=true;

		Ref<Texture> icon;
		String type=efsd->get_file_type(i);
		if (!has_icon(type,TTR("EditorIcons"))) {
			icon=get_icon("Object","EditorIcons");
		} else {
			icon=get_icon(type,"EditorIcons");
		}


		for(Set<String>::Element *E=met.front();E;E=E->next()) {

			String which = E->get();
			if (!files[which]) {
				TreeItem *ti=owners->create_item(owners->get_root());
				ti->set_text(0,which.get_file());
				files[which]=ti;

			}
			TreeItem *ti=owners->create_item(files[which]);
			ti->set_text(0,efsd->get_file_path(i));
			ti->set_icon(0,icon);
		}

	}

}
Ejemplo n.º 5
0
void DependencyRemoveDialog::show(const Vector<String> &to_erase) {

	exist = false;
	owners->clear();
	files.clear();
	owners->create_item(); // root
	for (int i = 0; i < to_erase.size(); i++) {
		files[to_erase[i]] = NULL;
	}

	_fill_owners(EditorFileSystem::get_singleton()->get_filesystem());

	if (exist) {
		owners->show();
		text->set_text(TTR("The files being removed are required by other resources in order for them to work.\nRemove them anyway? (no undo)"));
		popup_centered_minsize(Size2(500, 220));
	} else {
		owners->hide();
		text->set_text(TTR("Remove selected files from the project? (no undo)"));
		popup_centered_minsize(Size2(400, 100));
	}
}
Ejemplo n.º 6
0
void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {

	if (!efsd)
		return;

	for(int i=0;i<efsd->get_subdir_count();i++) {
		_fill_owners(efsd->get_subdir(i));
	}

	for(int i=0;i<efsd->get_file_count();i++) {

		Vector<String> deps = efsd->get_file_deps(i);
		//print_line(":::"+efsd->get_file_path(i));
		bool found=false;
		for(int j=0;j<deps.size();j++) {
			//print_line("\t"+deps[j]+" vs "+editing);
			if (deps[j]==editing) {
				//print_line("found");
				found=true;
				break;
			}
		}
		if (!found)
			continue;

		Ref<Texture> icon;
		String type=efsd->get_file_type(i);
		if (!has_icon(type,TTR("EditorIcons"))) {
			icon=get_icon("Object","EditorIcons");
		} else {
			icon=get_icon(type,"EditorIcons");
		}

		owners->add_item(efsd->get_file_path(i),icon);
	}

}
Ejemplo n.º 7
0
bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd,HashMap<String,int>& refs,TreeItem* p_parent){


	if (!efsd)
		return false;

	bool has_childs=false;

	for(int i=0;i<efsd->get_subdir_count();i++) {

		TreeItem *dir_item=NULL;
		if (p_parent) {
			dir_item = files->create_item(p_parent);
			dir_item->set_text(0,efsd->get_subdir(i)->get_name());
			dir_item->set_icon(0,get_icon("folder","FileDialog"));

		}
		bool children = _fill_owners(efsd->get_subdir(i),refs,dir_item);

		if (p_parent) {
			if (!children) {
				memdelete(dir_item);
			} else {
				has_childs=true;
			}
		}

	}


	for(int i=0;i<efsd->get_file_count();i++) {

		if (!p_parent) {
			Vector<String> deps = efsd->get_file_deps(i);
			//print_line(":::"+efsd->get_file_path(i));
			for(int j=0;j<deps.size();j++) {

				if (!refs.has(deps[j])) {
					refs[deps[j]]=1;
				}
			}
		} else {

			String path = efsd->get_file_path(i);
			if (!refs.has(path)) {
				TreeItem *ti=files->create_item(p_parent);
				ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
				ti->set_text(0,efsd->get_file(i));
				ti->set_editable(0,true);

				String type=efsd->get_file_type(i);

				Ref<Texture> icon;
				if (has_icon(type,TTR("EditorIcons"))) {
					icon=get_icon(type,"EditorIcons");
				} else {
					icon=get_icon("Object","EditorIcons");
				}
				ti->set_icon(0,icon);
				int ds = efsd->get_file_deps(i).size();
				ti->set_text(1,itos(ds));
				if (ds) {
					ti->add_button(1,get_icon("Visible","EditorIcons"));
				}
				ti->set_metadata(0,path);
				has_childs=true;
			}
		}

	}

	return has_childs;
}