diff options
Diffstat (limited to 'editor')
33 files changed, 503 insertions, 271 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 04c1c9951b..d3f3ecba54 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -581,7 +581,7 @@ void InputEventConfigurationDialog::set_allowed_input_types(int p_type_masks) { InputEventConfigurationDialog::InputEventConfigurationDialog() { allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION; - set_title("Event Configuration"); + set_title(TTR("Event Configuration")); set_min_size(Size2i(550 * EDSCALE, 0)); // Min width VBoxContainer *main_vbox = memnew(VBoxContainer); @@ -595,7 +595,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { main_vbox->add_child(tab_container); CenterContainer *cc = memnew(CenterContainer); - cc->set_name("Listen for Input"); + cc->set_name(TTR("Listen for Input")); event_as_text = memnew(Label); event_as_text->set_align(Label::ALIGN_CENTER); cc->add_child(event_as_text); @@ -604,7 +604,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { // List of all input options to manually select from. VBoxContainer *manual_vbox = memnew(VBoxContainer); - manual_vbox->set_name("Manual Selection"); + manual_vbox->set_name(TTR("Manual Selection")); manual_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL); tab_container->add_child(manual_vbox); @@ -632,7 +632,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { Label *opts_label = memnew(Label); opts_label->set_theme_type_variation("HeaderSmall"); - opts_label->set_text("Additional Options"); + opts_label->set_text(TTR("Additional Options")); additional_options_container->add_child(opts_label); // Device Selection @@ -641,7 +641,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { Label *device_label = memnew(Label); device_label->set_theme_type_variation("HeaderSmall"); - device_label->set_text("Device:"); + device_label->set_text(TTR("Device:")); device_container->add_child(device_label); device_id_option = memnew(OptionButton); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 3b002961f9..bfbd697409 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -195,7 +195,8 @@ void CreateDialog::_update_search() { select_type(_top_result(candidates, search_text)); } else { favorite->set_disabled(true); - help_bit->set_text(""); + help_bit->set_text(vformat(TTR("No results for \"%s\"."), search_text)); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); get_ok_button()->set_disabled(true); search_options->deselect_all(); } @@ -393,8 +394,15 @@ void CreateDialog::select_type(const String &p_type) { to_select->select(0); search_options->scroll_to_item(to_select); - if (EditorHelp::get_doc_data()->class_list.has(p_type)) { - help_bit->set_text(DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description)); + if (EditorHelp::get_doc_data()->class_list.has(p_type) && !DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description).is_empty()) { + // Display both class name and description, since the help bit may be displayed + // far away from the location (especially if the dialog was resized to be taller). + help_bit->set_text(vformat("[b]%s[/b]: %s", p_type, DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description))); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1)); + } else { + // Use nested `vformat()` as translators shouldn't interfere with BBCode tags. + help_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", p_type))); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); } favorite->set_disabled(false); diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 585552e1fc..6b015e1fda 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -356,7 +356,7 @@ void EditorProfiler::_update_frame() { item->set_metadata(1, it.script); item->set_metadata(2, it.line); item->set_text_align(2, TreeItem::ALIGN_RIGHT); - item->set_tooltip(0, it.script + ":" + itos(it.line)); + item->set_tooltip(0, it.name + "\n" + it.script + ":" + itos(it.line)); float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total; diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8968e562c1..1e3db1a7b0 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -37,19 +37,34 @@ #include "scene/resources/default_theme/default_theme.h" #include "scene/resources/font.h" -#define MAKE_FALLBACKS(m_name) \ - m_name->add_data(FontArabic); \ - m_name->add_data(FontBengali); \ - m_name->add_data(FontGeorgian); \ - m_name->add_data(FontMalayalam); \ - m_name->add_data(FontOriya); \ - m_name->add_data(FontSinhala); \ - m_name->add_data(FontTamil); \ - m_name->add_data(FontTelugu); \ - m_name->add_data(FontHebrew); \ - m_name->add_data(FontThai); \ - m_name->add_data(FontHindi); \ - m_name->add_data(FontJapanese); \ +#define MAKE_FALLBACKS(m_name) \ + m_name->add_data(FontArabic); \ + m_name->add_data(FontBengali); \ + m_name->add_data(FontDevanagari); \ + m_name->add_data(FontGeorgian); \ + m_name->add_data(FontHebrew); \ + m_name->add_data(FontMalayalam); \ + m_name->add_data(FontOriya); \ + m_name->add_data(FontSinhala); \ + m_name->add_data(FontTamil); \ + m_name->add_data(FontTelugu); \ + m_name->add_data(FontThai); \ + m_name->add_data(FontJapanese); \ + m_name->add_data(FontFallback); + +#define MAKE_FALLBACKS_BOLD(m_name) \ + m_name->add_data(FontArabicBold); \ + m_name->add_data(FontBengaliBold); \ + m_name->add_data(FontDevanagariBold); \ + m_name->add_data(FontGeorgianBold); \ + m_name->add_data(FontHebrewBold); \ + m_name->add_data(FontMalayalamBold); \ + m_name->add_data(FontOriyaBold); \ + m_name->add_data(FontSinhalaBold); \ + m_name->add_data(FontTamilBold); \ + m_name->add_data(FontTeluguBold); \ + m_name->add_data(FontThaiBold); \ + m_name->add_data(FontJapanese); \ m_name->add_data(FontFallback); // the custom spacings might only work with Noto Sans @@ -77,7 +92,7 @@ } \ m_name->set_spacing(Font::SPACING_TOP, -EDSCALE); \ m_name->set_spacing(Font::SPACING_BOTTOM, -EDSCALE); \ - MAKE_FALLBACKS(m_name); + MAKE_FALLBACKS_BOLD(m_name); #define MAKE_SOURCE_FONT(m_name) \ Ref<Font> m_name; \ @@ -175,36 +190,22 @@ void editor_register_fonts(Ref<Theme> p_theme) { memdelete(dir); - /* Droid Sans */ + /* Noto Sans UI */ Ref<FontData> DefaultFont; DefaultFont.instantiate(); - DefaultFont->load_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf", default_font_size); + DefaultFont->load_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf", default_font_size); DefaultFont->set_antialiased(font_antialiased); DefaultFont->set_hinting(font_hinting); DefaultFont->set_force_autohinter(true); //just looks better..i think? Ref<FontData> DefaultFontBold; DefaultFontBold.instantiate(); - DefaultFontBold->load_memory(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size, "ttf", default_font_size); + DefaultFontBold->load_memory(_font_NotoSans_Bold, _font_NotoSans_Bold_size, "ttf", default_font_size); DefaultFontBold->set_antialiased(font_antialiased); DefaultFontBold->set_hinting(font_hinting); DefaultFontBold->set_force_autohinter(true); // just looks better..i think? - Ref<FontData> FontFallback; - FontFallback.instantiate(); - FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size); - FontFallback->set_antialiased(font_antialiased); - FontFallback->set_hinting(font_hinting); - FontFallback->set_force_autohinter(true); //just looks better..i think? - - Ref<FontData> FontJapanese; - FontJapanese.instantiate(); - FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size); - FontJapanese->set_antialiased(font_antialiased); - FontJapanese->set_hinting(font_hinting); - FontJapanese->set_force_autohinter(true); //just looks better..i think? - Ref<FontData> FontArabic; FontArabic.instantiate(); FontArabic->load_memory(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, "ttf", default_font_size); @@ -212,13 +213,41 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontArabic->set_hinting(font_hinting); FontArabic->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontArabicBold; + FontArabicBold.instantiate(); + FontArabicBold->load_memory(_font_NotoNaskhArabicUI_Bold, _font_NotoNaskhArabicUI_Bold_size, "ttf", default_font_size); + FontArabicBold->set_antialiased(font_antialiased); + FontArabicBold->set_hinting(font_hinting); + FontArabicBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontBengali; FontBengali.instantiate(); - FontBengali->load_memory(_font_NotoSansBengali_Regular, _font_NotoSansBengali_Regular_size, "ttf", default_font_size); + FontBengali->load_memory(_font_NotoSansBengaliUI_Regular, _font_NotoSansBengaliUI_Regular_size, "ttf", default_font_size); FontBengali->set_antialiased(font_antialiased); FontBengali->set_hinting(font_hinting); FontBengali->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontBengaliBold; + FontBengaliBold.instantiate(); + FontBengaliBold->load_memory(_font_NotoSansBengaliUI_Bold, _font_NotoSansBengaliUI_Bold_size, "ttf", default_font_size); + FontBengaliBold->set_antialiased(font_antialiased); + FontBengaliBold->set_hinting(font_hinting); + FontBengaliBold->set_force_autohinter(true); //just looks better..i think? + + Ref<FontData> FontDevanagari; + FontDevanagari.instantiate(); + FontDevanagari->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size); + FontDevanagari->set_antialiased(font_antialiased); + FontDevanagari->set_hinting(font_hinting); + FontDevanagari->set_force_autohinter(true); //just looks better..i think? + + Ref<FontData> FontDevanagariBold; + FontDevanagariBold.instantiate(); + FontDevanagariBold->load_memory(_font_NotoSansDevanagariUI_Bold, _font_NotoSansDevanagariUI_Bold_size, "ttf", default_font_size); + FontDevanagariBold->set_antialiased(font_antialiased); + FontDevanagariBold->set_hinting(font_hinting); + FontDevanagariBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontGeorgian; FontGeorgian.instantiate(); FontGeorgian->load_memory(_font_NotoSansGeorgian_Regular, _font_NotoSansGeorgian_Regular_size, "ttf", default_font_size); @@ -226,6 +255,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontGeorgian->set_hinting(font_hinting); FontGeorgian->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontGeorgianBold; + FontGeorgianBold.instantiate(); + FontGeorgianBold->load_memory(_font_NotoSansGeorgian_Bold, _font_NotoSansGeorgian_Bold_size, "ttf", default_font_size); + FontGeorgianBold->set_antialiased(font_antialiased); + FontGeorgianBold->set_hinting(font_hinting); + FontGeorgianBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontHebrew; FontHebrew.instantiate(); FontHebrew->load_memory(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size, "ttf", default_font_size); @@ -233,6 +269,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontHebrew->set_hinting(font_hinting); FontHebrew->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontHebrewBold; + FontHebrewBold.instantiate(); + FontHebrewBold->load_memory(_font_NotoSansHebrew_Bold, _font_NotoSansHebrew_Bold_size, "ttf", default_font_size); + FontHebrewBold->set_antialiased(font_antialiased); + FontHebrewBold->set_hinting(font_hinting); + FontHebrewBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontMalayalam; FontMalayalam.instantiate(); FontMalayalam->load_memory(_font_NotoSansMalayalamUI_Regular, _font_NotoSansMalayalamUI_Regular_size, "ttf", default_font_size); @@ -240,6 +283,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontMalayalam->set_hinting(font_hinting); FontMalayalam->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontMalayalamBold; + FontMalayalamBold.instantiate(); + FontMalayalamBold->load_memory(_font_NotoSansMalayalamUI_Bold, _font_NotoSansMalayalamUI_Bold_size, "ttf", default_font_size); + FontMalayalamBold->set_antialiased(font_antialiased); + FontMalayalamBold->set_hinting(font_hinting); + FontMalayalamBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontOriya; FontOriya.instantiate(); FontOriya->load_memory(_font_NotoSansOriyaUI_Regular, _font_NotoSansOriyaUI_Regular_size, "ttf", default_font_size); @@ -247,6 +297,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontOriya->set_hinting(font_hinting); FontOriya->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontOriyaBold; + FontOriyaBold.instantiate(); + FontOriyaBold->load_memory(_font_NotoSansOriyaUI_Bold, _font_NotoSansOriyaUI_Bold_size, "ttf", default_font_size); + FontOriyaBold->set_antialiased(font_antialiased); + FontOriyaBold->set_hinting(font_hinting); + FontOriyaBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontSinhala; FontSinhala.instantiate(); FontSinhala->load_memory(_font_NotoSansSinhalaUI_Regular, _font_NotoSansSinhalaUI_Regular_size, "ttf", default_font_size); @@ -254,6 +311,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontSinhala->set_hinting(font_hinting); FontSinhala->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontSinhalaBold; + FontSinhalaBold.instantiate(); + FontSinhalaBold->load_memory(_font_NotoSansSinhalaUI_Bold, _font_NotoSansSinhalaUI_Bold_size, "ttf", default_font_size); + FontSinhalaBold->set_antialiased(font_antialiased); + FontSinhalaBold->set_hinting(font_hinting); + FontSinhalaBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTamil; FontTamil.instantiate(); FontTamil->load_memory(_font_NotoSansTamilUI_Regular, _font_NotoSansTamilUI_Regular_size, "ttf", default_font_size); @@ -261,6 +325,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontTamil->set_hinting(font_hinting); FontTamil->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTamilBold; + FontTamilBold.instantiate(); + FontTamilBold->load_memory(_font_NotoSansTamilUI_Bold, _font_NotoSansTamilUI_Bold_size, "ttf", default_font_size); + FontTamilBold->set_antialiased(font_antialiased); + FontTamilBold->set_hinting(font_hinting); + FontTamilBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTelugu; FontTelugu.instantiate(); FontTelugu->load_memory(_font_NotoSansTeluguUI_Regular, _font_NotoSansTeluguUI_Regular_size, "ttf", default_font_size); @@ -268,6 +339,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontTelugu->set_hinting(font_hinting); FontTelugu->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTeluguBold; + FontTeluguBold.instantiate(); + FontTeluguBold->load_memory(_font_NotoSansTeluguUI_Bold, _font_NotoSansTeluguUI_Bold_size, "ttf", default_font_size); + FontTeluguBold->set_antialiased(font_antialiased); + FontTeluguBold->set_hinting(font_hinting); + FontTeluguBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontThai; FontThai.instantiate(); FontThai->load_memory(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, "ttf", default_font_size); @@ -275,12 +353,30 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontThai->set_hinting(font_hinting); FontThai->set_force_autohinter(true); //just looks better..i think? - Ref<FontData> FontHindi; - FontHindi.instantiate(); - FontHindi->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size); - FontHindi->set_antialiased(font_antialiased); - FontHindi->set_hinting(font_hinting); - FontHindi->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontThaiBold; + FontThaiBold.instantiate(); + FontThaiBold->load_memory(_font_NotoSansThaiUI_Bold, _font_NotoSansThaiUI_Bold_size, "ttf", default_font_size); + FontThaiBold->set_antialiased(font_antialiased); + FontThaiBold->set_hinting(font_hinting); + FontThaiBold->set_force_autohinter(true); //just looks better..i think? + + /* Droid Sans Fallback */ + + Ref<FontData> FontFallback; + FontFallback.instantiate(); + FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size); + FontFallback->set_antialiased(font_antialiased); + FontFallback->set_hinting(font_hinting); + FontFallback->set_force_autohinter(true); //just looks better..i think? + + /* Droid Sans Japanese */ + + Ref<FontData> FontJapanese; + FontJapanese.instantiate(); + FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size); + FontJapanese->set_antialiased(font_antialiased); + FontJapanese->set_hinting(font_hinting); + FontJapanese->set_force_autohinter(true); //just looks better..i think? /* Hack */ diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index a1b9237609..9fa2007597 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2261,7 +2261,7 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo _edit_request_change(object, p_name); emit_signal(_prop_edited, p_name); } else { - undo_redo->create_action(TTR("Set") + " " + p_name, UndoRedo::MERGE_ENDS); + undo_redo->create_action(vformat(TTR("Set %s"), p_name), UndoRedo::MERGE_ENDS); undo_redo->add_do_property(object, p_name, p_value); undo_redo->add_undo_property(object, p_name, object->get(p_name)); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index b64cc3f31c..6de7f6c425 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -398,22 +398,22 @@ EditorLog::EditorLog() { vb_right->add_child(memnew(HSeparator)); LogFilter *std_filter = memnew(LogFilter(MSG_TYPE_STD)); - std_filter->initialize_button("Toggle visibility of standard output messages.", callable_mp(this, &EditorLog::_set_filter_active)); + std_filter->initialize_button(TTR("Toggle visibility of standard output messages."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(std_filter->toggle_button); type_filter_map.insert(MSG_TYPE_STD, std_filter); LogFilter *error_filter = memnew(LogFilter(MSG_TYPE_ERROR)); - error_filter->initialize_button("Toggle visibility of errors.", callable_mp(this, &EditorLog::_set_filter_active)); + error_filter->initialize_button(TTR("Toggle visibility of errors."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(error_filter->toggle_button); type_filter_map.insert(MSG_TYPE_ERROR, error_filter); LogFilter *warning_filter = memnew(LogFilter(MSG_TYPE_WARNING)); - warning_filter->initialize_button("Toggle visibility of warnings.", callable_mp(this, &EditorLog::_set_filter_active)); + warning_filter->initialize_button(TTR("Toggle visibility of warnings."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(warning_filter->toggle_button); type_filter_map.insert(MSG_TYPE_WARNING, warning_filter); LogFilter *editor_filter = memnew(LogFilter(MSG_TYPE_EDITOR)); - editor_filter->initialize_button("Toggle visibility of editor messages.", callable_mp(this, &EditorLog::_set_filter_active)); + editor_filter->initialize_button(TTR("Toggle visibility of editor messages."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(editor_filter->toggle_button); type_filter_map.insert(MSG_TYPE_EDITOR, editor_filter); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 712e571e57..6bdf428f81 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -508,6 +508,9 @@ void EditorNode::_update_from_settings() { float lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels"); scene_root->set_lod_threshold(lod_threshold); + + RS::get_singleton()->decals_set_filter(RS::DecalFilter(int(GLOBAL_GET("rendering/textures/decals/filter")))); + RS::get_singleton()->light_projectors_set_filter(RS::LightProjectorFilter(int(GLOBAL_GET("rendering/textures/light_projectors/filter")))); } void EditorNode::_notification(int p_what) { @@ -6302,7 +6305,7 @@ EditorNode::EditorNode() { tool_menu->add_item(TTR("Orphan Resource Explorer..."), TOOLS_ORPHAN_RESOURCES); p->add_separator(); - p->add_item(TTR("Reload Current Project"), RUN_RELOAD_CURRENT_PROJECT); + p->add_shortcut(ED_SHORTCUT("editor/reload_current_project", TTR("Reload Current Project")), RUN_RELOAD_CURRENT_PROJECT); #ifdef OSX_ENABLED p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q), RUN_PROJECT_MANAGER, true); #else diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index cea8081a5f..0c908be441 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1024,6 +1024,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("read_only", "LineEdit", style_line_edit_disabled); theme->set_icon("clear", "LineEdit", theme->get_icon("GuiClose", "EditorIcons")); theme->set_color("read_only", "LineEdit", font_disabled_color); + theme->set_color("font_uneditable_color", "LineEdit", font_disabled_color); theme->set_color("font_color", "LineEdit", font_color); theme->set_color("font_selected_color", "LineEdit", mono_color); theme->set_color("caret_color", "LineEdit", font_color); @@ -1189,7 +1190,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_tooltip->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE * 0.5); style_tooltip->set_default_margin(SIDE_RIGHT, default_margin_size * EDSCALE); style_tooltip->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE * 0.5); - style_tooltip->set_bg_color(mono_color.inverted() * Color(1, 1, 1, 0.8)); + style_tooltip->set_bg_color(mono_color.inverted()); style_tooltip->set_border_width_all(0); theme->set_color("font_color", "TooltipLabel", font_hover_color); theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0)); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index bb19ee4310..ab307500e7 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -340,7 +340,7 @@ void InspectorDock::_notification(int p_what) { resource_new_button->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); resource_load_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); resource_save_button->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); - resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); + resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); @@ -523,7 +523,8 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_save_button->set_disabled(true); resource_extra_button = memnew(MenuButton); - resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); + resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + resource_extra_button->set_tooltip(TTR("Extra resource options.")); general_options_hb->add_child(resource_extra_button); resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource from Clipboard")), RESOURCE_EDIT_CLIPBOARD); resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index acfa873f62..cbce5bb3f5 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1733,27 +1733,27 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay onion.capture.material = Ref<ShaderMaterial>(memnew(ShaderMaterial)); onion.capture.shader = Ref<Shader>(memnew(Shader)); - onion.capture.shader->set_code(" \ - shader_type canvas_item; \ - \ - uniform vec4 bkg_color; \ - uniform vec4 dir_color; \ - uniform bool differences_only; \ - uniform sampler2D present; \ - \ - float zero_if_equal(vec4 a, vec4 b) { \ - return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0)); \ - } \ - \ - void fragment() { \ - vec4 capture_samp = texture(TEXTURE, UV); \ - vec4 present_samp = texture(present, UV); \ - float bkg_mask = zero_if_equal(capture_samp, bkg_color); \ - float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color); \ - diff_mask = min(1.0, diff_mask + float(!differences_only)); \ - COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); \ - } \ - "); + onion.capture.shader->set_code(R"( +shader_type canvas_item; + +uniform vec4 bkg_color; +uniform vec4 dir_color; +uniform bool differences_only; +uniform sampler2D present; + +float zero_if_equal(vec4 a, vec4 b) { + return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0)); +} + +void fragment() { + vec4 capture_samp = texture(TEXTURE, UV); + vec4 present_samp = texture(present, UV); + float bkg_mask = zero_if_equal(capture_samp, bkg_color); + float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color); + diff_mask = min(1.0, diff_mask + float(!differences_only)); + COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); +} +)"); RS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid()); } diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index e90665f84d..9c28e023dd 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -79,7 +79,7 @@ void AnimationTreeEditor::_update_path() { group.instantiate(); Button *b = memnew(Button); - b->set_text("Root"); + b->set_text(TTR("Root")); b->set_toggle_mode(true); b->set_button_group(group); b->set_pressed(true); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index aedcf16fa5..d5ef13e426 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1197,7 +1197,17 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo Ref<InputEventKey> k = p_event; if (k.is_valid()) { if (k->is_pressed()) { - if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->is_shortcut(p_event)) { + if (ED_GET_SHORTCUT("canvas_item_editor/zoom_3.125_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 32.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_6.25_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 16.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_12.5_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 8.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_25_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 4.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_50_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 2.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->is_shortcut(p_event)) { _update_zoom(1.0 * MAX(1, EDSCALE)); } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_200_percent")->is_shortcut(p_event)) { _update_zoom(2.0 * MAX(1, EDSCALE)); @@ -5630,6 +5640,11 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { // those shortcuts one by one. // Resetting zoom to 100% is a duplicate shortcut of `canvas_item_editor/reset_zoom`, // but it ensures both 1 and Ctrl + 0 can be used to reset zoom. + ED_SHORTCUT("canvas_item_editor/zoom_3.125_percent", TTR("Zoom to 3.125%"), KEY_MASK_SHIFT | KEY_5); + ED_SHORTCUT("canvas_item_editor/zoom_6.25_percent", TTR("Zoom to 6.25%"), KEY_MASK_SHIFT | KEY_4); + ED_SHORTCUT("canvas_item_editor/zoom_12.5_percent", TTR("Zoom to 12.5%"), KEY_MASK_SHIFT | KEY_3); + ED_SHORTCUT("canvas_item_editor/zoom_25_percent", TTR("Zoom to 25%"), KEY_MASK_SHIFT | KEY_2); + ED_SHORTCUT("canvas_item_editor/zoom_50_percent", TTR("Zoom to 50%"), KEY_MASK_SHIFT | KEY_1); ED_SHORTCUT("canvas_item_editor/zoom_100_percent", TTR("Zoom to 100%"), KEY_1); ED_SHORTCUT("canvas_item_editor/zoom_200_percent", TTR("Zoom to 200%"), KEY_2); ED_SHORTCUT("canvas_item_editor/zoom_400_percent", TTR("Zoom to 400%"), KEY_3); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 7d07e99c2f..07ff0eb346 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -393,7 +393,8 @@ int CurveEditor::get_point_at(Vector2 pos) const { } const Curve &curve = **_curve_ref; - const float r = _hover_radius * _hover_radius; + const float true_hover_radius = Math::round(_hover_radius * EDSCALE); + const float r = true_hover_radius * true_hover_radius; for (int i = 0; i < curve.get_point_count(); ++i) { Vector2 p = get_view_pos(curve.get_point_position(i)); @@ -558,7 +559,7 @@ Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const { Vector2 point_pos = get_view_pos(_curve_ref->get_point_position(i)); Vector2 control_pos = get_view_pos(_curve_ref->get_point_position(i) + dir); - return point_pos + _tangents_length * (control_pos - point_pos).normalized(); + return point_pos + Math::round(_tangents_length * EDSCALE) * (control_pos - point_pos).normalized(); } Vector2 CurveEditor::get_view_pos(Vector2 world_pos) const { @@ -703,13 +704,13 @@ void CurveEditor::_draw() { if (i != 0) { Vector2 control_pos = get_tangent_view_pos(i, TANGENT_LEFT); draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE)); - draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color); + draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color); } if (i != curve.get_point_count() - 1) { Vector2 control_pos = get_tangent_view_pos(i, TANGENT_RIGHT); draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE)); - draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color); + draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color); } } @@ -732,7 +733,7 @@ void CurveEditor::_draw() { for (int i = 0; i < curve.get_point_count(); ++i) { Vector2 pos = curve.get_point_position(i); - draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(3), i == _selected_point ? selected_point_color : point_color); + draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(3 * EDSCALE)), i == _selected_point ? selected_point_color : point_color); // TODO Circles are prettier. Needs a fix! Or a texture //draw_circle(pos, 2, point_color); } @@ -742,7 +743,7 @@ void CurveEditor::_draw() { if (_hover_point != -1) { const Color hover_color = line_color; Vector2 pos = curve.get_point_position(_hover_point); - draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(_hover_radius), hover_color, false, Math::round(EDSCALE)); + draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(_hover_radius * EDSCALE)), hover_color, false, Math::round(EDSCALE)); } // Help text diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index 71598b904b..a4436525fb 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -131,7 +131,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String if (col_sdf) { Ref<Image> bake_img = col_sdf->bake(); if (bake_img.is_null()) { - EditorNode::get_singleton()->show_warning("Bake Error."); + EditorNode::get_singleton()->show_warning(TTR("Bake Error.")); return; } diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp index f1aa10844b..d3d2de92f5 100644 --- a/editor/plugins/input_event_editor_plugin.cpp +++ b/editor/plugins/input_event_editor_plugin.cpp @@ -86,7 +86,7 @@ InputEventConfigContainer::InputEventConfigContainer() { mc->add_child(hb); open_config_button = memnew(Button); - open_config_button->set_text("Configure"); + open_config_button->set_text(TTR("Configure")); open_config_button->connect("pressed", callable_mp(this, &InputEventConfigContainer::_configure_pressed)); hb->add_child(open_config_button); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index c341783d54..0764a4c46c 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -5381,35 +5381,37 @@ void Node3DEditor::_init_indicators() { } Ref<Shader> grid_shader = memnew(Shader); - grid_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded; \n" - "uniform bool orthogonal; \n" - "uniform float grid_size; \n" - "\n" - "void vertex() { \n" - " // From FLAG_SRGB_VERTEX_COLOR \n" - " if (!OUTPUT_IS_SRGB) { \n" - " COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045))); \n" - " } \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = COLOR.rgb; \n" - " vec3 dir = orthogonal ? -vec3(0, 0, 1) : VIEW; \n" - " float angle_fade = abs(dot(dir, NORMAL)); \n" - " angle_fade = smoothstep(0.05, 0.2, angle_fade); \n" - " \n" - " vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; \n" - " vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; \n" - " vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; \n" - " vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); \n" - " float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); \n" - " dist_fade = smoothstep(0.02, 0.3, dist_fade); \n" - " \n" - " ALPHA = COLOR.a * dist_fade * angle_fade; \n" - "}"); + grid_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded; + +uniform bool orthogonal; +uniform float grid_size; + +void vertex() { + // From FLAG_SRGB_VERTEX_COLOR. + if (!OUTPUT_IS_SRGB) { + COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045))); + } +} + +void fragment() { + ALBEDO = COLOR.rgb; + vec3 dir = orthogonal ? -vec3(0, 0, 1) : VIEW; + float angle_fade = abs(dot(dir, NORMAL)); + angle_fade = smoothstep(0.05, 0.2, angle_fade); + + vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; + vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; + vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; + vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); + float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); + dist_fade = smoothstep(0.02, 0.3, dist_fade); + + ALPHA = COLOR.a * dist_fade * angle_fade; +} +)"); for (int i = 0; i < 3; i++) { grid_mat[i].instantiate(); @@ -5621,33 +5623,35 @@ void Node3DEditor::_init_indicators() { Ref<Shader> rotate_shader = memnew(Shader); - rotate_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded, depth_test_disabled; \n" - "uniform vec4 albedo; \n" - "\n" - "mat3 orthonormalize(mat3 m) { \n" - " vec3 x = normalize(m[0]); \n" - " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n" - " vec3 z = m[2] - x * dot(x, m[2]); \n" - " z = normalize(z - y * (dot(y,m[2]))); \n" - " return mat3(x,y,z); \n" - "} \n" - "\n" - "void vertex() { \n" - " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n" - " vec3 n = mv * VERTEX; \n" - " float orientation = dot(vec3(0,0,-1),n); \n" - " if (orientation <= 0.005) { \n" - " VERTEX += NORMAL*0.02; \n" - " } \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = albedo.rgb; \n" - " ALPHA = albedo.a; \n" - "}"); + rotate_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded, depth_test_disabled; + +uniform vec4 albedo; + +mat3 orthonormalize(mat3 m) { + vec3 x = normalize(m[0]); + vec3 y = normalize(m[1] - x * dot(x, m[1])); + vec3 z = m[2] - x * dot(x, m[2]); + z = normalize(z - y * (dot(y,m[2]))); + return mat3(x,y,z); +} + +void vertex() { + mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); + vec3 n = mv * VERTEX; + float orientation = dot(vec3(0, 0, -1), n); + if (orientation <= 0.005) { + VERTEX += NORMAL * 0.02; + } +} + +void fragment() { + ALBEDO = albedo.rgb; + ALPHA = albedo.a; +} +)"); Ref<ShaderMaterial> rotate_mat = memnew(ShaderMaterial); rotate_mat->set_render_priority(Material::RENDER_PRIORITY_MAX); @@ -5667,34 +5671,36 @@ void Node3DEditor::_init_indicators() { Ref<ShaderMaterial> border_mat = rotate_mat->duplicate(); Ref<Shader> border_shader = memnew(Shader); - border_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded, depth_test_disabled; \n" - "uniform vec4 albedo; \n" - "\n" - "mat3 orthonormalize(mat3 m) { \n" - " vec3 x = normalize(m[0]); \n" - " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n" - " vec3 z = m[2] - x * dot(x, m[2]); \n" - " z = normalize(z - y * (dot(y,m[2]))); \n" - " return mat3(x,y,z); \n" - "} \n" - "\n" - "void vertex() { \n" - " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n" - " mv = inverse(mv); \n" - " VERTEX += NORMAL*0.008; \n" - " vec3 camera_dir_local = mv * vec3(0,0,1); \n" - " vec3 camera_up_local = mv * vec3(0,1,0); \n" - " mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); \n" - " VERTEX = rotation_matrix * VERTEX; \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = albedo.rgb; \n" - " ALPHA = albedo.a; \n" - "}"); + border_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded, depth_test_disabled; + +uniform vec4 albedo; + +mat3 orthonormalize(mat3 m) { + vec3 x = normalize(m[0]); + vec3 y = normalize(m[1] - x * dot(x, m[1])); + vec3 z = m[2] - x * dot(x, m[2]); + z = normalize(z - y * (dot(y,m[2]))); + return mat3(x,y,z); +} + +void vertex() { + mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); + mv = inverse(mv); + VERTEX += NORMAL*0.008; + vec3 camera_dir_local = mv * vec3(0,0,1); + vec3 camera_up_local = mv * vec3(0,1,0); + mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); + VERTEX = rotation_matrix * VERTEX; +} + +void fragment() { + ALBEDO = albedo.rgb; + ALPHA = albedo.a; +} +)"); border_mat->set_shader(border_shader); border_mat->set_shader_param("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0)); @@ -6248,7 +6254,7 @@ void Node3DEditor::_add_sun_to_scene(bool p_already_added_environment) { ERR_FAIL_COND(!base); Node *new_sun = preview_sun->duplicate(); - undo_redo->create_action("Add Preview Sun to Scene"); + undo_redo->create_action(TTR("Add Preview Sun to Scene")); undo_redo->add_do_method(base, "add_child", new_sun); // Move to the beginning of the scene tree since more "global" nodes // generally look better when placed at the top. @@ -6278,7 +6284,7 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { WorldEnvironment *new_env = memnew(WorldEnvironment); new_env->set_environment(preview_environment->get_environment()->duplicate(true)); - undo_redo->create_action("Add Preview Environment to Scene"); + undo_redo->create_action(TTR("Add Preview Environment to Scene")); undo_redo->add_do_method(base, "add_child", new_env); // Move to the beginning of the scene tree since more "global" nodes // generally look better when placed at the top. @@ -7155,9 +7161,21 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { sun_direction->connect("draw", callable_mp(this, &Node3DEditor::_sun_direction_draw)); sun_direction->set_default_cursor_shape(CURSOR_MOVE); - String sun_dir_shader_code = "shader_type canvas_item; uniform vec3 sun_direction; uniform vec3 sun_color; void fragment() { vec3 n; n.xy = UV * 2.0 - 1.0; n.z = sqrt(max(0.0, 1.0 - dot(n.xy, n.xy))); COLOR.rgb = dot(n,sun_direction) * sun_color; COLOR.a = 1.0 - smoothstep(0.99,1.0,length(n.xy)); }"; sun_direction_shader.instantiate(); - sun_direction_shader->set_code(sun_dir_shader_code); + sun_direction_shader->set_code(R"( +shader_type canvas_item; + +uniform vec3 sun_direction; +uniform vec3 sun_color; + +void fragment() { + vec3 n; + n.xy = UV * 2.0 - 1.0; + n.z = sqrt(max(0.0, 1.0 - dot(n.xy, n.xy))); + COLOR.rgb = dot(n, sun_direction) * sun_color; + COLOR.a = 1.0 - smoothstep(0.99, 1.0, length(n.xy)); +} +)"); sun_direction_material.instantiate(); sun_direction_material->set_shader(sun_direction_shader); sun_direction_material->set_shader_param("sun_direction", Vector3(0, 0, 1)); diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index 9a62b22d63..0f889ce33d 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -521,7 +521,7 @@ Sprite2DEditor::Sprite2DEditor() { debug_uv_dialog = memnew(ConfirmationDialog); debug_uv_dialog->get_ok_button()->set_text(TTR("Create Mesh2D")); - debug_uv_dialog->set_title("Mesh 2D Preview"); + debug_uv_dialog->set_title(TTR("Mesh 2D Preview")); VBoxContainer *vb = memnew(VBoxContainer); debug_uv_dialog->add_child(vb); ScrollContainer *scroll = memnew(ScrollContainer); diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.cpp b/editor/plugins/sub_viewport_preview_editor_plugin.cpp index 5fd173cae3..75c47bda2e 100644 --- a/editor/plugins/sub_viewport_preview_editor_plugin.cpp +++ b/editor/plugins/sub_viewport_preview_editor_plugin.cpp @@ -38,6 +38,7 @@ void EditorInspectorPluginSubViewportPreview::parse_begin(Object *p_object) { SubViewport *sub_viewport = Object::cast_to<SubViewport>(p_object); TexturePreview *sub_viewport_preview = memnew(TexturePreview(sub_viewport->get_texture(), false)); + // Otherwise `sub_viewport_preview`'s `texture_display` doesn't update properly when `sub_viewport`'s size changes. sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::update)); add_custom_control(sub_viewport_preview); } diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 096062fc8b..3987cdd6a0 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -77,16 +77,17 @@ void Texture3DEditor::_update_material() { } void Texture3DEditor::_make_shaders() { - String shader_3d = "" - "shader_type canvas_item;\n" - "uniform sampler3D tex;\n" - "uniform float layer;\n" - "void fragment() {\n" - " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n" - "}"; - shader.instantiate(); - shader->set_code(shader_3d); + shader->set_code(R"( +shader_type canvas_item; + +uniform sampler3D tex; +uniform float layer; + +void fragment() { + COLOR = textureLod(tex, vec3(UV, layer), 0.0); +} +)"); material.instantiate(); material->set_shader(shader); } diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 6ee652098d..4029d6785c 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -37,10 +37,8 @@ TextureRect *TexturePreview::get_texture_display() { } TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { - Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); - TextureRect *checkerboard = memnew(TextureRect); - checkerboard->set_texture(theme->get_icon("Checkerboard", "EditorIcons")); + checkerboard->set_texture(get_theme_icon("Checkerboard", "EditorIcons")); checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE); checkerboard->set_texture_repeat(CanvasItem::TEXTURE_REPEAT_ENABLED); checkerboard->set_custom_minimum_size(Size2(0.0, 256.0) * EDSCALE); @@ -70,10 +68,10 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { metadata_label->add_theme_font_size_override("font_size", 16 * EDSCALE); metadata_label->add_theme_color_override("font_outline_color", Color::named("black")); metadata_label->add_theme_constant_override("outline_size", 2 * EDSCALE); - Ref<Font> metadata_label_font = theme->get_font("expression", "EditorFonts"); + Ref<Font> metadata_label_font = get_theme_font("expression", "EditorFonts"); metadata_label->add_theme_font_override("font", metadata_label_font); - // it's okay that these colors are static since the grid color is static too + // It's okay that these colors are static since the grid color is static too. metadata_label->add_theme_color_override("font_color", Color::named("white")); metadata_label->add_theme_color_override("font_color_shadow", Color::named("black")); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index fb50e1c4a6..80359452ac 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -104,43 +104,46 @@ void TextureLayeredEditor::_update_material() { } void TextureLayeredEditor::_make_shaders() { - String shader_2d_array = "" - "shader_type canvas_item;\n" - "uniform sampler2DArray tex;\n" - "uniform float layer;\n" - "void fragment() {\n" - " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n" - "}"; - shaders[0].instantiate(); - shaders[0]->set_code(shader_2d_array); - - String shader_cube = "" - "shader_type canvas_item;\n" - "uniform samplerCube tex;\n" - "uniform vec3 normal;\n" - "uniform mat3 rot;\n" - "void fragment() {\n" - " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n" - " COLOR = textureLod(tex,n,0.0);\n" - "}"; + shaders[0]->set_code(R"( +shader_type canvas_item; + +uniform sampler2DArray tex; +uniform float layer; + +void fragment() { + COLOR = textureLod(tex, vec3(UV, layer), 0.0); +} +)"); shaders[1].instantiate(); - shaders[1]->set_code(shader_cube); - - String shader_cube_array = "" - "shader_type canvas_item;\n" - "uniform samplerCubeArray tex;\n" - "uniform vec3 normal;\n" - "uniform mat3 rot;\n" - "uniform float layer;\n" - "void fragment() {\n" - " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n" - " COLOR = textureLod(tex,vec4(n,layer),0.0);\n" - "}"; + shaders[1]->set_code(R"( +shader_type canvas_item; + +uniform samplerCube tex; +uniform vec3 normal; +uniform mat3 rot; + +void fragment() { + vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z)); + COLOR = textureLod(tex, n, 0.0); +} +)"); shaders[2].instantiate(); - shaders[2]->set_code(shader_cube_array); + shaders[2]->set_code(R"( +shader_type canvas_item; + +uniform samplerCubeArray tex; +uniform vec3 normal; +uniform mat3 rot; +uniform float layer; + +void fragment() { + vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z)); + COLOR = textureLod(tex, vec4(n, layer), 0.0); +} +)"); for (int i = 0; i < 3; i++) { materials[i].instantiate(); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 4a4816e3b8..9338ea6ddd 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -1459,13 +1459,16 @@ void ThemeItemEditorDialog::_item_tree_button_pressed(Object *p_item, int p_colu _update_edit_item_tree(edited_item_type); } -void ThemeItemEditorDialog::_add_theme_type() { - edited_theme->add_icon_type(edit_add_type_value->get_text()); - edited_theme->add_stylebox_type(edit_add_type_value->get_text()); - edited_theme->add_font_type(edit_add_type_value->get_text()); - edited_theme->add_font_size_type(edit_add_type_value->get_text()); - edited_theme->add_color_type(edit_add_type_value->get_text()); - edited_theme->add_constant_type(edit_add_type_value->get_text()); +void ThemeItemEditorDialog::_add_theme_type(const String &p_new_text) { + const String new_type = edit_add_type_value->get_text().strip_edges(); + edit_add_type_value->clear(); + + edited_theme->add_icon_type(new_type); + edited_theme->add_stylebox_type(new_type); + edited_theme->add_font_type(new_type); + edited_theme->add_font_size_type(new_type); + edited_theme->add_color_type(new_type); + edited_theme->add_constant_type(new_type); _update_edit_types(); // Force emit a change so that other parts of the editor can update. @@ -1776,11 +1779,12 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { edit_dialog_side_vb->add_child(edit_add_type_hb); edit_add_type_value = memnew(LineEdit); edit_add_type_value->set_h_size_flags(Control::SIZE_EXPAND_FILL); + edit_add_type_value->connect("text_submitted", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type)); edit_add_type_hb->add_child(edit_add_type_value); Button *edit_add_type_button = memnew(Button); edit_add_type_button->set_text(TTR("Add")); edit_add_type_hb->add_child(edit_add_type_button); - edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type)); + edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type), varray("")); VBoxContainer *edit_items_vb = memnew(VBoxContainer); edit_items_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 3c114a375a..e78b244a42 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -239,7 +239,7 @@ class ThemeItemEditorDialog : public AcceptDialog { void _update_edit_item_tree(String p_item_type); void _item_tree_button_pressed(Object *p_item, int p_column, int p_id); - void _add_theme_type(); + void _add_theme_type(const String &p_new_text); void _add_theme_item(Theme::DataType p_data_type, String p_item_name, String p_item_type); void _remove_data_type_items(Theme::DataType p_data_type, String p_item_type); void _remove_class_items(); diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index 502e30836b..84e40e2ffa 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -41,25 +41,31 @@ #include "editor/editor_settings.h" void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) { - bool ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL); - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { drag_type = DRAG_TYPE_NONE; - if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { - // Zoom out - zoom_widget->set_zoom_by_increments(-2); - emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); - _update_zoom_and_panning(true); - accept_event(); - } - if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { - // Zoom in - zoom_widget->set_zoom_by_increments(2); - emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); - _update_zoom_and_panning(true); - accept_event(); + Vector2i scroll_vec = Vector2((mb->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT) - (mb->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT), (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) - (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN)); + if (scroll_vec != Vector2()) { + if (mb->is_ctrl_pressed()) { + if (mb->is_shift_pressed()) { + panning.x += 32 * mb->get_factor() * scroll_vec.y; + panning.y += 32 * mb->get_factor() * scroll_vec.x; + } else { + panning.y += 32 * mb->get_factor() * scroll_vec.y; + panning.x += 32 * mb->get_factor() * scroll_vec.x; + } + + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + _update_zoom_and_panning(true); + accept_event(); + + } else if (!mb->is_shift_pressed()) { + zoom_widget->set_zoom_by_increments(scroll_vec.y * 2); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + _update_zoom_and_panning(true); + accept_event(); + } } if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE || mb->get_button_index() == MOUSE_BUTTON_RIGHT) { @@ -569,6 +575,7 @@ TileAtlasView::TileAtlasView() { button_center_view->connect("pressed", callable_mp(this, &TileAtlasView::_center_view)); button_center_view->set_flat(true); button_center_view->set_disabled(true); + button_center_view->set_tooltip(TTR("Center View")); add_child(button_center_view); center_container = memnew(CenterContainer); diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 8cfc4990ea..dd2922286f 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -1050,7 +1050,7 @@ void TileDataDefaultEditor::_notification(int p_what) { TileDataDefaultEditor::TileDataDefaultEditor() { label = memnew(Label); - label->set_text("Painting:"); + label->set_text(TTR("Painting:")); add_child(label); toolbar->add_child(memnew(VSeparator)); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index cf6ce1ff8b..6e3c55d801 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -168,9 +168,9 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { if (atlas_source) { texture = atlas_source->get_texture(); if (texture.is_valid()) { - item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); + item_text = vformat("%s (ID: %d)", texture->get_path().get_file(), source_id); } else { - item_text = vformat("No Texture Atlas Source (id:%d)", source_id); + item_text = vformat("No Texture Atlas Source (ID: %d)", source_id); } } @@ -178,12 +178,12 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); if (scene_collection_source) { texture = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); - item_text = vformat(TTR("Scene Collection Source (id:%d)"), source_id); + item_text = vformat(TTR("Scene Collection Source (ID: %d)"), source_id); } // Use default if not valid. if (item_text.is_empty()) { - item_text = vformat(TTR("Unknown Type Source (id:%d)"), source_id); + item_text = vformat(TTR("Unknown Type Source (ID: %d)"), source_id); } if (!texture.is_valid()) { texture = missing_atlas_texture_icon; @@ -302,7 +302,7 @@ void TileMapEditorTilesPlugin::_update_scenes_collection_view() { int item_index = 0; if (scene.is_valid()) { - item_index = scene_tiles_list->add_item(vformat("%s (path:%s id:%d)", scene->get_path().get_file().get_basename(), scene->get_path(), scene_id)); + item_index = scene_tiles_list->add_item(vformat("%s (Path: %s, ID: %d)", scene->get_path().get_file().get_basename(), scene->get_path(), scene_id)); Variant udata = i; EditorResourcePreview::get_singleton()->queue_edited_resource_preview(scene, this, "_scene_thumbnail_done", udata); } else { @@ -1865,6 +1865,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { toggle_grid_button = memnew(Button); toggle_grid_button->set_flat(true); toggle_grid_button->set_toggle_mode(true); + toggle_grid_button->set_tooltip(TTR("Toggle grid visibility.")); toggle_grid_button->connect("toggled", callable_mp(this, &TileMapEditorTilesPlugin::_on_grid_toggled)); toolbar->add_child(toggle_grid_button); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index c2542aa7c0..6b617cf4d8 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -2055,7 +2055,7 @@ void TileSetAtlasSourceEditor::_notification(int p_what) { tools_settings_erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - tool_advanced_menu_buttom->set_icon(get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); + tool_advanced_menu_buttom->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); resize_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); resize_handle_disabled = get_theme_icon(SNAME("EditorHandleDisabled"), SNAME("EditorIcons")); @@ -2176,7 +2176,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { // -- Dialogs -- confirm_auto_create_tiles = memnew(AcceptDialog); - confirm_auto_create_tiles->set_title(TTR("Create tiles automatically in non-transparent texture regions?")); + confirm_auto_create_tiles->set_title(TTR("Auto Create Tiles in Non-Transparent Texture Regions?")); confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?")); confirm_auto_create_tiles->get_ok_button()->set_text(TTR("Yes")); confirm_auto_create_tiles->add_cancel_button()->set_text(TTR("No")); @@ -2202,7 +2202,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { tool_setup_atlas_source_button->set_toggle_mode(true); tool_setup_atlas_source_button->set_pressed(true); tool_setup_atlas_source_button->set_button_group(tools_button_group); - tool_setup_atlas_source_button->set_tooltip(TTR("Atlas Setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); + tool_setup_atlas_source_button->set_tooltip(TTR("Atlas setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); toolbox->add_child(tool_setup_atlas_source_button); tool_select_button = memnew(Button); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 25b08a1509..5804f54649 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -164,7 +164,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() { _refresh_file_diff(); } } - commit_status->set_text("New changes detected"); + commit_status->set_text(TTR("New changes detected")); } } else { WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu."); @@ -270,9 +270,9 @@ void VersionControlEditorPlugin::_clear_file_diff() { void VersionControlEditorPlugin::_update_stage_status() { String status; if (staged_files_count == 1) { - status = "Stage contains 1 file"; + status = TTR("Stage contains 1 file"); } else { - status = "Stage contains " + String::num_int64(staged_files_count) + " files"; + status = vformat(TTR("Stage contains %d files"), staged_files_count); } commit_status->set_text(status); } @@ -280,9 +280,9 @@ void VersionControlEditorPlugin::_update_stage_status() { void VersionControlEditorPlugin::_update_commit_status() { String status; if (staged_files_count == 1) { - status = "Committed 1 file"; + status = TTR("Committed 1 file"); } else { - status = "Committed " + String::num_int64(staged_files_count) + " files "; + status = vformat(TTR("Committed %d files"), staged_files_count); } commit_status->set_text(status); staged_files_count = 0; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index b8e1613fca..1e818b9d43 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1153,7 +1153,7 @@ ProjectExportDialog::ProjectExportDialog() { enc_directory = memnew(CheckButton); enc_directory->connect("toggled", callable_mp(this, &ProjectExportDialog::_enc_directory_changed)); - enc_directory->set_text("Encrypt Index (File Names and Info)"); + enc_directory->set_text(TTR("Encrypt Index (File Names and Info)")); sec_vb->add_child(enc_directory); enc_in_filters = memnew(LineEdit); @@ -1219,7 +1219,7 @@ ProjectExportDialog::ProjectExportDialog() { export_all_dialog = memnew(ConfirmationDialog); add_child(export_all_dialog); - export_all_dialog->set_title("Export All"); + export_all_dialog->set_title(TTR("Export All")); export_all_dialog->set_text(TTR("Choose an export mode:")); export_all_dialog->get_ok_button()->hide(); export_all_dialog->add_button(TTR("Debug"), true, "debug"); @@ -1253,7 +1253,7 @@ ProjectExportDialog::ProjectExportDialog() { export_error2->set_text(" - " + TTR("Export templates for this platform are missing:") + " "); error_dialog = memnew(AcceptDialog); - error_dialog->set_title("Error"); + error_dialog->set_title(TTR("Error")); error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " "); main_vb->add_child(error_dialog); error_dialog->hide(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 77c29408d1..dad708612e 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1157,6 +1157,19 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } +void SceneTreeDock::_property_selected(int p_idx) { + ERR_FAIL_NULL(property_drop_node); + _perform_property_drop(property_drop_node, menu_properties->get_item_metadata(p_idx), ResourceLoader::load(resource_drop_path)); + property_drop_node = nullptr; +} + +void SceneTreeDock::_perform_property_drop(Node *p_node, String p_property, RES p_res) { + editor_data->get_undo_redo().create_action(vformat(TTR("Set %s"), p_property)); + editor_data->get_undo_redo().add_do_property(p_node, p_property, p_res); + editor_data->get_undo_redo().add_undo_property(p_node, p_property, p_node->get(p_property)); + editor_data->get_undo_redo().commit_action(); +} + void SceneTreeDock::add_root_node(Node *p_node) { editor_data->get_undo_redo().create_action(TTR("New Scene Root")); editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", p_node); @@ -2515,9 +2528,51 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_ Node *node = get_node(p_to); ERR_FAIL_COND(!node); - int to_pos = -1; - _normalize_drop(node, to_pos, p_type); - _perform_instantiate_scenes(p_files, node, to_pos); + if (scene_tree->get_scene_tree()->get_drop_mode_flags() & Tree::DROP_MODE_INBETWEEN) { + // Dropped PackedScene, instance it. + int to_pos = -1; + _normalize_drop(node, to_pos, p_type); + _perform_instantiate_scenes(p_files, node, to_pos); + } else { + String res_path = p_files[0]; + StringName res_type = EditorFileSystem::get_singleton()->get_file_type(res_path); + List<String> valid_properties; + + List<PropertyInfo> pinfo; + node->get_property_list(&pinfo); + + for (PropertyInfo &p : pinfo) { + if (!(p.usage & PROPERTY_USAGE_EDITOR) || !(p.usage & PROPERTY_USAGE_STORAGE) || p.hint != PROPERTY_HINT_RESOURCE_TYPE) { + continue; + } + Vector<String> valid_types = p.hint_string.split(","); + + for (String &prop_type : valid_types) { + if (res_type == prop_type || ClassDB::is_parent_class(res_type, prop_type) || EditorNode::get_editor_data().script_class_is_parent(res_type, prop_type)) { + valid_properties.push_back(p.name); + break; + } + } + } + + if (valid_properties.size() > 1) { + property_drop_node = node; + resource_drop_path = res_path; + + bool capitalize = bool(EDITOR_GET("interface/inspector/capitalize_properties")); + menu_properties->clear(); + for (String &p : valid_properties) { + menu_properties->add_item(capitalize ? p.capitalize() : p); + menu_properties->set_item_metadata(menu_properties->get_item_count() - 1, p); + } + + menu_properties->set_size(Size2(1, 1)); + menu_properties->set_position(get_screen_position() + get_local_mouse_position()); + menu_properties->popup(); + } else if (!valid_properties.is_empty()) { + _perform_property_drop(node, valid_properties[0], ResourceLoader::load(res_path)); + } + } } void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { @@ -3276,6 +3331,10 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel first_enter = true; restore_script_editor_on_drag = false; + menu_properties = memnew(PopupMenu); + add_child(menu_properties); + menu_properties->connect("id_pressed", callable_mp(this, &SceneTreeDock::_property_selected)); + clear_inherit_confirm = memnew(ConfirmationDialog); clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)")); clear_inherit_confirm->get_ok_button()->set_text(TTR("Clear")); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 08d992d465..fd9299fb2b 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -123,8 +123,13 @@ class SceneTreeDock : public VBoxContainer { HBoxContainer *tool_hbc; void _tool_selected(int p_tool, bool p_confirm_override = false); + void _property_selected(int p_idx); void _node_collapsed(Object *p_obj); + Node *property_drop_node = nullptr; + String resource_drop_path; + void _perform_property_drop(Node *p_node, String p_property, RES p_res); + EditorData *editor_data; EditorSelection *editor_selection; @@ -147,6 +152,7 @@ class SceneTreeDock : public VBoxContainer { PopupMenu *menu; PopupMenu *menu_subresources; + PopupMenu *menu_properties; ConfirmationDialog *clear_inherit_confirm; bool first_enter; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 414cc08777..c6f2c9253e 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -1025,15 +1025,24 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d return true; } + bool scene_drop = true; for (int i = 0; i < files.size(); i++) { String file = files[i]; String ftype = EditorFileSystem::get_singleton()->get_file_type(file); if (ftype != "PackedScene") { - return false; + scene_drop = false; + break; } } - tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); //so it works.. + if (scene_drop) { + tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); + } else { + if (files.size() > 1) { + return false; + } + tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM); + } return true; } diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index 3eda0dff0e..d504d3b137 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -84,7 +84,7 @@ protected: UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Set Shader Global Variable"); + undo_redo->create_action(TTR("Set Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_set", p_name, p_value); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_set", p_name, existing); RS::GlobalVariableType type = RS::get_singleton()->global_variable_get_type(p_name); @@ -394,7 +394,7 @@ void ShaderGlobalsEditor::_variable_added() { Variant value = create_var(RS::GlobalVariableType(variable_type->get_selected())); - undo_redo->create_action("Add Shader Global Variable"); + undo_redo->create_action(TTR("Add Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_add", var, RS::GlobalVariableType(variable_type->get_selected()), value); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_remove", var); Dictionary gv; @@ -411,7 +411,7 @@ void ShaderGlobalsEditor::_variable_added() { void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Add Shader Global Variable"); + undo_redo->create_action(TTR("Add Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_remove", p_variable); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_add", p_variable, RS::get_singleton()->global_variable_get_type(p_variable), RS::get_singleton()->global_variable_get(p_variable)); |