diff options
Diffstat (limited to 'tools/editor')
19 files changed, 521 insertions, 45 deletions
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index 8847654ad7..faaae4360b 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -309,7 +309,7 @@ ConnectDialog::ConnectDialog() { tree = memnew(SceneTreeEditor(false)); - vbc_left->add_margin_child(TTR("Conect To Node:"),tree,true); + vbc_left->add_margin_child(TTR("Connect To Node:"),tree,true); diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index 5afc4a7192..97feaa80a5 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -380,7 +380,7 @@ void EditorFileDialog::_action_pressed() { } - if (dir_access->file_exists(f)) { + if (dir_access->file_exists(f) && !disable_overwrite_warning) { confirm_save->set_text(TTR("File Exists, Overwrite?")); confirm_save->popup_centered(Size2(200,80)); } else { @@ -1162,6 +1162,8 @@ void EditorFileDialog::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_display_mode","mode"),&EditorFileDialog::set_display_mode); ObjectTypeDB::bind_method(_MD("get_display_mode"),&EditorFileDialog::get_display_mode); ObjectTypeDB::bind_method(_MD("_thumbnail_result"),&EditorFileDialog::_thumbnail_result); + ObjectTypeDB::bind_method(_MD("set_disable_overwrite_warning","disable"),&EditorFileDialog::set_disable_overwrite_warning); + ObjectTypeDB::bind_method(_MD("is_overwrite_warning_disabled"),&EditorFileDialog::is_overwrite_warning_disabled); ObjectTypeDB::bind_method(_MD("_recent_selected"),&EditorFileDialog::_recent_selected); ObjectTypeDB::bind_method(_MD("_go_back"),&EditorFileDialog::_go_back); @@ -1235,12 +1237,23 @@ void EditorFileDialog::_save_to_recent() { } +void EditorFileDialog::set_disable_overwrite_warning(bool p_disable) { + + disable_overwrite_warning=p_disable; +} + +bool EditorFileDialog::is_overwrite_warning_disabled() const{ + + return disable_overwrite_warning; +} + + EditorFileDialog::EditorFileDialog() { show_hidden_files=default_show_hidden_files; display_mode=default_display_mode; local_history_pos=0; - + disable_overwrite_warning=false; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); @@ -1466,4 +1479,5 @@ EditorLineEditFileChooser::EditorLineEditFileChooser() { dialog->connect("dir_selected",this,"_chosen"); dialog->connect("files_selected",this,"_chosen"); + } diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h index 5de33e2597..14683856c0 100644 --- a/tools/editor/editor_file_dialog.h +++ b/tools/editor/editor_file_dialog.h @@ -130,6 +130,7 @@ private: bool show_hidden_files; DisplayMode display_mode; + bool disable_overwrite_warning; bool invalidated; void update_dir(); @@ -216,6 +217,9 @@ public: void invalidate(); + void set_disable_overwrite_warning(bool p_disable); + bool is_overwrite_warning_disabled() const; + EditorFileDialog(); ~EditorFileDialog(); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index dd50b720f7..5a3e3069e4 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -205,6 +205,18 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) { case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break; //case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break; case KEY_F8: _menu_option_confirm(RUN_STOP,true); break;*/ + case KEY_TAB: + if (p_event.key.mod.command) { + int current_tab = editor_data.get_edited_scene(); + int tab_offset = 1; + if (p_event.key.mod.shift) + tab_offset = -1; + int next_tab = current_tab + tab_offset; + next_tab = next_tab >= 0 ? next_tab : editor_data.get_edited_scene_count() - 1; + next_tab %= editor_data.get_edited_scene_count(); + _scene_tab_changed(next_tab); + } + break; } } @@ -4606,9 +4618,9 @@ void EditorNode::_update_layouts_menu() { editor_layouts->set_size(Vector2()); editor_layouts->add_shortcut(ED_SHORTCUT("layout/save",TTR("Save Layout")), SETTINGS_LAYOUT_SAVE); - editor_layouts->add_shortcut(ED_SHORTCUT("layout/load",TTR("Load Layout")), SETTINGS_LAYOUT_DELETE); + editor_layouts->add_shortcut(ED_SHORTCUT("layout/delete",TTR("Delete Layout")), SETTINGS_LAYOUT_DELETE); editor_layouts->add_separator(); - editor_layouts->add_shortcut(ED_SHORTCUT("property_editor/reset",TTR("Default")), SETTINGS_LAYOUT_DEFAULT); + editor_layouts->add_shortcut(ED_SHORTCUT("layout/default",TTR("Default")), SETTINGS_LAYOUT_DEFAULT); Ref<ConfigFile> config; config.instance(); diff --git a/tools/editor/icons/2x/icon_loop_interpolation.png b/tools/editor/icons/2x/icon_loop_interpolation.png Binary files differnew file mode 100644 index 0000000000..6009b50300 --- /dev/null +++ b/tools/editor/icons/2x/icon_loop_interpolation.png diff --git a/tools/editor/icons/2x/icon_track_trigger.png b/tools/editor/icons/2x/icon_track_trigger.png Binary files differnew file mode 100644 index 0000000000..c04d47f9a4 --- /dev/null +++ b/tools/editor/icons/2x/icon_track_trigger.png diff --git a/tools/editor/icons/icon_loop_interpolation.png b/tools/editor/icons/icon_loop_interpolation.png Binary files differindex 2f92ab7bf3..488b33316e 100644 --- a/tools/editor/icons/icon_loop_interpolation.png +++ b/tools/editor/icons/icon_loop_interpolation.png diff --git a/tools/editor/icons/icon_track_trigger.png b/tools/editor/icons/icon_track_trigger.png Binary files differnew file mode 100644 index 0000000000..e89f95561a --- /dev/null +++ b/tools/editor/icons/icon_track_trigger.png diff --git a/tools/editor/icons/source/icon_loop_interpolation.svg b/tools/editor/icons/source/icon_loop_interpolation.svg new file mode 100644 index 0000000000..3733acb253 --- /dev/null +++ b/tools/editor/icons/source/icon_loop_interpolation.svg @@ -0,0 +1,111 @@ +<?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_loop_interpolation.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + sodipodi:docname="icon_loop_interpolation.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="3.8522581" + inkscape:cy="6.9411054" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="false" + 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:snap-midpoints="true" + inkscape:snap-smooth-nodes="true" + inkscape:object-nodes="true"> + <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 + id="layer1-8" + inkscape:label="Layer 1" + transform="matrix(0,-1,1,0,-1021.3622,1033.3622)" /> + <circle + style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path4155" + cx="3" + cy="1048.3622" + r="2" /> + <path + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="M 4 3 A 2 2 0 0 0 2.2675781 4 A 2 2 0 0 0 2.0019531 5 L 2 5 L 2 5.046875 L 2 12 L 4 12 L 4 7 L 4 5 L 6 5 L 6 3 L 4 3 z " + transform="translate(0,1036.3622)" + id="path4157" /> + <path + style="fill:#e0e0e0;fill-opacity:0.99607843;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 6,1037.3622 0,6 4,-3 z" + id="path4159" + inkscape:connector-curvature="0" /> + <circle + r="2" + cy="1040.3622" + cx="13" + id="circle4161" + style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <path + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="M 12 4 L 12 9 L 12 11 L 10 11 L 10 13 L 12 13 A 2 2 0 0 0 13.732422 12 A 2 2 0 0 0 13.998047 11 L 14 11 L 14 4 L 12 4 z " + transform="translate(0,1036.3622)" + id="path4163" /> + <path + inkscape:connector-curvature="0" + id="path4165" + d="m 10,1045.3622 0,6 -4,-3 z" + style="fill:#e0e0e0;fill-opacity:0.99607843;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + </g> +</svg> diff --git a/tools/editor/icons/source/icon_track_trigger.svg b/tools/editor/icons/source/icon_track_trigger.svg new file mode 100644 index 0000000000..9c13791f70 --- /dev/null +++ b/tools/editor/icons/source/icon_track_trigger.svg @@ -0,0 +1,109 @@ +<?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="8" + viewBox="0 0 16 8" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_track_trigger.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + sodipodi:docname="icon_track_trigger.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="0.93634514" + inkscape:cy="3.5256605" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + 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" + showguides="true" + inkscape:snap-smooth-nodes="true" + inkscape:object-nodes="true" + inkscape:object-paths="true" + inkscape:snap-intersection-paths="true"> + <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></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1044.3622)"> + <circle + r="1" + cy="1048.3622" + cx="11" + id="circle4232" + style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <circle + style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="circle4234" + cx="14" + cy="1046.3622" + r="1" /> + <rect + style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect4169" + width="6" + height="2" + x="1" + y="1045.3622" /> + <rect + style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect4171" + width="2" + height="3.9999826" + x="3" + y="1047.3622" /> + <circle + style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="circle4173" + cx="8" + cy="1050.3622" + r="1" /> + </g> +</svg> diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index caa838cfd1..97ccb766c0 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -533,7 +533,7 @@ class EditorFontImportDialog : public ConfirmationDialog { } if (dest->get_line_edit()->get_text().extension().to_lower() != "fnt") { - error_dialog->set_text(TTR("Invalid file extension. \nPlease use .fnt")); + error_dialog->set_text(TTR("Invalid file extension.\nPlease use .fnt.")); error_dialog->popup_centered(Size2(200,100)); return; } diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index 80cd54756e..363cba3678 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -2077,6 +2077,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones animation->add_track(Animation::TYPE_TRANSFORM); int track = animation->get_track_count() -1; animation->track_set_path( track , path ); + animation->track_set_imported( track , true ); //helps merging later Vector<float> snapshots = base_snapshots; @@ -2229,6 +2230,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones animation->add_track(Animation::TYPE_TRANSFORM); int track = animation->get_track_count() -1; animation->track_set_path( track , path ); + animation->track_set_imported( track , true ); //helps merging later Transform xform = cn->compute_transform(collada); @@ -2284,8 +2286,11 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones animation->add_track(Animation::TYPE_VALUE); int track = animation->get_track_count() -1; + path = path +":"+at.param; animation->track_set_path( track , path ); + animation->track_set_imported( track , true ); //helps merging later + for(int i=0;i<at.keys.size();i++) { @@ -2376,6 +2381,7 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_ state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); AnimationPlayer *ap = memnew( AnimationPlayer ); + ap->set_name("animations"); for(int i=0;i<state.animations.size();i++) { String name; if (state.animations[i]->get_name()=="") diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index ed766c6598..c7d92a9658 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1069,11 +1069,13 @@ const EditorSceneImportDialog::FlagInfo EditorSceneImportDialog::scene_flag_name {EditorSceneImportPlugin::SCENE_FLAG_IMPORT_ANIMATIONS,("Actions"),"Import Animations",true}, {EditorSceneImportPlugin::SCENE_FLAG_COMPRESS_GEOMETRY,("Actions"),"Compress Geometry",false}, {EditorSceneImportPlugin::SCENE_FLAG_GENERATE_TANGENT_ARRAYS,("Actions"),"Force Generation of Tangent Arrays",false}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_ALPHA,("Materials"),"Set Alpha in Materials (-alpha)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_VCOLOR,("Materials"),"Set Vert. Color in Materials (-vcol)",true}, {EditorSceneImportPlugin::SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES,("Actions"),"SRGB->Linear Of Diffuse Textures",false}, {EditorSceneImportPlugin::SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY,("Actions"),"Convert Normal Maps to XY",true}, {EditorSceneImportPlugin::SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS,("Actions"),"Set Material Lightmap to UV2 if Tex2Array Exists",true}, + {EditorSceneImportPlugin::SCENE_FLAG_MERGE_KEEP_MATERIALS,("Merge"),"Keep Materials after first import (delete them for re-import).",true}, + {EditorSceneImportPlugin::SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,("Merge"),"Keep user-added Animation tracks.",true}, + {EditorSceneImportPlugin::SCENE_FLAG_DETECT_ALPHA,("Materials"),"Set Alpha in Materials (-alpha)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_DETECT_VCOLOR,("Materials"),"Set Vert. Color in Materials (-vcol)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions and/or Rigid Bodies (-col,-colonly,-rigid)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_PORTALS,("Create"),"Create Portals (-portal)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_ROOMS,("Create"),"Create Rooms (-room)",true}, @@ -2455,6 +2457,138 @@ void EditorSceneImportPlugin::_optimize_animations(Node *scene, float p_max_lin_ } +void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node, bool p_merge_material, Map<String, Ref<Material> > &materials, bool p_merge_anims, Map<String,Ref<Animation> >& merged_anims,Set<Ref<Mesh> > &tested_meshes) { + + if (node->get_owner()!=scene) + return; + + String path = scene->get_path_to(node); + + if (p_merge_anims && node->cast_to<AnimationPlayer>()) { + + AnimationPlayer *ap = node->cast_to<AnimationPlayer>(); + List<StringName> anims; + ap->get_animation_list(&anims); + for (List<StringName>::Element *E=anims.front();E;E=E->next()) { + Ref<Animation> anim = ap->get_animation(E->get()); + Ref<Animation> clone; + + bool has_user_tracks=false; + + for(int i=0;i<anim->get_track_count();i++) { + + if (!anim->track_is_imported(i)) { + has_user_tracks=true; + break; + } + } + + if (has_user_tracks) { + + clone = anim->duplicate(); + for(int i=0;i<clone->get_track_count();i++) { + if (clone->track_is_imported(i)) { + clone->remove_track(i); + i--; + } + } + + merged_anims[path+"::"+String(E->get())]=clone; + } + } + } + + + + if (p_merge_material && node->cast_to<MeshInstance>()) { + MeshInstance *mi=node->cast_to<MeshInstance>(); + Ref<Mesh> mesh = mi->get_mesh(); + if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) { + + for(int i=0;i<mesh->get_surface_count();i++) { + Ref<Material> material = mesh->surface_get_material(i); + materials[mesh->get_name()+":surf:"+mesh->surface_get_name(i)]=material; + } + + tested_meshes.insert(mesh); + } + } + + + + for(int i=0;i<node->get_child_count();i++) { + _find_resources_to_merge(scene,node->get_child(i),p_merge_material,materials,p_merge_anims,merged_anims,tested_meshes); + } + +} + + +void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bool p_merge_material, const Map<String, Ref<Material> > &materials, bool p_merge_anims, const Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes) { + + if (node->get_owner()!=scene) + return; + + String path = scene->get_path_to(node); + + if (node->cast_to<AnimationPlayer>()) { + + AnimationPlayer *ap = node->cast_to<AnimationPlayer>(); + List<StringName> anims; + ap->get_animation_list(&anims); + for (List<StringName>::Element *E=anims.front();E;E=E->next()) { + Ref<Animation> anim = ap->get_animation(E->get()); + + String anim_path = path+"::"+String(E->get()); + + if (merged_anims.has(anim_path)) { + + Ref<Animation> user_tracks = merged_anims[anim_path]; + for(int i=0;i<user_tracks->get_track_count();i++) { + + int idx = anim->get_track_count(); + anim->add_track(user_tracks->track_get_type(i)); + anim->track_set_path(idx,user_tracks->track_get_path(i)); + anim->track_set_interpolation_type(idx,user_tracks->track_get_interpolation_type(i)); + for(int j=0;j<user_tracks->track_get_key_count(i);j++) { + + float ofs = user_tracks->track_get_key_time(i,j); + float trans = user_tracks->track_get_key_transition(i,j); + Variant value = user_tracks->track_get_key_value(i,j); + + anim->track_insert_key(idx,ofs,value,trans); + } + } + } + } + } + + + + if (node->cast_to<MeshInstance>()) { + MeshInstance *mi=node->cast_to<MeshInstance>(); + Ref<Mesh> mesh = mi->get_mesh(); + if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) { + + for(int i=0;i<mesh->get_surface_count();i++) { + String sname = mesh->get_name()+":surf:"+mesh->surface_get_name(i); + + if (materials.has(sname)) { + mesh->surface_set_material(i,materials[sname]); + } + } + + tested_meshes.insert(mesh); + } + } + + + + for(int i=0;i<node->get_child_count();i++) { + _merge_found_resources(scene,node->get_child(i),p_merge_material,materials,p_merge_anims,merged_anims,tested_meshes); + } + +} + Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, const Ref<ResourceImportMetadata>& p_from) { Error err=OK; @@ -2506,6 +2640,28 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c _filter_tracks(scene,animation_filter); + if (scene_flags&(SCENE_FLAG_MERGE_KEEP_MATERIALS|SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS) && FileAccess::exists(p_dest_path)) { + //must merge! + + Ref<PackedScene> pscene = ResourceLoader::load(p_dest_path,"PackedScene",true); + if (pscene.is_valid()) { + + Node *instance = pscene->instance(); + if (instance) { + Map<String,Ref<Animation> > merged_anims; + Map<String,Ref<Material> > merged_materials; + Set<Ref<Mesh> > tested_meshes; + + _find_resources_to_merge(instance,instance,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes); + tested_meshes.clear(); + _merge_found_resources(instance,instance,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes); + + memdelete(instance); + } + + } + + } /// BEFORE ANYTHING, RUN SCRIPT diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.h b/tools/editor/io_plugins/editor_scene_import_plugin.h index 8a2d30f1f6..c31d3a33d3 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.h +++ b/tools/editor/io_plugins/editor_scene_import_plugin.h @@ -116,6 +116,10 @@ class EditorSceneImportPlugin : public EditorImportPlugin { void _tag_import_paths(Node *p_scene,Node *p_node); + void _find_resources_to_merge(Node *scene, Node *node, bool p_merge_material, Map<String,Ref<Material> >&materials, bool p_merge_anims, Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes); + void _merge_found_resources(Node *scene, Node *node, bool p_merge_material, const Map<String, Ref<Material> > &materials, bool p_merge_anims, const Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes); + + public: enum SceneFlags { @@ -134,6 +138,9 @@ public: SCENE_FLAG_CREATE_NAVMESH=1<<17, SCENE_FLAG_DETECT_LIGHTMAP_LAYER=1<<18, + SCENE_FLAG_MERGE_KEEP_MATERIALS=1<<20, + SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS=1<<21, + SCENE_FLAG_REMOVE_NOIMP=1<<24, SCENE_FLAG_IMPORT_ANIMATIONS=1<<25, SCENE_FLAG_COMPRESS_GEOMETRY=1<<26, @@ -144,6 +151,7 @@ public: }; + virtual String get_name() const; virtual String get_visible_name() const; virtual void import_dialog(const String& p_from=""); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index f459bf483a..4061bb9827 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -531,7 +531,7 @@ static void _find_changed_scripts_for_external_editor(Node* p_base, Node*p_curre } -void ScriptEditor::_update_modified_scripts_for_external_editor() { +void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_for_script) { if (!bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor"))) return; @@ -547,6 +547,9 @@ void ScriptEditor::_update_modified_scripts_for_external_editor() { Ref<Script> script = E->get(); + if (p_for_script.is_valid() && p_for_script!=script) + continue; + if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) { continue; //internal script, who cares, though weird @@ -900,7 +903,7 @@ void ScriptEditor::_live_auto_reload_running_scripts() { } -bool ScriptEditor::_test_script_times_on_disk() { +bool ScriptEditor::_test_script_times_on_disk(Ref<Script> p_for_script) { disk_changed_list->clear(); @@ -920,6 +923,9 @@ bool ScriptEditor::_test_script_times_on_disk() { Ref<Script> script = ste->get_edited_script(); + if (p_for_script.is_valid() && p_for_script!=script) + continue; + if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) continue; //internal script, who cares @@ -2128,6 +2134,12 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { if (!restoring_layout) { EditorNode::get_singleton()->save_layout(); } + + //test for modification, maybe the script was not edited but was loaded + + _test_script_times_on_disk(p_script); + _update_modified_scripts_for_external_editor(p_script); + } void ScriptEditor::save_all_scripts() { diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 3d723adfe9..0636190a41 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -232,7 +232,7 @@ class ScriptEditor : public VBoxContainer { void _resave_scripts(const String& p_str); void _reload_scripts(); - bool _test_script_times_on_disk(); + bool _test_script_times_on_disk(Ref<Script> p_for_script=Ref<Script>()); void _close_current_tab(); @@ -291,7 +291,7 @@ class ScriptEditor : public VBoxContainer { void _go_to_tab(int p_idx); void _update_history_pos(int p_new_pos); void _update_script_colors(); - void _update_modified_scripts_for_external_editor(); + void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script=Ref<Script>()); int file_dialog_option; void _file_dialog_action(String p_file); diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index f4b294daa5..83db650952 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -30,6 +30,7 @@ #include "tools/editor/editor_settings.h" #include "spatial_editor_plugin.h" +#include "scene/resources/shader_graph.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/keyboard.h" @@ -144,8 +145,6 @@ void ShaderTextEditor::_validate_script() { //List<StringName> params; //shader->get_param_list(¶ms); - print_line("compile: type: "+itos(type)+" code:\n"+code); - Error err = ShaderLanguage::compile(code,type,NULL,NULL,&errortxt,&line,&col); if (err!=OK) { @@ -557,34 +556,41 @@ ShaderEditor::ShaderEditor() { void ShaderEditorPlugin::edit(Object *p_object) { - if (!p_object->cast_to<Shader>()) + Shader* s = p_object->cast_to<Shader>(); + if (!s || s->cast_to<ShaderGraph>()) { + shader_editor->hide(); //Dont edit ShaderGraph return; + } - shader_editor->edit(p_object->cast_to<Shader>()); + if (_2d && s->get_mode()==Shader::MODE_CANVAS_ITEM) + shader_editor->edit(s); + else if (!_2d && s->get_mode()==Shader::MODE_MATERIAL) + shader_editor->edit(s); } bool ShaderEditorPlugin::handles(Object *p_object) const { + bool handles = true; Shader *shader=p_object->cast_to<Shader>(); - if (!shader) - return false; - if (_2d) - return shader->get_mode()==Shader::MODE_CANVAS_ITEM; - else + if (!shader || shader->cast_to<ShaderGraph>()) // Dont handle ShaderGraph's + handles = false; + if (handles && _2d) + handles = shader->get_mode()==Shader::MODE_CANVAS_ITEM; + else if (handles && !_2d) return shader->get_mode()==Shader::MODE_MATERIAL; + + if (!handles) + shader_editor->hide(); + return handles; } void ShaderEditorPlugin::make_visible(bool p_visible) { if (p_visible) { shader_editor->show(); - //shader_editor->set_process(true); } else { - shader_editor->apply_shaders(); - //shader_editor->hide(); - //shader_editor->set_process(false); } } diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 16ae14c0b5..69d6d97980 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -49,11 +49,37 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) { if (!p_event.key.pressed || p_event.key.echo) return; + if (ED_IS_SHORTCUT("scene_tree/add_child_node", p_event)) { + _tool_selected(TOOL_NEW); + } + else if (ED_IS_SHORTCUT("scene_tree/instance_scene", p_event)) { + _tool_selected(TOOL_INSTANCE); + } + else if (ED_IS_SHORTCUT("scene_tree/change_node_type", p_event)) { + _tool_selected(TOOL_REPLACE); + } + else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) { + _tool_selected(TOOL_DUPLICATE); + } + else if (ED_IS_SHORTCUT("scene_tree/add_script", p_event)) { + _tool_selected(TOOL_SCRIPT); + } + else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) { + _tool_selected(TOOL_MOVE_UP); + } + else if (ED_IS_SHORTCUT("scene_tree/move_down", p_event)) { + _tool_selected(TOOL_MOVE_DOWN); + } + else if (ED_IS_SHORTCUT("scene_tree/reparent", p_event)) { + _tool_selected(TOOL_REPARENT); + } + else if (ED_IS_SHORTCUT("scene_tree/merge_from_scene", p_event)) { + _tool_selected(TOOL_MERGE_FROM_SCENE); + } + else if (ED_IS_SHORTCUT("scene_tree/save_branch_as_scene", p_event)) { + _tool_selected(TOOL_NEW_SCENE_FROM); + } switch(sc) { - case KEY_MASK_CMD|KEY_A: { _tool_selected(TOOL_NEW); } break; - case KEY_MASK_CMD|KEY_D: { _tool_selected(TOOL_DUPLICATE); } break; - case KEY_MASK_CMD|KEY_UP: { _tool_selected(TOOL_MOVE_UP); } break; - case KEY_MASK_CMD|KEY_DOWN: { _tool_selected(TOOL_MOVE_DOWN); } break; case KEY_MASK_SHIFT|KEY_DELETE: { _tool_selected(TOOL_ERASE, true); } break; case KEY_DELETE: { _tool_selected(TOOL_ERASE); } break; } @@ -1675,13 +1701,11 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) { } void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) { - - if (!EditorNode::get_singleton()->get_edited_scene()) { menu->clear(); - menu->add_icon_item(get_icon("Add","EditorIcons"),TTR("New Scene Root"),TOOL_NEW,KEY_MASK_CMD|KEY_A); - menu->add_icon_item(get_icon("Instance","EditorIcons"),TTR("Inherit Scene"),TOOL_INSTANCE); + menu->add_icon_shortcut(get_icon("Add","EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_icon("Instance","EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->set_size(Size2(1,1)); menu->set_pos(p_menu_pos); @@ -1698,31 +1722,31 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) { if (selection.size()==1) { - menu->add_icon_item(get_icon("Add","EditorIcons"),TTR("Add Child Node"),TOOL_NEW,KEY_MASK_CMD|KEY_A); - menu->add_icon_item(get_icon("Instance","EditorIcons"),TTR("Instance Child Scene"),TOOL_INSTANCE); + menu->add_icon_shortcut(get_icon("Add","EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_icon("Instance","EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->add_separator(); - menu->add_icon_item(get_icon("Reload","EditorIcons"),TTR("Change Type"),TOOL_REPLACE); + menu->add_icon_shortcut(get_icon("Reload","EditorIcons"),ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); //menu->add_separator(); moved to their own dock //menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP); //menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT); menu->add_separator(); - menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("Add Script"),TOOL_SCRIPT); + menu->add_icon_shortcut(get_icon("Script","EditorIcons"),ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_SCRIPT); menu->add_separator(); } - menu->add_icon_item(get_icon("Up","EditorIcons"),TTR("Move Up"),TOOL_MOVE_UP,KEY_MASK_CMD|KEY_UP); - menu->add_icon_item(get_icon("Down","EditorIcons"),TTR("Move Down"),TOOL_MOVE_DOWN,KEY_MASK_CMD|KEY_DOWN); - menu->add_icon_item(get_icon("Duplicate","EditorIcons"),TTR("Duplicate"),TOOL_DUPLICATE,KEY_MASK_CMD|KEY_D); - menu->add_icon_item(get_icon("Reparent","EditorIcons"),TTR("Reparent"),TOOL_REPARENT); + menu->add_icon_shortcut(get_icon("Up","EditorIcons"),ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); + menu->add_icon_shortcut(get_icon("Down","EditorIcons"),ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); + menu->add_icon_shortcut(get_icon("Duplicate","EditorIcons"),ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); + menu->add_icon_shortcut(get_icon("Reparent","EditorIcons"),ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); if (selection.size()==1) { menu->add_separator(); - menu->add_icon_item(get_icon("Blend","EditorIcons"),TTR("Merge From Scene"),TOOL_MERGE_FROM_SCENE); - menu->add_icon_item(get_icon("Save","EditorIcons"),TTR("Save Branch as Scene"),TOOL_NEW_SCENE_FROM); + menu->add_icon_shortcut(get_icon("Blend","EditorIcons"),ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE); + menu->add_icon_shortcut(get_icon("Save","EditorIcons"),ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); } menu->add_separator(); - menu->add_icon_item(get_icon("Remove","EditorIcons"),TTR("Delete Node(s)"),TOOL_ERASE,KEY_DELETE); + menu->add_icon_item(get_icon("Remove","EditorIcons"),TTR("Delete Node(s)"), TOOL_ERASE, KEY_DELETE); menu->set_size(Size2(1,1)); menu->set_pos(p_menu_pos); @@ -1789,15 +1813,28 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec HBoxContainer *filter_hbc = memnew( HBoxContainer ); ToolButton *tb; + ED_SHORTCUT("scene_tree/add_child_node",TTR("Add Child Node"), KEY_MASK_CMD|KEY_A); + ED_SHORTCUT("scene_tree/instance_scene",TTR("Instance Child Scene")); + ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type")); + ED_SHORTCUT("scene_tree/add_script", TTR("Add Script")); + ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP); + ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN); + ED_SHORTCUT("scene_tree/duplicate", TTR("Duplicate"),KEY_MASK_CMD | KEY_D); + ED_SHORTCUT("scene_tree/reparent", TTR("Reparent")); + ED_SHORTCUT("scene_tree/merge_from_scene", TTR("Merge From Scene")); + ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene")); + tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW, false)); - tb->set_tooltip(TTR("Add/Create a New Node")+"\n("+keycode_get_string(KEY_MASK_CMD|KEY_A)+")"); + tb->set_tooltip(TTR("Add/Create a New Node")); + tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_child_node")); filter_hbc->add_child(tb); button_add=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_INSTANCE, false)); tb->set_tooltip(TTR("Instance a scene file as a Node. Creates an inherited scene if no root node exists.")); + tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/instance_scene")); filter_hbc->add_child(tb); button_instance=tb; diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index e88d603b30..e93a40efbc 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -185,6 +185,7 @@ void ScriptCreateDialog::_built_in_pressed() { void ScriptCreateDialog::_browse_path() { file_browse->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_browse->set_disable_overwrite_warning(true); file_browse->clear_filters(); List<String> extensions; |