diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/SCsub | 2 | ||||
-rw-r--r-- | editor/action_map_editor.cpp | 25 | ||||
-rw-r--r-- | editor/editor_builders.py | 38 | ||||
-rw-r--r-- | editor/editor_dir_dialog.cpp | 7 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 7 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 104 | ||||
-rw-r--r-- | editor/editor_inspector.h | 12 | ||||
-rw-r--r-- | editor/editor_resource_picker.cpp | 7 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 6 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 6 | ||||
-rw-r--r-- | editor/groups_editor.cpp | 2 | ||||
-rw-r--r-- | editor/inspector_dock.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/mesh_library_editor_plugin.cpp | 2 |
13 files changed, 209 insertions, 10 deletions
diff --git a/editor/SCsub b/editor/SCsub index 35c215b663..5dcc253e8b 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -99,6 +99,8 @@ if env["tools"]: # Fonts flist = glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.ttf") flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.otf")) + flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff")) + flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff2")) flist.sort() env.Depends("#editor/builtin_fonts.gen.h", flist) env.CommandNoCache( diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index ea51e1f399..96931efd3b 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -1100,6 +1100,31 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info event_item->set_meta("__event", event); event_item->set_meta("__index", evnt_idx); + // First Column - Icon + Ref<InputEventKey> k = event; + if (k.is_valid()) { + if (k->get_physical_keycode() == Key::NONE) { + event_item->set_icon(0, action_tree->get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons"))); + } else { + event_item->set_icon(0, action_tree->get_theme_icon(SNAME("KeyboardPhysical"), SNAME("EditorIcons"))); + } + } + + Ref<InputEventMouseButton> mb = event; + if (mb.is_valid()) { + event_item->set_icon(0, action_tree->get_theme_icon(SNAME("Mouse"), SNAME("EditorIcons"))); + } + + Ref<InputEventJoypadButton> jb = event; + if (jb.is_valid()) { + event_item->set_icon(0, action_tree->get_theme_icon(SNAME("JoyButton"), SNAME("EditorIcons"))); + } + + Ref<InputEventJoypadMotion> jm = event; + if (jm.is_valid()) { + event_item->set_icon(0, action_tree->get_theme_icon(SNAME("JoyAxis"), SNAME("EditorIcons"))); + } + // Third Column - Buttons event_item->add_button(2, action_tree->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), BUTTON_EDIT_EVENT, false, TTR("Edit Event")); event_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_EVENT, false, TTR("Remove Event")); diff --git a/editor/editor_builders.py b/editor/editor_builders.py index 67d4b8534f..e73fbc6107 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -5,6 +5,10 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki """ import os import os.path +import shutil +import subprocess +import tempfile +import uuid from platform_methods import subprocess_main @@ -89,10 +93,40 @@ def make_translations_header(target, source, env, category): sorted_paths = sorted(source, key=lambda path: os.path.splitext(os.path.basename(path))[0]) + msgfmt_available = shutil.which("msgfmt") is not None + + if not msgfmt_available: + print("WARNING: msgfmt is not found, using .po files instead of .mo") + xl_names = [] for i in range(len(sorted_paths)): - with open(sorted_paths[i], "rb") as f: - buf = f.read() + if msgfmt_available: + mo_path = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex + ".mo") + cmd = "msgfmt " + sorted_paths[i] + " --no-hash -o " + mo_path + try: + subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE).communicate() + with open(mo_path, "rb") as f: + buf = f.read() + except OSError as e: + print( + "WARNING: msgfmt execution failed, using .po file instead of .mo: path=%r; [%s] %s" + % (sorted_paths[i], e.__class__.__name__, e) + ) + with open(sorted_paths[i], "rb") as f: + buf = f.read() + finally: + try: + os.remove(mo_path) + except OSError as e: + # Do not fail the entire build if it cannot delete a temporary file + print( + "WARNING: Could not delete temporary .mo file: path=%r; [%s] %s" + % (mo_path, e.__class__.__name__, e) + ) + else: + with open(sorted_paths[i], "rb") as f: + buf = f.read() + decomp_size = len(buf) # Use maximum zlib compression level to further reduce file size # (at the cost of initial build times). diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 32ef87a4ab..866f28c03b 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -156,10 +156,15 @@ void EditorDirDialog::_make_dir_confirm() { String dir = ti->get_metadata(0); + if (EditorFileSystem::get_singleton()->get_filesystem_path(dir + makedirname->get_text())) { + mkdirerr->set_text(TTR("Could not create folder. File with that name already exists.")); + mkdirerr->popup_centered(); + return; + } + DirAccessRef d = DirAccess::open(dir); ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + dir + "'."); Error err = d->make_dir(makedirname->get_text()); - if (err != OK) { mkdirerr->popup_centered(Size2(250, 80) * EDSCALE); } else { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 31f2f24066..0c2faacf02 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1092,6 +1092,13 @@ EditorFileDialog::Access EditorFileDialog::get_access() const { } void EditorFileDialog::_make_dir_confirm() { + if (EditorFileSystem::get_singleton()->get_filesystem_path(makedirname->get_text().strip_edges())) { + error_dialog->set_text(TTR("Could not create folder. File with that name already exists.")); + error_dialog->popup_centered(Size2(250, 50) * EDSCALE); + makedirname->set_text(""); // Reset label. + return; + } + Error err = dir_access->make_dir(makedirname->get_text().strip_edges()); if (err == OK) { dir_access->change_dir(makedirname->get_text().strip_edges()); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 9601eaf5f5..18c9a9f495 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -40,6 +40,7 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "multi_node_edit.h" +#include "scene/gui/center_container.h" #include "scene/property_utils.h" #include "scene/resources/packed_scene.h" @@ -2506,7 +2507,7 @@ void EditorInspector::update_tree() { List<PropertyInfo>::Element *N = E_property->next(); bool valid = true; while (N) { - if (N->get().usage & PROPERTY_USAGE_EDITOR && (!restrict_to_basic || (N->get().usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) { + if (!N->get().name.begins_with("metadata/_") && N->get().usage & PROPERTY_USAGE_EDITOR && (!restrict_to_basic || (N->get().usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) { break; } if (N->get().usage & PROPERTY_USAGE_CATEGORY) { @@ -2580,7 +2581,7 @@ void EditorInspector::update_tree() { continue; - } else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name) || (restrict_to_basic && !(p.usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) { + } else if (p.name.begins_with("metadata/_") || !(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name) || (restrict_to_basic && !(p.usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) { // Ignore properties that are not supposed to be in the inspector. continue; } @@ -2915,7 +2916,7 @@ void EditorInspector::update_tree() { ep->set_checked(checked); ep->set_keying(keying); ep->set_read_only(property_read_only); - ep->set_deletable(deletable_properties); + ep->set_deletable(deletable_properties || p.name.begins_with("metadata/")); } current_vbox->add_child(F.property_editor); @@ -2956,6 +2957,15 @@ void EditorInspector::update_tree() { } } + if (!hide_metadata) { + Button *add_md = memnew(Button); + add_md->set_text(TTR("Add Metadata")); + add_md->set_focus_mode(Control::FOCUS_NONE); + add_md->set_icon(get_theme_icon("Add", "EditorIcons")); + add_md->connect("pressed", callable_mp(this, &EditorInspector::_show_add_meta_dialog)); + main_vbox->add_child(add_md); + } + // Get the lists of to add at the end. for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { ped->parse_end(object); @@ -3055,6 +3065,11 @@ void EditorInspector::set_hide_script(bool p_hide) { update_tree(); } +void EditorInspector::set_hide_metadata(bool p_hide) { + hide_metadata = p_hide; + update_tree(); +} + void EditorInspector::set_use_filter(bool p_use) { use_filter = p_use; update_tree(); @@ -3323,6 +3338,14 @@ void EditorInspector::_property_deleted(const String &p_path) { return; } + if (p_path.begins_with("metadata/")) { + String name = p_path.replace_first("metadata/", ""); + undo_redo->create_action(vformat(TTR("Remove metadata %s"), name)); + undo_redo->add_do_method(object, "remove_meta", name); + undo_redo->add_undo_method(object, "set_meta", name, object->get_meta(name)); + undo_redo->commit_action(); + } + emit_signal(SNAME("property_deleted"), p_path); } @@ -3650,6 +3673,81 @@ Variant EditorInspector::get_property_clipboard() const { return property_clipboard; } +void EditorInspector::_add_meta_confirm() { + String name = add_meta_name->get_text(); + + object->editor_set_section_unfold("metadata", true); // Ensure metadata is unfolded when adding a new metadata. + + Variant defval; + Callable::CallError ce; + Variant::construct(Variant::Type(add_meta_type->get_selected_id()), defval, nullptr, 0, ce); + undo_redo->create_action(vformat(TTR("Add metadata %s"), name)); + undo_redo->add_do_method(object, "set_meta", name, defval); + undo_redo->add_undo_method(object, "remove_meta", name); + undo_redo->commit_action(); +} + +void EditorInspector::_check_meta_name(String name) { + String error; + + if (name == "") { + error = TTR("Metadata can't be empty."); + } else if (!name.is_valid_identifier()) { + error = TTR("Invalid metadata identifier."); + } else if (object->has_meta(name)) { + error = TTR("Metadata already exists."); + } + + if (error != "") { + add_meta_error->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + add_meta_error->set_text(error); + add_meta_dialog->get_ok_button()->set_disabled(true); + } else { + add_meta_error->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); + add_meta_error->set_text(TTR("Metadata name is valid.")); + add_meta_dialog->get_ok_button()->set_disabled(false); + } +} + +void EditorInspector::_show_add_meta_dialog() { + if (!add_meta_dialog) { + add_meta_dialog = memnew(ConfirmationDialog); + add_meta_dialog->set_title(TTR("Add Metadata Property")); + VBoxContainer *vbc = memnew(VBoxContainer); + add_meta_dialog->add_child(vbc); + HBoxContainer *hbc = memnew(HBoxContainer); + vbc->add_child(hbc); + hbc->add_child(memnew(Label(TTR("Name:")))); + add_meta_name = memnew(LineEdit); + add_meta_name->set_custom_minimum_size(Size2(200 * EDSCALE, 1)); + hbc->add_child(add_meta_name); + hbc->add_child(memnew(Label(TTR("Type:")))); + add_meta_type = memnew(OptionButton); + for (int i = 0; i < Variant::VARIANT_MAX; i++) { + if (i == Variant::NIL || i == Variant::RID || i == Variant::CALLABLE || i == Variant::SIGNAL) { + continue; //not editable by inspector. + } + String type = i == Variant::OBJECT ? String("Resource") : Variant::get_type_name(Variant::Type(i)); + + add_meta_type->add_icon_item(get_theme_icon(type, "EditorIcons"), type, i); + } + hbc->add_child(add_meta_type); + add_meta_dialog->get_ok_button()->set_text(TTR("Add")); + add_child(add_meta_dialog); + add_meta_dialog->register_text_enter(add_meta_name); + add_meta_dialog->connect("confirmed", callable_mp(this, &EditorInspector::_add_meta_confirm)); + add_meta_error = memnew(Label); + vbc->add_child(add_meta_error); + + add_meta_name->connect("text_changed", callable_mp(this, &EditorInspector::_check_meta_name)); + } + + add_meta_dialog->popup_centered(); + add_meta_name->set_text(""); + _check_meta_name(""); + add_meta_name->grab_focus(); +} + void EditorInspector::_bind_methods() { ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 3c482a07e7..d625a8043c 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -35,6 +35,7 @@ #include "scene/gui/button.h" #include "scene/gui/dialogs.h" #include "scene/gui/line_edit.h" +#include "scene/gui/option_button.h" #include "scene/gui/panel_container.h" #include "scene/gui/scroll_container.h" #include "scene/gui/texture_rect.h" @@ -445,6 +446,7 @@ class EditorInspector : public ScrollContainer { LineEdit *search_box; bool show_categories = false; bool hide_script = true; + bool hide_metadata = true; bool use_doc_hints = false; bool capitalize_paths = true; bool use_filter = false; @@ -511,6 +513,15 @@ class EditorInspector : public ScrollContainer { void _update_inspector_bg(); + ConfirmationDialog *add_meta_dialog = nullptr; + LineEdit *add_meta_name = nullptr; + OptionButton *add_meta_type = nullptr; + Label *add_meta_error = nullptr; + + void _add_meta_confirm(); + void _show_add_meta_dialog(); + void _check_meta_name(String name); + protected: static void _bind_methods(); void _notification(int p_what); @@ -541,6 +552,7 @@ public: void set_show_categories(bool p_show); void set_use_doc_hints(bool p_enable); void set_hide_script(bool p_hide); + void set_hide_metadata(bool p_hide); void set_use_filter(bool p_use); void register_text_enter(Node *p_line_edit); diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index a7b2a4cfa6..53f1a689d6 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -327,6 +327,13 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { case OBJ_MENU_PASTE: { edited_resource = EditorSettings::get_singleton()->get_resource_clipboard(); + if (edited_resource->is_built_in() && EditorNode::get_singleton()->get_edited_scene() && + edited_resource->get_path().get_slice("::", 0) != EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path()) { + // Automatically make resource unique if it belongs to another scene. + _edit_menu_cbk(OBJ_MENU_MAKE_UNIQUE); + return; + } + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 08cc957ec7..5057fc7531 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -422,9 +422,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { #endif EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/font_subpixel_positioning", 1, "Disabled,Auto,One half of a pixel,One quarter of a pixel") - EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/main_font", "", "*.ttf,*.otf") - EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/main_font_bold", "", "*.ttf,*.otf") - EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/code_font", "", "*.ttf,*.otf") + EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/main_font", "", "*.ttf,*.otf,*.woff,*.woff2,*.pfb,*.pfm") + EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/main_font_bold", "", "*.ttf,*.otf,*.woff,*.woff2,*.pfb,*.pfm") + EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/code_font", "", "*.ttf,*.otf,*.woff,*.woff2,*.pfb,*.pfm") EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/editor/low_processor_mode_sleep_usec", 6900, "1,100000,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) // Default unfocused usec sleep is for 10 FPS. Allow an unfocused FPS limit // as low as 1 FPS for those who really need low power usage (but don't need diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 038cc2ab2f..2100a787c8 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1413,6 +1413,12 @@ void FileSystemDock::_make_dir_confirm() { if (!directory.ends_with("/")) { directory = directory.get_base_dir(); } + + if (EditorFileSystem::get_singleton()->get_filesystem_path(directory + dir_name)) { + EditorNode::get_singleton()->show_warning(TTR("Could not create folder. File with that name already exists.")); + return; + } + print_verbose("Making folder " + dir_name + " in " + directory); DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); Error err = da->change_dir(directory); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 4b3a7a8313..37d535aed2 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -416,6 +416,8 @@ void GroupDialog::_bind_methods() { ClassDB::bind_method("_rename_group_item", &GroupDialog::_rename_group_item); + ClassDB::bind_method("_group_selected", &GroupDialog::_group_selected); + ADD_SIGNAL(MethodInfo("group_edited")); } diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 087e51b0cb..9ebea79435 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -679,6 +679,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL); inspector->set_use_doc_hints(true); inspector->set_hide_script(false); + inspector->set_hide_metadata(false); inspector->set_enable_capitalize_paths(bool(EDITOR_GET("interface/inspector/capitalize_properties"))); inspector->set_use_folding(!bool(EDITOR_GET("interface/inspector/disable_folding"))); inspector->register_text_enter(search); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 41e3471a78..423ec5f4ed 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -271,7 +271,7 @@ MeshLibraryEditor::MeshLibraryEditor() { menu = memnew(MenuButton); Node3DEditor::get_singleton()->add_control_to_menu_panel(menu); menu->set_position(Point2(1, 1)); - menu->set_text(TTR("Mesh Library")); + menu->set_text(TTR("MeshLibrary")); menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshLibrary"), SNAME("EditorIcons"))); menu->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM); menu->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM); |