diff options
Diffstat (limited to 'editor')
38 files changed, 574 insertions, 387 deletions
diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp index 971adb14cf..fcb92e13b4 100644 --- a/editor/asset_library_editor_plugin.cpp +++ b/editor/asset_library_editor_plugin.cpp @@ -683,17 +683,18 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt int len = image_data.size(); PoolByteArray::Read r = image_data.read(); - Image image(r.ptr(), len); - if (!image.empty()) { + Ref<Image> image = Ref<Image>(memnew(Image(r.ptr(), len))); + + if (!image->empty()) { float max_height = 10000; switch (image_queue[p_queue_id].image_type) { case IMAGE_QUEUE_ICON: max_height = 80; break; case IMAGE_QUEUE_THUMBNAIL: max_height = 80; break; case IMAGE_QUEUE_SCREENSHOT: max_height = 345; break; } - float scale_ratio = max_height / image.get_height(); + float scale_ratio = max_height / image->get_height(); if (scale_ratio < 1) { - image.resize(image.get_width() * scale_ratio, image.get_height() * scale_ratio, Image::INTERPOLATE_CUBIC); + image->resize(image->get_width() * scale_ratio, image->get_height() * scale_ratio, Image::INTERPOLATE_CUBIC); } Ref<ImageTexture> tex; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 93c2b7493c..e623d00cc9 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -239,7 +239,6 @@ void ConnectDialog::_add_bind() { case Variant::BASIS: value = Basis(); break; case Variant::TRANSFORM: value = Transform(); break; case Variant::COLOR: value = Color(); break; - case Variant::IMAGE: value = Image(); break; default: { ERR_FAIL(); } break; } @@ -327,7 +326,6 @@ ConnectDialog::ConnectDialog() { type_list->add_item("Transform", Variant::TRANSFORM); //type_list->add_separator(); type_list->add_item("Color", Variant::COLOR); - type_list->add_item("Image", Variant::IMAGE); type_list->select(0); Button *add_bind = memnew(Button); diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index af95f8d919..75d8721756 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -295,8 +295,8 @@ void DocData::generate(bool p_basic_types) { case Variant::REAL: //keep it break; - case Variant::STRING: // 15 - case Variant::NODE_PATH: // 15 + case Variant::STRING: + case Variant::NODE_PATH: default_arg_text = "\"" + default_arg_text + "\""; break; case Variant::TRANSFORM: @@ -307,19 +307,19 @@ void DocData::generate(bool p_basic_types) { default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; break; - case Variant::RECT3: //sorry naming convention fail :( not like it's used often // 10 + case Variant::RECT3: case Variant::COLOR: case Variant::PLANE: case Variant::POOL_BYTE_ARRAY: case Variant::POOL_INT_ARRAY: case Variant::POOL_REAL_ARRAY: - case Variant::POOL_STRING_ARRAY: //25 + case Variant::POOL_STRING_ARRAY: case Variant::POOL_VECTOR2_ARRAY: case Variant::POOL_VECTOR3_ARRAY: case Variant::POOL_COLOR_ARRAY: default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; break; - case Variant::VECTOR2: // 5 + case Variant::VECTOR2: case Variant::RECT2: case Variant::VECTOR3: case Variant::QUAT: @@ -332,14 +332,10 @@ void DocData::generate(bool p_basic_types) { break; } case Variant::INPUT_EVENT: - case Variant::DICTIONARY: // 20 + case Variant::DICTIONARY: case Variant::ARRAY: case Variant::_RID: - case Variant::IMAGE: - //case Variant::RESOURCE: - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "()"; - break; default: {} } diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index bda4d80f4d..10cd29b814 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -165,8 +165,8 @@ void DocDump::dump(const String &p_file) { case Variant::REAL: //keep it break; - case Variant::STRING: // 15 - case Variant::NODE_PATH: // 15 + case Variant::STRING: + case Variant::NODE_PATH: default_arg_text = "\"" + default_arg_text + "\""; break; case Variant::TRANSFORM: @@ -177,32 +177,28 @@ void DocDump::dump(const String &p_file) { default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; break; - case Variant::VECTOR2: // 5 + case Variant::VECTOR2: case Variant::RECT2: case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: //sorry naming convention fail :( not like it's used often // 10 + case Variant::RECT3: case Variant::BASIS: case Variant::COLOR: case Variant::POOL_BYTE_ARRAY: case Variant::POOL_INT_ARRAY: case Variant::POOL_REAL_ARRAY: - case Variant::POOL_STRING_ARRAY: //25 + case Variant::POOL_STRING_ARRAY: case Variant::POOL_VECTOR3_ARRAY: case Variant::POOL_COLOR_ARRAY: default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; break; case Variant::OBJECT: case Variant::INPUT_EVENT: - case Variant::DICTIONARY: // 20 + case Variant::DICTIONARY: case Variant::ARRAY: case Variant::_RID: - case Variant::IMAGE: - //case Variant::RESOURCE: - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "()"; - break; default: {} } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index c2e829e312..c47e3fc0de 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -488,8 +488,9 @@ void EditorFileDialog::update_file_list() { if (!has_icon("ResizedFolder", "EditorIcons")) { Ref<ImageTexture> folder = get_icon("FolderBig", "EditorIcons"); - Image img = folder->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = folder->get_data(); + img = img->duplicate(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_folder = Ref<ImageTexture>(memnew(ImageTexture)); resized_folder->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFolder", "EditorIcons", resized_folder); @@ -499,8 +500,9 @@ void EditorFileDialog::update_file_list() { if (!has_icon("ResizedFile", "EditorIcons")) { Ref<ImageTexture> file = get_icon("FileBig", "EditorIcons"); - Image img = file->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = file->get_data(); + img = img->duplicate(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture)); resized_file->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 698066f188..a9014ad97b 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3566,7 +3566,7 @@ bool EditorNode::is_scene_in_use(const String &p_path) { void EditorNode::register_editor_types() { ClassDB::register_class<EditorPlugin>(); - // ClassDB::register_class<EditorImportPlugin>(); + ClassDB::register_class<EditorImportPlugin>(); // ClassDB::register_class<EditorExportPlugin>(); // ClassDB::register_class<EditorScenePostImport>(); ClassDB::register_class<EditorScript>(); @@ -4463,8 +4463,9 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { { //todo make proper previews Ref<ImageTexture> pic = gui_base->get_icon("FileBig", "EditorIcons"); - Image img = pic->get_data(); - img.resize(48, 48); //meh + Ref<Image> img = pic->get_data(); + img = img->duplicate(); + img->resize(48, 48); //meh Ref<ImageTexture> resized_pic = Ref<ImageTexture>(memnew(ImageTexture)); resized_pic->create_from_image(img); preview = resized_pic; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 405784a7e2..5e5b31aac9 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -276,6 +276,11 @@ bool EditorPlugin::get_remove_list(List<Node *> *p_list) { void EditorPlugin::restore_global_state() {} void EditorPlugin::save_global_state() {} +void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer) { + ResourceFormatImporter::get_singleton()->add_importer(p_importer); + EditorFileSystem::get_singleton()->scan_changes(); +} + void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) { if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) { @@ -360,7 +365,7 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("get_editor_settings:EditorSettings"), &EditorPlugin::get_editor_settings); ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout); ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource); - + ClassDB::bind_method(D_METHOD("add_import_plugin"), &EditorPlugin::add_import_plugin); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::INPUT_EVENT, "event"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::INPUT_EVENT, "event"))); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 5df1f63fbe..5f4b47caee 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -30,6 +30,7 @@ #ifndef EDITOR_PLUGIN_H #define EDITOR_PLUGIN_H +#include "editor/import/editor_import_plugin.h" #include "io/config_file.h" #include "scene/gui/tool_button.h" #include "scene/main/node.h" @@ -146,6 +147,8 @@ public: virtual void restore_global_state(); virtual void save_global_state(); + void add_import_plugin(const Ref<EditorImportPlugin> &p_importer); + EditorPlugin(); virtual ~EditorPlugin(); }; diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index 8f4312111a..9d12ad687e 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -344,14 +344,16 @@ void EditorProfiler::_update_plot() { wr = PoolVector<uint8_t>::Write(); - Image img(w, h, 0, Image::FORMAT_RGBA8, graph_image); + Ref<Image> img; + img.instance(); + img->create(w, h, 0, Image::FORMAT_RGBA8, graph_image); if (reset_texture) { if (graph_texture.is_null()) { graph_texture.instance(); } - graph_texture->create(img.get_width(), img.get_height(), img.get_format(), Texture::FLAG_VIDEO_SURFACE); + graph_texture->create(img->get_width(), img->get_height(), img->get_format(), Texture::FLAG_VIDEO_SURFACE); } graph_texture->set_data(img); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 5a519a1dbd..4a767621ef 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -43,11 +43,12 @@ void EditorRunNative::_notification(int p_what) { continue; Ref<ImageTexture> icon = eep->get_logo(); if (!icon.is_null()) { - Image im = icon->get_data(); - im.clear_mipmaps(); - if (!im.empty()) { + Ref<Image> im = icon->get_data(); + im = im->duplicate(); + im->clear_mipmaps(); + if (!im->empty()) { - im.resize(16, 16); + im->resize(16, 16); Ref<ImageTexture> small_icon; small_icon.instance(); small_icon->create_from_image(im, 0); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index c324f474bb..71e43216b3 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -416,8 +416,9 @@ void FileSystemDock::_update_files(bool p_keep_selection) { if (!has_icon("ResizedFolder", "EditorIcons")) { Ref<ImageTexture> folder = get_icon("FolderBig", "EditorIcons"); - Image img = folder->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = folder->get_data(); + img = img->duplicate(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_folder = Ref<ImageTexture>(memnew(ImageTexture)); resized_folder->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFolder", "EditorIcons", resized_folder); @@ -427,8 +428,8 @@ void FileSystemDock::_update_files(bool p_keep_selection) { if (!has_icon("ResizedFile", "EditorIcons")) { Ref<ImageTexture> file = get_icon("FileBig", "EditorIcons"); - Image img = file->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = file->get_data(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture)); resized_file->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file); diff --git a/editor/icons/2x/icon_godot.png b/editor/icons/2x/icon_godot.png Binary files differdeleted file mode 100644 index 94d87e23cc..0000000000 --- a/editor/icons/2x/icon_godot.png +++ /dev/null diff --git a/editor/icons/2x/icon_godot_docs.png b/editor/icons/2x/icon_godot_docs.png Binary files differnew file mode 100644 index 0000000000..be30f092ef --- /dev/null +++ b/editor/icons/2x/icon_godot_docs.png diff --git a/editor/icons/SCsub b/editor/icons/SCsub index 3fc8e5461f..20a381cc78 100644 --- a/editor/icons/SCsub +++ b/editor/icons/SCsub @@ -62,9 +62,9 @@ def make_editor_icons_action(target, source, env): s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") - s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") - s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA8); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") - s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") + s.write("\tRef<Image> img = memnew(Image(use_hidpi_image?p_hidpi_png:p_png));\n") + s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img->convert(Image::FORMAT_RGBA8); img->expand_x2_hq2x(); use_hidpi_image=true;}\n") + s.write("\timg->resize(img->get_width()*EDSCALE/(use_hidpi_image?2:1),img->get_height()*EDSCALE/(use_hidpi_image?2:1));\n") s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") s.write("\treturn texture;\n") s.write("}\n\n") diff --git a/editor/icons/icon_default_project_icon.png b/editor/icons/icon_default_project_icon.png Binary files differindex e87a49bd28..4c31fe5cb2 100644 --- a/editor/icons/icon_default_project_icon.png +++ b/editor/icons/icon_default_project_icon.png diff --git a/editor/icons/icon_godot.png b/editor/icons/icon_godot.png Binary files differdeleted file mode 100644 index 0b72e6ecc7..0000000000 --- a/editor/icons/icon_godot.png +++ /dev/null diff --git a/editor/icons/icon_godot_docs.png b/editor/icons/icon_godot_docs.png Binary files differnew file mode 100644 index 0000000000..554280c5b4 --- /dev/null +++ b/editor/icons/icon_godot_docs.png diff --git a/editor/icons/icon_logo.png b/editor/icons/icon_logo.png Binary files differindex 9bbd7dc619..aed94cb87a 100644 --- a/editor/icons/icon_logo.png +++ b/editor/icons/icon_logo.png diff --git a/editor/icons/icon_logo_small.png b/editor/icons/icon_logo_small.png Binary files differindex 9c7c7fe365..809cf18541 100644 --- a/editor/icons/icon_logo_small.png +++ b/editor/icons/icon_logo_small.png diff --git a/editor/icons/source/icon_godot.svg b/editor/icons/source/icon_godot.svg deleted file mode 100644 index 419f23125b..0000000000 --- a/editor/icons/source/icon_godot.svg +++ /dev/null @@ -1,168 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="16" - height="16" - viewBox="0 0 16 16" - id="svg2" - version="1.1" - inkscape:version="0.91 r13725" - inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape_2d.png" - inkscape:export-xdpi="90" - inkscape:export-ydpi="90" - sodipodi:docname="icon_godot.svg"> - <defs - id="defs4" /> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="32" - inkscape:cx="9.8470361" - inkscape:cy="9.8599985" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - units="px" - inkscape:snap-bbox="true" - inkscape:bbox-paths="true" - inkscape:bbox-nodes="true" - inkscape:snap-bbox-edge-midpoints="true" - inkscape:snap-bbox-midpoints="true" - inkscape:snap-object-midpoints="true" - inkscape:snap-center="true" - inkscape:window-width="1920" - inkscape:window-height="1016" - inkscape:window-x="0" - inkscape:window-y="27" - inkscape:window-maximized="1"> - <inkscape:grid - type="xygrid" - id="grid3336" /> - </sodipodi:namedview> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - transform="translate(0,-1036.3622)"> - <g - transform="matrix(0.01724138,0,0,0.01724138,-0.82758647,1035.0456)" - id="layer1-5" - inkscape:label="Layer 1"> - <g - transform="matrix(1.0688992,0,0,1.1334985,-45.061194,-81.689066)" - id="g4149"> - <path - style="fill:#ffffff;fill-opacity:1;stroke:none" - d="m 116.99388,715.36604 43.13957,-74.51381 75.99672,-171.42666 271.088,-13.63746 282.06373,14.1696 138.45065,255.56931 -25.0756,66.96734 -376.12685,53.39482 -367.70391,-40.32222 z" - id="path3239" - inkscape:connector-curvature="0" - sodipodi:nodetypes="cccccccccc" /> - <g - id="g3412" - transform="matrix(12.995388,0,0,-12.995388,898.37246,704.73082)"> - <path - inkscape:connector-curvature="0" - d="m 0,0 0,-3.942 c 0,-0.39 -0.25,-0.734 -0.621,-0.852 L -6.835,-6.8 c -0.273,-0.091 -0.57,-0.042 -0.8,0.128 -0.232,0.168 -0.37,0.437 -0.37,0.721 l 0,4.305 -5.818,-1.108 0,-4.381 c 0,-0.447 -0.332,-0.824 -0.775,-0.885 l -8.41,-1.152 c -0.039,-0.003 -0.081,-0.008 -0.121,-0.008 -0.214,0 -0.424,0.078 -0.588,0.22 -0.195,0.172 -0.306,0.416 -0.306,0.676 l 0,4.638 -4.341,-0.018 0,-10e-4 -0.318,10e-4 -0.319,-10e-4 0,10e-4 -4.34,0.018 0,-4.638 c 0,-0.26 -0.112,-0.504 -0.307,-0.676 -0.164,-0.142 -0.374,-0.22 -0.587,-0.22 -0.041,0 -0.082,0.005 -0.123,0.008 l -8.41,1.152 c -0.442,0.061 -0.774,0.438 -0.774,0.885 l 0,4.381 -5.819,1.108 0,-4.305 c 0,-0.284 -0.137,-0.553 -0.368,-0.721 -0.232,-0.17 -0.529,-0.219 -0.802,-0.128 l -6.215,2.006 c -0.369,0.118 -0.619,0.462 -0.619,0.852 l 0,3.942 -3.837,1.29 c -0.19,-0.811 -0.295,-1.642 -0.295,-2.481 0,-10.301 14.512,-18.252 32.448,-18.309 l 0.022,0 0.023,0 c 17.936,0.057 32.448,8.008 32.448,18.309 0,0.766 -0.088,1.521 -0.247,2.266 L 0,0 Z" - style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none" - id="path3414" /> - </g> - <g - id="g3416" - transform="matrix(12.995388,0,0,-12.995388,140.10982,467.34929)"> - <path - inkscape:connector-curvature="0" - d="m 0,0 0,-16.047 2.163,-0.729 c 0.364,-0.122 0.61,-0.462 0.61,-0.847 l 0,-3.936 4.426,-1.428 0,4.154 c 0,0.27 0.118,0.52 0.323,0.689 0.206,0.172 0.474,0.241 0.739,0.192 l 7.608,-1.452 c 0.422,-0.079 0.728,-0.448 0.728,-0.877 l 0,-4.338 6.62,-0.904 0,4.509 c 0,0.241 0.096,0.467 0.264,0.635 0.167,0.166 0.394,0.259 0.633,0.259 l 0.002,0 5.551,-0.022 5.549,0.022 c 0.245,-10e-4 0.468,-0.093 0.635,-0.259 0.169,-0.168 0.264,-0.394 0.264,-0.635 l 0,-4.509 6.621,0.904 0,4.338 c 0,0.429 0.304,0.798 0.726,0.877 l 7.609,1.452 c 0.262,0.049 0.533,-0.02 0.738,-0.192 0.205,-0.169 0.325,-0.419 0.325,-0.689 l 0,-4.154 4.425,1.428 0,3.936 c 0,0.385 0.245,0.725 0.609,0.847 l 1.475,0.497 0,16.279 0.04,0 c 1.437,1.834 2.767,3.767 4.042,5.828 -1.694,2.883 -3.768,5.459 -5.986,7.846 -2.057,-1.035 -4.055,-2.208 -5.942,-3.456 -0.944,0.938 -2.008,1.706 -3.052,2.509 -1.027,0.824 -2.183,1.428 -3.281,2.132 0.327,2.433 0.489,4.828 0.554,7.327 -2.831,1.424 -5.85,2.369 -8.903,3.047 -1.219,-2.048 -2.334,-4.267 -3.304,-6.436 -1.152,0.192 -2.309,0.264 -3.467,0.277 l 0,0.002 c -0.008,0 -0.015,-0.002 -0.022,-0.002 -0.008,0 -0.015,0.002 -0.022,0.002 l 0,-0.002 c -1.16,-0.013 -2.316,-0.085 -3.468,-0.277 -0.97,2.169 -2.084,4.388 -3.305,6.436 C 19.475,24.555 16.456,23.61 13.626,22.186 13.69,19.687 13.852,17.292 14.18,14.859 13.081,14.155 11.925,13.551 10.898,12.727 9.855,11.924 8.79,11.156 7.846,10.218 5.958,11.466 3.961,12.639 1.904,13.674 -0.314,11.287 -2.388,8.711 -4.082,5.828 -2.807,3.767 -1.477,1.834 -0.04,0 L 0,0 Z" - style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none" - id="path3418" /> - </g> - <g - id="g3420" - transform="matrix(12.995388,0,0,-12.995388,411.4457,567.42812)"> - <path - inkscape:connector-curvature="0" - d="m 0,0 c 0,-3.611 -2.926,-6.537 -6.537,-6.537 -3.608,0 -6.535,2.926 -6.535,6.537 0,3.609 2.927,6.533 6.535,6.533 C -2.926,6.533 0,3.609 0,0" - style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" - id="path3422" /> - </g> - <g - id="g3424" - transform="matrix(12.995388,0,0,-12.995388,391.00655,572.46636)"> - <path - inkscape:connector-curvature="0" - d="m 0,0 c 0,-2.396 -1.941,-4.337 -4.339,-4.337 -2.396,0 -4.339,1.941 -4.339,4.337 0,2.396 1.943,4.339 4.339,4.339 C -1.941,4.339 0,2.396 0,0" - style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none" - id="path3426" /> - </g> - <g - id="g3428" - transform="matrix(12.995388,0,0,-12.995388,526.30933,660.10985)"> - <path - inkscape:connector-curvature="0" - d="m 0,0 c -1.162,0 -2.104,0.856 -2.104,1.912 l 0,6.018 c 0,1.054 0.942,1.912 2.104,1.912 1.162,0 2.106,-0.858 2.106,-1.912 l 0,-6.018 C 2.106,0.856 1.162,0 0,0" - style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" - id="path3430" /> - </g> - <g - id="g3432" - transform="matrix(12.995388,0,0,-12.995388,641.18731,567.42812)"> - <path - inkscape:connector-curvature="0" - d="m 0,0 c 0,-3.611 2.926,-6.537 6.537,-6.537 3.609,0 6.535,2.926 6.535,6.537 0,3.609 -2.926,6.533 -6.535,6.533 C 2.926,6.533 0,3.609 0,0" - style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" - id="path3434" /> - </g> - <g - id="g3436" - transform="matrix(12.995388,0,0,-12.995388,661.63165,572.46636)"> - <path - inkscape:connector-curvature="0" - d="m 0,0 c 0,-2.396 1.941,-4.337 4.336,-4.337 2.398,0 4.339,1.941 4.339,4.337 0,2.396 -1.941,4.339 -4.339,4.339 C 1.941,4.339 0,2.396 0,0" - style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none" - id="path3438" /> - </g> - </g> - </g> - <path - style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436" - d="m 4,1041.3622 a 3,3 0 0 0 -3,3 3,3 0 0 0 3,3 3,3 0 0 0 3,-3 3,3 0 0 0 -3,-3 z m 0,1 a 2.0000174,2.0000174 0 0 1 2,2 2.0000174,2.0000174 0 0 1 -2,2 2.0000174,2.0000174 0 0 1 -2,-2 2.0000174,2.0000174 0 0 1 2,-2 z" - id="path4151" - inkscape:connector-curvature="0" /> - <path - inkscape:connector-curvature="0" - id="path4156" - d="m 12,1041.3622 a 3,3 0 0 0 -3,3 3,3 0 0 0 3,3 3,3 0 0 0 3,-3 3,3 0 0 0 -3,-3 z m 0,1 a 2.0000174,2.0000174 0 0 1 2,2 2.0000174,2.0000174 0 0 1 -2,2 2.0000174,2.0000174 0 0 1 -2,-2 2.0000174,2.0000174 0 0 1 2,-2 z" - style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436" /> - <rect - style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436" - id="rect4160" - width="4" - height="1" - x="6" - y="1043.3622" - ry="0" /> - </g> -</svg> diff --git a/editor/icons/source/icon_godot_docs.svg b/editor/icons/source/icon_godot_docs.svg new file mode 100644 index 0000000000..77aa92b31f --- /dev/null +++ b/editor/icons/source/icon_godot_docs.svg @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 15 15" + id="svg2" + version="1.1" + inkscape:version="0.92.1 r15371" + inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_collision_shape_2d.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + sodipodi:docname="icon_godot_docs.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="22.627417" + inkscape:cx="-14.305844" + inkscape:cy="5.1981046" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="true" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1920" + inkscape:window-height="1011" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1"> + <inkscape:grid + type="xygrid" + id="grid3336" + originx="0" + originy="0" + spacingx="1" + spacingy="1" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1037.3622)"> + <g + id="g78" + transform="matrix(0.06307836,0,0,-0.06307664,13.671143,1047.293)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 c 0,0 -0.325,1.994 -0.515,1.976 l -36.182,-3.491 c -2.879,-0.278 -5.115,-2.574 -5.317,-5.459 l -0.994,-14.247 -27.992,-1.997 -1.904,12.912 c -0.424,2.872 -2.932,5.037 -5.835,5.037 h -38.188 c -2.902,0 -5.41,-2.165 -5.834,-5.037 l -1.905,-12.912 -27.992,1.997 -0.994,14.247 c -0.202,2.886 -2.438,5.182 -5.317,5.46 l -36.2,3.49 c -0.187,0.018 -0.324,-1.978 -0.511,-1.978 l -0.049,-7.83 30.658,-4.944 1.004,-14.374 c 0.203,-2.91 2.551,-5.263 5.463,-5.472 l 38.551,-2.75 c 0.146,-0.01 0.29,-0.016 0.434,-0.016 2.897,0 5.401,2.166 5.825,5.038 l 1.959,13.286 h 28.005 l 1.959,-13.286 c 0.423,-2.871 2.93,-5.037 5.831,-5.037 0.142,0 0.284,0.005 0.423,0.015 l 38.556,2.75 c 2.911,0.209 5.26,2.562 5.463,5.472 l 1.003,14.374 30.645,4.966 z" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path80" + inkscape:connector-curvature="0" /> + </g> + <g + id="g82-3" + transform="matrix(0.06307836,0,0,-0.06307664,1.3279404,1043.5689)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 v -47.514 -6.035 -5.492 c 0.108,-0.001 0.216,-0.005 0.323,-0.015 l 36.196,-3.49 c 1.896,-0.183 3.382,-1.709 3.514,-3.609 l 1.116,-15.978 31.574,-2.253 2.175,14.747 c 0.282,1.912 1.922,3.329 3.856,3.329 h 38.188 c 1.933,0 3.573,-1.417 3.855,-3.329 l 2.175,-14.747 31.575,2.253 1.115,15.978 c 0.133,1.9 1.618,3.425 3.514,3.609 l 36.182,3.49 c 0.107,0.01 0.214,0.014 0.322,0.015 v 4.711 l 0.015,0.005 V 0 h 0.134 c 4.795,6.12 9.232,12.569 13.487,19.449 -5.651,9.62 -12.575,18.217 -19.976,26.182 -6.864,-3.455 -13.531,-7.369 -19.828,-11.534 -3.151,3.132 -6.7,5.694 -10.186,8.372 -3.425,2.751 -7.285,4.768 -10.946,7.118 1.09,8.117 1.629,16.108 1.846,24.448 -9.446,4.754 -19.519,7.906 -29.708,10.17 -4.068,-6.837 -7.788,-14.241 -11.028,-21.479 -3.842,0.642 -7.702,0.88 -11.567,0.926 v 0.006 c -0.027,0 -0.052,-0.006 -0.075,-0.006 -0.024,0 -0.049,0.006 -0.073,0.006 V 63.652 C 93.903,63.606 90.046,63.368 86.203,62.726 82.965,69.964 79.247,77.368 75.173,84.205 64.989,81.941 54.915,78.789 45.47,74.035 45.686,65.695 46.225,57.704 47.318,49.587 43.65,47.237 39.795,45.22 36.369,42.469 32.888,39.791 29.333,37.229 26.181,34.097 19.884,38.262 13.219,42.176 6.353,45.631 -1.048,37.666 -7.968,29.069 -13.621,19.449 -9.368,12.569 -4.928,6.12 -0.134,0 Z" + style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path84-6" + inkscape:connector-curvature="0" /> + </g> + <g + id="g86-7" + transform="matrix(0.06307836,0,0,-0.06307664,11.62285,1047.9836)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 -1.121,-16.063 c -0.135,-1.936 -1.675,-3.477 -3.611,-3.616 l -38.555,-2.751 c -0.094,-0.007 -0.188,-0.01 -0.281,-0.01 -1.916,0 -3.569,1.406 -3.852,3.33 l -2.211,14.994 H -81.09 l -2.211,-14.994 c -0.297,-2.018 -2.101,-3.469 -4.133,-3.32 l -38.555,2.751 c -1.936,0.139 -3.476,1.68 -3.611,3.616 L -130.721,0 -163.268,3.138 c 0.015,-3.498 0.06,-7.33 0.06,-8.093 0,-34.374 43.605,-50.896 97.781,-51.086 h 0.066 0.067 c 54.176,0.19 97.766,16.712 97.766,51.086 0,0.777 0.047,4.593 0.063,8.093 z" + style="fill:#478cbf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path88-5" + inkscape:connector-curvature="0" /> + </g> + <g + id="g90-3" + transform="matrix(0.06307836,0,0,-0.06307664,5.6393685,1045.0806)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 c 0,-12.052 -9.765,-21.815 -21.813,-21.815 -12.042,0 -21.81,9.763 -21.81,21.815 0,12.044 9.768,21.802 21.81,21.802 C -9.765,21.802 0,12.044 0,0" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path92-5" + inkscape:connector-curvature="0" /> + </g> + <g + id="g94-6" + transform="matrix(0.06307836,0,0,-0.06307664,5.3082938,1045.1623)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 c 0,-7.994 -6.479,-14.473 -14.479,-14.473 -7.996,0 -14.479,6.479 -14.479,14.473 0,7.994 6.483,14.479 14.479,14.479 C -6.479,14.479 0,7.994 0,0" + style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path96-2" + inkscape:connector-curvature="0" /> + </g> + <g + id="g98-9" + transform="matrix(0.06307836,0,0,-0.06307664,7.4998997,1046.5818)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 c -3.878,0 -7.021,2.858 -7.021,6.381 v 20.081 c 0,3.52 3.143,6.381 7.021,6.381 3.878,0 7.028,-2.861 7.028,-6.381 V 6.381 C 7.028,2.858 3.878,0 0,0" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path100-1" + inkscape:connector-curvature="0" /> + </g> + <g + id="g102-2" + transform="matrix(0.06307836,0,0,-0.06307664,9.3606615,1045.0806)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 c 0,-12.052 9.765,-21.815 21.815,-21.815 12.041,0 21.808,9.763 21.808,21.815 0,12.044 -9.767,21.802 -21.808,21.802 C 9.765,21.802 0,12.044 0,0" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path104-7" + inkscape:connector-curvature="0" /> + </g> + <g + id="g106-0" + transform="matrix(0.06307836,0,0,-0.06307664,9.6918191,1045.1623)" + style="stroke-width:19.8168869"> + <path + d="m 0,0 c 0,-7.994 6.477,-14.473 14.471,-14.473 8.002,0 14.479,6.479 14.479,14.473 0,7.994 -6.477,14.479 -14.479,14.479 C 6.477,14.479 0,7.994 0,0" + style="fill:#414042;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:19.8168869" + id="path108-9" + inkscape:connector-curvature="0" /> + </g> + <path + inkscape:connector-curvature="0" + id="path4392" + d="m 4.3227149,1042.5597 a 2.5297459,2.5296773 0 0 0 -2.5297461,2.5297 2.5297459,2.5296773 0 0 0 2.5297461,2.5297 2.5297459,2.5296773 0 0 0 2.5297463,-2.5297 2.5297459,2.5296773 0 0 0 -2.5297463,-2.5297 z m 0,0.5084 a 2.0213759,2.021321 0 0 1 2.0213758,2.0213 2.0213759,2.021321 0 0 1 -2.0213758,2.0213 2.0213759,2.021321 0 0 1 -2.0213757,-2.0213 2.0213759,2.021321 0 0 1 2.0213757,-2.0213 z" + style="opacity:1;fill:#414042;fill-opacity:1;stroke:none;stroke-width:1.94780529;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter:url(#filter4200);enable-background:new" /> + <path + style="opacity:1;fill:#414042;fill-opacity:1;stroke:none;stroke-width:1.94780529;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter:url(#filter4200);enable-background:new" + d="m 10.679126,1042.5597 a 2.5297459,2.5296773 0 0 0 -2.5297472,2.5297 2.5297459,2.5296773 0 0 0 2.5297472,2.5297 2.5297459,2.5296773 0 0 0 2.529744,-2.5297 2.5297459,2.5296773 0 0 0 -2.529744,-2.5297 z m 0,0.5084 a 2.0213759,2.021321 0 0 1 2.021373,2.0213 2.0213759,2.021321 0 0 1 -2.021373,2.0213 2.0213759,2.021321 0 0 1 -2.0213767,-2.0213 2.0213759,2.021321 0 0 1 2.0213767,-2.0213 z" + id="path4403" + inkscape:connector-curvature="0" /> + <rect + style="opacity:1;fill:#414042;fill-opacity:1;stroke:none;stroke-width:5.625;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.44162436" + id="rect4160" + width="2.3136585" + height="0.53352129" + x="6.3440895" + y="1043.9767" /> + </g> +</svg> diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp new file mode 100644 index 0000000000..6dee5da538 --- /dev/null +++ b/editor/import/editor_import_plugin.cpp @@ -0,0 +1,152 @@ +/*************************************************************************/ +/* editor_import_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "editor_import_plugin.h" +#include "core/script_language.h" + +EditorImportPlugin::EditorImportPlugin() { +} + +String EditorImportPlugin::get_importer_name() const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_importer_name")), ""); + return get_script_instance()->call("get_importer_name"); +} + +String EditorImportPlugin::get_visible_name() const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_visible_name")), ""); + return get_script_instance()->call("get_visible_name"); +} + +void EditorImportPlugin::get_recognized_extensions(List<String> *p_extensions) const { + ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("get_recognized_extensions"))); + Array extensions = get_script_instance()->call("get_recognized_extensions"); + for (int i = 0; i < extensions.size(); i++) { + p_extensions->push_back(extensions[i]); + } +} + +String EditorImportPlugin::get_preset_name(int p_idx) const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_preset_name")), ""); + return get_script_instance()->call("get_preset_name", p_idx); +} + +int EditorImportPlugin::get_preset_count() { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_preset_count")), 0); + return get_script_instance()->call("get_preset_count"); +} + +String EditorImportPlugin::get_save_extension() const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_save_extension")), ""); + return get_script_instance()->call("get_save_extension"); +} + +String EditorImportPlugin::get_resource_type() const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_resource_type")), ""); + return get_script_instance()->call("get_resource_type"); +} + +void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options, int p_preset) const { + + ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("get_import_options"))); + Array needed; + needed.push_back("name"); + needed.push_back("default_value"); + Array options = get_script_instance()->call("get_import_options", p_preset); + for (int i = 0; i < options.size(); i++) { + Dictionary d = options[i]; + ERR_FAIL_COND(!d.has_all(needed)); + String name = d["name"]; + Variant default_value = d["default_value"]; + + PropertyHint hint = PROPERTY_HINT_NONE; + if (d.has("property_hint")) { + hint = (PropertyHint)d["property_hint"].operator int64_t(); + } + + String hint_string; + if (d.has("hint_string")) { + hint_string = d["hint_string"]; + } + + uint32_t usage = PROPERTY_USAGE_DEFAULT; + if (d.has("usage")) { + usage = d["usage"]; + } + + ImportOption option(PropertyInfo(default_value.get_type(), name, hint, hint_string, usage), default_value); + r_options->push_back(option); + } +} + +bool EditorImportPlugin::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_option_visibility")), true); + Dictionary d; + Map<StringName, Variant>::Element *E = p_options.front(); + while (E) { + d[E->key()] = E->get(); + E = E->next(); + } + return get_script_instance()->call("get_option_visibility", p_option, d); +} + +Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { + + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("import")), ERR_UNAVAILABLE); + Dictionary options; + Array platform_variants, gen_files; + + Map<StringName, Variant>::Element *E = p_options.front(); + while (E) { + options[E->key()] = E->get(); + E = E->next(); + } + Error err = (Error)get_script_instance()->call("import", p_source_file, p_save_path, options, platform_variants, gen_files).operator int64_t(); + + for (int i = 0; i < platform_variants.size(); i++) { + r_platform_variants->push_back(platform_variants[i]); + } + for (int i = 0; i < gen_files.size(); i++) { + r_gen_files->push_back(gen_files[i]); + } + return err; +} + +void EditorImportPlugin::_bind_methods() { + + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_importer_name")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_visible_name")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_preset_count")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_preset_name", PropertyInfo(Variant::INT, "preset"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::ARRAY, "get_recognized_extensions")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::ARRAY, "get_import_options", PropertyInfo(Variant::INT, "preset"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_save_extension")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_resource_type")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "get_option_visibility", PropertyInfo(Variant::STRING, "option"), PropertyInfo(Variant::DICTIONARY, "options"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "import", PropertyInfo(Variant::STRING, "source_file"), PropertyInfo(Variant::STRING, "save_path"), PropertyInfo(Variant::DICTIONARY, "options"), PropertyInfo(Variant::ARRAY, "r_platform_variants"), PropertyInfo(Variant::ARRAY, "r_gen_files"))); +} diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h new file mode 100644 index 0000000000..3c16b79713 --- /dev/null +++ b/editor/import/editor_import_plugin.h @@ -0,0 +1,54 @@ +/*************************************************************************/ +/* editor_import_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef EDITOR_IMPORT_PLUGIN_H +#define EDITOR_IMPORT_PLUGIN_H + +#include "io/resource_import.h" + +class EditorImportPlugin : public ResourceImporter { + GDCLASS(EditorImportPlugin, Reference) +protected: + static void _bind_methods(); + +public: + EditorImportPlugin(); + virtual String get_importer_name() const; + virtual String get_visible_name() const; + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual String get_preset_name(int p_idx) const; + virtual int get_preset_count(); + virtual String get_save_extension() const; + virtual String get_resource_type() const; + virtual void get_import_options(List<ImportOption> *r_options, int p_preset) const; + virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files); +}; + +#endif //EDITOR_IMPORT_PLUGIN_H diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index f0dcc4a298..c115f0014a 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -181,7 +181,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT)); } -void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb) { +void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb) { FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); f->store_8('G'); @@ -189,8 +189,8 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t f->store_8('S'); f->store_8('T'); //godot streamable texture - f->store_32(p_image.get_width()); - f->store_32(p_image.get_height()); + f->store_32(p_image->get_width()); + f->store_32(p_image->get_height()); f->store_32(p_texture_flags); uint32_t format = 0; @@ -207,14 +207,14 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t switch (p_compress_mode) { case COMPRESS_LOSSLESS: { - Image image = p_image; + Ref<Image> image = p_image->duplicate(); if (p_mipmaps) { - image.generate_mipmaps(); + image->generate_mipmaps(); } else { - image.clear_mipmaps(); + image->clear_mipmaps(); } - int mmc = image.get_mipmap_count() + 1; + int mmc = image->get_mipmap_count() + 1; format |= StreamTexture::FORMAT_BIT_LOSSLESS; f->store_32(format); @@ -223,7 +223,7 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t for (int i = 0; i < mmc; i++) { if (i > 0) { - image.shrink_x2(); + image->shrink_x2(); } PoolVector<uint8_t> data = Image::lossless_packer(image); @@ -236,14 +236,14 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t } break; case COMPRESS_LOSSY: { - Image image = p_image; + Ref<Image> image = p_image->duplicate(); if (p_mipmaps) { - image.generate_mipmaps(); + image->generate_mipmaps(); } else { - image.clear_mipmaps(); + image->clear_mipmaps(); } - int mmc = image.get_mipmap_count() + 1; + int mmc = image->get_mipmap_count() + 1; format |= StreamTexture::FORMAT_BIT_LOSSY; f->store_32(format); @@ -252,7 +252,7 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t for (int i = 0; i < mmc; i++) { if (i > 0) { - image.shrink_x2(); + image->shrink_x2(); } PoolVector<uint8_t> data = Image::lossy_packer(image, p_lossy_quality); @@ -265,15 +265,15 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t } break; case COMPRESS_VIDEO_RAM: { - Image image = p_image; - image.generate_mipmaps(); - image.compress(p_vram_compression); + Ref<Image> image = p_image->duplicate(); + image->generate_mipmaps(); + image->compress(p_vram_compression); - format |= image.get_format(); + format |= image->get_format(); f->store_32(format); - PoolVector<uint8_t> data = image.get_data(); + PoolVector<uint8_t> data = image->get_data(); int dl = data.size(); PoolVector<uint8_t>::Read r = data.read(); f->store_buffer(r.ptr(), dl); @@ -281,17 +281,17 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t } break; case COMPRESS_UNCOMPRESSED: { - Image image = p_image; + Ref<Image> image = p_image->duplicate(); if (p_mipmaps) { - image.generate_mipmaps(); + image->generate_mipmaps(); } else { - image.clear_mipmaps(); + image->clear_mipmaps(); } - format |= image.get_format(); + format |= image->get_format(); f->store_32(format); - PoolVector<uint8_t> data = image.get_data(); + PoolVector<uint8_t> data = image->get_data(); int dl = data.size(); PoolVector<uint8_t>::Read r = data.read(); @@ -317,8 +317,9 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String bool stream = p_options["stream"]; int size_limit = p_options["size_limit"]; - Image image; - Error err = ImageLoader::load_image(p_source_file, &image); + Ref<Image> image; + image.instance(); + Error err = ImageLoader::load_image(p_source_file, image); if (err != OK) return err; @@ -336,28 +337,28 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (srgb == 1) tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR; - if (size_limit > 0 && (image.get_width() > size_limit || image.get_height() > size_limit)) { + if (size_limit > 0 && (image->get_width() > size_limit || image->get_height() > size_limit)) { //limit size - if (image.get_width() >= image.get_height()) { + if (image->get_width() >= image->get_height()) { int new_width = size_limit; - int new_height = image.get_height() * new_width / image.get_width(); + int new_height = image->get_height() * new_width / image->get_width(); - image.resize(new_width, new_height, Image::INTERPOLATE_CUBIC); + image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC); } else { int new_height = size_limit; - int new_width = image.get_width() * new_height / image.get_height(); + int new_width = image->get_width() * new_height / image->get_height(); - image.resize(new_width, new_height, Image::INTERPOLATE_CUBIC); + image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC); } } if (fix_alpha_border) { - image.fix_alpha_edges(); + image->fix_alpha_edges(); } if (premult_alpha) { - image.premultiply_alpha(); + image->premultiply_alpha(); } bool detect_3d = p_options["detect_3d"]; diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index 196eb48469..e782fc2978 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -30,7 +30,9 @@ #ifndef RESOURCEIMPORTTEXTURE_H #define RESOURCEIMPORTTEXTURE_H +#include "image.h" #include "io/resource_import.h" + class StreamTexture; class ResourceImporterTexture : public ResourceImporter { @@ -78,7 +80,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - void _save_stex(const Image &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb); + void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb); virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL); diff --git a/editor/plugins/baked_light_baker.h b/editor/plugins/baked_light_baker.h index 5f32e236c0..123812fc07 100644 --- a/editor/plugins/baked_light_baker.h +++ b/editor/plugins/baked_light_baker.h @@ -31,7 +31,7 @@ #define BAKED_LIGHT_BAKER_H #include "os/thread.h" -#include "scene/3d/baked_light_instance.h" + #include "scene/3d/light.h" #include "scene/3d/mesh_instance.h" diff --git a/editor/plugins/gradient_texture_editor_plugin.cpp b/editor/plugins/gradient_texture_editor_plugin.cpp index 41dd64d931..005633a10e 100644 --- a/editor/plugins/gradient_texture_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_editor_plugin.cpp @@ -48,7 +48,8 @@ GradientTextureEdit::GradientTextureEdit() { add_child(popup); checker = Ref<ImageTexture>(memnew(ImageTexture)); - checker->create_from_image(Image(checker_bg_png), ImageTexture::FLAG_REPEAT); + Ref<Image> checker_bg = memnew(Image(checker_bg_png)); + checker->create_from_image(checker_bg, ImageTexture::FLAG_REPEAT); } int GradientTextureEdit::_get_point_from_pos(int x) { diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index 35743ce0b3..c6c85d8be2 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -64,17 +64,18 @@ void Particles2DEditorPlugin::_file_selected(const String &p_file) { int epc = epoints->get_value(); - Image img; - Error err = ImageLoader::load_image(p_file, &img); + Ref<Image> img; + img.instance(); + Error err = ImageLoader::load_image(p_file, img); ERR_EXPLAIN(TTR("Error loading image:") + " " + p_file); ERR_FAIL_COND(err != OK); - img.convert(Image::FORMAT_LA8); - ERR_FAIL_COND(img.get_format() != Image::FORMAT_LA8); - Size2i s = Size2(img.get_width(), img.get_height()); + img->convert(Image::FORMAT_LA8); + ERR_FAIL_COND(img->get_format() != Image::FORMAT_LA8); + Size2i s = Size2(img->get_width(), img->get_height()); ERR_FAIL_COND(s.width == 0 || s.height == 0); - PoolVector<uint8_t> data = img.get_data(); + PoolVector<uint8_t> data = img->get_data(); PoolVector<uint8_t>::Read r = data.read(); Vector<Point2i> valid_positions; @@ -98,7 +99,7 @@ void Particles2DEditorPlugin::_file_selected(const String &p_file) { epoints.resize(epc); PoolVector<Point2>::Write w = epoints.write(); - Size2 extents = Size2(img.get_width() * 0.5, img.get_height() * 0.5); + Size2 extents = Size2(img->get_width() * 0.5, img->get_height() * 0.5); for (int i = 0; i < epc; i++) { diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 4c84e831c1..dc2da80b06 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -329,7 +329,7 @@ void ParticlesEditor::_generate_emission_points() { copymem(iw.ptr(), r.ptr(), point_count * sizeof(float) * 3); } - Image image(w, h, false, Image::FORMAT_RGBF, point_img); + Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img)); Ref<ImageTexture> tex; tex.instance(); @@ -354,7 +354,7 @@ void ParticlesEditor::_generate_emission_points() { copymem(iw.ptr(), r.ptr(), point_count * sizeof(float) * 3); } - Image image2(w, h, false, Image::FORMAT_RGBF, point_img2); + Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2)); Ref<ImageTexture> tex2; tex2.instance(); diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index e00111b565..045084d2ec 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -81,7 +81,7 @@ bool Path2DEditor::forward_gui_input(const InputEvent &p_event) { Vector2 cpoint = !mb.mod.alt ? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint)) : node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint))); //first check if a point is to be added (segment split) - real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); // Test move point!! @@ -93,34 +93,57 @@ bool Path2DEditor::forward_gui_input(const InputEvent &p_event) { bool pointunder = false; - { - Point2 p = xform.xform(curve->get_point_pos(i)); - if (gpoint.distance_to(p) < grab_treshold) { + real_t dist_to_p = gpoint.distance_to(xform.xform(curve->get_point_pos(i))); + real_t dist_to_p_out = gpoint.distance_to(xform.xform(curve->get_point_pos(i) + curve->get_point_out(i))); + real_t dist_to_p_in = gpoint.distance_to(xform.xform(curve->get_point_pos(i) + curve->get_point_in(i))); - if (mb.button_index == BUTTON_LEFT && !mb.mod.shift && mode == MODE_EDIT) { + if (mb.button_index == BUTTON_LEFT && !mb.mod.shift && mode == MODE_EDIT) { + if (dist_to_p < grab_threshold) { - action = ACTION_MOVING_POINT; - action_point = i; - moving_from = curve->get_point_pos(i); - moving_screen_from = gpoint; - return true; - } else if ((mb.button_index == BUTTON_RIGHT && mode == MODE_EDIT) || (mb.button_index == BUTTON_LEFT && mode == MODE_DELETE)) { + action = ACTION_MOVING_POINT; + action_point = i; + moving_from = curve->get_point_pos(i); + moving_screen_from = gpoint; + return true; + } + } - undo_redo->create_action(TTR("Remove Point from Curve")); - undo_redo->add_do_method(curve.ptr(), "remove_point", i); - undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_pos(i), curve->get_point_in(i), curve->get_point_out(i), i); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->commit_action(); - return true; - } else - pointunder = true; + if ((mb.button_index == BUTTON_RIGHT && mode == MODE_EDIT) || (mb.button_index == BUTTON_LEFT && mode == MODE_DELETE)) { + if (dist_to_p < grab_threshold) { + + undo_redo->create_action(TTR("Remove Point from Curve")); + undo_redo->add_do_method(curve.ptr(), "remove_point", i); + undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_pos(i), curve->get_point_in(i), curve->get_point_out(i), i); + undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->commit_action(); + return true; + } else if (dist_to_p_out < grab_threshold) { + + undo_redo->create_action(TTR("Remove Out-Control from Curve")); + undo_redo->add_do_method(curve.ptr(), "set_point_out", i, Vector2()); + undo_redo->add_undo_method(curve.ptr(), "set_point_out", i, curve->get_point_out(i)); + undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->commit_action(); + return true; + } else if (dist_to_p_in < grab_threshold) { + + undo_redo->create_action(TTR("Remove In-Control from Curve")); + undo_redo->add_do_method(curve.ptr(), "set_point_in", i, Vector2()); + undo_redo->add_undo_method(curve.ptr(), "set_point_in", i, curve->get_point_in(i)); + undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->commit_action(); + return true; } } + if (dist_to_p < grab_threshold) + pointunder = true; + if (mb.button_index == BUTTON_LEFT && i < (curve->get_point_count() - 1)) { - Point2 p = xform.xform(curve->get_point_pos(i) + curve->get_point_out(i)); - if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode == MODE_EDIT_CURVE)) { + if (dist_to_p_out < grab_threshold && (mode == MODE_EDIT || mode == MODE_EDIT_CURVE)) { action = ACTION_MOVING_OUT; action_point = i; @@ -131,8 +154,7 @@ bool Path2DEditor::forward_gui_input(const InputEvent &p_event) { } if (mb.button_index == BUTTON_LEFT && i > 0) { - Point2 p = xform.xform(curve->get_point_pos(i) + curve->get_point_in(i)); - if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode == MODE_EDIT_CURVE)) { + if (dist_to_p_in < grab_threshold && (mode == MODE_EDIT || mode == MODE_EDIT_CURVE)) { action = ACTION_MOVING_IN; action_point = i; @@ -234,7 +256,7 @@ bool Path2DEditor::forward_gui_input(const InputEvent &p_event) { return true; } else { - if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_treshold) { + if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_threshold) { //wip closed _wip_close(); @@ -291,7 +313,7 @@ bool Path2DEditor::forward_gui_input(const InputEvent &p_event) { continue; //not valid to reuse point real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_treshold) { + if (d<closest_dist && d<grab_threshold) { closest_dist=d; closest_pos=cp; closest_idx=i; @@ -322,7 +344,7 @@ bool Path2DEditor::forward_gui_input(const InputEvent &p_event) { Vector2 cp =xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_treshold) { + if (d<closest_dist && d<grab_threshold) { closest_dist=d; closest_pos=cp; closest_idx=i; @@ -370,7 +392,7 @@ bool Path2DEditor::forward_gui_input(const InputEvent &p_event) { Vector2 cp =xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_treshold) { + if (d<closest_dist && d<grab_threshold) { closest_dist=d; closest_pos=cp; closest_idx=i; diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 9c95cee388..9e18a5c4c5 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -407,24 +407,38 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEve } else if (mb.pressed && ((mb.button_index==BUTTON_LEFT && curve_del->is_pressed()) || (mb.button_index==BUTTON_RIGHT && curve_edit->is_pressed()))) { - int erase_idx=-1; for(int i=0;i<c->get_point_count();i++) { - //find the offset and point index of the place to break up - if (p_camera->unproject_position(gt.xform(c->get_point_pos(i))).distance_to(mbpos)<click_dist) { - - erase_idx=i; - break; - } - } + real_t dist_to_p = p_camera->unproject_position(gt.xform(c->get_point_pos(i))).distance_to(mbpos); + real_t dist_to_p_out = p_camera->unproject_position(gt.xform(c->get_point_pos(i) + c->get_point_out(i))).distance_to(mbpos); + real_t dist_to_p_in = p_camera->unproject_position(gt.xform(c->get_point_pos(i) + c->get_point_in(i))).distance_to(mbpos); + + // Find the offset and point index of the place to break up. + // Also check for the control points. + if (dist_to_p < click_dist) { + + UndoRedo *ur = editor->get_undo_redo(); + ur->create_action(TTR("Remove Path Point")); + ur->add_do_method(c.ptr(),"remove_point",i); + ur->add_undo_method(c.ptr(),"add_point",c->get_point_pos(i),c->get_point_in(i),c->get_point_out(i),i); + ur->commit_action(); + return true; + } else if (dist_to_p_out < click_dist) { - if (erase_idx!=-1) { + UndoRedo *ur = editor->get_undo_redo(); + ur->create_action(TTR("Remove Out-Control Point")); + ur->add_do_method(c.ptr(),"set_point_out",i,Vector3()); + ur->add_undo_method(c.ptr(),"set_point_out",i,c->get_point_out(i)); + ur->commit_action(); + return true; + } else if (dist_to_p_in < click_dist) { - UndoRedo *ur = editor->get_undo_redo(); - ur->create_action(TTR("Remove Path Point")); - ur->add_do_method(c.ptr(),"remove_point",erase_idx); - ur->add_undo_method(c.ptr(),"add_point",c->get_point_pos(erase_idx),c->get_point_in(erase_idx),c->get_point_out(erase_idx),erase_idx); - ur->commit_action(); - return true; + UndoRedo *ur = editor->get_undo_redo(); + ur->create_action(TTR("Remove In-Control Point")); + ur->add_do_method(c.ptr(),"set_point_in",i,Vector3()); + ur->add_undo_method(c.ptr(),"set_point_in",i,c->get_point_in(i)); + ur->commit_action(); + return true; + } } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index a5414325d0..48e61a0967 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1037,7 +1037,7 @@ void ScriptEditor::_notification(int p_what) { EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed"); help_search->set_icon(get_icon("Help", "EditorIcons")); - site_search->set_icon(get_icon("Godot", "EditorIcons")); + site_search->set_icon(get_icon("GodotDocs", "EditorIcons")); class_search->set_icon(get_icon("ClassList", "EditorIcons")); script_forward->set_icon(get_icon("Forward", "EditorIcons")); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 01435028ac..3e46724efc 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -428,7 +428,7 @@ private: ViewportContainer *settings_light_base; Viewport *settings_light_vp; ColorPickerButton *settings_ambient_color; - Image settings_light_dir_image; + Ref<Image> settings_light_dir_image; void _xform_dialog_action(); void _menu_item_pressed(int p_option); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 4c49b467d8..89995edf05 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -678,12 +678,13 @@ void TextureRegionEditor::_edit_region() { } autoslice_cache.clear(); - Image i; - if (i.load(texture->get_path()) == OK) { + Ref<Image> i; + i.instance(); + if (i->load(texture->get_path()) == OK) { BitMap bm; bm.create_from_image_alpha(i); - for (int y = 0; y < i.get_height(); y++) { - for (int x = 0; x < i.get_width(); x++) { + for (int y = 0; y < i->get_height(); y++) { + for (int x = 0; x < i->get_width(); x++) { if (bm.get_bit(Point2(x, y))) { bool found = false; for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 289655e9da..2d3b3a2200 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -806,11 +806,12 @@ void ProjectManager::_load_recent_projects() { if (cf->has_section_key("application", "icon")) { String appicon = cf->get_value("application", "icon"); if (appicon != "") { - Image img; - Error err = img.load(appicon.replace_first("res://", path + "/")); + Ref<Image> img; + img.instance(); + Error err = img->load(appicon.replace_first("res://", path + "/")); if (err == OK) { - img.resize(64, 64); + img->resize(64, 64); Ref<ImageTexture> it = memnew(ImageTexture); it->create_from_image(img); icon = it; diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 3dd9ba080c..1bd00f3d1e 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -861,15 +861,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: */ } break; - case Variant::IMAGE: { - List<String> names; - names.push_back(TTR("New")); - names.push_back(TTR("Load")); - names.push_back(TTR("Clear")); - config_action_buttons(names); - - } break; case Variant::NODE_PATH: { List<String> names; @@ -1061,16 +1053,6 @@ void CustomPropertyEditor::_file_selected(String p_file) { emit_signal("variant_changed"); hide(); } break; - case Variant::IMAGE: { - - Image image; - Error err = ImageLoader::load_image(p_file, &image); - ERR_EXPLAIN(TTR("Couldn't load image")); - ERR_FAIL_COND(err); - v = image; - emit_signal("variant_changed"); - hide(); - } break; default: {} } } @@ -1387,36 +1369,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } } break; - case Variant::IMAGE: { - if (p_which == 0) { - //new image too difficult - ERR_PRINT("New Image Unimplemented"); - - } else if (p_which == 1) { - - file->set_access(EditorFileDialog::ACCESS_RESOURCES); - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - List<String> extensions; - ImageLoader::get_recognized_extensions(&extensions); - - file->clear_filters(); - - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); - } - - file->popup_centered_ratio(); - - } else if (p_which == 2) { - - v = Image(); - emit_signal("variant_changed"); - hide(); - } - - } break; default: {}; } } @@ -1756,9 +1709,7 @@ void CustomPropertyEditor::_modified(String p_string) { emit_signal("variant_changed"); */ } break; - case Variant::IMAGE: { - } break; case Variant::NODE_PATH: { v = NodePath(value_editor[0]->get_text()); @@ -2357,15 +2308,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p //p_item->set_text(1,obj->get(p_name)); } break; - case Variant::IMAGE: { - - Image img = obj->get(p_name); - if (img.empty()) - p_item->set_text(1, "[Image (empty)]"); - else - p_item->set_text(1, "[Image " + itos(img.get_width()) + "x" + itos(img.get_height()) + "-" + String(Image::get_format_name(img.get_format())) + "]"); - - } break; case Variant::NODE_PATH: { p_item->set_text(1, obj->get(p_name)); @@ -3588,19 +3530,7 @@ void PropertyEditor::update_tree() { item->set_icon(0, get_icon("Color", "EditorIcons")); } break; - case Variant::IMAGE: { - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, !read_only); - Image img = obj->get(p.name); - if (img.empty()) - item->set_text(1, "[Image (empty)]"); - else - item->set_text(1, "[Image " + itos(img.get_width()) + "x" + itos(img.get_height()) + "-" + String(Image::get_format_name(img.get_format())) + "]"); - if (show_type_icons) - item->set_icon(0, get_icon("Image", "EditorIcons")); - - } break; case Variant::NODE_PATH: { item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); @@ -3922,9 +3852,7 @@ void PropertyEditor::_item_edited() { case Variant::COLOR: { //_edit_set(name,item->get_custom_bg_color(0)); } break; - case Variant::IMAGE: { - } break; case Variant::NODE_PATH: { _edit_set(name, NodePath(item->get_text(1)), refresh_all); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 565d25e0e5..752965c806 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -136,7 +136,6 @@ void PropertySelector::_update_search() { Control::get_icon("MiniMatrix3", "EditorIcons"), Control::get_icon("MiniTransform", "EditorIcons"), Control::get_icon("MiniColor", "EditorIcons"), - Control::get_icon("MiniImage", "EditorIcons"), Control::get_icon("MiniPath", "EditorIcons"), Control::get_icon("MiniRid", "EditorIcons"), Control::get_icon("MiniObject", "EditorIcons"), diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index 6edcd60188..ef875bbead 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -89,7 +89,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { args.push_back("-m"); Ref<ImageTexture> t = memnew(ImageTexture); - t->create_from_image(*p_image, 0); + t->create_from_image(Ref<Image>(p_image), 0); ResourceSaver::save(src_img, t); Error err = OS::get_singleton()->execute(ttpath, args, true); @@ -101,7 +101,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { ERR_EXPLAIN(TTR("Can't load back converted image using PVRTC tool:") + " " + dst_img); ERR_FAIL_COND(t.is_null()); - *p_image = t->get_data(); + p_image->copy_internals_from(t->get_data()); } static void _compress_pvrtc2(Image *p_image) { |