diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/code_editor.cpp | 19 | ||||
-rw-r--r-- | editor/editor_data.cpp | 16 | ||||
-rw-r--r-- | editor/editor_data.h | 4 | ||||
-rw-r--r-- | editor/editor_fonts.cpp | 61 | ||||
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 26 | ||||
-rw-r--r-- | editor/editor_settings.h | 2 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 91 | ||||
-rw-r--r-- | editor/import/resource_importer_bitmask.cpp | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_wav.cpp | 12 | ||||
-rw-r--r-- | editor/plugins/baked_lightmap_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 110 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/plugins/gi_probe_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 32 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/progress_dialog.cpp | 2 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 42 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 1 | ||||
-rw-r--r-- | editor/script_editor_debugger.cpp | 20 |
22 files changed, 276 insertions, 183 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index feb5bf2a8f..3e079cb3ca 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1034,7 +1034,7 @@ void CodeTextEditor::_reset_zoom() { Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default if (font.is_valid()) { - EditorSettings::get_singleton()->set("interface/editor/source_font_size", 14); + EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14); font->set_size(14); } } @@ -1098,7 +1098,7 @@ bool CodeTextEditor::_add_font_size(int p_delta) { if (font.is_valid()) { int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE); if (new_size != font->get_size()) { - EditorSettings::get_singleton()->set("interface/editor/source_font_size", new_size / EDSCALE); + EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE); font->set_size(new_size); } @@ -1140,20 +1140,7 @@ void CodeTextEditor::set_error(const String &p_error) { void CodeTextEditor::_update_font() { - // FONTS - String editor_font = EDITOR_DEF("text_editor/theme/font", ""); - bool font_overridden = false; - if (editor_font != "") { - Ref<Font> fnt = ResourceLoader::load(editor_font); - if (fnt.is_valid()) { - text_editor->add_font_override("font", fnt); - font_overridden = true; - } - } - if (!font_overridden) { - - text_editor->add_font_override("font", get_font("source", "EditorFonts")); - } + text_editor->add_font_override("font", get_font("source", "EditorFonts")); } void CodeTextEditor::_on_settings_change() { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 9e8521e0fe..374688f2db 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -38,7 +38,7 @@ #include "project_settings.h" #include "scene/resources/packed_scene.h" -void EditorHistory::_cleanup_history() { +void EditorHistory::cleanup_history() { for (int i = 0; i < history.size(); i++) { @@ -48,8 +48,14 @@ void EditorHistory::_cleanup_history() { if (!history[i].path[j].ref.is_null()) continue; - if (ObjectDB::get_instance(history[i].path[j].object)) - continue; //has isntance, try next + Object *obj = ObjectDB::get_instance(history[i].path[j].object); + if (obj) { + Node *n = Object::cast_to<Node>(obj); + if (n && n->is_inside_tree()) + continue; + if (!n) // Possibly still alive + continue; + } if (j <= history[i].level) { //before or equal level, complete fail @@ -152,7 +158,7 @@ bool EditorHistory::is_at_end() const { bool EditorHistory::next() { - _cleanup_history(); + cleanup_history(); if ((current + 1) < history.size()) current++; @@ -164,7 +170,7 @@ bool EditorHistory::next() { bool EditorHistory::previous() { - _cleanup_history(); + cleanup_history(); if (current > 0) current--; diff --git a/editor/editor_data.h b/editor/editor_data.h index eacde04134..844145853d 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -70,11 +70,11 @@ class EditorHistory { Variant value; }; - void _cleanup_history(); - void _add_object(ObjectID p_object, const String &p_property, int p_level_change); public: + void cleanup_history(); + bool is_at_beginning() const; bool is_at_end() const; diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index c970ae355b..a58257962a 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -85,10 +85,24 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ MAKE_FALLBACKS(m_name); +#define MAKE_SOURCE_FONT(m_name, m_size) \ + Ref<DynamicFont> m_name; \ + m_name.instance(); \ + m_name->set_size(m_size); \ + if (CustomFontSource.is_valid()) { \ + m_name->set_font_data(CustomFontSource); \ + m_name->add_fallback(dfmono); \ + } else { \ + m_name->set_font_data(dfmono); \ + } \ + m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \ + m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ + MAKE_FALLBACKS(m_name); + void editor_register_fonts(Ref<Theme> p_theme) { /* Custom font */ - String custom_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); + String custom_font = EditorSettings::get_singleton()->get("interface/editor/main_font"); Ref<DynamicFontData> CustomFont; if (custom_font.length() > 0) { CustomFont.instance(); @@ -96,6 +110,15 @@ void editor_register_fonts(Ref<Theme> p_theme) { CustomFont->set_force_autohinter(true); //just looks better..i think? } + /* Custom source code font */ + + String custom_font_source = EditorSettings::get_singleton()->get("interface/editor/code_font"); + Ref<DynamicFontData> CustomFontSource; + if (custom_font_source.length() > 0) { + CustomFontSource.instance(); + CustomFontSource->set_font_path(custom_font_source); + } + /* Droid Sans */ Ref<DynamicFontData> DefaultFont; @@ -135,7 +158,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); //dfd->set_force_autohinter(true); //just looks better..i think? - int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE; + int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/main_font_size")) * EDSCALE; MAKE_DEFAULT_FONT(df, default_font_size); p_theme->set_default_theme_font(df); @@ -153,41 +176,15 @@ void editor_register_fonts(Ref<Theme> p_theme) { MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE); p_theme->set_font("rulers", "EditorFonts", df_rulers); - Ref<DynamicFont> df_code; - df_code.instance(); - df_code->set_size(int(EditorSettings::get_singleton()->get("interface/editor/source_font_size")) * EDSCALE); - df_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_code); - + MAKE_SOURCE_FONT(df_code, int(EditorSettings::get_singleton()->get("interface/editor/code_font_size")) * EDSCALE); p_theme->set_font("source", "EditorFonts", df_code); - Ref<DynamicFont> df_doc_code; - df_doc_code.instance(); - df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); - df_doc_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); - df_doc_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); - df_doc_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_doc_code); - + MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); p_theme->set_font("doc_source", "EditorFonts", df_doc_code); - Ref<DynamicFont> df_output_code; - df_output_code.instance(); - df_output_code->set_size(int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE); - df_output_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); - df_output_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); - df_output_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_output_code); - + MAKE_SOURCE_FONT(df_output_code, int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE); p_theme->set_font("output_source", "EditorFonts", df_output_code); - Ref<DynamicFont> df_text_editor_status_code; - df_text_editor_status_code.instance(); - df_text_editor_status_code->set_size(14 * EDSCALE); - df_text_editor_status_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); - df_text_editor_status_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); - df_text_editor_status_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_text_editor_status_code); - + MAKE_SOURCE_FONT(df_text_editor_status_code, 14 * EDSCALE); p_theme->set_font("status_source", "EditorFonts", df_text_editor_status_code); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f480883867..2b62faf218 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1398,7 +1398,7 @@ void EditorNode::_property_editor_forward() { } void EditorNode::_property_editor_back() { - if (editor_history.previous()) + if (editor_history.previous() || editor_history.get_path_size() == 1) _edit_current(); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index bcdd232260..d3e3269c42 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -281,12 +281,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/hidpi_mode", 0); hints["interface/editor/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/editor/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/scene_tabs/show_script_button", false); - _initial_set("interface/editor/font_size", 14); - hints["interface/editor/font_size"] = PropertyInfo(Variant::INT, "interface/editor/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/editor/source_font_size", 14); - hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/editor/custom_font", ""); - hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/main_font_size", 14); + hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/code_font_size", 14); + hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/main_font", ""); + hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/code_font", ""); + hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/dim_editor_on_dialog_popup", true); _initial_set("interface/editor/dim_amount", 0.6f); hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); @@ -375,8 +377,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::REAL, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.1"); _initial_set("text_editor/cursor/right_click_moves_caret", true); - _initial_set("text_editor/theme/font", ""); - hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res"); _initial_set("text_editor/completion/auto_brace_complete", false); _initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true); _initial_set("text_editor/completion/callhint_tooltip_offset", Vector2()); @@ -992,13 +992,17 @@ void EditorSettings::raise_order(const String &p_setting) { props[p_setting].order = ++last_order; } -void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value) { +void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current) { _THREAD_SAFE_METHOD_ if (!props.has(p_setting)) return; - _initial_set(p_setting, p_value); + props[p_setting].initial = p_value; + props[p_setting].has_default_value = true; + if (p_update_current) { + set(p_setting, p_value); + } } Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) { @@ -1432,7 +1436,7 @@ void EditorSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &EditorSettings::set_setting); ClassDB::bind_method(D_METHOD("get_setting", "name"), &EditorSettings::get_setting); ClassDB::bind_method(D_METHOD("erase", "property"), &EditorSettings::erase); - ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &EditorSettings::set_initial_value); + ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value", "update_current"), &EditorSettings::set_initial_value); ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &EditorSettings::property_can_revert); ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &EditorSettings::property_get_revert); ClassDB::bind_method(D_METHOD("add_property_info", "info"), &EditorSettings::_add_property_info_bind); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 5fc49de0a7..914316ee61 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -145,7 +145,7 @@ public: bool has_setting(const String &p_setting) const; void erase(const String &p_setting); void raise_order(const String &p_setting); - void set_initial_value(const StringName &p_setting, const Variant &p_value); + void set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current = false); void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) { if (p_emit_signal) _set(p_setting, p_value); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 0ebcef8e5e..9fda9d2ff6 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1063,38 +1063,67 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { EditorSettings *setting = EditorSettings::get_singleton(); String text_editor_color_theme = setting->get("text_editor/theme/color_theme"); if (text_editor_color_theme == "Adaptive") { - setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color); - setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color); - setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color); - setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color); - setting->set_initial_value("text_editor/highlighting/comment_color", comment_color); - setting->set_initial_value("text_editor/highlighting/string_color", string_color); - setting->set_initial_value("text_editor/highlighting/background_color", background_color); - setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color); - setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color); - setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color); - setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color); - setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color); - setting->set_initial_value("text_editor/highlighting/text_color", text_color); - setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color); - setting->set_initial_value("text_editor/highlighting/caret_color", caret_color); - setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color); - setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color); - setting->set_initial_value("text_editor/highlighting/selection_color", selection_color); - setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color); - setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color); - setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color); - setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color); - setting->set_initial_value("text_editor/highlighting/number_color", number_color); - setting->set_initial_value("text_editor/highlighting/function_color", function_color); - setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color); - setting->set_initial_value("text_editor/highlighting/mark_color", mark_color); - setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color); - setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color); - setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color); - setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color); + setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true); + setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true); + setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true); + setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true); + setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true); + setting->set_initial_value("text_editor/highlighting/string_color", string_color, true); + setting->set_initial_value("text_editor/highlighting/background_color", background_color, true); + setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true); + setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true); + setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true); + setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true); + setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true); + setting->set_initial_value("text_editor/highlighting/text_color", text_color, true); + setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true); + setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true); + setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true); + setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true); + setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true); + setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true); + setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true); + setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true); + setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true); + setting->set_initial_value("text_editor/highlighting/number_color", number_color, true); + setting->set_initial_value("text_editor/highlighting/function_color", function_color, true); + setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true); + setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true); + setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true); + setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true); + setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true); + setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true); } else if (text_editor_color_theme == "Default") { - setting->load_text_editor_theme(); + setting->set_initial_value("text_editor/highlighting/symbol_color", Color::html("badfff"), true); + setting->set_initial_value("text_editor/highlighting/keyword_color", Color::html("ffffb3"), true); + setting->set_initial_value("text_editor/highlighting/base_type_color", Color::html("a4ffd4"), true); + setting->set_initial_value("text_editor/highlighting/engine_type_color", Color::html("83d3ff"), true); + setting->set_initial_value("text_editor/highlighting/comment_color", Color::html("676767"), true); + setting->set_initial_value("text_editor/highlighting/string_color", Color::html("ef6ebe"), true); + setting->set_initial_value("text_editor/highlighting/background_color", Color::html("3b000000"), true); + setting->set_initial_value("text_editor/highlighting/completion_background_color", Color::html("2C2A32"), true); + setting->set_initial_value("text_editor/highlighting/completion_selected_color", Color::html("434244"), true); + setting->set_initial_value("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"), true); + setting->set_initial_value("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"), true); + setting->set_initial_value("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/text_color", Color::html("aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/caret_color", Color::html("aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/caret_background_color", Color::html("000000"), true); + setting->set_initial_value("text_editor/highlighting/text_selected_color", Color::html("000000"), true); + setting->set_initial_value("text_editor/highlighting/selection_color", Color::html("6ca9c2"), true); + setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2), true); + setting->set_initial_value("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15), true); + setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1), true); + setting->set_initial_value("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15), true); + setting->set_initial_value("text_editor/highlighting/number_color", Color::html("EB9532"), true); + setting->set_initial_value("text_editor/highlighting/function_color", Color::html("66a2ce"), true); + setting->set_initial_value("text_editor/highlighting/member_variable_color", Color::html("e64e59"), true); + setting->set_initial_value("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4), true); + setting->set_initial_value("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2), true); + setting->set_initial_value("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8), true); + setting->set_initial_value("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1), true); + setting->set_initial_value("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1), true); } return theme; diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp index 3d2959c598..a5d3959952 100644 --- a/editor/import/resource_importer_bitmask.cpp +++ b/editor/import/resource_importer_bitmask.cpp @@ -77,7 +77,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String & bit = c.a > threshold; } - bitmap->set_bit(Vector2(i, j), bit); + bitmap->set_bit(Vector2(j, i), bit); } } diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 12aa0bb33c..03155b3a48 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -268,9 +268,15 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s for (int i = 0; i < 10; i++) file->get_32(); // i wish to know why should i do this... no doc! - loop = file->get_32() ? AudioStreamSample::LOOP_PING_PONG : AudioStreamSample::LOOP_FORWARD; - loop_begin = file->get_32(); - loop_end = file->get_32(); + // only read 0x00 (loop forward) and 0x01 (loop ping-pong) and skip anything else because + // it's not supported (loop backward), reserved for future uses or sampler specific + // from https://sites.google.com/site/musicgapi/technical-documents/wav-file-format#smpl (loop type values table) + int loop_type = file->get_32(); + if (loop_type == 0x00 || loop_type == 0x01) { + loop = loop_type ? AudioStreamSample::LOOP_PING_PONG : AudioStreamSample::LOOP_FORWARD; + loop_begin = file->get_32(); + loop_end = file->get_32(); + } } file->seek(file_pos + chunksize); } diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp index af175c3493..59b79bd070 100644 --- a/editor/plugins/baked_lightmap_editor_plugin.cpp +++ b/editor/plugins/baked_lightmap_editor_plugin.cpp @@ -90,7 +90,7 @@ void BakedLightmapEditorPlugin::bake_func_begin(int p_steps) { bool BakedLightmapEditorPlugin::bake_func_step(int p_step, const String &p_description) { ERR_FAIL_COND_V(tmp_progress == NULL, false); - return tmp_progress->step(p_description, p_step); + return tmp_progress->step(p_description, p_step, false); } void BakedLightmapEditorPlugin::bake_func_end() { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 2a46aba207..bd5e5c7355 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4435,6 +4435,7 @@ void CanvasItemEditorViewport::_on_change_type_closed() { void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const { label->set_position(get_global_position() + Point2(14, 14) * EDSCALE); label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); + bool add_preview = false; for (int i = 0; i < files.size(); i++) { String path = files[i]; RES res = ResourceLoader::load(path); @@ -4456,9 +4457,12 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons } } } - editor->get_scene_root()->add_child(preview_node); + add_preview = true; } } + + if (add_preview) + editor->get_scene_root()->add_child(preview_node); } void CanvasItemEditorViewport::_remove_preview() { @@ -4603,6 +4607,14 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons void CanvasItemEditorViewport::_perform_drop_data() { _remove_preview(); + // Without root dropping multiple files is not allowed + if (!target_node && selected_files.size() > 1) { + accept->get_ok()->set_text(TTR("Ok")); + accept->set_text(TTR("Cannot instantiate multiple nodes without root.")); + accept->popup_centered_minsize(); + return; + } + Vector<String> error_files; editor_data->get_undo_redo().create_action(TTR("Create Node")); @@ -4613,30 +4625,40 @@ void CanvasItemEditorViewport::_perform_drop_data() { if (res.is_null()) { continue; } - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); - if (texture != NULL) { - Node *child; - if (default_type == "Light2D") - child = memnew(Light2D); - else if (default_type == "Particles2D") - child = memnew(Particles2D); - else if (default_type == "Polygon2D") - child = memnew(Polygon2D); - else if (default_type == "TouchScreenButton") - child = memnew(TouchScreenButton); - else if (default_type == "TextureRect") - child = memnew(TextureRect); - else if (default_type == "NinePatchRect") - child = memnew(NinePatchRect); - else - child = memnew(Sprite); // default - - _create_nodes(target_node, child, path, drop_pos); - } else if (scene != NULL) { - bool success = _create_instance(target_node, path, drop_pos); - if (!success) { - error_files.push_back(path); + if (scene != NULL && scene.is_valid()) { + if (!target_node) { + // Without root node act the same as "Load Inherited Scene" + Error err = EditorNode::get_singleton()->load_scene(path, false, true); + if (err != OK) { + error_files.push_back(path); + } + } else { + bool success = _create_instance(target_node, path, drop_pos); + if (!success) { + error_files.push_back(path); + } + } + } else { + Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + if (texture != NULL && texture.is_valid()) { + Node *child; + if (default_type == "Light2D") + child = memnew(Light2D); + else if (default_type == "Particles2D") + child = memnew(Particles2D); + else if (default_type == "Polygon2D") + child = memnew(Polygon2D); + else if (default_type == "TouchScreenButton") + child = memnew(TouchScreenButton); + else if (default_type == "TextureRect") + child = memnew(TextureRect); + else if (default_type == "NinePatchRect") + child = memnew(NinePatchRect); + else + child = memnew(Sprite); // default + + _create_nodes(target_node, child, path, drop_pos); } } } @@ -4661,14 +4683,14 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian if (String(d["type"]) == "files") { Vector<String> files = d["files"]; bool can_instance = false; - for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least one + for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once RES res = ResourceLoader::load(files[i]); if (res.is_null()) { continue; } String type = res->get_class(); if (type == "PackedScene") { - Ref<PackedScene> sdata = ResourceLoader::load(files[i]); + Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); if (!instanced_scene) { continue; @@ -4682,7 +4704,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian type == "StreamTexture" || type == "AtlasTexture" || type == "LargeTexture") { - Ref<Texture> texture = ResourceLoader::load(files[i]); + Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); if (texture.is_valid() == false) { continue; } @@ -4708,6 +4730,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian } void CanvasItemEditorViewport::_show_resource_type_selector() { + _remove_preview(); List<BaseButton *> btn_list; button_group->get_buttons(&btn_list); @@ -4719,6 +4742,17 @@ void CanvasItemEditorViewport::_show_resource_type_selector() { selector->popup_centered_minsize(); } +bool CanvasItemEditorViewport::_only_packed_scenes_selected() const { + + for (int i = 0; i < selected_files.size(); ++i) { + if (ResourceLoader::load(selected_files[i])->get_class() != "PackedScene") { + return false; + } + } + + return true; +} + void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) { bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT); bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT); @@ -4728,6 +4762,8 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p if (d.has("type") && String(d["type"]) == "files") { selected_files = d["files"]; } + if (selected_files.size() == 0) + return; List<Node *> list = editor->get_editor_selection()->get_selected_node_list(); if (list.size() == 0) { @@ -4737,25 +4773,19 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p } else { drop_pos = p_point; target_node = NULL; - _show_resource_type_selector(); - return; } } - if (list.size() != 1) { - accept->get_ok()->set_text(TTR("I see..")); - accept->set_text(TTR("This operation requires a single selected node.")); - accept->popup_centered_minsize(); - _remove_preview(); - return; - } - target_node = list[0]; - if (is_shift && target_node != editor->get_edited_scene()) { - target_node = target_node->get_parent(); + if (list.size() > 0) { + target_node = list[0]; + if (is_shift && target_node != editor->get_edited_scene()) { + target_node = target_node->get_parent(); + } } + drop_pos = p_point; - if (is_alt) { + if (is_alt && !_only_packed_scenes_selected()) { _show_resource_type_selector(); } else { _perform_drop_data(); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 5be71bfc28..ace87f9fe2 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -576,6 +576,7 @@ class CanvasItemEditorViewport : public Control { void _remove_preview(); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); + bool _only_packed_scenes_selected() const; void _create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point); bool _create_instance(Node *parent, String &path, const Point2 &p_point); void _perform_drop_data(); diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp index 42aad7a8a1..06da64b181 100644 --- a/editor/plugins/gi_probe_editor_plugin.cpp +++ b/editor/plugins/gi_probe_editor_plugin.cpp @@ -73,7 +73,7 @@ void GIProbeEditorPlugin::bake_func_begin(int p_steps) { void GIProbeEditorPlugin::bake_func_step(int p_step, const String &p_description) { ERR_FAIL_COND(tmp_progress == NULL); - tmp_progress->step(p_description, p_step); + tmp_progress->step(p_description, p_step, false); } void GIProbeEditorPlugin::bake_func_end() { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bc986cee9c..f99768400f 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -313,24 +313,22 @@ void ScriptEditor::_goto_script_line2(int p_line) { void ScriptEditor::_goto_script_line(REF p_script, int p_line) { - editor->push_item(p_script.ptr()); + Ref<Script> script = Object::cast_to<Script>(*p_script); + if (!script.is_null() && script->get_path().is_resource_file()) { + if (edit(p_script, p_line, 0)) { + editor->push_item(p_script.ptr()); - if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) { - - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (!script.is_null() && script->get_path().is_resource_file()) - edit(p_script, p_line, 0); - } - - int selected = tab_container->get_current_tab(); - if (selected < 0 || selected >= tab_container->get_child_count()) - return; + int selected = tab_container->get_current_tab(); + if (selected < 0 || selected >= tab_container->get_child_count()) + return; - ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected)); - if (!current) - return; + ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected)); + if (!current) + return; - current->goto_line(p_line, true); + current->goto_line(p_line, true); + } + } } void ScriptEditor::_update_history_arrows() { @@ -514,7 +512,6 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { if (p_save) { apply_scripts(); } - current->clear_edit_menu(); notify_script_close(current->get_edited_script()); } else { EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_child(selected)); @@ -540,6 +537,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { } int idx = tab_container->get_current_tab(); + if (current) { + current->clear_edit_menu(); + } memdelete(tselected); if (idx >= tab_container->get_child_count()) idx = tab_container->get_child_count() - 1; diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 535ce79b30..b677017371 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -3915,7 +3915,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) { if (d.has("snap_enabled")) { snap_enabled = d["snap_enabled"]; - tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_pressed(d["snap_enabled"]); + tool_option_button[TOOL_OPT_USE_SNAP]->set_pressed(d["snap_enabled"]); } if (d.has("translate_snap")) diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 08679b781a..612bdb1d2a 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -583,6 +583,14 @@ void AutotileEditor::_notification(int p_what) { } } +void AutotileEditor::_changed_callback(Object *p_changed, const char *p_prop) { + if (p_prop == StringName("texture") || p_prop == StringName("is_autotile")) { + edit(tile_set.ptr()); + autotile_list->update(); + workspace->update(); + } +} + void AutotileEditor::_on_autotile_selected(int p_index) { if (get_current_tile() >= 0) { @@ -1581,6 +1589,7 @@ Vector2 AutotileEditor::snap_point(const Vector2 &point) { void AutotileEditor::edit(Object *p_node) { tile_set = Ref<TileSet>(Object::cast_to<TileSet>(p_node)); + tile_set->add_change_receptor(this); helper->set_tileset(tile_set); autotile_list->clear(); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index 9bd3e23181..93d403deea 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -124,6 +124,7 @@ class AutotileEditor : public Control { protected: static void _bind_methods(); void _notification(int p_what); + virtual void _changed_callback(Object *p_changed, const char *p_prop); private: void _on_autotile_selected(int p_index); diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 5d79b8f94c..f735ef97db 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -200,7 +200,7 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int if (!p_force_redraw) { uint64_t tus = OS::get_singleton()->get_ticks_usec(); - if (tus - last_progress_tick < 50000) //50ms + if (tus - last_progress_tick < 200000) //200ms return cancelled; } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1f732992d5..98871d5193 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -237,13 +237,20 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) Node *parent = base->get_parent(); int pos = base->get_index(); - memdelete(base); + parent->remove_child(base); parent->add_child(instanced_scene); parent->move_child(instanced_scene, pos); instanced_scene->set_owner(edited_scene); editor_selection->clear(); editor_selection->add_node(instanced_scene); scene_tree->set_selected(instanced_scene); + + // Delete the node as late as possible because before another one is selected + // an editor plugin could be referencing it to do something with it before + // switching to another (or to none); and since some steps of changing the + // editor state are deferred, the safest thing is to do this is as the last + // step of this function and also by enqueing instead of memdelete()-ing it here + base->queue_delete(); } bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) { @@ -343,8 +350,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (existing.is_valid()) { const RefPtr empty; selected->set_script(empty); - button_create_script->show(); - button_clear_script->hide(); + _update_script_button(); } } break; @@ -1204,8 +1210,7 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) { return; selected->set_script(p_script.get_ref_ptr()); editor->push_item(p_script.operator->()); - button_create_script->hide(); - button_clear_script->show(); + _update_script_button(); } void SceneTreeDock::_delete_confirm() { @@ -1285,17 +1290,15 @@ void SceneTreeDock::_delete_confirm() { editor->get_viewport_control()->update(); editor->push_item(NULL); -} -void SceneTreeDock::_selection_changed() { - - int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size(); - if (selection_size > 1) { - //automatically turn on multi-edit - _tool_selected(TOOL_MULTI_EDIT); - } + // Fixes the EditorHistory from still offering deleted notes + EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + editor_history->cleanup_history(); + EditorNode::get_singleton()->call("_prepare_history"); +} - if (selection_size == 1) { +void SceneTreeDock::_update_script_button() { + if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) { if (EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) { button_create_script->show(); button_clear_script->hide(); @@ -1309,6 +1312,16 @@ void SceneTreeDock::_selection_changed() { } } +void SceneTreeDock::_selection_changed() { + + int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size(); + if (selection_size > 1) { + //automatically turn on multi-edit + _tool_selected(TOOL_MULTI_EDIT); + } + _update_script_button(); +} + void SceneTreeDock::_create() { if (current_option == TOOL_NEW) { @@ -1643,6 +1656,7 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { Node *n = get_node(p_to); if (n) { n->set_script(scr.get_ref_ptr()); + _update_script_button(); } } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index f5234fc547..0a68aa7dc2 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -160,6 +160,7 @@ class SceneTreeDock : public VBoxContainer { bool _validate_no_foreign(); void _selection_changed(); + void _update_script_button(); void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath> > *p_renames); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index e993c2fd46..629b5b63fb 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1053,6 +1053,8 @@ void ScriptEditorDebugger::_notification(int p_what) { break; }; + const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; + while (ppeer->get_available_packet_count() > 0) { if (pending_in_queue) { @@ -1117,6 +1119,9 @@ void ScriptEditorDebugger::_notification(int p_what) { break; } } + + if (OS::get_singleton()->get_ticks_msec() > until) + break; } } break; @@ -1611,30 +1616,33 @@ void ScriptEditorDebugger::_error_selected(int p_idx) { error_stack->clear(); Array st = error_list->get_item_metadata(p_idx); - for (int i = 0; i < st.size(); i += 2) { + for (int i = 0; i < st.size(); i += 3) { String script = st[i]; - int line = st[i + 1]; + String func = st[i + 1]; + int line = st[i + 2]; Array md; md.push_back(st[i]); md.push_back(st[i + 1]); + md.push_back(st[i + 2]); - String str = script.get_file() + ":" + itos(line); + String str = func + " in " + script.get_file() + ":line " + itos(line); error_stack->add_item(str); error_stack->set_item_metadata(error_stack->get_item_count() - 1, md); - error_stack->set_item_tooltip(error_stack->get_item_count() - 1, TTR("File:") + " " + String(st[i]) + "\n" + TTR("Line:") + " " + itos(line)); + error_stack->set_item_tooltip(error_stack->get_item_count() - 1, + TTR("File:") + " " + script + "\n" + TTR("Function:") + " " + func + "\n" + TTR("Line:") + " " + itos(line)); } } void ScriptEditorDebugger::_error_stack_selected(int p_idx) { Array arr = error_stack->get_item_metadata(p_idx); - if (arr.size() != 2) + if (arr.size() != 3) return; Ref<Script> s = ResourceLoader::load(arr[0]); - emit_signal("goto_script_line", s, int(arr[1]) - 1); + emit_signal("goto_script_line", s, int(arr[2]) - 1); } void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) { |