EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* p_plugin, bool p_2d, bool p_atlas) {


	atlas=p_atlas;
	plugin=p_plugin;
	set_title("Import Textures");

	texture_options = memnew( EditorImportTextureOptions );;
	VBoxContainer *vbc = texture_options;
	add_child(vbc);
	set_child_rect(vbc);


	VBoxContainer *source_vb=memnew(VBoxContainer);
	vbc->add_margin_child("Source Texture(s):",source_vb);

	HBoxContainer *hbc = memnew( HBoxContainer );
	source_vb->add_child(hbc);

	import_path = memnew( LineEdit );
	import_path->set_h_size_flags(SIZE_EXPAND_FILL);
	hbc->add_child(import_path);
	crop_source = memnew( CheckButton );
	crop_source->set_pressed(true);
	source_vb->add_child(crop_source);
	crop_source->set_text("Crop empty space.");
	if (!p_atlas)
		crop_source->hide();

	Button * import_choose = memnew( Button );
	import_choose->set_text(" .. ");
	hbc->add_child(import_choose);

	import_choose->connect("pressed", this,"_browse");

	hbc = memnew( HBoxContainer );
	vbc->add_margin_child("Target Path:",hbc);

	save_path = memnew( LineEdit );
	save_path->set_h_size_flags(SIZE_EXPAND_FILL);
	hbc->add_child(save_path);

	Button * save_choose = memnew( Button );
	save_choose->set_text(" .. ");
	hbc->add_child(save_choose);

	save_choose->connect("pressed", this,"_browse_target");

	file_select = memnew(FileDialog);
	file_select->set_access(FileDialog::ACCESS_FILESYSTEM);
	add_child(file_select);
	file_select->set_mode(FileDialog::MODE_OPEN_FILES);
	file_select->connect("files_selected", this,"_choose_files");

	save_file_select = memnew(FileDialog);
	save_file_select->set_access(FileDialog::ACCESS_RESOURCES);
	add_child(save_file_select);
	save_file_select->set_mode(FileDialog::MODE_SAVE_FILE);
	save_file_select->clear_filters();
	save_file_select->add_filter("*.tex;Base Atlas Texture");
	save_file_select->connect("file_selected", this,"_choose_save_dir");

	save_select = memnew(	EditorDirDialog );
	add_child(save_select);

//	save_select->set_mode(FileDialog::MODE_OPEN_DIR);
	save_select->connect("dir_selected", this,"_choose_save_dir");

	get_ok()->connect("pressed", this,"_import");
	get_ok()->set_text("Import");

	//move stuff up
	for(int i=0;i<4;i++)
		vbc->move_child( vbc->get_child( vbc->get_child_count() -1), 0);

	error_dialog = memnew ( ConfirmationDialog );
	add_child(error_dialog);
	error_dialog->get_ok()->set_text("Accept");
//	error_dialog->get_cancel()->hide();

	set_hide_on_ok(false);

	if (atlas) {

		texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS|EditorTextureImportPlugin::IMAGE_FLAG_FILTER);
		texture_options->set_quality(0.7);
		texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY);
		texture_options->show_2d_notice();
		set_title("Import Textures for Atlas (2D)");

	} else if (p_2d) {

		texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS|EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_FILTER);
		texture_options->set_quality(0.7);
		texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY);
		texture_options->show_2d_notice();
		set_title("Import Textures for 2D");
	} else {

		//texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_);
		//texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS);
		texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_FILTER|EditorTextureImportPlugin::IMAGE_FLAG_REPEAT);
		texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM);
		set_title("Import Textures for 3D");
	}


//	GLOBAL_DEF("import/shared_textures","res://");
//	Globals::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR));


}