diff options
Diffstat (limited to 'tools/editor')
30 files changed, 713 insertions, 112 deletions
diff --git a/tools/editor/asset_library_editor_plugin.cpp b/tools/editor/asset_library_editor_plugin.cpp index c571310ded..a2448921d7 100644 --- a/tools/editor/asset_library_editor_plugin.cpp +++ b/tools/editor/asset_library_editor_plugin.cpp @@ -227,11 +227,12 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) { } } -void EditorAssetLibraryItemDescription::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,int p_version,const String& p_version_string,const String& p_description,const String& p_download_url,const String& p_browse_url) { +void EditorAssetLibraryItemDescription::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,int p_version,const String& p_version_string,const String& p_description,const String& p_download_url,const String& p_browse_url,const String& p_sha256_hash) { asset_id=p_asset_id; title=p_title; download_url=p_download_url; + sha256=p_sha256_hash; item->configure(p_title,p_asset_id,p_category,p_category_id,p_author,p_author_id,p_rating,p_cost); description->clear(); description->add_text("Version: "+p_version_string+"\n"); @@ -358,9 +359,12 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int if (p_code!=200) { error_text=("Request failed, return code: "+itos(p_code)); status->set_text("Failed: "+itos(p_code)); - } else { - - //all good + } else if(sha256 != "") { + String download_sha256 = FileAccess::get_sha256(download->get_download_file()); + if(sha256 != download_sha256) { + error_text="Bad download hash, assuming file has been tampered with.\nExpected: " + sha256 + "\nGot: " + download_sha256; + status->set_text("Failed sha256 hash check"); + } } } break; @@ -384,15 +388,15 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int } -void EditorAssetLibraryItemDownload::configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url) { +void EditorAssetLibraryItemDownload::configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url, const String& p_sha256_hash) { title->set_text(p_title); icon->set_texture(p_preview); asset_id=p_asset_id; if (!p_preview.is_valid()) icon->set_texture(get_icon("GodotAssetDefault","EditorIcons")); - host=p_download_url; + sha256=p_sha256_hash; asset_installer->connect("confirmed",this,"_close"); dismiss->set_normal_texture( get_icon("Close","EditorIcons")); _make_request(); @@ -604,7 +608,7 @@ void EditorAssetLibrary::_install_asset() { EditorAssetLibraryItemDownload * download = memnew( EditorAssetLibraryItemDownload ); downloads_hb->add_child(download); - download->configure(description->get_title(),description->get_asset_id(),description->get_preview_icon(),description->get_download_url()); + download->configure(description->get_title(),description->get_asset_id(),description->get_preview_icon(),description->get_download_url(),description->get_sha256()); } @@ -624,6 +628,12 @@ const char* EditorAssetLibrary::sort_text[SORT_MAX]={ "Updated" }; +const char* EditorAssetLibrary::support_key[SUPPORT_MAX]={ + "official", + "community", + "testing" +}; + void EditorAssetLibrary::_select_author(int p_id) { @@ -832,14 +842,43 @@ void EditorAssetLibrary::_request_image(ObjectID p_for,String p_image_url,ImageT void EditorAssetLibrary::_repository_changed(int p_repository_id) { host=repository->get_item_metadata(p_repository_id); print_line(".." + host); - _api_request("configure", REQUESTING_CONFIG); + if(templates_only) { + _api_request("configure", REQUESTING_CONFIG, "?type=project"); + } else { + _api_request("configure", REQUESTING_CONFIG); + } +} + +void EditorAssetLibrary::_support_toggled(int p_support) { + support->get_popup()->set_item_checked(p_support, !support->get_popup()->is_item_checked(p_support)); + _search(); +} + +void EditorAssetLibrary::_rerun_search(int p_ignore) { + _search(); } void EditorAssetLibrary::_search(int p_page) { String args; - args=String()+"?sort="+sort_key[sort->get_selected()]; + if(templates_only) { + args += "?type=project&"; + } else { + args += "?"; + } + args+=String()+"sort="+sort_key[sort->get_selected()]; + + + String support_list; + for(int i = 0; i < SUPPORT_MAX; i++) { + if(support->get_popup()->is_item_checked(i)) { + support_list += String(support_key[i]) + "+"; + } + } + if(support_list != String()) { + args += "&support=" + support_list.substr(0, support_list.length() - 1); + } if (categories->get_selected()>0) { @@ -1134,6 +1173,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const ERR_FAIL_COND(!r.has("cost")); ERR_FAIL_COND(!r.has("description")); ERR_FAIL_COND(!r.has("download_url")); + ERR_FAIL_COND(!r.has("download_hash")); ERR_FAIL_COND(!r.has("browse_url")); if (description) { @@ -1145,7 +1185,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const description->popup_centered_minsize(); description->connect("confirmed",this,"_install_asset"); - description->configure(r["title"],r["asset_id"],category_map[r["category_id"]],r["category_id"],r["author"],r["author_id"],r["rating"],r["cost"],r["version"],r["version_string"],r["description"],r["download_url"],r["browse_url"]); + description->configure(r["title"],r["asset_id"],category_map[r["category_id"]],r["category_id"],r["author"],r["author_id"],r["rating"],r["cost"],r["version"],r["version_string"],r["description"],r["download_url"],r["browse_url"], r["download_hash"]); /*item->connect("asset_selected",this,"_select_asset"); item->connect("author_selected",this,"_select_author"); item->connect("category_selected",this,"_category_selected");*/ @@ -1231,6 +1271,8 @@ void EditorAssetLibrary::_bind_methods() { ObjectTypeDB::bind_method("_asset_open",&EditorAssetLibrary::_asset_open); ObjectTypeDB::bind_method("_asset_file_selected",&EditorAssetLibrary::_asset_file_selected); ObjectTypeDB::bind_method("_repository_changed",&EditorAssetLibrary::_repository_changed); + ObjectTypeDB::bind_method("_support_toggled",&EditorAssetLibrary::_support_toggled); + ObjectTypeDB::bind_method("_rerun_search",&EditorAssetLibrary::_rerun_search); } @@ -1298,9 +1340,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(sort); sort->set_h_size_flags(SIZE_EXPAND_FILL); + sort->connect("item_selected", this, "_rerun_search"); reverse = memnew( ToolButton ); reverse->set_toggle_mode(true); + reverse->connect("toggled", this, "_rerun_search"); //reverse->set_text(TTR("Reverse")); search_hb2->add_child(reverse); @@ -1314,6 +1358,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(categories); categories->set_h_size_flags(SIZE_EXPAND_FILL); //search_hb2->add_spacer(); + categories->connect("item_selected", this, "_rerun_search"); search_hb2->add_child(memnew(VSeparator)); @@ -1340,6 +1385,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { support->get_popup()->add_check_item(TTR("Testing"),SUPPORT_TESTING); support->get_popup()->set_item_checked(SUPPORT_OFFICIAL,true); support->get_popup()->set_item_checked(SUPPORT_COMMUNITY,true); + support->get_popup()->connect("item_pressed",this,"_support_toggled"); ///////// diff --git a/tools/editor/asset_library_editor_plugin.h b/tools/editor/asset_library_editor_plugin.h index 6a6e29338f..89663aa00b 100644 --- a/tools/editor/asset_library_editor_plugin.h +++ b/tools/editor/asset_library_editor_plugin.h @@ -111,6 +111,7 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog { int asset_id; String download_url; String title; + String sha256; Ref<Texture> icon; void _link_click(const String& p_url); @@ -120,13 +121,14 @@ protected: static void _bind_methods(); public: - void configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,int p_version,const String& p_version_string,const String& p_description,const String& p_download_url,const String& p_browse_url); + void configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,int p_version,const String& p_version_string,const String& p_description,const String& p_download_url,const String& p_browse_url,const String& p_sha256_hash); void add_preview(int p_id, bool p_video,const String& p_url); String get_title() { return title; } Ref<Texture> get_preview_icon() { return icon; } String get_download_url() { return download_url; } int get_asset_id() { return asset_id; } + String get_sha256() { return sha256; } EditorAssetLibraryItemDescription(); }; @@ -146,6 +148,7 @@ class EditorAssetLibraryItemDownload : public PanelContainer { AcceptDialog *download_error; HTTPRequest *download; String host; + String sha256; Label *status; int prev_status; @@ -166,7 +169,7 @@ protected: public: int get_asset_id() { return asset_id; } - void configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url); + void configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url, const String& p_sha256_hash); EditorAssetLibraryItemDownload(); }; @@ -210,7 +213,8 @@ class EditorAssetLibrary : public PanelContainer { enum Support { SUPPORT_OFFICIAL, SUPPORT_COMMUNITY, - SUPPORT_TESTING + SUPPORT_TESTING, + SUPPORT_MAX }; enum SortOrder { @@ -225,6 +229,7 @@ class EditorAssetLibrary : public PanelContainer { static const char* sort_key[SORT_MAX]; static const char* sort_text[SORT_MAX]; + static const char* support_key[SUPPORT_MAX]; ///MainListing @@ -288,11 +293,13 @@ class EditorAssetLibrary : public PanelContainer { void _manage_plugins(); void _search(int p_page=0); + void _rerun_search(int p_ignore); void _api_request(const String& p_request, RequestType p_request_type, const String &p_arguments=""); void _http_request_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data); void _http_download_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data); void _repository_changed(int p_repository_id); + void _support_toggled(int p_support); friend class EditorAssetLibraryItemDescription; friend class EditorAssetLibraryItem; 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 d555da0650..a55c835787 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -409,7 +409,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 { @@ -1191,6 +1191,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); @@ -1264,12 +1266,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); @@ -1507,4 +1520,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_import_export.cpp b/tools/editor/editor_import_export.cpp index f9b9c0b41c..357d139c04 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -861,9 +861,11 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); //imd->set_editor(); + for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) { imd->add_source(EditorImportPlugin::validate_source_path(F->get()),FileAccess::get_md5(F->get())); + } diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index dd50b720f7..0f8ddafb20 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; } } @@ -2940,6 +2952,9 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) { //singleton->main_editor_tabs->add_tab(p_editor->get_name()); singleton->editor_table.erase(p_editor); } + p_editor->make_visible(false); + p_editor->clear(); + singleton->editor_plugins_over->get_plugins_list().erase(p_editor); singleton->remove_child(p_editor); singleton->editor_data.remove_editor_plugin( p_editor ); @@ -2992,7 +3007,7 @@ void EditorNode::set_addon_plugin_enabled(const String& p_addon,bool p_enabled) if (!p_enabled) { EditorPlugin *addon = plugin_addons[p_addon]; - editor_data.remove_editor_plugin( addon ); + remove_editor_plugin(addon); memdelete(addon); //bye plugin_addons.erase(p_addon); _update_addon_config(); @@ -4606,9 +4621,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/editor_settings.cpp b/tools/editor/editor_settings.cpp index 0fffaca782..49a1158ec6 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -583,7 +583,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("3d_editor/zoom_modifier",4); hints["3d_editor/zoom_modifier"]=PropertyInfo(Variant::INT,"3d_editor/zoom_modifier",PROPERTY_HINT_ENUM,"None,Shift,Alt,Meta,Ctrl"); set("3d_editor/emulate_numpad",false); - set("3d_editor/trackpad_hint", false); + set("3d_editor/emulate_3_button_mouse", false); set("2d_editor/bone_width",5); set("2d_editor/bone_color1",Color(1.0,1.0,1.0,0.9)); 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 a6de849e44..70bc44ba7d 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -102,6 +102,7 @@ public: bool disable_filter; bool round_advance; + bool premultiply_alpha; @@ -167,6 +168,8 @@ public: round_advance=p_value; else if (n=="advanced/disable_filter") disable_filter=p_value; + else if (n=="advanced/premultiply_alpha") + premultiply_alpha=p_value; else return false; @@ -235,6 +238,8 @@ public: r_ret=round_advance; else if (n=="advanced/disable_filter") r_ret=disable_filter; + else if (n=="advanced/premultiply_alpha") + r_ret=premultiply_alpha; else return false; @@ -297,6 +302,7 @@ public: p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/round_advance")); p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/disable_filter")); + p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/premultiply_alpha")); } @@ -336,6 +342,7 @@ public: font_mode=FONT_BITMAP; round_advance=true; disable_filter=false; + premultiply_alpha=false; } @@ -368,6 +375,7 @@ public: round_advance=true; disable_filter=false; + premultiply_alpha=false; } @@ -533,7 +541,7 @@ class EditorFontImportDialog : public ConfirmationDialog { } if (dest->get_line_edit()->get_text().extension().to_lower() != "fnt") { - error_dialog->set_text("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; } @@ -1542,12 +1550,30 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe } + if (from->has_option("advanced/premultiply_alpha") && bool(from->get_option("advanced/premultiply_alpha"))) { + + DVector<uint8_t> data = atlas.get_data(); + int dl = data.size(); + { + DVector<uint8_t>::Write w = data.write(); + + for(int i=0;i<dl;i+=4) { + + w[i+0]= uint8_t(int(w[i+0])*int(w[i+3])/255); + w[i+1]= uint8_t(int(w[i+1])*int(w[i+3])/255); + w[i+2]= uint8_t(int(w[i+2])*int(w[i+3])/255); + } + } + + atlas=Image(res_size.x,res_size.y,0,Image::FORMAT_RGBA,data); + } if (from->has_option("color/monochrome") && bool(from->get_option("color/monochrome"))) { atlas.convert(Image::FORMAT_GRAYSCALE_ALPHA); } + if (0) { //debug the texture Ref<ImageTexture> atlast = memnew( ImageTexture ); 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/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 1fa7a50515..16ea803da4 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -1312,21 +1312,30 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc ERR_CONTINUE( !source_map.has(i) ); for (List<int>::Element *E=source_map[i].front();E;E=E->next()) { - String apath = p_path.get_base_dir().plus_file(from->get_source_path(E->get()).get_file().basename()+".atex"); + String apath; + String spath = from->get_source_path(E->get()).get_file(); + + if (p_external) { + apath = p_path.get_base_dir().plus_file(spath.basename()+"."+from->get_source_path(E->get()).md5_text()+".atex"); + } else { + apath = p_path.get_base_dir().plus_file(spath.basename()+".atex"); + } Ref<AtlasTexture> at; if (ResourceCache::has(apath)) { + at = Ref<AtlasTexture>( ResourceCache::get(apath)->cast_to<AtlasTexture>() ); } else { at = Ref<AtlasTexture>( memnew( AtlasTexture ) ); + } at->set_region(region); at->set_margin(margin); at->set_path(apath); atlases[E->get()]=at; - print_line("Atlas Tex: "+apath); + } } if (ResourceCache::has(p_path)) { diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index f5470451ba..a057e6c2a1 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -669,7 +669,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -687,8 +687,8 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { float max[2]={-1e10,-1e10}; float min[2]={1e10,1e10}; int c=stereo?2:1; - int from = i*len/w; - int to = (i+1)*len/w; + int from = uint64_t(i)*len/w; + int to = (uint64_t(i)+1)*len/w; if (to>=len) to=len-1; @@ -699,7 +699,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int k=from;k<=to;k++) { - float v = src[k*c+j]/32768.0; + float v = src[uint64_t(k)*c+j]/32768.0; if (v>max[j]) max[j]=v; if (v<min[j]) @@ -715,7 +715,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int k=from;k<=to;k++) { - float v = src[k*c+j]/128.0; + float v = src[uint64_t(k)*c+j]/128.0; if (v>max[j]) max[j]=v; if (v<min[j]) diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.cpp b/tools/editor/plugins/mesh_instance_editor_plugin.cpp index f604e4c57c..c952feb1da 100644 --- a/tools/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_instance_editor_plugin.cpp @@ -183,6 +183,12 @@ void MeshInstanceEditor::_create_outline_mesh() { return; } + if (mesh->get_surface_count() == 0) { + err_dialog->set_text(TTR("Mesh has not surface to create outlines from!")); + err_dialog->popup_centered_minsize(); + return; + } + Ref<Mesh> mesho = mesh->create_outline(outline_size->get_val()); if (mesho.is_null()) { diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index a3891a648b..b094184a29 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -211,7 +211,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -229,8 +229,8 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag float max[2]={-1e10,-1e10}; float min[2]={1e10,1e10}; int c=stereo?2:1; - int from = i*len/w; - int to = (i+1)*len/w; + int from = uint64_t(i)*len/w; + int to = (uint64_t(i)+1)*len/w; if (to>=len) to=len-1; @@ -241,7 +241,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int k=from;k<=to;k++) { - float v = src[k*c+j]/32768.0; + float v = src[uint64_t(k)*c+j]/32768.0; if (v>max[j]) max[j]=v; if (v<min[j]) @@ -257,7 +257,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int k=from;k<=to;k++) { - float v = src[k*c+j]/128.0; + float v = src[uint64_t(k)*c+j]/128.0; if (v>max[j]) max[j]=v; if (v<min[j]) @@ -270,7 +270,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag if (!stereo) { for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -297,7 +297,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0; } - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[half] && v<max[half]) { imgofs[0]=255; imgofs[1]=150; diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index f459bf483a..7de80e767b 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() { @@ -2623,7 +2635,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save", TTR("Save"), KEY_MASK_ALT|KEY_MASK_CMD|KEY_S), FILE_SAVE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_as", TTR("Save As..")), FILE_SAVE_AS); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_all", TTR("Save All"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_S), FILE_SAVE_ALL); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_all", TTR("Save All"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_MASK_ALT|KEY_S), FILE_SAVE_ALL); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Prev"), KEY_MASK_CTRL|KEY_MASK_ALT|KEY_LEFT), WINDOW_PREV); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_next", TTR("History Next"), KEY_MASK_CTRL|KEY_MASK_ALT|KEY_RIGHT), WINDOW_NEXT); 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/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index fdb654571a..8d72178f23 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1580,7 +1580,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { nav_mode = NAVIGATION_PAN; } - } else if (EditorSettings::get_singleton()->get("3d_editor/trackpad_hint")) { + } else if (EditorSettings::get_singleton()->get("3d_editor/emulate_3_button_mouse")) { // Handle trackpad (no external mouse) use case int mod = 0; if (m.mod.shift) diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 77097b11f6..5db331ba45 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -348,7 +348,7 @@ void ThemeEditor::_dialog_cbk() { names.clear(); Theme::get_default()->get_icon_list(fromtype,&names); for(List<StringName>::Element *E=names.front();E;E=E->next()) { - theme->set_icon(E->get(),fromtype,Theme::get_default()->get_icon(E->get(),fromtype)); + theme->set_icon(E->get(),fromtype,Ref<Texture>()); } @@ -357,7 +357,7 @@ void ThemeEditor::_dialog_cbk() { names.clear(); Theme::get_default()->get_stylebox_list(fromtype,&names); for(List<StringName>::Element *E=names.front();E;E=E->next()) { - theme->set_stylebox(E->get(),fromtype,Theme::get_default()->get_stylebox(E->get(),fromtype)); + theme->set_stylebox(E->get(),fromtype,Ref<StyleBox>()); } @@ -366,7 +366,7 @@ void ThemeEditor::_dialog_cbk() { names.clear(); Theme::get_default()->get_font_list(fromtype,&names); for(List<StringName>::Element *E=names.front();E;E=E->next()) { - theme->set_font(E->get(),fromtype,Theme::get_default()->get_font(E->get(),fromtype)); + theme->set_font(E->get(),fromtype,Ref<Font>()); } } @@ -537,7 +537,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { add_del_dialog->set_title(TTR("Add Item")); add_del_dialog->get_ok()->set_text(TTR("Add")); - add_del_dialog->popup_centered(Size2(490,85)); + add_del_dialog->popup_centered(Size2(490,85)*EDSCALE); base_theme=Theme::get_default(); @@ -545,7 +545,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { add_del_dialog->set_title(TTR("Add All Items")); add_del_dialog->get_ok()->set_text(TTR("Add All")); - add_del_dialog->popup_centered(Size2(240,85)); + add_del_dialog->popup_centered(Size2(240,85)*EDSCALE); base_theme=Theme::get_default(); @@ -559,7 +559,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { add_del_dialog->set_title(TTR("Remove Item")); add_del_dialog->get_ok()->set_text(TTR("Remove")); - add_del_dialog->popup_centered(Size2(490,85)); + add_del_dialog->popup_centered(Size2(490,85)*EDSCALE); base_theme=theme; @@ -567,7 +567,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { add_del_dialog->set_title("Remove All Items"); add_del_dialog->get_ok()->set_text("Remove All"); - add_del_dialog->popup_centered(Size2(240,85)); + add_del_dialog->popup_centered(Size2(240,85)*EDSCALE); base_theme=Theme::get_default(); @@ -583,12 +583,14 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { List<StringName> types; base_theme->get_type_list(&types); + type_menu->get_popup()->clear();; if (p_option==0 || p_option==1) {//add List<StringName> new_types; theme->get_type_list(&new_types); + //uh kind of sucks for(List<StringName>::Element *F=new_types.front();F;F=F->next()) { @@ -606,8 +608,8 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { } } - types.sort(); - + //types.sort(); + types.sort_custom<StringName::AlphCompare>(); for(List<StringName>::Element *E=types.front();E;E=E->next()) { type_menu->get_popup()->add_item( E->get() ); @@ -641,15 +643,23 @@ ThemeEditor::ThemeEditor() { time_left=0; + scroll = memnew( ScrollContainer ); + add_child(scroll); + scroll->set_area_as_parent_rect(3); + scroll->set_margin(MARGIN_TOP,30*EDSCALE); + //scroll->set_enable_h_scroll(true); + scroll->set_enable_v_scroll(true); + scroll->set_enable_h_scroll(false); + Panel * panel = memnew( Panel ); - add_child(panel); - panel->set_area_as_parent_rect(0); - panel->set_margin(MARGIN_TOP,25); + scroll->add_child(panel); + panel->set_custom_minimum_size(Size2(500,800)*EDSCALE); panel->set_theme(Theme::get_default()); + panel->set_h_size_flags(SIZE_EXPAND_FILL); main_vb= memnew( VBoxContainer ); panel->add_child(main_vb); - main_vb->set_area_as_parent_rect(4); + main_vb->set_area_as_parent_rect(4*EDSCALE); HBoxContainer *hb_menu = memnew(HBoxContainer); @@ -667,7 +677,8 @@ ThemeEditor::ThemeEditor() { theme_menu->get_popup()->add_item(TTR("Create Empty Template"),POPUP_CREATE_EMPTY); theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"),POPUP_CREATE_EDITOR_EMPTY); - hb_menu->add_child(theme_menu); + add_child(theme_menu); + theme_menu->set_pos(Vector2(3,3)*EDSCALE); theme_menu->get_popup()->connect("item_pressed", this,"_theme_menu_cbk"); @@ -742,26 +753,26 @@ ThemeEditor::ThemeEditor() { pb->set_val(50); first_vb->add_child( pb); Panel *pn=memnew( Panel ); - pn->set_custom_minimum_size(Size2(40,40)); + pn->set_custom_minimum_size(Size2(40,40)*EDSCALE); first_vb->add_child( pn); - first_vb->add_constant_override("separation",10); + first_vb->add_constant_override("separation",10*EDSCALE); VBoxContainer *second_vb = memnew( VBoxContainer ); second_vb->set_h_size_flags(SIZE_EXPAND_FILL); main_hb->add_child(second_vb); - second_vb->add_constant_override("separation",10); + second_vb->add_constant_override("separation",10*EDSCALE); LineEdit *le = memnew( LineEdit ); le->set_text("LineEdit"); second_vb->add_child(le); TextEdit *te = memnew( TextEdit ); te->set_text("TextEdit"); //te->set_v_size_flags(SIZE_EXPAND_FILL); - te->set_custom_minimum_size(Size2(0,160)); + te->set_custom_minimum_size(Size2(0,160)*EDSCALE); second_vb->add_child(te); Tree *test_tree = memnew(Tree); second_vb->add_child(test_tree); - test_tree->set_custom_minimum_size(Size2(0,160)); + test_tree->set_custom_minimum_size(Size2(0,160)*EDSCALE); TreeItem *item = test_tree->create_item(); @@ -789,7 +800,7 @@ ThemeEditor::ThemeEditor() { main_hb->add_child(third_vb); HBoxContainer *vhb = memnew( HBoxContainer ); - vhb->set_custom_minimum_size(Size2(0,160)); + vhb->set_custom_minimum_size(Size2(0,160)*EDSCALE); vhb->add_child(memnew(VSeparator)); vhb->add_child(memnew(VSlider)); vhb->add_child(memnew(VScrollBar)); @@ -797,7 +808,7 @@ ThemeEditor::ThemeEditor() { TabContainer *tc = memnew( TabContainer ); third_vb->add_child(tc); - tc->set_custom_minimum_size(Size2(0,160)); + tc->set_custom_minimum_size(Size2(0,160)*EDSCALE); Control *tcc = memnew( Control ); tcc->set_name(TTR("Tab 1")); tc->add_child(tcc); @@ -808,7 +819,7 @@ ThemeEditor::ThemeEditor() { tcc->set_name(TTR("Tab 3")); tc->add_child(tcc); - main_hb->add_constant_override("separation",20); + main_hb->add_constant_override("separation",20*EDSCALE); @@ -871,37 +882,37 @@ ThemeEditor::ThemeEditor() { Label *l = memnew( Label ); - l->set_pos( Point2(5,5) ); + l->set_pos( Point2(5,5)*EDSCALE ); l->set_text(TTR("Type:")); add_del_dialog->add_child(l); dtype_select_label=l; type_edit = memnew( LineEdit ); - type_edit->set_pos(Point2(5,25)); - type_edit->set_size(Point2(150,5)); + type_edit->set_pos(Point2(5,25)*EDSCALE); + type_edit->set_size(Point2(150,5)*EDSCALE); add_del_dialog->add_child(type_edit); type_menu = memnew( MenuButton ); - type_menu->set_pos(Point2(160,25)); - type_menu->set_size(Point2(30,5)); + type_menu->set_pos(Point2(160,25)*EDSCALE); + type_menu->set_size(Point2(30,5)*EDSCALE); type_menu->set_text(".."); add_del_dialog->add_child(type_menu); type_menu->get_popup()->connect("item_pressed", this,"_type_menu_cbk"); l = memnew( Label ); - l->set_pos( Point2(200,5) ); + l->set_pos( Point2(200,5)*EDSCALE ); l->set_text(TTR("Name:")); add_del_dialog->add_child(l); name_select_label=l; name_edit = memnew( LineEdit ); - name_edit->set_pos(Point2(200,25)); - name_edit->set_size(Point2(150,5)); + name_edit->set_pos(Point2(200,25)*EDSCALE); + name_edit->set_size(Point2(150,5)*EDSCALE); add_del_dialog->add_child(name_edit); name_menu = memnew( MenuButton ); - name_menu->set_pos(Point2(360,25)); - name_menu->set_size(Point2(30,5)); + name_menu->set_pos(Point2(360,25)*EDSCALE); + name_menu->set_size(Point2(30,5)*EDSCALE); name_menu->set_text(".."); add_del_dialog->add_child(name_menu); @@ -910,7 +921,7 @@ ThemeEditor::ThemeEditor() { name_menu->get_popup()->connect("item_pressed", this,"_name_menu_cbk"); type_select_label= memnew( Label ); - type_select_label->set_pos( Point2(400,5) ); + type_select_label->set_pos( Point2(400,5)*EDSCALE ); type_select_label->set_text(TTR("Data Type:")); add_del_dialog->add_child(type_select_label); @@ -920,8 +931,8 @@ ThemeEditor::ThemeEditor() { type_select->add_item(TTR("Font")); type_select->add_item(TTR("Color")); type_select->add_item(TTR("Constant")); - type_select->set_pos( Point2( 400,25 ) ); - type_select->set_size( Point2( 80,5 ) ); + type_select->set_pos( Point2( 400,25 )*EDSCALE ); + type_select->set_size( Point2( 80,5 )*EDSCALE ); add_del_dialog->add_child(type_select); @@ -974,7 +985,7 @@ ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) { editor=p_node; theme_editor = memnew( ThemeEditor ); - theme_editor->set_custom_minimum_size(Size2(0,500)); + theme_editor->set_custom_minimum_size(Size2(0,200)); // p_node->get_viewport()->add_child(theme_editor); button=editor->add_bottom_panel_item("Theme",theme_editor); diff --git a/tools/editor/plugins/theme_editor_plugin.h b/tools/editor/plugins/theme_editor_plugin.h index 1384fa6b69..ea8f8c1d3c 100644 --- a/tools/editor/plugins/theme_editor_plugin.h +++ b/tools/editor/plugins/theme_editor_plugin.h @@ -35,16 +35,19 @@ #include "scene/gui/file_dialog.h" #include "scene/gui/check_box.h" #include "scene/gui/button_group.h" +#include "scene/gui/scroll_container.h" #include "tools/editor/editor_node.h" + class ThemeEditor : public Control { OBJ_TYPE( ThemeEditor, Control ); + ScrollContainer *scroll; VBoxContainer *main_vb; Ref<Theme> theme; diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 16ae14c0b5..30ffdf6664 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; } @@ -1362,6 +1388,13 @@ void SceneTreeDock::_create() { } String newname=n->get_name(); + + List<Node*> to_erase; + for(int i=0;i<n->get_child_count();i++) { + if (n->get_child(i)->get_owner()==NULL && n->is_owned_by_parent()) { + to_erase.push_back(n->get_child(i)); + } + } n->replace_by(newnode,true); if (n==edited_scene) { @@ -1382,6 +1415,11 @@ void SceneTreeDock::_create() { memdelete(n); + while(to_erase.front()) { + memdelete(to_erase.front()->get()); + to_erase.pop_front(); + } + } @@ -1675,13 +1713,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 +1734,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 +1825,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; |