diff options
Diffstat (limited to 'editor')
55 files changed, 626 insertions, 294 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index e9719f8618..2edfcced60 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1727,7 +1727,7 @@ void AnimationTimelineEdit::update_values() { time_icon->set_tooltip(TTR("Animation length (frames)")); } else { length->set_value(animation->get_length()); - length->set_step(0.01); + length->set_step(0.001); length->set_tooltip(TTR("Animation length (seconds)")); time_icon->set_tooltip(TTR("Animation length (seconds)")); } @@ -1890,7 +1890,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() { length = memnew(EditorSpinSlider); length->set_min(0.001); length->set_max(36000); - length->set_step(0.01); + length->set_step(0.001); length->set_allow_greater(true); length->set_custom_minimum_size(Vector2(70 * EDSCALE, 0)); length->set_hide_slider(true); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 4f684c7bdc..e05ace53da 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -277,7 +277,8 @@ void FindReplaceBar::_replace_all() { } text_edit->set_v_scroll(vsval); - set_error(vformat(TTR("Replaced %d occurrence(s)."), rc)); + matches_label->add_color_override("font_color", rc > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor")); + matches_label->set_text(vformat(TTR("%d replaced."), rc)); text_edit->call_deferred("connect", "text_changed", this, "_editor_text_changed"); results_count = -1; diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 3f773c646a..0a60aabd2d 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -856,7 +856,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { HBoxContainer *audioprev_hbc = memnew(HBoxContainer); audioprev_hbc->set_v_size_flags(SIZE_EXPAND_FILL); audioprev_hbc->set_h_size_flags(SIZE_EXPAND_FILL); - audioprev_hbc->set_mouse_filter(MOUSE_FILTER_PASS); audio_value_preview_box->add_child(audioprev_hbc); audio_value_preview_label = memnew(Label); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 46a54969e0..dba8c2ec8c 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -120,6 +120,7 @@ void EditorAutoloadSettings::_autoload_add() { autoload_add_path->get_line_edit()->set_text(""); autoload_add_name->set_text(""); + add_autoload->set_disabled(true); } void EditorAutoloadSettings::_autoload_selected() { @@ -312,7 +313,34 @@ void EditorAutoloadSettings::_autoload_open(const String &fpath) { void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { - autoload_add_name->set_text(p_path.get_file().get_basename()); + // Convert the file name to PascalCase, which is the convention for classes in GDScript. + const String class_name = p_path.get_file().get_basename().capitalize().replace(" ", ""); + + // If the name collides with a built-in class, prefix the name to make it possible to add without having to edit the name. + // The prefix is subjective, but it provides better UX than leaving the Add button disabled :) + const String prefix = ClassDB::class_exists(class_name) ? "Global" : ""; + + autoload_add_name->set_text(prefix + class_name); + add_autoload->set_disabled(false); +} + +void EditorAutoloadSettings::_autoload_text_entered(const String p_name) { + + if (autoload_add_path->get_line_edit()->get_text() != "" && _autoload_name_is_valid(p_name, NULL)) { + _autoload_add(); + } +} + +void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { + + add_autoload->set_disabled( + p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), NULL)); +} + +void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { + + add_autoload->set_disabled( + autoload_add_path->get_line_edit()->get_text() == "" || !_autoload_name_is_valid(p_name, NULL)); } Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { @@ -424,7 +452,7 @@ void EditorAutoloadSettings::update_autoload() { item->set_editable(2, true); item->set_text(2, TTR("Enable")); item->set_checked(2, info.is_singleton); - item->add_button(3, get_icon("FileList", "EditorIcons"), BUTTON_OPEN); + item->add_button(3, get_icon("Load", "EditorIcons"), BUTTON_OPEN); item->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP); item->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN); item->add_button(3, get_icon("Remove", "EditorIcons"), BUTTON_DELETE); @@ -713,7 +741,9 @@ void EditorAutoloadSettings::_bind_methods() { ClassDB::bind_method("_autoload_edited", &EditorAutoloadSettings::_autoload_edited); ClassDB::bind_method("_autoload_button_pressed", &EditorAutoloadSettings::_autoload_button_pressed); ClassDB::bind_method("_autoload_activated", &EditorAutoloadSettings::_autoload_activated); + ClassDB::bind_method("_autoload_path_text_changed", &EditorAutoloadSettings::_autoload_path_text_changed); ClassDB::bind_method("_autoload_text_entered", &EditorAutoloadSettings::_autoload_text_entered); + ClassDB::bind_method("_autoload_text_changed", &EditorAutoloadSettings::_autoload_text_changed); ClassDB::bind_method("_autoload_open", &EditorAutoloadSettings::_autoload_open); ClassDB::bind_method("_autoload_file_callback", &EditorAutoloadSettings::_autoload_file_callback); @@ -806,6 +836,8 @@ EditorAutoloadSettings::EditorAutoloadSettings() { autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL); autoload_add_path->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE); autoload_add_path->get_file_dialog()->connect("file_selected", this, "_autoload_file_callback"); + autoload_add_path->get_line_edit()->connect("text_changed", this, "_autoload_path_text_changed"); + hbc->add_child(autoload_add_path); l = memnew(Label); @@ -815,11 +847,14 @@ EditorAutoloadSettings::EditorAutoloadSettings() { autoload_add_name = memnew(LineEdit); autoload_add_name->set_h_size_flags(SIZE_EXPAND_FILL); autoload_add_name->connect("text_entered", this, "_autoload_text_entered"); + autoload_add_name->connect("text_changed", this, "_autoload_text_changed"); hbc->add_child(autoload_add_name); - Button *add_autoload = memnew(Button); + add_autoload = memnew(Button); add_autoload->set_text(TTR("Add")); add_autoload->connect("pressed", this, "_autoload_add"); + // The button will be enabled once a valid name is entered (either automatically or manually). + add_autoload->set_disabled(true); hbc->add_child(add_autoload); tree = memnew(Tree); diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index e1a04644aa..653a1b0a78 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -76,6 +76,7 @@ class EditorAutoloadSettings : public VBoxContainer { Tree *tree; EditorLineEditFileChooser *autoload_add_path; LineEdit *autoload_add_name; + Button *add_autoload; bool _autoload_name_is_valid(const String &p_name, String *r_error = NULL); @@ -84,7 +85,9 @@ class EditorAutoloadSettings : public VBoxContainer { void _autoload_edited(); void _autoload_button_pressed(Object *p_item, int p_column, int p_button); void _autoload_activated(); - void _autoload_text_entered(String) { _autoload_add(); } + void _autoload_path_text_changed(const String p_path); + void _autoload_text_entered(const String p_name); + void _autoload_text_changed(const String p_name); void _autoload_open(const String &fpath); void _autoload_file_callback(const String &p_path); Node *_create_autoload(const String &p_path); diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index d66b386f93..3d8ea0b040 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -748,7 +748,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & config.instance(); Error err = config->load(path + ".import"); if (err != OK) { - ERR_PRINTS("Could not parse: '" + path + "', not exported."); + ERR_PRINT("Could not parse: '" + path + "', not exported."); continue; } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index a4a7a0cd45..559a0ef0ea 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -192,14 +192,14 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) { Variant v; err = JSON::parse(text, v, err_str, err_line); if (err != OK) { - ERR_PRINTS("Error parsing '" + p_path + "' on line " + itos(err_line) + ": " + err_str); + ERR_PRINT("Error parsing '" + p_path + "' on line " + itos(err_line) + ": " + err_str); return ERR_PARSE_ERROR; } Dictionary json = v; if (!json.has("type") || String(json["type"]) != "feature_profile") { - ERR_PRINTS("Error parsing '" + p_path + "', it's not a feature profile."); + ERR_PRINT("Error parsing '" + p_path + "', it's not a feature profile."); return ERR_PARSE_ERROR; } @@ -298,7 +298,7 @@ void EditorFeatureProfileManager::_notification(int p_what) { current.instance(); Error err = current->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(current_profile + ".profile")); if (err != OK) { - ERR_PRINTS("Error loading default feature profile: " + current_profile); + ERR_PRINT("Error loading default feature profile: " + current_profile); current_profile = String(); current.unref(); } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 5abb3c4ec2..107ecac3b0 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -387,7 +387,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo if (err == ERR_FILE_EOF) { break; } else if (err != OK) { - ERR_PRINTS("ResourceFormatImporter::load - '" + p_path + ".import:" + itos(lines) + "' error '" + error_text + "'."); + ERR_PRINT("ResourceFormatImporter::load - '" + p_path + ".import:" + itos(lines) + "' error '" + error_text + "'."); memdelete(f); return false; //parse error, try reimport manually (Avoid reimport loop on broken file) } @@ -435,7 +435,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo if (err == ERR_FILE_EOF) { break; } else if (err != OK) { - ERR_PRINTS("ResourceFormatImporter::load - '" + p_path + ".import.md5:" + itos(lines) + "' error '" + error_text + "'."); + ERR_PRINT("ResourceFormatImporter::load - '" + p_path + ".import.md5:" + itos(lines) + "' error '" + error_text + "'."); memdelete(md5s); return false; // parse error } @@ -675,9 +675,12 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (f == "") break; + if (da->current_is_hidden()) + continue; + if (da->current_is_dir()) { - if (f.begins_with(".")) //ignore hidden and . / .. + if (f.begins_with(".")) // Ignore special and . / .. continue; if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this @@ -734,7 +737,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess da->change_dir(".."); } } else { - ERR_PRINTS("Cannot go into subdir '" + E->get() + "'."); + ERR_PRINT("Cannot go into subdir '" + E->get() + "'."); } p_progress.update(idx, total); @@ -871,9 +874,12 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const if (f == "") break; + if (da->current_is_hidden()) + continue; + if (da->current_is_dir()) { - if (f.begins_with(".")) //ignore hidden and . / .. + if (f.begins_with(".")) // Ignore special and . / .. continue; int idx = p_dir->find_dir_index(f); @@ -1059,8 +1065,12 @@ void EditorFileSystem::get_changed_sources(List<String> *r_changed) { void EditorFileSystem::scan_changes() { - if (scanning || scanning_changes || thread) + if (first_scan || // Prevent a premature changes scan from inhibiting the first full scan + scanning || scanning_changes || thread) { + scan_changes_pending = true; + set_process(true); return; + } _update_extensions(); sources_changed.clear(); @@ -1105,16 +1115,18 @@ void EditorFileSystem::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - if (use_threads && thread) { + Thread *active_thread = thread ? thread : thread_sources; + if (use_threads && active_thread) { //abort thread if in progress abort_scan = true; while (scanning) { OS::get_singleton()->delay_usec(1000); } - Thread::wait_to_finish(thread); - memdelete(thread); + Thread::wait_to_finish(active_thread); + memdelete(active_thread); thread = NULL; - WARN_PRINTS("Scan thread aborted..."); + thread_sources = NULL; + WARN_PRINT("Scan thread aborted..."); set_process(false); } @@ -1164,6 +1176,11 @@ void EditorFileSystem::_notification(int p_what) { _queue_update_script_classes(); first_scan = false; } + + if (!is_processing() && scan_changes_pending) { + scan_changes_pending = false; + scan_changes(); + } } } break; } @@ -1780,7 +1797,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) { Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &metadata); if (err != OK) { - ERR_PRINTS("Error importing '" + p_file + "'."); + ERR_PRINT("Error importing '" + p_file + "'."); } //as import is complete, save the .import file @@ -2138,6 +2155,7 @@ EditorFileSystem::EditorFileSystem() { scan_total = 0; update_script_classes_queued = false; first_scan = true; + scan_changes_pending = false; revalidate_import_files = false; } diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index ce9936f983..381acc0fe2 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -145,6 +145,7 @@ class EditorFileSystem : public Node { bool scanning; bool importing; bool first_scan; + bool scan_changes_pending; float scan_total; String filesystem_settings_version_for_import; bool revalidate_import_files; diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 700d9b692b..80981e8fa1 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -307,7 +307,7 @@ bool EditorHelpSearch::Runner::_slice() { case PHASE_MAX: return true; default: - WARN_PRINTS("Invalid or unhandled phase in EditorHelpSearch::Runner, aborting search."); + WARN_PRINT("Invalid or unhandled phase in EditorHelpSearch::Runner, aborting search."); return true; }; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 56da7d93fa..7c1e58862e 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1596,7 +1596,7 @@ void EditorInspector::update_tree() { if (capitalize_paths) cat = cat.capitalize(); - if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name)) + if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name) && property_prefix.to_lower().find(filter.to_lower()) == -1) continue; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index dd15910d09..7d0601e8db 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2732,7 +2732,7 @@ void EditorNode::_tool_menu_option(int p_idx) { handler->call(callback, (const Variant **)&ud, 1, ce); if (ce.error != Variant::CallError::CALL_OK) { String err = Variant::get_call_error_text(handler, callback, (const Variant **)&ud, 1, ce); - ERR_PRINTS("Error calling function from tool menu: " + err); + ERR_PRINT("Error calling function from tool menu: " + err); } } // else it's a submenu so don't do anything. } break; @@ -3042,7 +3042,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, } ps->set("editor_plugins/enabled", enabled_plugins); ps->save(); - WARN_PRINTS("Addon '" + p_addon + "' failed to load. No directory found. Removing from enabled plugins."); + WARN_PRINT("Addon '" + p_addon + "' failed to load. No directory found. Removing from enabled plugins."); return; } Error err = cf->load(addon_path); @@ -3988,7 +3988,7 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) { warning->set_title(p_title); warning->popup_centered_minsize(); } else { - WARN_PRINTS(p_title + " " + p_text); + WARN_PRINT(p_title + " " + p_text); } } diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index b81a996956..16decf5c04 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -96,28 +96,28 @@ void EditorPluginSettings::update_plugins() { Error err2 = cf->load(path); if (err2 != OK) { - WARN_PRINTS("Can't load plugin config: " + path); + WARN_PRINT("Can't load plugin config: " + path); } else { bool key_missing = false; if (!cf->has_section_key("plugin", "name")) { - WARN_PRINTS("Plugin config misses \"plugin/name\" key: " + path); + WARN_PRINT("Plugin config misses \"plugin/name\" key: " + path); key_missing = true; } if (!cf->has_section_key("plugin", "author")) { - WARN_PRINTS("Plugin config misses \"plugin/author\" key: " + path); + WARN_PRINT("Plugin config misses \"plugin/author\" key: " + path); key_missing = true; } if (!cf->has_section_key("plugin", "version")) { - WARN_PRINTS("Plugin config misses \"plugin/version\" key: " + path); + WARN_PRINT("Plugin config misses \"plugin/version\" key: " + path); key_missing = true; } if (!cf->has_section_key("plugin", "description")) { - WARN_PRINTS("Plugin config misses \"plugin/description\" key: " + path); + WARN_PRINT("Plugin config misses \"plugin/description\" key: " + path); key_missing = true; } if (!cf->has_section_key("plugin", "script")) { - WARN_PRINTS("Plugin config misses \"plugin/script\" key: " + path); + WARN_PRINT("Plugin config misses \"plugin/script\" key: " + path); key_missing = true; } diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index 4807f8839c..e5a9c4d699 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -102,26 +102,28 @@ void EditorProfiler::clear() { } static String _get_percent_txt(float p_value, float p_total) { - if (p_total == 0) + if (p_total == 0) { p_total = 0.00001; + } + return String::num((p_value / p_total) * 100, 1) + "%"; } String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_calls) { - int dmode = display_mode->get_selected(); + const int dmode = display_mode->get_selected(); if (dmode == DISPLAY_FRAME_TIME) { - return rtos(p_time); + return rtos(p_time * 1000).pad_decimals(2) + " ms"; } else if (dmode == DISPLAY_AVERAGE_TIME) { - if (p_calls == 0) - return "0"; - else - return rtos(p_time / p_calls); + if (p_calls == 0) { + return "0.00 ms"; + } else { + return rtos((p_time / p_calls) * 1000).pad_decimals(2) + " ms"; + } } else if (dmode == DISPLAY_FRAME_PERCENT) { return _get_percent_txt(p_time, m.frame_time); } else if (dmode == DISPLAY_PHYSICS_FRAME_PERCENT) { - return _get_percent_txt(p_time, m.physics_frame_time); } @@ -163,12 +165,10 @@ void EditorProfiler::_item_edited() { void EditorProfiler::_update_plot() { - int w = graph->get_size().width; - int h = graph->get_size().height; - + const int w = graph->get_size().width; + const int h = graph->get_size().height; bool reset_texture = false; - - int desired_len = w * h * 4; + const int desired_len = w * h * 4; if (graph_image.size() != desired_len) { reset_texture = true; @@ -176,18 +176,19 @@ void EditorProfiler::_update_plot() { } PoolVector<uint8_t>::Write wr = graph_image.write(); + const Color background_color = get_color("dark_color_2", "Editor"); - //clear + // Clear the previous frame and set the background color. for (int i = 0; i < desired_len; i += 4) { - wr[i + 0] = 0; - wr[i + 1] = 0; - wr[i + 2] = 0; + wr[i + 0] = Math::fast_ftoi(background_color.r * 255); + wr[i + 1] = Math::fast_ftoi(background_color.g * 255); + wr[i + 2] = Math::fast_ftoi(background_color.b * 255); wr[i + 3] = 255; } //find highest value - bool use_self = display_time->get_selected() == DISPLAY_SELF_TIME; + const bool use_self = display_time->get_selected() == DISPLAY_SELF_TIME; float highest = 0; for (int i = 0; i < frame_metrics.size(); i++) { @@ -319,21 +320,23 @@ void EditorProfiler::_update_plot() { for (int j = 0; j < h * 4; j += 4) { - int a = column[j + 3]; + const int a = column[j + 3]; if (a > 0) { column[j + 0] /= a; column[j + 1] /= a; column[j + 2] /= a; } - uint8_t r = uint8_t(column[j + 0]); - uint8_t g = uint8_t(column[j + 1]); - uint8_t b = uint8_t(column[j + 2]); + const uint8_t red = uint8_t(column[j + 0]); + const uint8_t green = uint8_t(column[j + 1]); + const uint8_t blue = uint8_t(column[j + 2]); + const bool is_filled = red >= 1 || green >= 1 || blue >= 1; + const int widx = ((j >> 2) * w + i) * 4; - int widx = ((j >> 2) * w + i) * 4; - wr[widx + 0] = r; - wr[widx + 1] = g; - wr[widx + 2] = b; + // If the pixel isn't filled by any profiler line, apply the background color instead. + wr[widx + 0] = is_filled ? red : Math::fast_ftoi(background_color.r * 255); + wr[widx + 1] = is_filled ? green : Math::fast_ftoi(background_color.g * 255); + wr[widx + 2] = is_filled ? blue : Math::fast_ftoi(background_color.b * 255); wr[widx + 3] = 255; } } @@ -729,7 +732,7 @@ EditorProfiler::EditorProfiler() { h_split->set_v_size_flags(SIZE_EXPAND_FILL); variables = memnew(Tree); - variables->set_custom_minimum_size(Size2(300, 0) * EDSCALE); + variables->set_custom_minimum_size(Size2(320, 0) * EDSCALE); variables->set_hide_folding(true); h_split->add_child(variables); variables->set_hide_root(true); @@ -737,10 +740,10 @@ EditorProfiler::EditorProfiler() { variables->set_column_titles_visible(true); variables->set_column_title(0, TTR("Name")); variables->set_column_expand(0, true); - variables->set_column_min_width(0, 60); + variables->set_column_min_width(0, 60 * EDSCALE); variables->set_column_title(1, TTR("Time")); variables->set_column_expand(1, false); - variables->set_column_min_width(1, 60 * EDSCALE); + variables->set_column_min_width(1, 100 * EDSCALE); variables->set_column_title(2, TTR("Calls")); variables->set_column_expand(2, false); variables->set_column_min_width(2, 60 * EDSCALE); @@ -749,7 +752,6 @@ EditorProfiler::EditorProfiler() { graph = memnew(TextureRect); graph->set_expand(true); graph->set_mouse_filter(MOUSE_FILTER_STOP); - //graph->set_ignore_mouse(false); graph->connect("draw", this, "_graph_tex_draw"); graph->connect("gui_input", this, "_graph_tex_input"); graph->connect("mouse_exited", this, "_graph_tex_mouse_exit"); @@ -760,13 +762,10 @@ EditorProfiler::EditorProfiler() { int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024); frame_metrics.resize(metric_size); last_metric = -1; - //cursor_metric=-1; hover_metric = -1; EDITOR_DEF("debugger/profiler_frame_max_functions", 64); - //display_mode=DISPLAY_FRAME_TIME; - frame_delay = memnew(Timer); frame_delay->set_wait_time(0.1); frame_delay->set_one_shot(true); @@ -784,6 +783,4 @@ EditorProfiler::EditorProfiler() { seeking = false; graph_height = 1; - - //activate->set_disabled(true); } diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index f63d4884e2..1f2a02c9a0 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -297,7 +297,7 @@ void EditorResourcePreview::_thread() { if (!f) { // Not returning as this would leave the thread hanging and would require // some proper cleanup/disabling of resource preview generation. - ERR_PRINTS("Cannot create file '" + file + "'. Check user write permissions."); + ERR_PRINT("Cannot create file '" + file + "'. Check user write permissions."); } else { f->store_line(itos(thumbnail_size)); f->store_line(itos(has_small_texture)); diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 28825b45e1..2090c12c91 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -245,6 +245,9 @@ void SectionedInspector::update_category_list() { if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene" || pi.name.begins_with("_global_script")) continue; + if (!filter.empty() && !filter.is_subsequence_ofi(pi.name) && !filter.is_subsequence_ofi(pi.name.replace("/", " ").capitalize())) + continue; + int sp = pi.name.find("/"); if (sp == -1) pi.name = "global/" + pi.name; @@ -252,9 +255,6 @@ void SectionedInspector::update_category_list() { Vector<String> sectionarr = pi.name.split("/"); String metasection; - if (!filter.empty() && !filter.is_subsequence_ofi(sectionarr[sectionarr.size() - 1].capitalize())) - continue; - int sc = MIN(2, sectionarr.size() - 1); for (int i = 0; i < sc; i++) { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 92e3f61ca5..715ce6bea7 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -148,7 +148,7 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { const VariantContainer *v = props.getptr(p_name); if (!v) { - WARN_PRINTS("EditorSettings::_get - Property not found: " + String(p_name)); + WARN_PRINT("EditorSettings::_get - Property not found: " + String(p_name)); return false; } r_ret = v->variant; @@ -794,13 +794,13 @@ void EditorSettings::create() { self_contained = true; Error err = extra_config->load(exe_path + "/._sc_"); if (err != OK) { - ERR_PRINTS("Can't load config from path '" + exe_path + "/._sc_'."); + ERR_PRINT("Can't load config from path '" + exe_path + "/._sc_'."); } } else if (d->file_exists(exe_path + "/_sc_")) { self_contained = true; Error err = extra_config->load(exe_path + "/_sc_"); if (err != OK) { - ERR_PRINTS("Can't load config from path '" + exe_path + "/_sc_'."); + ERR_PRINT("Can't load config from path '" + exe_path + "/_sc_'."); } } memdelete(d); @@ -1056,7 +1056,7 @@ void EditorSettings::save() { Error err = ResourceSaver::save(singleton->config_file_path, singleton); if (err != OK) { - ERR_PRINTS("Error saving editor settings to " + singleton->config_file_path); + ERR_PRINT("Error saving editor settings to " + singleton->config_file_path); } else { print_verbose("EditorSettings: Save OK!"); } diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 621f531687..28bc20a957 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -35,7 +35,11 @@ #include "editor_icons.gen.h" #include "editor_scale.h" #include "editor_settings.h" + +#include "modules/modules_enabled.gen.h" +#ifdef MODULE_SVG_ENABLED #include "modules/svg/image_loader_svg.h" +#endif static Ref<StyleBoxTexture> make_stylebox(Ref<Texture> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) { Ref<StyleBoxTexture> style(memnew(StyleBoxTexture)); @@ -89,7 +93,11 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float // dumb gizmo check bool is_gizmo = String(editor_icons_names[p_index]).begins_with("Gizmo"); - ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, true, p_convert_color); + // Upsample icon generation only if the editor scale isn't an integer multiplier. + // Generating upsampled icons is slower, and the benefit is hardly visible + // with integer editor scales. + const bool upsample = !Math::is_equal_approx(Math::round(p_scale), p_scale); + ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, upsample, p_convert_color); if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || p_force_filter) icon->create_from_image(img); // in this case filter really helps @@ -105,8 +113,16 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = true, int p_thumb_size = 32, bool p_only_thumbs = false) { -#ifdef SVG_ENABLED +#ifdef MODULE_SVG_ENABLED + // The default icon theme is designed to be used for a dark theme. + // This dictionary stores color codes to convert to other colors + // for better readability on a light theme. Dictionary dark_icon_color_dictionary; + + // The names of the icons to never convert, even if one of their colors + // are contained in the dictionary above. + Set<StringName> exceptions; + if (!p_dark_theme) { // convert color: FROM TO ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e0e0e0", "#5a5a5a"); // common icon color @@ -172,9 +188,31 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ec9a", "#2ce573"); // VS rid ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#79f3e8", "#12d5c3"); // VS object ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#77edb1", "#57e99f"); // VS dict + + exceptions.insert("EditorPivot"); + exceptions.insert("EditorHandle"); + exceptions.insert("Editor3DHandle"); + exceptions.insert("Godot"); + exceptions.insert("PanoramaSky"); + exceptions.insert("ProceduralSky"); + exceptions.insert("EditorControlAnchor"); + exceptions.insert("DefaultProjectIcon"); + exceptions.insert("GuiCloseCustomizable"); + exceptions.insert("GuiGraphNodePort"); + exceptions.insert("GuiResizer"); + exceptions.insert("ZoomMore"); + exceptions.insert("ZoomLess"); + exceptions.insert("ZoomReset"); + exceptions.insert("LockViewport"); + exceptions.insert("GroupViewport"); + exceptions.insert("StatusError"); + exceptions.insert("StatusSuccess"); + exceptions.insert("StatusWarning"); + exceptions.insert("NodeWarning"); + exceptions.insert("OverbrightIndicator"); } - // these ones should be converted even if we are using a dark theme + // These ones should be converted even if we are using a dark theme. const Color error_color = p_theme->get_color("error_color", "Editor"); const Color success_color = p_theme->get_color("success_color", "Editor"); const Color warning_color = p_theme->get_color("warning_color", "Editor"); @@ -182,65 +220,44 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = dark_icon_color_dictionary[Color::html("#45ff8b")] = success_color; dark_icon_color_dictionary[Color::html("#dbab09")] = warning_color; - List<String> exceptions; - exceptions.push_back("EditorPivot"); - exceptions.push_back("EditorHandle"); - exceptions.push_back("Editor3DHandle"); - exceptions.push_back("Godot"); - exceptions.push_back("PanoramaSky"); - exceptions.push_back("ProceduralSky"); - exceptions.push_back("EditorControlAnchor"); - exceptions.push_back("DefaultProjectIcon"); - exceptions.push_back("GuiCloseCustomizable"); - exceptions.push_back("GuiGraphNodePort"); - exceptions.push_back("GuiResizer"); - exceptions.push_back("ZoomMore"); - exceptions.push_back("ZoomLess"); - exceptions.push_back("ZoomReset"); - exceptions.push_back("LockViewport"); - exceptions.push_back("GroupViewport"); - exceptions.push_back("StatusError"); - exceptions.push_back("StatusSuccess"); - exceptions.push_back("StatusWarning"); - exceptions.push_back("NodeWarning"); - exceptions.push_back("OverbrightIndicator"); - ImageLoaderSVG::set_convert_colors(&dark_icon_color_dictionary); - // generate icons - if (!p_only_thumbs) + // Generate icons. + if (!p_only_thumbs) { for (int i = 0; i < editor_icons_count; i++) { - List<String>::Element *is_exception = exceptions.find(editor_icons_names[i]); - if (is_exception) exceptions.erase(is_exception); - Ref<ImageTexture> icon = editor_generate_icon(i, !is_exception); + const int is_exception = exceptions.has(editor_icons_names[i]); + const Ref<ImageTexture> icon = editor_generate_icon(i, !is_exception); + p_theme->set_icon(editor_icons_names[i], "EditorIcons", icon); } + } - // generate thumb files with the given thumb size - bool force_filter = p_thumb_size != 64 && p_thumb_size != 32; // we don't need filter with original resolution + // Generate thumbnail icons with the given thumbnail size. + // We don't need filtering when generating at one of the default resolutions. + const bool force_filter = p_thumb_size != 64 && p_thumb_size != 32; if (p_thumb_size >= 64) { - float scale = (float)p_thumb_size / 64.0 * EDSCALE; + const float scale = (float)p_thumb_size / 64.0 * EDSCALE; for (int i = 0; i < editor_bg_thumbs_count; i++) { - int index = editor_bg_thumbs_indices[i]; - List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]); - if (is_exception) exceptions.erase(is_exception); - Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter); + const int index = editor_bg_thumbs_indices[i]; + const int is_exception = exceptions.has(editor_icons_names[index]); + const Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter); + p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon); } } else { - float scale = (float)p_thumb_size / 32.0 * EDSCALE; + const float scale = (float)p_thumb_size / 32.0 * EDSCALE; for (int i = 0; i < editor_md_thumbs_count; i++) { - int index = editor_md_thumbs_indices[i]; - List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]); - if (is_exception) exceptions.erase(is_exception); - Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter); + const int index = editor_md_thumbs_indices[i]; + const bool is_exception = exceptions.has(editor_icons_names[index]); + const Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter); + p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon); } } ImageLoaderSVG::set_convert_colors(NULL); #else - print_line("SVG support disabled, editor icons won't be rendered."); + WARN_PRINT("SVG support disabled, editor icons won't be rendered."); #endif } diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index 0562c3ba43..c420cf44e7 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -63,7 +63,7 @@ void EditorVCSInterface::_bind_methods() { bool EditorVCSInterface::_initialize(String p_project_root_path) { - WARN_PRINT("Selected VCS addon does not implement an initialization function. This warning will be suppressed.") + WARN_PRINT("Selected VCS addon does not implement an initialization function. This warning will be suppressed."); return true; } diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index cb636f8cdc..7ed6688154 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -638,7 +638,7 @@ Error ExportTemplateManager::install_android_template() { FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF); #endif } else { - ERR_PRINTS("Can't uncompress file: " + to_write); + ERR_PRINT("Can't uncompress file: " + to_write); } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 62effb406d..684942dbad 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1413,17 +1413,13 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool overw if (!can_move) { // Ask to do something. overwrite_dialog->popup_centered_minsize(); - overwrite_dialog->grab_focus(); return; } } // Check groups. for (int i = 0; i < to_move.size(); i++) { - - print_line("is group: " + to_move[i].path + ": " + itos(EditorFileSystem::get_singleton()->is_group_file(to_move[i].path))); if (to_move[i].is_file && EditorFileSystem::get_singleton()->is_group_file(to_move[i].path)) { - print_line("move to: " + p_to_path.plus_file(to_move[i].path.get_file())); EditorFileSystem::get_singleton()->move_group_file(to_move[i].path, p_to_path.plus_file(to_move[i].path.get_file())); } } @@ -1442,7 +1438,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool overw if (is_moved) { int current_tab = editor->get_current_tab(); - _save_scenes_after_move(file_renames); //save scenes before updating + _save_scenes_after_move(file_renames); // Save scenes before updating. _update_dependencies_after_move(file_renames); _update_resource_paths_after_move(file_renames); _update_project_settings_after_move(file_renames); @@ -1786,6 +1782,14 @@ void FileSystemDock::_resource_created() const { Resource *r = Object::cast_to<Resource>(c); ERR_FAIL_COND(!r); + PackedScene *scene = Object::cast_to<PackedScene>(r); + if (scene) { + Node *node = memnew(Node); + node->set_name("Node"); + scene->pack(node); + memdelete(node); + } + REF res(r); editor->push_item(c); @@ -1948,7 +1952,7 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da return false; // Attempting to move a folder into itself will fail later, - // rather than bring up a message don't try to do it in the first place + // rather than bring up a message don't try to do it in the first place. to_dir = to_dir.ends_with("/") ? to_dir : (to_dir + "/"); Vector<String> fnames = drag_data["files"]; for (int i = 0; i < fnames.size(); ++i) { @@ -2050,11 +2054,15 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, Vector<String> fnames = drag_data["files"]; to_move.clear(); for (int i = 0; i < fnames.size(); i++) { - to_move.push_back(FileOrFolder(fnames[i], !fnames[i].ends_with("/"))); + if (fnames[i].get_base_dir() != to_dir) { + to_move.push_back(FileOrFolder(fnames[i], !fnames[i].ends_with("/"))); + } + } + if (!to_move.empty()) { + _move_operation_confirm(to_dir); } - _move_operation_confirm(to_dir); } else if (favorite) { - // Add the files from favorites + // Add the files from favorites. Vector<String> fnames = drag_data["files"]; Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); for (int i = 0; i < fnames.size(); i++) { @@ -2103,6 +2111,10 @@ void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favori // We drop on a folder. target = fpath; return; + } else { + // We drop on the folder that the target file is in. + target = fpath.get_base_dir(); + return; } } else { if (ti->get_parent() != tree->get_root()->get_children()) { diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 4ab90ad3e4..b24a5c38f2 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -235,9 +235,11 @@ void FindInFiles::_scan_dir(String path, PoolStringArray &out_folders) { if (file == "") break; - // Ignore special dirs and hidden dirs (such as .git and .import) + // Ignore special dirs (such as .git and .import) if (file == "." || file == ".." || file.begins_with(".")) continue; + if (dir->current_is_hidden()) + continue; if (dir->current_is_dir()) out_folders.append(file); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 83259afb35..c76ff9d679 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -197,7 +197,7 @@ void GroupDialog::_add_group(String p_name) { } String name = p_name.strip_edges(); - if (name == "" || groups->search_item_text(name)) { + if (name.empty() || groups->get_item_with_text(name)) { return; } diff --git a/editor/icons/icon_godot_docs.svg b/editor/icons/icon_godot_docs.svg deleted file mode 100644 index e38885aed9..0000000000 --- a/editor/icons/icon_godot_docs.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g stroke-width=".32031" transform="matrix(.017241 0 0 .017241 -.82759 -2.7)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 919.24 771.67)"/><path d="m0 0v-59.041c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325h.134c4.795 6.12 9.232 12.569 13.487 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.253-6.88 8.693-13.329 13.487-19.449z" fill="#478cbf" transform="matrix(4.1626 0 0 -4.1626 104.7 525.91)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.133c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(4.1626 0 0 -4.1626 784.07 817.24)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 389.21 625.67)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(4.1626 0 0 -4.1626 367.37 631.06)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 511.99 724.74)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 634.79 625.67)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(4.1626 0 0 -4.1626 656.64 631.06)"/></g><path d="m4 5a3 3 0 0 0 -3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3h2a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0 -3-3 3 3 0 0 0 -2.8262 2h-2.3496a3 3 0 0 0 -2.8242-2zm0 1a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2-2 2 2 0 0 1 2-2zm8 0a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2-2 2 2 0 0 1 2-2z"/></svg>
\ No newline at end of file diff --git a/editor/icons/icon_particle_attractor_2d.svg b/editor/icons/icon_particle_attractor_2d.svg deleted file mode 100644 index 85f289dc4b..0000000000 --- a/editor/icons/icon_particle_attractor_2d.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1a3 7 0 0 0 -2.0801 1.9668 7 3 45 0 0 -2.8691.083984 7 3 45 0 0 -.080078 2.8633 7 3 0 0 0 -1.9707 2.0859 7 3 0 0 0 1.9668 2.0801 3 7 45 0 0 .083984 2.8691 3 7 45 0 0 2.8633.080078 3 7 0 0 0 2.0859 1.9707 3 7 0 0 0 2.0801-1.9668 7 3 45 0 0 2.8691-.083984 7 3 45 0 0 .080078-2.8633 7 3 0 0 0 1.9707-2.0859 7 3 0 0 0 -1.9668-2.0801 3 7 45 0 0 -.083984-2.8691 3 7 45 0 0 -2.8633-.080078 3 7 0 0 0 -2.0859-1.9707zm0 1a2 6 0 0 1 1.2598 1.3438 3 7 45 0 0 -1.2578.75977 7 3 45 0 0 -1.2637-.75781 2 6 0 0 1 1.2617-1.3457zm-3.6348 1.5293a6 2 45 0 1 1.2344.28906 3 7 0 0 0 -.35352 1.4238 7 3 0 0 0 -1.4297.35742 6 2 45 0 1 -.058594-1.8418 6 2 45 0 1 .60742-.22852zm7.0762.0039062a2 6 45 0 1 .80078.22461 2 6 45 0 1 -.060547 1.8418 7 3 0 0 0 -1.4238-.35352 3 7 0 0 0 -.35742-1.4297 2 6 45 0 1 1.041-.2832zm-4.998.70703a6 2 45 0 1 .74023.4707 3 7 45 0 0 -.41211.33984 7 3 0 0 0 -.52344.048828 2 6 0 0 1 .19531-.85938zm3.1152.0019531a2 6 0 0 1 .18945.85547 7 3 0 0 0 -.5293-.050781 7 3 45 0 0 -.4043-.33594 2 6 45 0 1 .74414-.46875zm-1.5586 1.7578a6 2 0 0 1 .82031.021484 6 2 45 0 1 .59375.56445 6 2 45 0 1 .56445.59375 2 6 0 0 1 .021484.82031 2 6 0 0 1 -.021484.82031 2 6 45 0 1 -.56445.59375 2 6 45 0 1 -.59375.56445 6 2 0 0 1 -.82031.021484 6 2 0 0 1 -.82031-.021484 6 2 45 0 1 -.59375-.56445 6 2 45 0 1 -.56445-.59375 2 6 0 0 1 -.021484-.82031 2 6 0 0 1 .021484-.82031 2 6 45 0 1 .56445-.59375 2 6 45 0 1 .59375-.56445 6 2 0 0 1 .82031-.021484zm2.9004.24805a6 2 0 0 1 .85938.19531 2 6 45 0 1 -.4707.74023 7 3 45 0 0 -.33984-.41211 3 7 0 0 0 -.048828-.52344zm-5.8027.0039062a3 7 0 0 0 -.050781.5293 3 7 45 0 0 -.33594.4043 6 2 45 0 1 -.46875-.74414 6 2 0 0 1 .85547-.18945zm7.5566.48633a6 2 0 0 1 1.3457 1.2617 6 2 0 0 1 -1.3438 1.2598 7 3 45 0 0 -.75977-1.2578 3 7 45 0 0 .75781-1.2637zm-9.3105.0019532a7 3 45 0 0 .75977 1.2578 3 7 45 0 0 -.75781 1.2637 6 2 0 0 1 -1.3457-1.2617 6 2 0 0 1 1.3438-1.2598zm4.6562.25977a1 1 0 0 0 -1 1 1 1 0 0 0 1 1 1 1 0 0 0 1-1 1 1 0 0 0 -1-1zm3.2891 1.8145a6 2 45 0 1 .46875.74414 6 2 0 0 1 -.85547.18945 3 7 0 0 0 .050781-.5293 3 7 45 0 0 .33594-.4043zm-6.5781.0019531a7 3 45 0 0 .33984.41211 3 7 0 0 0 .048828.52344 6 2 0 0 1 -.85938-.19531 2 6 45 0 1 .4707-.74023zm-.89258 1.584a7 3 0 0 0 1.4238.35352 3 7 0 0 0 .35742 1.4297 2 6 45 0 1 -1.8418.058594 2 6 45 0 1 .060547-1.8418zm8.3652 0a6 2 45 0 1 .058594 1.8418 6 2 45 0 1 -1.8418-.060547 3 7 0 0 0 .35352-1.4238 7 3 0 0 0 1.4297-.35742zm-2.4316.5a2 6 0 0 1 -.19531.85938 6 2 45 0 1 -.74023-.4707 3 7 45 0 0 .41211-.33984 7 3 0 0 0 .52344-.048828zm-3.5.001953a7 3 0 0 0 .5293.050781 7 3 45 0 0 .4043.33594 2 6 45 0 1 -.74414.46875 2 6 0 0 1 -.18945-.85547zm1.7461.99414a7 3 45 0 0 1.2637.75781 2 6 0 0 1 -1.2617 1.3457 2 6 0 0 1 -1.2598-1.3438 3 7 45 0 0 1.2578-.75977z" fill="#a5b7f3" fill-opacity=".98824"/></svg>
\ No newline at end of file diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index b3f97714ae..e2d8dc8962 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -892,7 +892,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me material = material_cache[target]; } else if (p.material != "") { - WARN_PRINTS("Collada: Unreferenced material in geometry instance: " + p.material); + WARN_PRINT("Collada: Unreferenced material in geometry instance: " + p.material); } } @@ -1210,7 +1210,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres mesh_cache[meshid] = mesh; } else { - WARN_PRINTS("Collada: Will not import geometry: " + meshid); + WARN_PRINT("Collada: Will not import geometry: " + meshid); } } @@ -1237,7 +1237,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres mi->set_surface_material(i, material); } else if (matname != "") { - WARN_PRINTS("Collada: Unreferenced material in geometry instance: " + matname); + WARN_PRINT("Collada: Unreferenced material in geometry instance: " + matname); } } } @@ -1408,7 +1408,7 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im node = node_name_map[at.target]; } else { - WARN_PRINTS("Collada: Couldn't find node: " + at.target); + WARN_PRINT("Collada: Couldn't find node: " + at.target); continue; } } else { @@ -1588,7 +1588,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones } if (xform_idx == -1) { - WARN_PRINTS("Collada: Couldn't find matching node " + at.target + " xform for track " + at.param + "."); + WARN_PRINT("Collada: Couldn't find matching node " + at.target + " xform for track " + at.param + "."); continue; } @@ -1666,7 +1666,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones Collada::Node *cn = collada.state.scene_map[E->key()]; if (cn->ignore_anim) { - WARN_PRINTS("Collada: Ignoring animation on node: " + path); + WARN_PRINT("Collada: Ignoring animation on node: " + path); continue; } @@ -1735,7 +1735,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones //matrix WARN_PRINT("Collada: Value keys for matrices not supported."); } else { - WARN_PRINTS("Collada: Unexpected amount of value keys: " + itos(data.size())); + WARN_PRINT("Collada: Unexpected amount of value keys: " + itos(data.size())); } animation->track_insert_key(track, time, value); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 2f9135c52c..d4664e1bb9 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "editor_scene_importer_gltf.h" + #include "core/crypto/crypto_core.h" #include "core/io/json.h" #include "core/math/disjoint_set.h" @@ -233,7 +234,7 @@ Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) { if (state.json.has("scene")) { loaded_scene = state.json["scene"]; } else { - WARN_PRINT("The load-time scene is not defined in the glTF2 file. Picking the first scene.") + WARN_PRINT("The load-time scene is not defined in the glTF2 file. Picking the first scene."); } if (scenes.size()) { @@ -2438,7 +2439,7 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { track->weight_tracks.write[k] = cf; } } else { - WARN_PRINTS("Invalid path '" + path + "'."); + WARN_PRINT("Invalid path '" + path + "'."); } } diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index b1ed59a2db..bdd6a197f8 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -63,7 +63,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati material_map[current_name] = current; } else if (l.begins_with("Ka ")) { //uv - WARN_PRINTS("OBJ: Ambient light for material '" + current_name + "' is ignored in PBR"); + WARN_PRINT("OBJ: Ambient light for material '" + current_name + "' is ignored in PBR"); } else if (l.begins_with("Kd ")) { //normal @@ -119,7 +119,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati } else if (l.begins_with("map_Ka ")) { //uv - WARN_PRINTS("OBJ: Ambient light texture for material '" + current_name + "' is ignored in PBR"); + WARN_PRINT("OBJ: Ambient light texture for material '" + current_name + "' is ignored in PBR"); } else if (l.begins_with("map_Kd ")) { //normal diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 2be3464d30..ecd1e341d1 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -337,6 +337,7 @@ void InspectorDock::_notification(int p_what) { history_menu->set_icon(get_icon("History", "EditorIcons")); object_menu->set_icon(get_icon("Tools", "EditorIcons")); warning->set_icon(get_icon("NodeWarning", "EditorIcons")); + warning->add_color_override("font_color", get_color("warning_color", "Editor")); } break; } } @@ -584,6 +585,8 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { add_child(warning); warning->set_text(TTR("Changes may be lost!")); warning->set_icon(get_icon("NodeWarning", "EditorIcons")); + warning->add_color_override("font_color", get_color("warning_color", "Editor")); + warning->set_clip_text(true); warning->hide(); warning->connect("pressed", this, "_warning_pressed"); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 07b87633a9..1506ba319c 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -35,9 +35,13 @@ #include "editor/editor_plugin.h" #include "editor/editor_scale.h" #include "editor/project_settings_editor.h" -#include "modules/gdscript/gdscript.h" #include "scene/gui/grid_container.h" +#include "modules/modules_enabled.gen.h" +#ifdef MODULE_GDSCRIPT_ENABLED +#include "modules/gdscript/gdscript.h" +#endif + void PluginConfigDialog::_clear_fields() { name_edit->set_text(""); subfolder_edit->set_text(""); @@ -75,6 +79,9 @@ void PluginConfigDialog::_on_confirmed() { // TODO Use script templates. Right now, this code won't add the 'tool' annotation to other languages. // TODO Better support script languages with named classes (has_named_classes). + // FIXME: It's hacky to have hardcoded access to the GDScript module here. + // The editor code should not have to know what languages are enabled. +#ifdef MODULE_GDSCRIPT_ENABLED if (lang_name == GDScriptLanguage::get_singleton()->get_name()) { // Hard-coded GDScript template to keep usability until we use script templates. Ref<Script> gdscript = memnew(GDScript); @@ -95,12 +102,15 @@ void PluginConfigDialog::_on_confirmed() { ResourceSaver::save(script_path, gdscript); script = gdscript; } else { +#endif String script_path = path.plus_file(script_edit->get_text()); String class_name = script_path.get_file().get_basename(); script = ScriptServer::get_language(lang_idx)->get_template(class_name, "EditorPlugin"); script->set_path(script_path); ResourceSaver::save(script_path, script); +#ifdef MODULE_GDSCRIPT_ENABLED } +#endif emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? subfolder_edit->get_text() : ""); } else { @@ -229,9 +239,11 @@ PluginConfigDialog::PluginConfigDialog() { for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptLanguage *lang = ScriptServer::get_language(i); script_option_edit->add_item(lang->get_name()); +#ifdef MODULE_GDSCRIPT_ENABLED if (lang == GDScriptLanguage::get_singleton()) { default_lang = i; } +#endif } script_option_edit->select(default_lang); grid->add_child(script_option_edit); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 4f73a5eaea..d88a716122 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -31,6 +31,8 @@ #include "asset_library_editor_plugin.h" #include "core/io/json.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/version.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" @@ -139,8 +141,6 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { set_custom_minimum_size(Size2(250, 100) * EDSCALE); set_h_size_flags(SIZE_EXPAND_FILL); - - set_mouse_filter(MOUSE_FILTER_PASS); } ////////////////////////////////////////////////////////////////////////////// @@ -622,6 +622,21 @@ void EditorAssetLibrary::_notification(int p_what) { } } +void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) { + + const Ref<InputEventKey> key = p_event; + + if (key.is_valid() && key->is_pressed()) { + + if (key->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) { + + filter->grab_focus(); + filter->select_all(); + accept_event(); + } + } +} + void EditorAssetLibrary::_install_asset() { ERR_FAIL_COND(!description); @@ -812,7 +827,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons _image_update(p_code == HTTPClient::RESPONSE_NOT_MODIFIED, true, p_data, p_queue_id); } else { - WARN_PRINTS("Error getting image file from URL: " + image_queue[p_queue_id].image_url); + WARN_PRINT("Error getting image file from URL: " + image_queue[p_queue_id].image_url); Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target); if (obj) { obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_icon("FileBrokenBigThumb", "EditorIcons")); @@ -1322,6 +1337,7 @@ void EditorAssetLibrary::disable_community_support() { void EditorAssetLibrary::_bind_methods() { + ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input); ClassDB::bind_method("_http_request_completed", &EditorAssetLibrary::_http_request_completed); ClassDB::bind_method("_select_asset", &EditorAssetLibrary::_select_asset); ClassDB::bind_method("_select_author", &EditorAssetLibrary::_select_author); @@ -1455,7 +1471,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_scroll->add_child(library_vb_border); library_vb_border->add_style_override("panel", border2); library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL); - library_vb_border->set_mouse_filter(MOUSE_FILTER_PASS); library_vb = memnew(VBoxContainer); library_vb->set_h_size_flags(SIZE_EXPAND_FILL); @@ -1505,6 +1520,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { description = NULL; set_process(true); + set_process_unhandled_input(true); downloads_scroll = memnew(ScrollContainer); downloads_scroll->set_enable_h_scroll(true); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index aa3c735810..8852125b8b 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -300,6 +300,7 @@ class EditorAssetLibrary : public PanelContainer { protected: static void _bind_methods(); void _notification(int p_what); + void _unhandled_input(const Ref<InputEvent> &p_event); public: void disable_community_support(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 260ad8b593..1024e853be 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -58,6 +58,7 @@ #define RULER_WIDTH (15 * EDSCALE) #define SCALE_HANDLE_DISTANCE 25 +#define MOVE_HANDLE_DISTANCE 25 class SnapDialog : public ConfirmationDialog { @@ -1868,14 +1869,16 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { drag_type = DRAG_SCALE_BOTH; - Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); - Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { - drag_type = DRAG_SCALE_X; - } - Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { - drag_type = DRAG_SCALE_Y; + if (show_transformation_gizmos) { + Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); + Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_SCALE_X; + } + Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_SCALE_Y; + } } drag_from = transform.affine_inverse().xform(b->get_position()); @@ -1926,7 +1929,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { scale.y = scale.x * ratio; } } else if (drag_type == DRAG_SCALE_Y) { - scale.y += scale_factor.y; + scale.y -= scale_factor.y; if (uniform) { scale.x = scale.y / ratio; } @@ -1985,6 +1988,24 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (selection.size() > 0) { drag_type = DRAG_MOVE; + + CanvasItem *canvas_item = drag_selection[0]; + Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse(); + Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + + if (show_transformation_gizmos) { + Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE); + Rect2 x_handle_rect = Rect2(move_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_MOVE_X; + } + Rect2 y_handle_rect = Rect2(-5 * EDSCALE, move_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_MOVE_Y; + } + } + drag_from = transform.affine_inverse().xform(b->get_position()); drag_selection = selection; _save_canvas_item_state(drag_selection); @@ -1994,7 +2015,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } } - if (drag_type == DRAG_MOVE) { + if (drag_type == DRAG_MOVE || drag_type == DRAG_MOVE_X || drag_type == DRAG_MOVE_Y) { // Move the nodes if (m.is_valid()) { @@ -2016,7 +2037,15 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } else { previous_pos = _get_encompassing_rect_from_list(drag_selection).position; } + Point2 new_pos = snap_point(previous_pos + (drag_to - drag_from), SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL | SNAP_NODE_PARENT | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES, 0, NULL, drag_selection); + + if (drag_type == DRAG_MOVE_X) { + new_pos.y = previous_pos.y; + } else if (drag_type == DRAG_MOVE_Y) { + new_pos.x = previous_pos.x; + } + bool single_axis = m->get_shift(); if (single_axis) { if (ABS(new_pos.x - previous_pos.x) > ABS(new_pos.y - previous_pos.y)) { @@ -3259,10 +3288,39 @@ void CanvasItemEditor::_draw_selection() { } } - // Draw the rescale handles + // Draw the move handles bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL); bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT); - if ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) { + if (tool == TOOL_MOVE && show_transformation_gizmos) { + if (_is_node_movable(canvas_item)) { + Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + + Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE); + viewport->draw_set_transform_matrix(simple_xform); + + Vector<Point2> points; + points.push_back(Vector2(move_factor.x * EDSCALE, 5 * EDSCALE)); + points.push_back(Vector2(move_factor.x * EDSCALE, -5 * EDSCALE)); + points.push_back(Vector2((move_factor.x + 10) * EDSCALE, 0)); + + viewport->draw_colored_polygon(points, get_color("axis_x_color", "Editor")); + viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE), true); + + points.clear(); + points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE)); + points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE)); + points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE)); + + viewport->draw_colored_polygon(points, get_color("axis_y_color", "Editor")); + viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE), true); + + viewport->draw_set_transform_matrix(viewport->get_transform()); + } + } + + // Draw the rescale handles + if (show_transformation_gizmos && ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y)) { if (_is_node_movable(canvas_item)) { Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; @@ -3277,9 +3335,9 @@ void CanvasItemEditor::_draw_selection() { scale_factor.y += offset.x; } } else if (drag_type == DRAG_SCALE_Y) { - scale_factor.y -= offset.y; + scale_factor.y += offset.y; if (uniform) { - scale_factor.x -= offset.y; + scale_factor.x += offset.y; } } @@ -3288,9 +3346,9 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_rect(x_handle_rect, get_color("axis_x_color", "Editor")); viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE), true); - Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); viewport->draw_rect(y_handle_rect, get_color("axis_y_color", "Editor")); - viewport->draw_line(Point2(), Point2(0, -scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE), true); + viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE), true); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -4405,10 +4463,8 @@ void CanvasItemEditor::_update_override_camera_button(bool p_game_running) { } void CanvasItemEditor::_popup_callback(int p_op) { - last_option = MenuOption(p_op); switch (p_op) { - case SHOW_GRID: { show_grid = !show_grid; int idx = view_menu->get_popup()->get_item_index(SHOW_GRID); @@ -4433,6 +4489,12 @@ void CanvasItemEditor::_popup_callback(int p_op) { view_menu->get_popup()->set_item_checked(idx, show_edit_locks); viewport->update(); } break; + case SHOW_TRANSFORMATION_GIZMOS: { + show_transformation_gizmos = !show_transformation_gizmos; + int idx = view_menu->get_popup()->get_item_index(SHOW_TRANSFORMATION_GIZMOS); + view_menu->get_popup()->set_item_checked(idx, show_transformation_gizmos); + viewport->update(); + } break; case SNAP_USE_NODE_PARENT: { snap_node_parent = !snap_node_parent; int idx = smartsnap_config_popup->get_item_index(SNAP_USE_NODE_PARENT); @@ -4991,6 +5053,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { zoom = scale_x < scale_y ? scale_x : scale_y; zoom *= 0.90; viewport->update(); + _update_zoom_label(); call_deferred("_popup_callback", VIEW_CENTER_TO_SELECTION); } } @@ -5058,6 +5121,7 @@ Dictionary CanvasItemEditor::get_state() const { state["show_helpers"] = show_helpers; state["show_zoom_control"] = zoom_hb->is_visible(); state["show_edit_locks"] = show_edit_locks; + state["show_transformation_gizmos"] = show_transformation_gizmos; state["snap_rotation"] = snap_rotation; state["snap_scale"] = snap_scale; state["snap_relative"] = snap_relative; @@ -5196,6 +5260,12 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { view_menu->get_popup()->set_item_checked(idx, show_edit_locks); } + if (state.has("show_transformation_gizmos")) { + show_transformation_gizmos = state["show_transformation_gizmos"]; + int idx = view_menu->get_popup()->get_item_index(SHOW_TRANSFORMATION_GIZMOS); + view_menu->get_popup()->set_item_checked(idx, show_transformation_gizmos); + } + if (state.has("show_zoom_control")) { // This one is not user-controllable, but instrumentable zoom_hb->set_visible(state["show_zoom_control"]); @@ -5288,6 +5358,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { show_helpers = false; show_rulers = true; show_guides = true; + show_transformation_gizmos = true; show_edit_locks = true; zoom = 1.0 / MAX(1, EDSCALE); view_offset = Point2(-150 - RULER_WIDTH, -95 - RULER_WIDTH); @@ -5619,6 +5690,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_origin", TTR("Show Origin")), SHOW_ORIGIN); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_viewport", TTR("Show Viewport")), SHOW_VIEWPORT); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_edit_locks", TTR("Show Group And Lock Icons")), SHOW_EDIT_LOCKS); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_transformation_gizmos", TTR("Show Transformation Gizmos")), SHOW_TRANSFORMATION_GIZMOS); p->add_separator(); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 8657700711..0ee155dfd0 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -119,6 +119,7 @@ private: SHOW_ORIGIN, SHOW_VIEWPORT, SHOW_EDIT_LOCKS, + SHOW_TRANSFORMATION_GIZMOS, LOCK_SELECTED, UNLOCK_SELECTED, GROUP_SELECTED, @@ -189,7 +190,6 @@ private: SKELETON_SHOW_BONES, SKELETON_SET_IK_CHAIN, SKELETON_CLEAR_IK_CHAIN - }; enum DragType { @@ -209,6 +209,8 @@ private: DRAG_ANCHOR_BOTTOM_LEFT, DRAG_ANCHOR_ALL, DRAG_MOVE, + DRAG_MOVE_X, + DRAG_MOVE_Y, DRAG_SCALE_X, DRAG_SCALE_Y, DRAG_SCALE_BOTH, @@ -248,6 +250,8 @@ private: bool show_viewport; bool show_helpers; bool show_edit_locks; + bool show_transformation_gizmos; + float zoom; Point2 view_offset; Point2 previous_update_view_offset; diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index be9e5b0e3a..179ebca562 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -448,8 +448,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla float radius = shape->get_radius(); float height = shape->get_height() / 2; - handles.write[0] = Point2(radius, -height); - handles.write[1] = Point2(0, -(height + radius)); + handles.write[0] = Point2(radius, height); + handles.write[1] = Point2(0, height + radius); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); p_overlay->draw_texture(h, gt.xform(handles[1]) - size); @@ -502,8 +502,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla handles.resize(3); Vector2 ext = shape->get_extents(); handles.write[0] = Point2(ext.x, 0); - handles.write[1] = Point2(0, -ext.y); - handles.write[2] = Point2(ext.x, -ext.y); + handles.write[1] = Point2(0, ext.y); + handles.write[2] = Point2(ext.x, ext.y); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); p_overlay->draw_texture(h, gt.xform(handles[1]) - size); diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp index 25329906a9..6e5307cebe 100644 --- a/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_editor_plugin.cpp @@ -60,10 +60,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { } switch (p_option) { - case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: - case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: { - - bool trimesh_shape = (p_option == MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); + case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: { EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); @@ -71,9 +68,12 @@ void MeshInstanceEditor::_menu_option(int p_option) { List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.empty()) { - Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape(); - if (shape.is_null()) + Ref<Shape> shape = mesh->create_trimesh_shape(); + if (shape.is_null()) { + err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape.")); + err_dialog->popup_centered_minsize(); return; + } CollisionShape *cshape = memnew(CollisionShape); cshape->set_shape(shape); @@ -82,11 +82,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner(); - if (trimesh_shape) - ur->create_action(TTR("Create Static Trimesh Body")); - else - ur->create_action(TTR("Create Static Convex Body")); - + ur->create_action(TTR("Create Static Trimesh Body")); ur->add_do_method(node, "add_child", body); ur->add_do_method(body, "set_owner", owner); ur->add_do_method(cshape, "set_owner", owner); @@ -108,7 +104,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { if (m.is_null()) continue; - Ref<Shape> shape = trimesh_shape ? m->create_trimesh_shape() : m->create_convex_shape(); + Ref<Shape> shape = m->create_trimesh_shape(); if (shape.is_null()) continue; @@ -158,10 +154,44 @@ void MeshInstanceEditor::_menu_option(int p_option) { ur->add_undo_method(node->get_parent(), "remove_child", cshape); ur->commit_action(); } break; - case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: { + case MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE: { if (node == get_tree()->get_edited_scene_root()) { - err_dialog->set_text(TTR("This doesn't work on scene root!")); + err_dialog->set_text(TTR("Can't create a single convex collision shape for the scene root.")); + err_dialog->popup_centered_minsize(); + return; + } + + Ref<Shape> shape = mesh->create_convex_shape(); + + if (shape.is_null()) { + err_dialog->set_text(TTR("Couldn't create a single convex collision shape.")); + err_dialog->popup_centered_minsize(); + return; + } + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + + ur->create_action(TTR("Create Single Convex Shape")); + + CollisionShape *cshape = memnew(CollisionShape); + cshape->set_shape(shape); + cshape->set_transform(node->get_transform()); + + Node *owner = node->get_owner(); + + ur->add_do_method(node->get_parent(), "add_child", cshape); + ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1); + ur->add_do_method(cshape, "set_owner", owner); + ur->add_do_reference(cshape); + ur->add_undo_method(node->get_parent(), "remove_child", cshape); + + ur->commit_action(); + + } break; + case MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES: { + + if (node == get_tree()->get_edited_scene_root()) { + err_dialog->set_text(TTR("Can't create multiple convex collision shapes for the scene root.")); err_dialog->popup_centered_minsize(); return; } @@ -169,13 +199,13 @@ void MeshInstanceEditor::_menu_option(int p_option) { Vector<Ref<Shape> > shapes = mesh->convex_decompose(); if (!shapes.size()) { - err_dialog->set_text(TTR("Failed creating shapes!")); + err_dialog->set_text(TTR("Couldn't create any collision shapes.")); err_dialog->popup_centered_minsize(); return; } UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Create Convex Shape(s)")); + ur->create_action(TTR("Create Multiple Convex Shapes")); for (int i = 0; i < shapes.size(); i++) { @@ -421,13 +451,19 @@ MeshInstanceEditor::MeshInstanceEditor() { options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance", "EditorIcons")); options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); - options->get_popup()->add_item(TTR("Create Convex Collision Sibling(s)"), MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection.")); + options->get_popup()->add_item(TTR("Create Single Convex Collision Siblings"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a single convex collision shape.\nThis is the fastest (but least accurate) option for collision detection.")); + options->get_popup()->add_item(TTR("Create Multiple Convex Collision Siblings"), MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between the two above options.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the SpatialMaterial Grow property when using that property isn't possible.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1); options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2); diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_editor_plugin.h index 5c95676fc4..5ca9aa3fec 100644 --- a/editor/plugins/mesh_instance_editor_plugin.h +++ b/editor/plugins/mesh_instance_editor_plugin.h @@ -43,9 +43,9 @@ class MeshInstanceEditor : public Control { enum Menu { MENU_OPTION_CREATE_STATIC_TRIMESH_BODY, - MENU_OPTION_CREATE_STATIC_CONVEX_BODY, MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE, - MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE, + MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE, + MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES, MENU_OPTION_CREATE_NAVMESH, MENU_OPTION_CREATE_OUTLINE_MESH, MENU_OPTION_CREATE_UV2, diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index f13abd47a9..1da47196f8 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3209,7 +3209,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { script_list = memnew(ItemList); scripts_vbox->add_child(script_list); - script_list->set_custom_minimum_size(Size2(150, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing + script_list->set_custom_minimum_size(Size2(150, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing script_list->set_v_size_flags(SIZE_EXPAND_FILL); script_split->set_split_offset(140); _sort_list_on_update = true; @@ -3254,14 +3254,14 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { overview_vbox->add_child(members_overview); members_overview->set_allow_reselect(true); - members_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing + members_overview->set_custom_minimum_size(Size2(0, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing members_overview->set_v_size_flags(SIZE_EXPAND_FILL); members_overview->set_allow_rmb_select(true); help_overview = memnew(ItemList); overview_vbox->add_child(help_overview); help_overview->set_allow_reselect(true); - help_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing + help_overview->set_custom_minimum_size(Size2(0, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing help_overview->set_v_size_flags(SIZE_EXPAND_FILL); tab_container = memnew(TabContainer); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index c24a666c55..a19f0b4975 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -369,6 +369,7 @@ void ShaderEditor::_editor_settings_changed() { shader_editor->get_text_edit()->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type")); shader_editor->get_text_edit()->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent")); shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs")); + shader_editor->get_text_edit()->set_draw_spaces(EditorSettings::get_singleton()->get("text_editor/indent/draw_spaces")); shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers")); shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting")); shader_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences")); @@ -381,6 +382,9 @@ void ShaderEditor::_editor_settings_changed() { shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed")); shader_editor->get_text_edit()->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap")); shader_editor->get_text_edit()->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE); + shader_editor->get_text_edit()->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guideline")); + shader_editor->get_text_edit()->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_column")); + shader_editor->get_text_edit()->set_breakpoint_gutter_enabled(false); } void ShaderEditor::_bind_methods() { diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_editor_plugin.cpp index 8b5fe7d2c5..9101c64eab 100644 --- a/editor/plugins/skeleton_editor_plugin.cpp +++ b/editor/plugins/skeleton_editor_plugin.cpp @@ -103,8 +103,10 @@ void SkeletonEditor::create_physical_skeleton() { PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) { - real_t half_height(skeleton->get_bone_rest(bone_child_id).origin.length() * 0.5); - real_t radius(half_height * 0.2); + const Transform child_rest = skeleton->get_bone_rest(bone_child_id); + + const real_t half_height(child_rest.origin.length() * 0.5); + const real_t radius(half_height * 0.2); CapsuleShape *bone_shape_capsule = memnew(CapsuleShape); bone_shape_capsule->set_height((half_height - radius) * 2); @@ -114,7 +116,8 @@ PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_i bone_shape->set_shape(bone_shape_capsule); Transform body_transform; - body_transform.origin = Vector3(0, 0, -half_height); + body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin, Vector3(0, 1, 0)); + body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height)); Transform joint_transform; joint_transform.origin = Vector3(0, 0, half_height); diff --git a/editor/plugins/skeleton_ik_editor_plugin.cpp b/editor/plugins/skeleton_ik_editor_plugin.cpp index 43dc13b270..eb6ad9498d 100644 --- a/editor/plugins/skeleton_ik_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_editor_plugin.cpp @@ -41,21 +41,12 @@ void SkeletonIKEditorPlugin::_play() { return; if (play_btn->is_pressed()) { - - initial_bone_poses.resize(skeleton_ik->get_parent_skeleton()->get_bone_count()); - for (int i = 0; i < skeleton_ik->get_parent_skeleton()->get_bone_count(); ++i) { - initial_bone_poses.write[i] = skeleton_ik->get_parent_skeleton()->get_bone_pose(i); - } - skeleton_ik->start(); } else { skeleton_ik->stop(); - if (initial_bone_poses.size() != skeleton_ik->get_parent_skeleton()->get_bone_count()) - return; - for (int i = 0; i < skeleton_ik->get_parent_skeleton()->get_bone_count(); ++i) { - skeleton_ik->get_parent_skeleton()->set_bone_pose(i, initial_bone_poses[i]); + skeleton_ik->get_parent_skeleton()->set_bone_global_pose_override(i, Transform(), 0); } } } diff --git a/editor/plugins/skeleton_ik_editor_plugin.h b/editor/plugins/skeleton_ik_editor_plugin.h index 06c07031f6..814eb8ff5b 100644 --- a/editor/plugins/skeleton_ik_editor_plugin.h +++ b/editor/plugins/skeleton_ik_editor_plugin.h @@ -44,7 +44,6 @@ class SkeletonIKEditorPlugin : public EditorPlugin { Button *play_btn; EditorNode *editor; - Vector<Transform> initial_bone_poses; void _play(); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 507ea0b83d..94aef60f1f 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -546,6 +546,17 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { edit_draw->update(); } } + + Ref<InputEventMagnifyGesture> magnify_gesture = p_input; + if (magnify_gesture.is_valid()) { + _zoom_on_position(draw_zoom * magnify_gesture->get_factor(), magnify_gesture->get_position()); + } + + Ref<InputEventPanGesture> pan_gesture = p_input; + if (pan_gesture.is_valid()) { + hscroll->set_value(hscroll->get_value() + hscroll->get_page() * pan_gesture->get_delta().x / 8); + vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y / 8); + } } void TextureRegionEditor::_scroll_changed(float) { diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index f889228f87..0c3e29028c 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -2026,13 +2026,13 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { toolbar->add_child(bucket_fill_button); picker_button = memnew(ToolButton); - picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_CONTROL)); + picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_I)); picker_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_PICKING)); picker_button->set_toggle_mode(true); toolbar->add_child(picker_button); select_button = memnew(ToolButton); - select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD + KEY_B)); + select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_M)); select_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_SELECTING)); select_button->set_toggle_mode(true); toolbar->add_child(select_button); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index c53fc7e6c5..3622ca8d61 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -203,7 +203,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() { } } else { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu.") + WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu."); } } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index e334d4b093..fb095692bc 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -556,6 +556,7 @@ void VisualShaderEditor::_update_graph() { } Ref<VisualShaderNodeUniform> uniform = vsnode; + Ref<VisualShaderNodeScalarUniform> scalar_uniform = vsnode; if (uniform.is_valid()) { graph->add_child(node); _update_created_node(node); @@ -570,7 +571,9 @@ void VisualShaderEditor::_update_graph() { //shortcut VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0); node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]); - continue; + if (!scalar_uniform.is_valid()) { + continue; + } } port_offset++; } @@ -582,11 +585,16 @@ void VisualShaderEditor::_update_graph() { } } - if (custom_editor && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) { + if (custom_editor && !scalar_uniform.is_valid() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) { //will be embedded in first port } else if (custom_editor) { + port_offset++; node->add_child(custom_editor); + if (scalar_uniform.is_valid()) { + custom_editor->call_deferred("_show_prop_names", true); + continue; + } custom_editor = NULL; } @@ -2972,6 +2980,13 @@ public: bool updating; Ref<VisualShaderNode> node; Vector<EditorProperty *> properties; + Vector<Label *> prop_names; + + void _show_prop_names(bool p_show) { + for (int i = 0; i < prop_names.size(); i++) { + prop_names[i]->set_visible(p_show); + } + } void setup(Ref<Resource> p_parent_resource, Vector<EditorProperty *> p_properties, const Vector<StringName> &p_names, Ref<VisualShaderNode> p_node) { parent_resource = p_parent_resource; @@ -2981,7 +2996,20 @@ public: for (int i = 0; i < p_properties.size(); i++) { - add_child(p_properties[i]); + HBoxContainer *hbox = memnew(HBoxContainer); + hbox->set_h_size_flags(SIZE_EXPAND_FILL); + add_child(hbox); + + Label *prop_name = memnew(Label); + String prop_name_str = p_names[i]; + prop_name_str = prop_name_str.capitalize() + ":"; + prop_name->set_text(prop_name_str); + prop_name->set_visible(false); + hbox->add_child(prop_name); + prop_names.push_back(prop_name); + + p_properties[i]->set_h_size_flags(SIZE_EXPAND_FILL); + hbox->add_child(p_properties[i]); bool res_prop = Object::cast_to<EditorPropertyResource>(p_properties[i]); if (res_prop) { @@ -3003,6 +3031,7 @@ public: ClassDB::bind_method("_refresh_request", &VisualShaderNodePluginDefaultEditor::_refresh_request); ClassDB::bind_method("_resource_selected", &VisualShaderNodePluginDefaultEditor::_resource_selected); ClassDB::bind_method("_open_inspector", &VisualShaderNodePluginDefaultEditor::_open_inspector); + ClassDB::bind_method("_show_prop_names", &VisualShaderNodePluginDefaultEditor::_show_prop_names); } }; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 8245264e0d..3c8fef6233 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -974,7 +974,7 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) { error_dialog->set_text(vformat(TTR("Failed to export the project for platform '%s'.\nThis might be due to a configuration issue in the export preset or your export settings."), platform->get_name())); } - ERR_PRINTS(vformat("Failed to export the project for platform '%s'.", platform->get_name())); + ERR_PRINT(vformat("Failed to export the project for platform '%s'.", platform->get_name())); error_dialog->show(); error_dialog->popup_centered_minsize(Size2(300, 80)); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 30e31cb530..9cc2a79399 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -163,7 +163,7 @@ private: } if (valid_path == "") { - set_message(TTR("The path does not exist."), MESSAGE_ERROR); + set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR); memdelete(d); get_ok()->set_disabled(true); return ""; @@ -177,7 +177,7 @@ private: } if (valid_install_path == "") { - set_message(TTR("The path does not exist."), MESSAGE_ERROR, INSTALL_PATH); + set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR, INSTALL_PATH); memdelete(d); get_ok()->set_disabled(true); return ""; @@ -195,7 +195,7 @@ private: unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io); if (!pkg) { - set_message(TTR("Error opening package file, not in ZIP format."), MESSAGE_ERROR); + set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR); memdelete(d); get_ok()->set_disabled(true); unzClose(pkg); @@ -216,7 +216,7 @@ private: } if (ret == UNZ_END_OF_LIST_OF_FILE) { - set_message(TTR("Invalid '.zip' project file, does not contain a 'project.godot' file."), MESSAGE_ERROR); + set_message(TTR("Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."), MESSAGE_ERROR); memdelete(d); get_ok()->set_disabled(true); unzClose(pkg); @@ -230,7 +230,11 @@ private: bool is_empty = true; String n = d->get_next(); while (n != String()) { - if (n != "." && n != "..") { + if (!n.begins_with(".")) { + // Allow `.`, `..` (reserved current/parent folder names) + // and hidden files/folders to be present. + // For instance, this lets users initialize a Git repository + // and still be able to create a project in the directory afterwards. is_empty = false; break; } @@ -247,7 +251,7 @@ private: } } else { - set_message(TTR("Please choose a 'project.godot' or '.zip' file."), MESSAGE_ERROR); + set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR); memdelete(d); install_path_container->hide(); get_ok()->set_disabled(true); @@ -256,7 +260,7 @@ private: } else if (valid_path.ends_with("zip")) { - set_message(TTR("Directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH); + set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH); memdelete(d); get_ok()->set_disabled(true); return ""; @@ -269,7 +273,11 @@ private: bool is_empty = true; String n = d->get_next(); while (n != String()) { - if (n != "." && n != "..") { // i don't know if this is enough to guarantee an empty dir + if (!n.begins_with(".")) { + // Allow `.`, `..` (reserved current/parent folder names) + // and hidden files/folders to be present. + // For instance, this lets users initialize a Git repository + // and still be able to create a project in the directory afterwards. is_empty = false; break; } @@ -332,7 +340,7 @@ private: install_path_container->show(); get_ok()->set_disabled(false); } else { - set_message(TTR("Please choose a 'project.godot' or '.zip' file."), MESSAGE_ERROR); + set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR); get_ok()->set_disabled(true); return; } @@ -877,7 +885,8 @@ public: rs_button->set_pressed(true); rvb->add_child(rs_button); l = memnew(Label); - l->set_text(TTR("Higher visual quality\nAll features available\nIncompatible with older hardware\nNot recommended for web games")); + l->set_text(TTR("- Higher visual quality\n- All features available\n- Incompatible with older hardware\n- Not recommended for web games")); + l->set_modulate(Color(1, 1, 1, 0.7)); rvb->add_child(l); rshb->add_child(memnew(VSeparator)); @@ -891,12 +900,17 @@ public: rs_button->set_meta("driver_name", "GLES2"); rvb->add_child(rs_button); l = memnew(Label); - l->set_text(TTR("Lower visual quality\nSome features not available\nWorks on most hardware\nRecommended for web games")); + l->set_text(TTR("- Lower visual quality\n- Some features not available\n- Works on most hardware\n- Recommended for web games")); + l->set_modulate(Color(1, 1, 1, 0.7)); rvb->add_child(l); l = memnew(Label); - l->set_text(TTR("Renderer can be changed later, but scenes may need to be adjusted.")); + l->set_text(TTR("The renderer can be changed later, but scenes may need to be adjusted.")); + // Add some extra spacing to separate it from the list above and the buttons below. + l->set_custom_minimum_size(Size2(0, 40) * EDSCALE); l->set_align(Label::ALIGN_CENTER); + l->set_valign(Label::VALIGN_CENTER); + l->set_modulate(Color(1, 1, 1, 0.7)); rasterizer_container->add_child(l); fdialog = memnew(FileDialog); @@ -1029,6 +1043,7 @@ public: void sort_projects(); int get_project_count() const; void select_project(int p_index); + void select_first_visible_project(); void erase_selected_projects(); Vector<Item> get_selected_projects() const; const Set<String> &get_selected_project_keys() const; @@ -1316,6 +1331,7 @@ void ProjectList::create_project_item_control(int p_index) { // The project icon may not be loaded by the time the control is displayed, // so use a loading placeholder. tf->set_texture(get_icon("ProjectIconLoading", "EditorIcons")); + tf->set_v_size_flags(SIZE_SHRINK_CENTER); if (item.missing) { tf->set_modulate(Color(1, 1, 1, 0.5)); } @@ -1620,6 +1636,23 @@ void ProjectList::select_project(int p_index) { toggle_select(p_index); } +void ProjectList::select_first_visible_project() { + bool found = false; + + for (int i = 0; i < _projects.size(); i++) { + if (_projects[i].control->is_visible()) { + select_project(i); + found = true; + break; + } + } + + if (!found) { + // Deselect all projects if there are no visible projects in the list. + _selected_project_keys.clear(); + } +} + inline void sort(int &a, int &b) { if (a > b) { int temp = a; @@ -2338,6 +2371,12 @@ void ProjectManager::_on_order_option_changed() { void ProjectManager::_on_filter_option_changed() { _project_list->set_search_term(project_filter->get_search_term()); _project_list->sort_projects(); + + // Select the first visible project in the list. + // This makes it possible to open a project without ever touching the mouse, + // as the search field is automatically focused on startup. + _project_list->select_first_visible_project(); + _update_project_buttons(); } void ProjectManager::_bind_methods() { diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index b656fd647f..6635f5cb47 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -719,9 +719,18 @@ void ProjectSettingsEditor::_update_actions() { item->set_range(1, action["deadzone"]); item->set_custom_bg_color(1, get_color("prop_subsection", "Editor")); + const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != NULL; + const String tooltip = is_builtin_input ? TTR("Built-in actions can't be removed as they're used for UI navigation.") : TTR("Remove"); item->add_button(2, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event")); - if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) { - item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove")); + item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, tooltip); + + if (is_builtin_input) { + // Built-in action (like `ui_up`). Make the action not removable, + // but still display the button so the "Add" button is at the same + // horizontal position as for custom actions. + item->set_button_disabled(2, 1, true); + } else { + // Not a built-in action. Make the action name editable. item->set_editable(0, true); } @@ -747,10 +756,9 @@ void ProjectSettingsEditor::_update_actions() { if (jb.is_valid()) { String str = _get_device_string(jb->get_device()) + ", " + TTR("Button") + " " + itos(jb->get_button_index()); - if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX) - str += String() + " (" + _button_names[jb->get_button_index()] + ")."; - else - str += "."; + if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX) { + str += String() + " (" + _button_names[jb->get_button_index()] + ")"; + } action2->set_text(0, str); action2->set_icon(0, get_icon("JoyButton", "EditorIcons")); @@ -761,12 +769,12 @@ void ProjectSettingsEditor::_update_actions() { if (mb.is_valid()) { String str = _get_device_string(mb->get_device()) + ", "; switch (mb->get_button_index()) { - case BUTTON_LEFT: str += TTR("Left Button."); break; - case BUTTON_RIGHT: str += TTR("Right Button."); break; - case BUTTON_MIDDLE: str += TTR("Middle Button."); break; - case BUTTON_WHEEL_UP: str += TTR("Wheel Up."); break; - case BUTTON_WHEEL_DOWN: str += TTR("Wheel Down."); break; - default: str += TTR("Button") + " " + itos(mb->get_button_index()) + "."; + case BUTTON_LEFT: str += TTR("Left Button"); break; + case BUTTON_RIGHT: str += TTR("Right Button"); break; + case BUTTON_MIDDLE: str += TTR("Middle Button"); break; + case BUTTON_WHEEL_UP: str += TTR("Wheel Up"); break; + case BUTTON_WHEEL_DOWN: str += TTR("Wheel Down"); break; + default: str += vformat(TTR("%d Button"), mb->get_button_index()); } action2->set_text(0, str); @@ -780,7 +788,7 @@ void ProjectSettingsEditor::_update_actions() { int ax = jm->get_axis(); int n = 2 * ax + (jm->get_axis_value() < 0 ? 0 : 1); String desc = _axis_names[n]; - String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc + "."; + String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc; action2->set_text(0, str); action2->set_icon(0, get_icon("JoyAxis", "EditorIcons")); } @@ -789,6 +797,10 @@ void ProjectSettingsEditor::_update_actions() { action2->add_button(2, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit")); action2->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove")); + // Fade out the individual event buttons slightly to make the + // Add/Remove buttons stand out more. + action2->set_button_color(2, 0, Color(1, 1, 1, 0.75)); + action2->set_button_color(2, 1, Color(1, 1, 1, 0.75)); } } diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 32fcdab4c6..317be309a3 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -109,9 +109,13 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und const int feature_min_height = 160 * EDSCALE; - CheckButton *chk_collapse_features = memnew(CheckButton); - chk_collapse_features->set_text(TTR("Advanced Options")); - vbc->add_child(chk_collapse_features); + cbut_regex = memnew(CheckButton); + cbut_regex->set_text(TTR("Use Regular Expressions")); + vbc->add_child(cbut_regex); + + CheckButton *cbut_collapse_features = memnew(CheckButton); + cbut_collapse_features->set_text(TTR("Advanced Options")); + vbc->add_child(cbut_collapse_features); tabc_features = memnew(TabContainer); tabc_features->set_tab_align(TabContainer::ALIGN_LEFT); @@ -195,7 +199,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und grd_substitute->add_child(but_insert_count); chk_per_level_counter = memnew(CheckBox); - chk_per_level_counter->set_text(TTR("Per Level counter")); + chk_per_level_counter->set_text(TTR("Per-level Counter")); chk_per_level_counter->set_tooltip(TTR("If set the counter restarts for each group of child nodes")); vbc_substitute->add_child(chk_per_level_counter); @@ -233,18 +237,6 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und spn_count_padding->set_step(1); hbc_count_options->add_child(spn_count_padding); - // ---- Tab RegEx - - VBoxContainer *vbc_regex = memnew(VBoxContainer); - vbc_regex->set_h_size_flags(SIZE_EXPAND_FILL); - vbc_regex->set_name(TTR("Regular Expressions")); - vbc_regex->set_custom_minimum_size(Size2(0, feature_min_height)); - tabc_features->add_child(vbc_regex); - - cbut_regex = memnew(CheckBox); - cbut_regex->set_text(TTR("Regular Expressions")); - vbc_regex->add_child(cbut_regex); - // ---- Tab Process VBoxContainer *vbc_process = memnew(VBoxContainer); @@ -268,8 +260,8 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und opt_style = memnew(OptionButton); opt_style->add_item(TTR("Keep")); - opt_style->add_item(TTR("CamelCase to under_scored")); - opt_style->add_item(TTR("under_scored to CamelCase")); + opt_style->add_item(TTR("PascalCase to snake_case")); + opt_style->add_item(TTR("snake_case to PascalCase")); hbc_style->add_child(opt_style); // ------ Case @@ -299,7 +291,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und lbl_preview = memnew(Label); lbl_preview->set_text(""); - lbl_preview->add_color_override("font_color", Color(1, 0.5f, 0, 1)); + lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); vbc->add_child(lbl_preview); // ---- Dialog related @@ -314,7 +306,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und // ---- Connections - chk_collapse_features->connect("toggled", this, "_features_toggled"); + cbut_collapse_features->connect("toggled", this, "_features_toggled"); // Substitite Buttons @@ -414,9 +406,12 @@ void RenameDialog::_update_preview(String new_text) { lbl_preview->set_text(new_name); if (new_name == preview_node->get_name()) { - lbl_preview->add_color_override("font_color", Color(0, 0.5f, 0.25f, 1)); + // New name is identical to the old one. Don't color it as much to avoid distracting the user. + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_color("accent_color", "Editor"); + const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_color("default_color", "RichTextLabel"); + lbl_preview->add_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5)); } else { - lbl_preview->add_color_override("font_color", Color(0, 1, 0.5f, 1)); + lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor")); } } @@ -501,9 +496,9 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * } self->has_errors = true; - self->lbl_preview_title->set_text(TTR("Error")); - self->lbl_preview->add_color_override("font_color", Color(1, 0.25f, 0, 1)); - self->lbl_preview->set_text(err_str); + self->lbl_preview_title->set_text(TTR("Regular Expression Error")); + self->lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + self->lbl_preview->set_text(vformat(TTR("At character %s"), err_str)); } String RenameDialog::_regex(const String &pattern, const String &subject, const String &replacement) { @@ -520,18 +515,18 @@ String RenameDialog::_postprocess(const String &subject) { String result = subject; if (style_id == 1) { + // PascalCase to snake_case - // CamelCase to Under_Line result = result.camelcase_to_underscore(true); result = _regex("_+", result, "_"); } else if (style_id == 2) { + // snake_case to PascalCase - // Under_Line to CamelCase RegEx pattern("_+(.?)"); Array matches = pattern.search_all(result); - // _ name would become empty. Ignore + // The name `_` would become empty; ignore it. if (matches.size() && result != "_") { String buffer; int start = 0; @@ -617,7 +612,7 @@ void RenameDialog::rename() { const String &new_name = to_rename[i].second; if (!n) { - ERR_PRINTS("Skipping missing node: " + to_rename[i].first.get_concatenated_subnames()); + ERR_PRINT("Skipping missing node: " + to_rename[i].first.get_concatenated_subnames()); continue; } diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 692e56f1a4..2825cb2cd2 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -75,7 +75,7 @@ class RenameDialog : public ConfirmationDialog { TabContainer *tabc_features; CheckBox *cbut_substitute; - CheckBox *cbut_regex; + CheckButton *cbut_regex; CheckBox *cbut_process; CheckBox *chk_per_level_counter; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index dca6087f8b..7410a998ad 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -981,7 +981,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!new_node) { new_node = memnew(Node); - ERR_PRINTS("Creating root from favorite '" + selected_favorite_root + "' failed. Creating 'Node' instead."); + ERR_PRINT("Creating root from favorite '" + selected_favorite_root + "' failed. Creating 'Node' instead."); } } else { switch (p_tool) { diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 35d5fe5f70..c4627e6627 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -84,7 +84,9 @@ void ScriptCreateDialog::_path_hbox_sorted() { int filename_start_pos = initial_bp.find_last("/") + 1; int filename_end_pos = initial_bp.length(); - file_path->select(filename_start_pos, filename_end_pos); + if (!is_built_in) { + file_path->select(filename_start_pos, filename_end_pos); + } // First set cursor to the end of line to scroll LineEdit view // to the right and then set the actual cursor position. @@ -575,6 +577,10 @@ void ScriptCreateDialog::_browse_class_in_tree() { void ScriptCreateDialog::_path_changed(const String &p_path) { + if (is_built_in) { + return; + } + is_path_valid = false; is_new_script_created = true; @@ -644,7 +650,7 @@ void ScriptCreateDialog::_update_dialog() { } if (script_ok) { - _msg_script_valid(true, TTR("Script is valid.")); + _msg_script_valid(true, TTR("Script path/name is valid.")); } // Does script have named classes? diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 71a946b256..34547717fd 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -338,7 +338,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err != OK) { - ERR_PRINTS("Failed to open " + p_file); + ERR_PRINT("Failed to open " + p_file); return; } Vector<String> line; @@ -484,8 +484,10 @@ int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &node void ScriptEditorDebugger::_video_mem_request() { - ERR_FAIL_COND(connection.is_null()); - ERR_FAIL_COND(!connection->is_connected_to_host()); + if (connection.is_null() || !connection->is_connected_to_host()) { + // Video RAM usage is only available while a project is being debugged. + return; + } Array msg; msg.push_back("request_video_mem"); @@ -806,25 +808,25 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da p.write[i] = arr[i]; if (i < perf_items.size()) { - float v = p[i]; - String vs = rtos(v); - String tt = vs; + const float value = p[i]; + String label = rtos(value); + String tooltip = label; switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) { case Performance::MONITOR_TYPE_MEMORY: { - vs = String::humanize_size(v); - tt = vs; + label = String::humanize_size(value); + tooltip = label; } break; case Performance::MONITOR_TYPE_TIME: { - tt += " seconds"; - vs += " s"; + label = rtos(value * 1000).pad_decimals(2) + " ms"; + tooltip = label; } break; default: { - tt += " " + perf_items[i]->get_text(0); + tooltip += " " + perf_items[i]->get_text(0); } break; } - perf_items[i]->set_text(1, vs); - perf_items[i]->set_tooltip(1, tt); + perf_items[i]->set_text(1, label); + perf_items[i]->set_tooltip(1, tooltip); if (p[i] > perf_max[i]) perf_max.write[i] = p[i]; } @@ -1323,6 +1325,7 @@ void ScriptEditorDebugger::_notification(int p_what) { inspect_scene_tree->clear(); le_set->set_disabled(true); le_clear->set_disabled(false); + vmem_refresh->set_disabled(false); error_tree->clear(); error_count = 0; warning_count = 0; @@ -1523,6 +1526,7 @@ void ScriptEditorDebugger::stop() { le_clear->set_disabled(false); le_set->set_disabled(true); profiler->set_enabled(true); + vmem_refresh->set_disabled(true); inspect_scene_tree->clear(); inspector->edit(NULL); @@ -1622,6 +1626,7 @@ void ScriptEditorDebugger::_output_clear() { void ScriptEditorDebugger::_export_csv() { file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_mode = SAVE_CSV; file_dialog->popup_centered_ratio(); } @@ -2187,6 +2192,13 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { } } +void ScriptEditorDebugger::_tab_changed(int p_tab) { + if (tabs->get_tab_title(p_tab) == TTR("Video RAM")) { + // "Video RAM" tab was clicked, refresh the data it's dislaying when entering the tab. + _video_mem_request(); + } +} + void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); @@ -2218,6 +2230,7 @@ void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_error_tree_item_rmb_selected"), &ScriptEditorDebugger::_error_tree_item_rmb_selected); ClassDB::bind_method(D_METHOD("_item_menu_id_pressed"), &ScriptEditorDebugger::_item_menu_id_pressed); + ClassDB::bind_method(D_METHOD("_tab_changed"), &ScriptEditorDebugger::_tab_changed); ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused); @@ -2258,13 +2271,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles")); tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles")); tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles")); + tabs->connect("tab_changed", this, "_tab_changed"); add_child(tabs); { //debugger VBoxContainer *vbc = memnew(VBoxContainer); vbc->set_name(TTR("Debugger")); - //tabs->add_child(vbc); Control *dbg = vbc; HBoxContainer *hbc = memnew(HBoxContainer); @@ -2522,6 +2535,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { vmem_total->set_custom_minimum_size(Size2(100, 0) * EDSCALE); vmem_hb->add_child(vmem_total); vmem_refresh = memnew(ToolButton); + vmem_refresh->set_disabled(true); vmem_hb->add_child(vmem_refresh); vmem_vb->add_child(vmem_hb); vmem_refresh->connect("pressed", this, "_video_mem_request"); @@ -2534,20 +2548,20 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { vmmc->set_v_size_flags(SIZE_EXPAND_FILL); vmem_vb->add_child(vmmc); - vmem_vb->set_name(TTR("Video Mem")); + vmem_vb->set_name(TTR("Video RAM")); vmem_tree->set_columns(4); vmem_tree->set_column_titles_visible(true); vmem_tree->set_column_title(0, TTR("Resource Path")); vmem_tree->set_column_expand(0, true); vmem_tree->set_column_expand(1, false); vmem_tree->set_column_title(1, TTR("Type")); - vmem_tree->set_column_min_width(1, 100); + vmem_tree->set_column_min_width(1, 100 * EDSCALE); vmem_tree->set_column_expand(2, false); vmem_tree->set_column_title(2, TTR("Format")); - vmem_tree->set_column_min_width(2, 150); + vmem_tree->set_column_min_width(2, 150 * EDSCALE); vmem_tree->set_column_expand(3, false); vmem_tree->set_column_title(3, TTR("Usage")); - vmem_tree->set_column_min_width(3, 80); + vmem_tree->set_column_min_width(3, 80 * EDSCALE); vmem_tree->set_hide_root(true); tabs->add_child(vmem_vb); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index 7d91e247b6..589a011bff 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -226,6 +226,7 @@ private: void _error_tree_item_rmb_selected(const Vector2 &p_pos); void _item_menu_id_pressed(int p_option); + void _tab_changed(int p_tab); void _export_csv(); |