Merge pull request #7651 from leezh/collada_import_tweaks
Re-Implemented Texture Actions for Scene Import (2.1 Branch)
This commit is contained in:
commit
bd71020354
|
@ -720,13 +720,6 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
|
|||
return;
|
||||
}
|
||||
|
||||
String dst_path;
|
||||
|
||||
if (texture_action->get_selected()==0)
|
||||
dst_path=save_path->get_text();//.get_base_dir();
|
||||
else
|
||||
dst_path=Globals::get_singleton()->get("import/shared_textures");
|
||||
|
||||
uint32_t flags=0;
|
||||
|
||||
for(int i=0;i<scene_flags.size();i++) {
|
||||
|
@ -781,6 +774,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
|
|||
rim->set_option("texture_flags",texture_options->get_flags());
|
||||
rim->set_option("texture_format",texture_options->get_format());
|
||||
rim->set_option("texture_quality",texture_options->get_quality());
|
||||
rim->set_option("texture_action",texture_action->get_selected());
|
||||
rim->set_option("animation_flags",animation_options->get_flags());
|
||||
rim->set_option("animation_bake_fps",animation_options->get_fps());
|
||||
rim->set_option("animation_optimizer_linear_error",animation_options->get_optimize_linear_error());
|
||||
|
@ -925,6 +919,7 @@ void EditorSceneImportDialog::popup_import(const String &p_from) {
|
|||
texture_options->set_flags(rimd->get_option("texture_flags"));
|
||||
texture_options->set_format(EditorTextureImportPlugin::ImageFormat(int(rimd->get_option("texture_format"))));
|
||||
texture_options->set_quality(rimd->get_option("texture_quality"));
|
||||
texture_action->select(rimd->get_option("texture_action"));
|
||||
animation_options->set_flags(rimd->get_option("animation_flags"));
|
||||
if (rimd->has_option("animation_clips"))
|
||||
animation_options->setup_clips(rimd->get_option("animation_clips"));
|
||||
|
@ -1147,12 +1142,6 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce
|
|||
|
||||
save_choose->connect("pressed", this,"_browse_target");
|
||||
|
||||
texture_action = memnew( OptionButton );
|
||||
texture_action->add_item(TTR("Same as Target Scene"));
|
||||
texture_action->add_item(TTR("Shared"));
|
||||
texture_action->select(0);
|
||||
vbc->add_margin_child(TTR("Target Texture Folder:"),texture_action);
|
||||
|
||||
import_options = memnew( Tree );
|
||||
vbc->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
vbc->add_margin_child(TTR("Options:"),import_options,true);
|
||||
|
@ -1274,8 +1263,8 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce
|
|||
*/
|
||||
set_hide_on_ok(false);
|
||||
|
||||
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));
|
||||
GLOBAL_DEF("editor/import_shared_textures","res://");
|
||||
Globals::get_singleton()->set_custom_property_info("editor/import_shared_textures",PropertyInfo(Variant::STRING,"editor/import_shared_textures",PROPERTY_HINT_DIR));
|
||||
|
||||
import_hb->add_constant_override("separation",30);
|
||||
|
||||
|
@ -1284,6 +1273,14 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce
|
|||
ovb->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
import_hb->add_child(ovb);
|
||||
|
||||
texture_action = memnew( OptionButton );
|
||||
texture_action->add_item(TTR("Import to Target Scene Folder"));
|
||||
texture_action->add_item(TTR("Import to Shared Textures Folder"));
|
||||
texture_action->add_item(TTR("Import to Source Folder"));
|
||||
texture_action->add_item(TTR("Reuse Source Textures"));
|
||||
texture_action->select(0);
|
||||
ovb->add_margin_child(TTR("Texture Action"),texture_action);
|
||||
|
||||
texture_options = memnew( EditorImportTextureOptions );
|
||||
ovb->add_child(texture_options);
|
||||
texture_options->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
@ -2788,6 +2785,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
|
|||
int image_format = from->get_option("texture_format");
|
||||
int image_flags = from->get_option("texture_flags");
|
||||
float image_quality = from->get_option("texture_quality");
|
||||
int texture_action = from->get_option("texture_action");
|
||||
|
||||
for (Map< Ref<ImageTexture>,TextureRole >::Element *E=imagemap.front();E;E=E->next()) {
|
||||
|
||||
|
@ -2800,15 +2798,25 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
|
|||
|
||||
String path = texture->get_path();
|
||||
String fname= path.get_file();
|
||||
String target_path = Globals::get_singleton()->localize_path(target_res_path.plus_file(fname));
|
||||
String target_path;
|
||||
progress.step(TTR("Import Image:")+" "+fname,3+(idx)*100/imagemap.size());
|
||||
|
||||
idx++;
|
||||
|
||||
if (path==target_path) {
|
||||
|
||||
EditorNode::add_io_error(TTR("Can't import a file over itself:")+" "+target_path);
|
||||
continue;
|
||||
switch (texture_action) {
|
||||
case 1:
|
||||
target_path = Globals::get_singleton()->get("editor/import_shared_textures");
|
||||
target_path = target_path.plus_file(fname.basename() + ".tex");
|
||||
break;
|
||||
case 2:
|
||||
target_path = path.basename() + ".tex";
|
||||
break;
|
||||
case 3:
|
||||
target_path = path;
|
||||
break;
|
||||
default:
|
||||
target_path = target_res_path.plus_file(fname.basename() + ".tex");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!target_path.begins_with("res://")) {
|
||||
|
@ -2817,8 +2825,17 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
|
|||
}
|
||||
|
||||
|
||||
{
|
||||
if (texture_action == 3) {
|
||||
|
||||
texture->set_path(target_path);
|
||||
|
||||
} else {
|
||||
|
||||
if (path==target_path) {
|
||||
|
||||
EditorNode::add_io_error(TTR("Can't import a file over itself:")+" "+target_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
target_path=target_path.basename()+".tex";
|
||||
|
||||
|
|
Loading…
Reference in New Issue