diff options
Diffstat (limited to 'tools/editor')
-rw-r--r-- | tools/editor/editor_import_export.cpp | 22 | ||||
-rw-r--r-- | tools/editor/editor_import_export.h | 4 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_texture_import_plugin.cpp | 21 | ||||
-rw-r--r-- | tools/editor/project_export.cpp | 14 | ||||
-rw-r--r-- | tools/editor/project_export.h | 3 |
6 files changed, 56 insertions, 10 deletions
diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index 22b611fdcc..1a5dd73040 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -492,6 +492,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func int group_format=0; float group_lossy_quality=EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(E->get()); int group_shrink=EditorImportExport::get_singleton()->image_export_group_get_shrink(E->get()); + group_shrink*=EditorImportExport::get_singleton()->get_export_image_shrink(); switch(EditorImportExport::get_singleton()->image_export_group_get_image_action(E->get())) { case EditorImportExport::IMAGE_ACTION_NONE: { @@ -1186,6 +1187,16 @@ EditorImportExport::ImageAction EditorImportExport::get_export_image_action() co return image_action; } +void EditorImportExport::set_export_image_shrink(int p_shrink) { + + image_shrink=p_shrink; +} + +int EditorImportExport::get_export_image_shrink() const{ + + return image_shrink; +} + void EditorImportExport::set_export_image_quality(float p_quality){ @@ -1336,6 +1347,10 @@ void EditorImportExport::load_config() { image_action=IMAGE_ACTION_COMPRESS_DISK; image_action_compress_quality = cf->get_value(ci,"compress_quality"); + if (cf->has_section_key(ci,"shrink")) + image_shrink = cf->get_value(ci,"shrink"); + else + image_shrink=1; String formats=cf->get_value(ci,"formats"); Vector<String> f = formats.split(","); image_formats.clear(); @@ -1382,8 +1397,6 @@ void EditorImportExport::load_config() { List<String> keys; cf->get_section_keys(s,&keys); for(List<String>::Element *F=keys.front();F;F=F->next()) { - print_line("sk: "+F->get()); - ep->set(F->get(),cf->get_value(s,F->get())); } } @@ -1494,6 +1507,7 @@ void EditorImportExport::save_config() { case IMAGE_ACTION_COMPRESS_DISK: cf->set_value("convert_images","action","compress_disk"); break; } + cf->set_value("convert_images","shrink",image_shrink); cf->set_value("convert_images","compress_quality",image_action_compress_quality); String formats; @@ -1562,9 +1576,7 @@ EditorImportExport::EditorImportExport() { image_action=IMAGE_ACTION_NONE; image_action_compress_quality=0.7; image_formats.insert("png"); - - - + image_shrink=1; } diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 17f2592ad5..94fbaba842 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -243,6 +243,7 @@ protected: Map<String,int> by_idx; ImageAction image_action; float image_action_compress_quality; + int image_shrink; Set<String> image_formats; ExportFilter export_filter; @@ -288,6 +289,9 @@ public: void set_export_image_action(ImageAction p_action); ImageAction get_export_image_action() const; + void set_export_image_shrink(int p_shrink); + int get_export_image_shrink() const; + void set_export_image_quality(float p_quality); float get_export_image_quality() const; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 2f7b6759b9..d8f9dcc947 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3458,8 +3458,8 @@ EditorNode::EditorNode() { p->add_item("Run Script",FILE_RUN_SCRIPT,KEY_MASK_CMD+KEY_R); p->add_separator(); p->add_item("Project Settings",RUN_SETTINGS); - p->add_item("Project Manager",RUN_PROJECT_MANAGER); p->add_separator(); + p->add_item("Quit to Project List",RUN_PROJECT_MANAGER); p->add_item("Quit",FILE_QUIT,KEY_MASK_CMD+KEY_Q); recent_scenes = memnew( PopupMenu ); diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 067edee5a0..ff4da6af13 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -899,6 +899,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc } } + if (format==IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS || format==IMAGE_FORMAT_COMPRESS_DISK_LOSSY) { Image image=texture->get_data(); @@ -952,6 +953,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc } else { + print_line("compress..."); Image image=texture->get_data(); ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); @@ -988,13 +990,17 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc } + print_line("COMPRESSED TO: "+itos(image.get_format())); texture->create_from_image(image,tex_flags); + if (shrink>1) { texture->set_size_override(Size2(orig_w,orig_h)); } - Error err = ResourceSaver::save(p_path,texture); + uint32_t save_flags=ResourceSaver::FLAG_COMPRESS; + + Error err = ResourceSaver::save(p_path,texture,save_flags); if (err!=OK) { EditorNode::add_io_error("Couldn't save converted texture: "+p_path); return err; @@ -1021,6 +1027,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c int group_format=0; float group_lossy_quality=EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(group); int group_shrink=EditorImportExport::get_singleton()->image_export_group_get_shrink(group); + group_shrink*=EditorImportExport::get_singleton()->get_export_image_shrink(); switch(EditorImportExport::get_singleton()->image_export_group_get_image_action(group)) { case EditorImportExport::IMAGE_ACTION_NONE: { @@ -1062,6 +1069,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; + print_line("group format"+itos(group_format)); rimd->set_option("format",group_format); rimd->set_option("flags",flags); rimd->set_option("quality",group_lossy_quality); @@ -1090,6 +1098,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; + rimd->set_option("shrink",EditorImportExport::get_singleton()->get_export_image_shrink()); rimd->set_option("flags",flags); rimd->set_option("quality",EditorImportExport::get_singleton()->get_export_image_quality()); rimd->set_option("atlas",false); @@ -1108,18 +1117,21 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c } uint32_t flags = rimd->get_option("flags"); + uint8_t shrink = rimd->has_option("shrink") ? rimd->get_option("shrink"): Variant(1); + uint8_t format = rimd->get_option("format"); + uint8_t comp = (format==EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM)?uint8_t(p_platform->get_image_compression()):uint8_t(255); MD5_CTX ctx; uint8_t f4[4]; encode_uint32(flags,&f4[0]); - uint8_t ic = p_platform->get_image_compression(); MD5Init(&ctx); String gp = Globals::get_singleton()->globalize_path(p_path); CharString cs = gp.utf8(); MD5Update(&ctx,(unsigned char*)cs.get_data(),cs.length()); MD5Update(&ctx,f4,4); - MD5Update(&ctx,&ic,1); - + MD5Update(&ctx,&format,1); + MD5Update(&ctx,&comp,1); + MD5Update(&ctx,&shrink,1); MD5Final(&ctx); uint64_t sd=0; @@ -1137,6 +1149,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c uint64_t d = f->get_line().strip_edges().to_int64(); sd = FileAccess::get_modified_time(p_path); + if (d==sd) { valid=true; } else { diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 192fcaa908..eae5dacb27 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -207,6 +207,12 @@ void ProjectExportDialog::_quality_edited(float what) { _save_export_cfg(); } +void ProjectExportDialog::_shrink_edited(float what) { + + EditorImportExport::get_singleton()->set_export_image_shrink(what); + _save_export_cfg(); +} + void ProjectExportDialog::_image_export_edited(int what) { EditorImportExport::get_singleton()->set_export_image_action(EditorImportExport::ImageAction(what)); @@ -270,7 +276,9 @@ void ProjectExportDialog::_notification(int p_what) { image_action->select(EditorImportExport::get_singleton()->get_export_image_action()); image_quality->set_val(EditorImportExport::get_singleton()->get_export_image_quality()); + image_shrink->set_val(EditorImportExport::get_singleton()->get_export_image_quality()); image_quality->connect("value_changed",this,"_quality_edited"); + image_shrink->connect("value_changed",this,"_shrink_edited"); image_action->connect("item_selected",this,"_image_export_edited"); for(int i=0;i<formats.size();i++) { @@ -966,6 +974,7 @@ void ProjectExportDialog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_export_action"),&ProjectExportDialog::_export_action); ObjectTypeDB::bind_method(_MD("_export_action_pck"),&ProjectExportDialog::_export_action_pck); ObjectTypeDB::bind_method(_MD("_quality_edited"),&ProjectExportDialog::_quality_edited); + ObjectTypeDB::bind_method(_MD("_shrink_edited"),&ProjectExportDialog::_shrink_edited); ObjectTypeDB::bind_method(_MD("_image_export_edited"),&ProjectExportDialog::_image_export_edited); ObjectTypeDB::bind_method(_MD("_format_toggled"),&ProjectExportDialog::_format_toggled); ObjectTypeDB::bind_method(_MD("_group_changed"),&ProjectExportDialog::_group_changed); @@ -1090,6 +1099,11 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { image_quality->set_max(1); image_quality->set_step(0.01); image_vb->add_margin_child("Compress for Disk (Lossy) Quality:",qhb); + image_shrink = memnew( SpinBox ); + image_shrink->set_min(1); + image_shrink->set_max(8); + image_shrink->set_step(1); + image_vb->add_margin_child("Shrink All Images:",image_shrink); sections->add_child(image_vb); image_formats=memnew(Tree); diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h index 25709babb9..6ceffadc62 100644 --- a/tools/editor/project_export.h +++ b/tools/editor/project_export.h @@ -110,6 +110,7 @@ private: VBoxContainer *image_vb; OptionButton *image_action; HSlider *image_quality; + SpinBox *image_shrink; Tree *image_formats; Vector<TreeItem*> formats; @@ -150,6 +151,8 @@ private: void _quality_edited(float what); void _image_export_edited(int what); + void _shrink_edited(float what); + void _update_group_list(); void _select_group(const String& p_by_name); |