diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_track_editor.cpp | 4 | ||||
-rw-r--r-- | editor/editor_command_palette.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 32 | ||||
-rw-r--r-- | editor/editor_node.h | 16 | ||||
-rw-r--r-- | editor/editor_resource_picker.cpp | 146 | ||||
-rw-r--r-- | editor/editor_resource_picker.h | 1 | ||||
-rw-r--r-- | editor/import/dynamic_font_import_settings.cpp | 7 | ||||
-rw-r--r-- | editor/project_converter_3_to_4.cpp | 2 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 1 |
9 files changed, 129 insertions, 82 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index c2e04e4be9..8919d23982 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1445,7 +1445,9 @@ void AnimationTimelineEdit::_anim_loop_pressed() { default: break; } + undo_redo->add_do_method(this, "update_values"); undo_redo->add_undo_method(animation.ptr(), "set_loop_mode", animation->get_loop_mode()); + undo_redo->add_undo_method(this, "update_values"); undo_redo->commit_action(); } else { String base_path = animation->get_path(); @@ -1913,6 +1915,8 @@ void AnimationTimelineEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "drag"), PropertyInfo(Variant::BOOL, "timeline_only"))); ADD_SIGNAL(MethodInfo("track_added", PropertyInfo(Variant::INT, "track"))); ADD_SIGNAL(MethodInfo("length_changed", PropertyInfo(Variant::FLOAT, "size"))); + + ClassDB::bind_method(D_METHOD("update_values"), &AnimationTimelineEdit::update_values); } AnimationTimelineEdit::AnimationTimelineEdit() { diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index ba1f2fd6af..a0913265eb 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -130,7 +130,7 @@ void EditorCommandPalette::_update_command_search(const String &search_text) { ti->set_metadata(0, entries[i].key_name); ti->set_text_alignment(1, HORIZONTAL_ALIGNMENT_RIGHT); ti->set_text(1, shortcut_text); - Color c = Color(1, 1, 1, 0.5); + Color c = get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5); ti->set_custom_color(1, c); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 8eaddcb7e1..cf24195b5b 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2763,18 +2763,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } else if (extensions.size()) { String root_name = scene->get_name(); - // Very similar to node naming logic. - switch (ProjectSettings::get_singleton()->get("editor/scene/scene_naming").operator int()) { - case SCENE_NAME_CASING_AUTO: - // Use casing of the root node. - break; - case SCENE_NAME_CASING_PASCAL_CASE: { - root_name = root_name.to_pascal_case(); - } break; - case SCENE_NAME_CASING_SNAKE_CASE: - root_name = root_name.replace("-", "_").to_snake_case(); - break; - } + root_name = EditorNode::adjust_scene_name_casing(root_name); file->set_current_path(root_name + "." + extensions.front()->get().to_lower()); } file->popup_file_dialog(); @@ -3090,6 +3079,19 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } +String EditorNode::adjust_scene_name_casing(const String &root_name) { + switch (ProjectSettings::get_singleton()->get("editor/scene/scene_naming").operator int()) { + case SCENE_NAME_CASING_AUTO: + // Use casing of the root node. + break; + case SCENE_NAME_CASING_PASCAL_CASE: + return root_name.to_pascal_case(); + case SCENE_NAME_CASING_SNAKE_CASE: + return root_name.replace("-", "_").to_snake_case(); + } + return root_name; +} + void EditorNode::_request_screenshot() { _screenshot(); } @@ -3668,10 +3670,6 @@ bool EditorNode::is_changing_scene() const { return changing_scene; } -void EditorNode::_clear_undo_history() { - get_undo_redo()->clear_history(false); -} - void EditorNode::set_current_scene(int p_idx) { // Save the folding in case the scene gets reloaded. if (editor_data.get_scene_path(p_idx) != "" && editor_data.get_edited_scene_root(p_idx)) { @@ -5981,8 +5979,6 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state); ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes); - ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history); - ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource); ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base); diff --git a/editor/editor_node.h b/editor/editor_node.h index 200d68908c..b0299744f1 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -125,6 +125,12 @@ public: EDITOR_ASSETLIB }; + enum SceneNameCasing { + SCENE_NAME_CASING_AUTO, + SCENE_NAME_CASING_PASCAL_CASE, + SCENE_NAME_CASING_SNAKE_CASE + }; + struct ExecuteThreadArgs { String path; List<String> args; @@ -233,12 +239,6 @@ private: MAX_BUILD_CALLBACKS = 128 }; - enum ScriptNameCasing { - SCENE_NAME_CASING_AUTO, - SCENE_NAME_CASING_PASCAL_CASE, - SCENE_NAME_CASING_SNAKE_CASE - }; - struct BottomPanelItem { String name; Control *control = nullptr; @@ -658,8 +658,6 @@ private: void _update_layouts_menu(); void _layout_menu_option(int p_id); - void _clear_undo_history(); - void _update_addon_config(); void _toggle_distraction_free_mode(); @@ -720,6 +718,8 @@ public: static HBoxContainer *get_menu_hb() { return singleton->menu_hb; } static VSplitContainer *get_top_split() { return singleton->top_split; } + static String adjust_scene_name_casing(const String &root_name); + static bool has_unsaved_changes() { return singleton->unsaved_cache; } static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames); static void add_io_error(const String &p_error); diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 84cb085551..de8259c25c 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -53,6 +53,7 @@ void EditorResourcePicker::_update_resource() { if (edited_resource.is_valid() && edited_resource->get_path().is_resource_file()) { resource_path = edited_resource->get_path() + "\n"; } + String class_name = _get_resource_type(edited_resource); if (preview_rect) { preview_rect->set_texture(Ref<Texture2D>()); @@ -64,16 +65,20 @@ void EditorResourcePicker::_update_resource() { assign_button->set_text(TTR("<empty>")); assign_button->set_tooltip_text(""); } else { - assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), "Object")); + assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), SNAME("Object"))); if (!edited_resource->get_name().is_empty()) { assign_button->set_text(edited_resource->get_name()); } else if (edited_resource->get_path().is_resource_file()) { assign_button->set_text(edited_resource->get_path().get_file()); } else { - assign_button->set_text(edited_resource->get_class()); + assign_button->set_text(class_name); } - assign_button->set_tooltip_text(resource_path + TTR("Type:") + " " + edited_resource->get_class()); + + if (edited_resource->get_path().is_resource_file()) { + resource_path = edited_resource->get_path() + "\n"; + } + assign_button->set_tooltip_text(resource_path + TTR("Type:") + " " + class_name); // Preview will override the above, so called at the end. EditorResourcePreview::get_singleton()->queue_edited_resource_preview(edited_resource, this, "_update_resource_preview", edited_resource->get_instance_id()); @@ -134,16 +139,29 @@ void EditorResourcePicker::_file_selected(const String &p_path) { if (!base_type.is_empty()) { bool any_type_matches = false; + String res_type = loaded_resource->get_class(); + Ref<Script> res_script = loaded_resource->get_script(); + bool is_global_class = false; + if (res_script.is_valid()) { + String script_type = EditorNode::get_editor_data().script_class_get_name(res_script->get_path()); + if (!script_type.is_empty()) { + is_global_class = true; + res_type = script_type; + } + } + for (int i = 0; i < base_type.get_slice_count(","); i++) { String base = base_type.get_slice(",", i); - if (loaded_resource->is_class(base)) { - any_type_matches = true; + + any_type_matches = is_global_class ? EditorNode::get_editor_data().script_class_is_parent(res_type, base) : loaded_resource->is_class(base); + + if (!any_type_matches) { break; } } if (!any_type_matches) { - EditorNode::get_singleton()->show_warning(vformat(TTR("The selected resource (%s) does not match any type expected for this property (%s)."), loaded_resource->get_class(), base_type)); + EditorNode::get_singleton()->show_warning(vformat(TTR("The selected resource (%s) does not match any type expected for this property (%s)."), res_type, base_type)); return; } } @@ -227,16 +245,19 @@ void EditorResourcePicker::_update_menu_items() { // Add options to copy/paste resource. Ref<Resource> cb = EditorSettings::get_singleton()->get_resource_clipboard(); bool paste_valid = false; - if (is_editable()) { - if (cb.is_valid()) { - if (base_type.is_empty()) { - paste_valid = true; - } else { - for (int i = 0; i < base_type.get_slice_count(","); i++) { - if (ClassDB::is_parent_class(cb->get_class(), base_type.get_slice(",", i))) { - paste_valid = true; - break; - } + if (is_editable() && cb.is_valid()) { + if (base_type.is_empty()) { + paste_valid = true; + } else { + String res_type = _get_resource_type(cb); + + for (int i = 0; i < base_type.get_slice_count(","); i++) { + String base = base_type.get_slice(",", i); + + paste_valid = ClassDB::is_parent_class(res_type, base) || EditorNode::get_editor_data().script_class_is_parent(res_type, base); + + if (!paste_valid) { + break; } } } @@ -281,6 +302,9 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { for (int i = 0; i < base_type.get_slice_count(","); i++) { String base = base_type.get_slice(",", i); ResourceLoader::get_recognized_extensions_for_type(base, &extensions); + if (ScriptServer::is_global_class(base)) { + ResourceLoader::get_recognized_extensions_for_type(ScriptServer::get_global_class_native_base(base), &extensions); + } } HashSet<String> valid_extensions; @@ -408,13 +432,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { Variant obj; if (ScriptServer::is_global_class(intype)) { - obj = ClassDB::instantiate(ScriptServer::get_global_class_native_base(intype)); - if (obj) { - Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(intype)); - if (script.is_valid()) { - ((Object *)obj)->set_script(script); - } - } + obj = EditorNode::get_editor_data().script_class_instance(intype); } else { obj = ClassDB::instantiate(intype); } @@ -512,23 +530,40 @@ void EditorResourcePicker::_button_draw() { void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; - if (mb.is_valid()) { - if (mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) { - // Only attempt to update and show the menu if we have - // a valid resource or the Picker is editable, as - // there will otherwise be nothing to display. - if (edited_resource.is_valid() || is_editable()) { - _update_menu_items(); - - Vector2 pos = get_screen_position() + mb->get_position(); - edit_menu->reset_size(); - edit_menu->set_position(pos); - edit_menu->popup(); - } + if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) { + // Only attempt to update and show the menu if we have + // a valid resource or the Picker is editable, as + // there will otherwise be nothing to display. + if (edited_resource.is_valid() || is_editable()) { + _update_menu_items(); + + Vector2 pos = get_screen_position() + mb->get_position(); + edit_menu->reset_size(); + edit_menu->set_position(pos); + edit_menu->popup(); } } } +String EditorResourcePicker::_get_resource_type(const Ref<Resource> &p_resource) const { + if (p_resource.is_null()) { + return String(); + } + String res_type = p_resource->get_class(); + + Ref<Script> res_script = p_resource->get_script(); + if (res_script.is_null()) { + return res_type; + } + + // TODO: Replace with EditorFileSystem when PR #60606 is merged to use cached resource type. + String script_type = EditorNode::get_editor_data().script_class_get_name(res_script->get_path()); + if (!script_type.is_empty()) { + res_type = script_type; + } + return res_type; +} + void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const { Vector<String> allowed_types = base_type.split(","); int size = allowed_types.size(); @@ -550,7 +585,9 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSet<Strin List<StringName> allowed_subtypes; List<StringName> inheriters; - ClassDB::get_inheriters_from_class(base, &inheriters); + if (!ScriptServer::is_global_class(base)) { + ClassDB::get_inheriters_from_class(base, &inheriters); + } for (const StringName &subtype_name : inheriters) { p_vector->insert(subtype_name); allowed_subtypes.push_back(subtype_name); @@ -602,32 +639,29 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { } } else if (drag_data.has("type") && String(drag_data["type"]) == "resource") { res = drag_data["resource"]; + } else if (drag_data.has("type") && String(drag_data["type"]) == "files") { + Vector<String> files = drag_data["files"]; + + // TODO: Extract the typename of the dropped filepath's resource in a more performant way, without fully loading it. + if (files.size() == 1) { + String file = files[0]; + res = ResourceLoader::load(file); + } } HashSet<String> allowed_types; _get_allowed_types(true, &allowed_types); - if (res.is_valid() && _is_type_valid(res->get_class(), allowed_types)) { - return true; - } + if (res.is_valid()) { + String res_type = _get_resource_type(res); - if (res.is_valid() && res->get_script()) { - StringName custom_class = EditorNode::get_singleton()->get_object_custom_type_name(res->get_script()); - if (_is_type_valid(custom_class, allowed_types)) { + if (_is_type_valid(res_type, allowed_types)) { return true; } - } - - if (drag_data.has("type") && String(drag_data["type"]) == "files") { - Vector<String> files = drag_data["files"]; - - if (files.size() == 1) { - String file = files[0]; - String file_type = EditorFileSystem::get_singleton()->get_file_type(file); - if (!file_type.is_empty() && _is_type_valid(file_type, allowed_types)) { - return true; - } + StringName custom_class = EditorNode::get_singleton()->get_object_custom_type_name(res.ptr()); + if (_is_type_valid(custom_class, allowed_types)) { + return true; } } @@ -685,8 +719,10 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ HashSet<String> allowed_types; _get_allowed_types(false, &allowed_types); + String res_type = _get_resource_type(dropped_resource); + // If the accepted dropped resource is from the extended list, it requires conversion. - if (!_is_type_valid(dropped_resource->get_class(), allowed_types)) { + if (!_is_type_valid(res_type, allowed_types)) { for (const String &E : allowed_types) { String at = E.strip_edges(); diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index 3d6127e656..d1a20f04b7 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -91,6 +91,7 @@ class EditorResourcePicker : public HBoxContainer { void _button_draw(); void _button_input(const Ref<InputEvent> &p_event); + String _get_resource_type(const Ref<Resource> &p_resource) const; void _get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const; bool _is_drop_valid(const Dictionary &p_drag_data) const; bool _is_type_valid(const String p_type_name, HashSet<String> p_allowed_types) const; diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index d1f37179f3..c1761339b2 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -302,6 +302,7 @@ static UniRange unicode_ranges[] = { { 0x10D00, 0x10D3F, U"Hanifi Rohingya" }, { 0x10E60, 0x10E7F, U"Rumi Numeral Symbols" }, { 0x10E80, 0x10EBF, U"Yezidi" }, + { 0x10EC0, 0x10EFF, U"Arabic Extended-C" }, { 0x10F00, 0x10F2F, U"Old Sogdian" }, { 0x10F30, 0x10F6F, U"Sogdian" }, { 0x10F70, 0x10FAF, U"Old Uyghur" }, @@ -333,11 +334,13 @@ static UniRange unicode_ranges[] = { { 0x11A50, 0x11AAF, U"Soyombo" }, { 0x11AB0, 0x11ABF, U"Unified Canadian Aboriginal Syllabics Extended-A" }, { 0x11AC0, 0x11AFF, U"Pau Cin Hau" }, + { 0x11B00, 0x11B5F, U"Devanagari Extended-A" }, { 0x11C00, 0x11C6F, U"Bhaiksuki" }, { 0x11C70, 0x11CBF, U"Marchen" }, { 0x11D00, 0x11D5F, U"Masaram Gondi" }, { 0x11D60, 0x11DAF, U"Gunjala Gondi" }, { 0x11EE0, 0x11EFF, U"Makasar" }, + { 0x11F00, 0x11F5F, U"Kawi" }, { 0x11FB0, 0x11FBF, U"Lisu Supplement" }, { 0x11FC0, 0x11FFF, U"Tamil Supplement" }, { 0x12000, 0x123FF, U"Cuneiform" }, @@ -370,6 +373,7 @@ static UniRange unicode_ranges[] = { { 0x1D000, 0x1D0FF, U"Byzantine Musical Symbols" }, { 0x1D100, 0x1D1FF, U"Musical Symbols" }, { 0x1D200, 0x1D24F, U"Ancient Greek Musical Notation" }, + { 0x1D2C0, 0x1D2DF, U"Kaktovik Numerals" }, { 0x1D2E0, 0x1D2FF, U"Mayan Numerals" }, { 0x1D300, 0x1D35F, U"Tai Xuan Jing Symbols" }, { 0x1D360, 0x1D37F, U"Counting Rod Numerals" }, @@ -377,9 +381,11 @@ static UniRange unicode_ranges[] = { { 0x1D800, 0x1DAAF, U"Sutton SignWriting" }, { 0x1DF00, 0x1DFFF, U"Latin Extended-G" }, { 0x1E000, 0x1E02F, U"Glagolitic Supplement" }, + { 0x1E030, 0x1E08F, U"Cyrillic Extended-D" }, { 0x1E100, 0x1E14F, U"Nyiakeng Puachue Hmong" }, { 0x1E290, 0x1E2BF, U"Toto" }, { 0x1E2C0, 0x1E2FF, U"Wancho" }, + { 0x1E4D0, 0x1E4FF, U"Nag Mundari" }, { 0x1E7E0, 0x1E7FF, U"Ethiopic Extended-B" }, { 0x1E800, 0x1E8DF, U"Mende Kikakui" }, { 0x1E900, 0x1E95F, U"Adlam" }, @@ -409,6 +415,7 @@ static UniRange unicode_ranges[] = { { 0x2CEB0, 0x2EBEF, U"CJK Unified Ideographs Extension F" }, { 0x2F800, 0x2FA1F, U"CJK Compatibility Ideographs Supplement" }, { 0x30000, 0x3134F, U"CJK Unified Ideographs Extension G" }, + { 0x31350, 0x323AF, U"CJK Unified Ideographs Extension H" }, //{ 0xE0000, 0xE007F, U"Tags" }, //{ 0xE0100, 0xE01EF, U"Variation Selectors Supplement" }, { 0xF0000, 0xFFFFF, U"Supplementary Private Use Area-A" }, diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index 39b30b31fb..3d46864b02 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -3950,6 +3950,8 @@ String ProjectConverter3To4::collect_string_from_vector(Vector<String> &vector) #else // No RegEx. +ProjectConverter3To4::ProjectConverter3To4(int _p_maximum_file_size_kb, int _p_maximum_line_length) {} + int ProjectConverter3To4::convert() { ERR_FAIL_V_MSG(ERROR_CODE, "Can't run converter for Godot 3.x projects, because RegEx module is disabled."); } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a437245c57..7714df9c4e 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -916,6 +916,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { String existing; if (extensions.size()) { String root_name(tocopy->get_name()); + root_name = EditorNode::adjust_scene_name_casing(root_name); existing = root_name + "." + extensions.front()->get().to_lower(); } new_scene_from_dialog->set_current_path(existing); |