diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_file_system.cpp | 55 | ||||
-rw-r--r-- | editor/editor_file_system.h | 36 | ||||
-rw-r--r-- | editor/editor_node.cpp | 1 | ||||
-rw-r--r-- | editor/editor_property_name_processor.cpp | 13 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 7 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 47 | ||||
-rwxr-xr-x | editor/translations/extract.py | 10 |
9 files changed, 165 insertions, 9 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index f3d9449c6c..2b98a4b02a 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -520,6 +520,45 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return false; //nothing changed } +bool EditorFileSystem::_scan_import_support(Vector<String> reimports) { + if (import_support_queries.size() == 0) { + return false; + } + Map<String, int> import_support_test; + Vector<bool> import_support_tested; + import_support_tested.resize(import_support_queries.size()); + for (int i = 0; i < import_support_queries.size(); i++) { + import_support_tested.write[i] = false; + if (import_support_queries[i]->is_active()) { + Vector<String> extensions = import_support_queries[i]->get_file_extensions(); + for (int j = 0; j < extensions.size(); j++) { + import_support_test.insert(extensions[j], i); + } + } + } + + if (import_support_test.size() == 0) { + return false; //well nothing to do + } + + for (int i = 0; i < reimports.size(); i++) { + Map<String, int>::Element *E = import_support_test.find(reimports[i].get_extension()); + if (E) { + import_support_tested.write[E->get()] = true; + } + } + + for (int i = 0; i < import_support_tested.size(); i++) { + if (import_support_tested[i]) { + if (import_support_queries.write[i]->query()) { + return true; + } + } + } + + return false; +} + bool EditorFileSystem::_update_scan_actions() { sources_changed.clear(); @@ -612,7 +651,7 @@ bool EditorFileSystem::_update_scan_actions() { if (_scan_extensions()) { //needs editor restart //extensions also may provide filetypes to be imported, so they must run before importing - if (EditorNode::immediate_confirmation_dialog(TTR("Some extensions need the editor to restart to take effect."), first_scan ? TTR("Restart") : TTR("Save&Restart"), TTR("Continue"))) { + if (EditorNode::immediate_confirmation_dialog(TTR("Some extensions need the editor to restart to take effect."), first_scan ? TTR("Restart") : TTR("Save & Restart"), TTR("Continue"))) { if (!first_scan) { EditorNode::get_singleton()->save_all_scenes(); } @@ -621,7 +660,12 @@ bool EditorFileSystem::_update_scan_actions() { return true; } } + if (reimports.size()) { + if (_scan_import_support(reimports)) { + return true; + } + reimport_files(reimports); } else { //reimport files will update the uid cache file so if nothing was reimported, update it manually @@ -2274,6 +2318,7 @@ static void _scan_extensions_dir(EditorFileSystemDirectory *d, Set<String> &exte bool EditorFileSystem::_scan_extensions() { EditorFileSystemDirectory *d = get_filesystem(); Set<String> extensions; + _scan_extensions_dir(d, extensions); //verify against loaded extensions @@ -2374,6 +2419,14 @@ void EditorFileSystem::_update_extensions() { } } +void EditorFileSystem::add_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) { + ERR_FAIL_COND(import_support_queries.find(p_query) != -1); + import_support_queries.push_back(p_query); +} +void EditorFileSystem::remove_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) { + import_support_queries.erase(p_query); +} + EditorFileSystem::EditorFileSystem() { ResourceLoader::import = _resource_import; reimport_on_missing_imported_files = GLOBAL_DEF("editor/import/reimport_missing_imported_files", true); diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 0ec0094030..0ddac65839 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -109,6 +109,37 @@ public: ~EditorFileSystemDirectory(); }; +class EditorFileSystemImportFormatSupportQuery : public RefCounted { + GDCLASS(EditorFileSystemImportFormatSupportQuery, RefCounted); + +protected: + GDVIRTUAL0RC(bool, _is_active) + GDVIRTUAL0RC(Vector<String>, _get_file_extensions) + GDVIRTUAL0RC(bool, _query) + static void _bind_methods() { + GDVIRTUAL_BIND(_is_active); + GDVIRTUAL_BIND(_get_file_extensions); + GDVIRTUAL_BIND(_query); + } + +public: + virtual bool is_active() const { + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_is_active, ret); + return ret; + } + virtual Vector<String> get_file_extensions() const { + Vector<String> ret; + GDVIRTUAL_REQUIRED_CALL(_get_file_extensions, ret); + return ret; + } + virtual bool query() { + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_query, ret); + return ret; + } +}; + class EditorFileSystem : public Node { GDCLASS(EditorFileSystem, Node); @@ -257,6 +288,9 @@ class EditorFileSystem : public Node { static ResourceUID::ID _resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate); bool _scan_extensions(); + bool _scan_import_support(Vector<String> reimports); + + Vector<Ref<EditorFileSystemImportFormatSupportQuery>> import_support_queries; protected: void _notification(int p_what); @@ -289,6 +323,8 @@ public: static bool _should_skip_directory(const String &p_path); + void add_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query); + void remove_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query); EditorFileSystem(); ~EditorFileSystem(); }; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 25e3bc8d6a..52f7366dd7 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3920,6 +3920,7 @@ void EditorNode::register_editor_types() { GDREGISTER_CLASS(EditorScriptPicker); GDREGISTER_ABSTRACT_CLASS(FileSystemDock); + GDREGISTER_VIRTUAL_CLASS(EditorFileSystemImportFormatSupportQuery); GDREGISTER_CLASS(EditorScenePostImport); GDREGISTER_CLASS(EditorCommandPalette); diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index 5e6c35806c..5b5d451df9 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -117,17 +117,23 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["bvh"] = "BVH"; capitalize_string_remaps["ca"] = "CA"; capitalize_string_remaps["cd"] = "CD"; + capitalize_string_remaps["commentfocus"] = "Comment Focus"; capitalize_string_remaps["cpu"] = "CPU"; capitalize_string_remaps["csg"] = "CSG"; capitalize_string_remaps["db"] = "dB"; + capitalize_string_remaps["defaultfocus"] = "Default Focus"; + capitalize_string_remaps["defaultframe"] = "Default Frame"; capitalize_string_remaps["dof"] = "DoF"; capitalize_string_remaps["dpi"] = "DPI"; capitalize_string_remaps["dtls"] = "DTLS"; + capitalize_string_remaps["eol"] = "EOL"; capitalize_string_remaps["erp"] = "ERP"; capitalize_string_remaps["etc"] = "ETC"; capitalize_string_remaps["etc2"] = "ETC2"; capitalize_string_remaps["fbx"] = "FBX"; + capitalize_string_remaps["fbx2gltf"] = "FBX2glTF"; capitalize_string_remaps["fft"] = "FFT"; + capitalize_string_remaps["fg"] = "FG"; capitalize_string_remaps["fov"] = "FOV"; capitalize_string_remaps["fps"] = "FPS"; capitalize_string_remaps["fs"] = "FS"; @@ -145,6 +151,8 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["hdr"] = "HDR"; capitalize_string_remaps["hidpi"] = "hiDPI"; capitalize_string_remaps["hipass"] = "High-pass"; + capitalize_string_remaps["hl"] = "HL"; + capitalize_string_remaps["hseparation"] = "H Separation"; capitalize_string_remaps["hsv"] = "HSV"; capitalize_string_remaps["html"] = "HTML"; capitalize_string_remaps["http"] = "HTTP"; @@ -177,6 +185,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["msaa"] = "MSAA"; capitalize_string_remaps["nfc"] = "NFC"; capitalize_string_remaps["normalmap"] = "Normal Map"; + capitalize_string_remaps["ofs"] = "Offset"; capitalize_string_remaps["ok"] = "OK"; capitalize_string_remaps["opengl"] = "OpenGL"; capitalize_string_remaps["opentype"] = "OpenType"; @@ -195,6 +204,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["sdfgi"] = "SDFGI"; capitalize_string_remaps["sdk"] = "SDK"; capitalize_string_remaps["sec"] = "(sec)"; // Unit. + capitalize_string_remaps["selectedframe"] = "Selected Frame"; capitalize_string_remaps["sms"] = "SMS"; capitalize_string_remaps["srgb"] = "sRGB"; capitalize_string_remaps["ssao"] = "SSAO"; @@ -203,6 +213,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["ssl"] = "SSL"; capitalize_string_remaps["stderr"] = "stderr"; capitalize_string_remaps["stdout"] = "stdout"; + capitalize_string_remaps["sv"] = "SV"; capitalize_string_remaps["svg"] = "SVG"; capitalize_string_remaps["tcp"] = "TCP"; capitalize_string_remaps["ui"] = "UI"; @@ -216,9 +227,11 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["uv1"] = "UV1"; capitalize_string_remaps["uv2"] = "UV2"; capitalize_string_remaps["uwp"] = "UWP"; + capitalize_string_remaps["vadjust"] = "V Adjust"; capitalize_string_remaps["vector2"] = "Vector2"; capitalize_string_remaps["vpn"] = "VPN"; capitalize_string_remaps["vram"] = "VRAM"; + capitalize_string_remaps["vseparation"] = "V Separation"; capitalize_string_remaps["vsync"] = "V-Sync"; capitalize_string_remaps["wap"] = "WAP"; capitalize_string_remaps["webp"] = "WebP"; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 1364f7891e..66bbb79de8 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -542,7 +542,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/behavior/navigation/move_caret_on_right_click", true); _initial_set("text_editor/behavior/navigation/scroll_past_end_of_file", false); _initial_set("text_editor/behavior/navigation/smooth_scrolling", true); - _initial_set("text_editor/behavior/navigation/v_scroll_speed", 80); + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/behavior/navigation/v_scroll_speed", 80, "1,10000,1") // Behavior: Indent EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/behavior/indent/type", 0, "Tabs,Spaces") diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bbaf2bef98..677b55bb88 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1232,9 +1232,6 @@ void ScriptEditor::_menu_option(int p_option) { if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { if (!EditorNode::get_singleton()->is_scene_open(res_path)) { EditorNode::get_singleton()->load_scene(res_path); - script_editor->call_deferred(SNAME("_menu_option"), p_option); - previous_scripts.push_back(path); //repeat the operation - return; } } else { EditorNode::get_singleton()->load_resource(res_path); @@ -1250,7 +1247,6 @@ void ScriptEditor::_menu_option(int p_option) { edit(scr); file_dialog_option = -1; - return; } else { Error error; Ref<TextFile> text_file = _load_text_file(path, &error); @@ -1261,7 +1257,6 @@ void ScriptEditor::_menu_option(int p_option) { if (text_file.is_valid()) { edit(text_file); file_dialog_option = -1; - return; } } } break; @@ -3960,7 +3955,7 @@ void ScriptEditorPlugin::edit(Object *p_object) { Script *p_script = Object::cast_to<Script>(p_object); String res_path = p_script->get_path().get_slice("::", 0); - if (p_script->is_built_in()) { + if (p_script->is_built_in() && !res_path.is_empty()) { if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { if (!EditorNode::get_singleton()->is_scene_open(res_path)) { EditorNode::get_singleton()->load_scene(res_path); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index c1b0a32fc7..4626f10b8d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -699,6 +699,9 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptLa } String hint; Error err = script->get_language()->complete_code(p_code, script->get_path(), base, r_options, r_force, hint); + + r_options->sort_custom_inplace<CodeCompletionOptionCompare>(); + if (err == OK) { code_editor->get_text_editor()->set_code_hint(hint); } diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 5c3a66404e..c1c4b0af54 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -256,4 +256,51 @@ public: ~ScriptTextEditor(); }; +const int KIND_COUNT = 10; +// The order in which to sort code completion options. +const ScriptLanguage::CodeCompletionKind KIND_SORT_ORDER[KIND_COUNT] = { + ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE, + ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, + ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION, + ScriptLanguage::CODE_COMPLETION_KIND_ENUM, + ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, + ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, + ScriptLanguage::CODE_COMPLETION_KIND_CLASS, + ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH, + ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH, + ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT, +}; + +// The custom comparer which will sort completion options. +struct CodeCompletionOptionCompare { + _FORCE_INLINE_ bool operator()(const ScriptLanguage::CodeCompletionOption &l, const ScriptLanguage::CodeCompletionOption &r) const { + if (l.location == r.location) { + // If locations are same, sort on kind + if (l.kind == r.kind) { + // If kinds are same, sort alphanumeric + return l.display < r.display; + } + + // Sort kinds based on the const sorting array defined above. Lower index = higher priority. + int l_index = -1; + int r_index = -1; + for (int i = 0; i < KIND_COUNT; i++) { + const ScriptLanguage::CodeCompletionKind kind = KIND_SORT_ORDER[i]; + l_index = kind == l.kind ? i : l_index; + r_index = kind == r.kind ? i : r_index; + + if (l_index != -1 && r_index != -1) { + return l_index < r_index; + } + } + + // This return should never be hit unless something goes wrong. + // l and r should always have a Kind which is in the sort order array. + return l.display < r.display; + } + + return l.location < r.location; + } +}; + #endif // SCRIPT_TEXT_EDITOR_H diff --git a/editor/translations/extract.py b/editor/translations/extract.py index cb918c0092..bd32fc01c7 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -3,6 +3,7 @@ import enum import fnmatch import os +import os.path import re import shutil import subprocess @@ -128,6 +129,9 @@ message_patterns = { re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP, re.compile(r'#define WRTC_\w+ "(?P<message>[^"]+?)"'): ExtractType.PROPERTY_PATH, } +theme_property_patterns = { + re.compile(r'set_(constant|font|font_size|stylebox|color|icon)\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH, +} # See String::camelcase_to_underscore(). @@ -200,6 +204,10 @@ def process_file(f, fname): translator_comment = "" current_group = "" + patterns = message_patterns + if os.path.basename(fname) == "default_theme.cpp": + patterns = {**message_patterns, **theme_property_patterns} + while l: # Detect translator comments. @@ -217,7 +225,7 @@ def process_file(f, fname): translator_comment = translator_comment[:-1] # Remove extra \n at the end. if not reading_translator_comment: - for pattern, extract_type in message_patterns.items(): + for pattern, extract_type in patterns.items(): for m in pattern.finditer(l): location = os.path.relpath(fname).replace("\\", "/") if line_nb: |