diff options
Diffstat (limited to 'editor')
36 files changed, 371 insertions, 387 deletions
diff --git a/editor/SCsub b/editor/SCsub index 2b6494608b..c531d2c7a6 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -39,6 +39,8 @@ def make_doc_header(target, source, env): docend = "" for s in source: src = s.srcnode().abspath + if not src.endswith(".xml"): + continue f = open_utf8(src, "r") content = f.read() buf+=content diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 057b2d827d..533ed48d15 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -615,11 +615,6 @@ void DocData::generate(bool p_basic_types) { } } -static String _format_description(const String &string) { - - return string.dedent().strip_edges().replace("\n", "\n\n"); -} - static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &methods) { String section = parser->get_node_name(); @@ -666,7 +661,7 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> & parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - method.description = _format_description(parser->get_node_data()); + method.description = parser->get_node_data(); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == element) @@ -781,20 +776,20 @@ Error DocData::_load(Ref<XMLParser> parser) { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.brief_description = _format_description(parser->get_node_data()); + c.brief_description = parser->get_node_data(); } else if (name == "description") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.description = _format_description(parser->get_node_data()); + c.description = parser->get_node_data(); } else if (name == "tutorials") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.tutorials = parser->get_node_data().strip_edges(); + c.tutorials = parser->get_node_data(); } else if (name == "demos") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.demos = parser->get_node_data().strip_edges(); + c.demos = parser->get_node_data(); } else if (name == "methods") { Error err = _parse_methods(parser, c.methods); @@ -828,7 +823,7 @@ Error DocData::_load(Ref<XMLParser> parser) { prop.enumeration = parser->get_attribute_value("enum"); parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - prop.description = _format_description(parser->get_node_data()); + prop.description = parser->get_node_data(); c.properties.push_back(prop); } else { ERR_EXPLAIN("Invalid tag in doc file: " + name); @@ -857,7 +852,7 @@ Error DocData::_load(Ref<XMLParser> parser) { prop.type = parser->get_attribute_value("type"); parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - prop.description = parser->get_node_data().strip_edges(); + prop.description = parser->get_node_data(); c.theme_properties.push_back(prop); } else { ERR_EXPLAIN("Invalid tag in doc file: " + name); @@ -888,7 +883,7 @@ Error DocData::_load(Ref<XMLParser> parser) { } parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - constant.description = parser->get_node_data().strip_edges(); + constant.description = parser->get_node_data(); c.constants.push_back(constant); } else { ERR_EXPLAIN("Invalid tag in doc file: " + name); @@ -915,6 +910,8 @@ Error DocData::_load(Ref<XMLParser> parser) { static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { + if (p_string == "") + return; String tab; for (int i = 0; i < p_tablevel; i++) tab += "\t"; @@ -957,20 +954,16 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri header += ">"; _write_string(f, 0, header); _write_string(f, 1, "<brief_description>"); - if (c.brief_description != "") - _write_string(f, 2, c.brief_description.xml_escape()); + _write_string(f, 2, c.brief_description.strip_edges().xml_escape()); _write_string(f, 1, "</brief_description>"); _write_string(f, 1, "<description>"); - if (c.description != "") - _write_string(f, 2, c.description.xml_escape()); + _write_string(f, 2, c.description.strip_edges().xml_escape()); _write_string(f, 1, "</description>"); _write_string(f, 1, "<tutorials>"); - if (c.tutorials != "") - _write_string(f, 2, c.tutorials.xml_escape()); + _write_string(f, 2, c.tutorials.strip_edges().xml_escape()); _write_string(f, 1, "</tutorials>"); _write_string(f, 1, "<demos>"); - if (c.demos != "") - _write_string(f, 2, c.demos.xml_escape()); + _write_string(f, 2, c.demos.strip_edges().xml_escape()); _write_string(f, 1, "</demos>"); _write_string(f, 1, "<methods>"); @@ -1014,8 +1007,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } _write_string(f, 3, "<description>"); - if (m.description != "") - _write_string(f, 4, m.description.xml_escape()); + _write_string(f, 4, m.description.strip_edges().xml_escape()); _write_string(f, 3, "</description>"); _write_string(f, 2, "</method>"); @@ -1036,8 +1028,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } PropertyDoc &p = c.properties[i]; _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + enum_text + ">"); - if (p.description != "") - _write_string(f, 3, p.description.xml_escape()); + _write_string(f, 3, p.description.strip_edges().xml_escape()); _write_string(f, 2, "</member>"); } _write_string(f, 1, "</members>"); @@ -1060,8 +1051,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } _write_string(f, 3, "<description>"); - if (m.description != "") - _write_string(f, 4, m.description.xml_escape()); + _write_string(f, 4, m.description.strip_edges().xml_escape()); _write_string(f, 3, "</description>"); _write_string(f, 2, "</signal>"); @@ -1080,8 +1070,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } else { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">"); } - if (k.description != "") - _write_string(f, 3, k.description.xml_escape()); + _write_string(f, 3, k.description.strip_edges().xml_escape()); _write_string(f, 2, "</constant>"); } diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index a48e6c9057..290cb1be42 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -117,7 +117,7 @@ EditorAbout::EditorAbout() { Label *about_text = memnew(Label); about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER); - about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + + about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\xc2\xa9 2007-2017 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2017 ") + TTR("Godot Engine contributors") + "\n"); hbc->add_child(about_text); @@ -201,7 +201,7 @@ EditorAbout::EditorAbout() { for (int j = 0; j < about_tp_copyright_count[i]; j++) { text += "\n Files:\n " + String(about_tp_file[read_idx]).replace("\n", "\n ") + "\n"; - String copyright = String::utf8(" \u00A9 ") + String::utf8(about_tp_copyright[read_idx]).replace("\n", String::utf8("\n \u00A9 ")); + String copyright = String::utf8(" \xc2\xa9 ") + String::utf8(about_tp_copyright[read_idx]).replace("\n", String::utf8("\n \xc2\xa9 ")); text += copyright; long_text += copyright; String license = "\n License: " + String(about_tp_license[read_idx]) + "\n"; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index a6fc8dcddf..9e002bc73d 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -821,8 +821,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const scan_actions.push_back(ia); } } - - EditorResourcePreview::get_singleton()->check_for_invalidation(p_dir->get_file_path(i)); } for (int i = 0; i < p_dir->subdirs.size(); i++) { @@ -1266,7 +1264,6 @@ void EditorFileSystem::update_file(const String &p_file) { fs->files[cpos]->deps = _get_dependencies(p_file); fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); - EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation", p_file); call_deferred("emit_signal", "filesystem_changed"); //update later } @@ -1436,6 +1433,8 @@ void EditorFileSystem::_reimport_file(const String &p_file) { r->set_import_last_modified_time(0); } } + + EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); } void EditorFileSystem::reimport_files(const Vector<String> &p_files) { diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 05f9da03e1..7e20077fd6 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -122,20 +122,24 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); //dfd->set_force_autohinter(true); //just looks better..i think? - MAKE_DEFAULT_FONT(df, int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE); + int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE; + MAKE_DEFAULT_FONT(df, default_font_size); p_theme->set_default_theme_font(df); + MAKE_DEFAULT_FONT(df_title, default_font_size + 2 * EDSCALE); + p_theme->set_font("title", "EditorFonts", df_title); + //Ref<BitmapFont> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons")); //Ref<BitmapFont> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons")); //Ref<BitmapFont> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons")); - MAKE_DEFAULT_FONT(df_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 16)) * EDSCALE); + MAKE_DEFAULT_FONT(df_doc_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 16)) * EDSCALE); MAKE_DEFAULT_FONT(df_doc, int(EDITOR_DEF("text_editor/help/help_font_size", 14)) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); - p_theme->set_font("doc_title", "EditorFonts", df_title); + p_theme->set_font("doc_title", "EditorFonts", df_doc_title); MAKE_DEFAULT_FONT(df_rulers, int(EDITOR_DEF("canvas_item_editor/rulers", 8)) * EDSCALE); p_theme->set_font("rulers", "EditorFonts", df_rulers); @@ -176,9 +180,4 @@ void editor_register_fonts(Ref<Theme> p_theme) { df_output_code->set_font_data(dfmono); MAKE_FALLBACKS(df_output_code); p_theme->set_font("status_source", "EditorFonts", df_output_code); - - //replace default theme - Ref<Texture> di; - Ref<StyleBox> ds; - fill_default_theme(p_theme, df, df_doc, di, ds, EDSCALE); } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 03cd2c9b6b..bdb621a258 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1478,9 +1478,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp"); Color link_color = p_rt->get_color("accent_color", "Editor").linear_interpolate(font_color_hl, 0.8); - String bbcode = p_bbcode.replace("\t", " ").replace("\r", " ").strip_edges(); + String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges(); List<String> tag_stack; + bool code_tag = false; int pos = 0; while (pos < bbcode.length()) { @@ -1491,7 +1492,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { brk_pos = bbcode.length(); if (brk_pos > pos) { - p_rt->add_text(bbcode.substr(pos, brk_pos - pos)); + String text = bbcode.substr(pos, brk_pos - pos); + if (!code_tag) + text = text.replace("\n", "\n\n"); + p_rt->add_text(text); } if (brk_pos == bbcode.length()) @@ -1500,7 +1504,11 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { int brk_end = bbcode.find("]", brk_pos + 1); if (brk_end == -1) { - p_rt->add_text(bbcode.substr(brk_pos, bbcode.length() - brk_pos)); + + String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos); + if (!code_tag) + text = text.replace("\n", "\n\n"); + p_rt->add_text(text); break; } @@ -1509,20 +1517,23 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { if (tag.begins_with("/")) { bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length()); - if (tag_stack.size()) { - } if (!tag_ok) { p_rt->add_text("["); - pos++; + pos = brk_pos + 1; continue; } tag_stack.pop_front(); pos = brk_end + 1; + code_tag = false; if (tag != "/img") p_rt->pop(); + } else if (code_tag) { + + p_rt->add_text("["); + pos = brk_pos + 1; } else if (tag.begins_with("method ")) { @@ -1559,6 +1570,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { //use monospace font p_rt->push_font(doc_code_font); + code_tag = true; pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "center") { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3513126a9b..e0cae7de57 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -284,9 +284,10 @@ void EditorNode::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/editor/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true))); - Ref<Theme> theme = create_editor_theme(theme_base->get_theme()); + Ref<Theme> theme = create_custom_theme(theme_base->get_theme()); theme_base->set_theme(theme); + gui_base->set_theme(theme); gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles")); @@ -871,7 +872,7 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) { _find_node_types(p_node->get_child(i), count_2d, count_3d); } -void EditorNode::_save_scene_with_preview(String p_file) { +void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { EditorProgress save("save", TTR("Saving Scene"), 4); save.step(TTR("Analyzing"), 0); @@ -937,7 +938,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { } save.step(TTR("Saving Scene"), 4); - _save_scene(p_file); + _save_scene(p_file, p_idx); EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); } @@ -1095,10 +1096,7 @@ void EditorNode::_dialog_action(String p_file) { if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { _save_default_environment(); - if (scene_idx != editor_data.get_edited_scene()) - _save_scene(p_file, scene_idx); - else - _save_scene_with_preview(p_file); + _save_scene_with_preview(p_file, scene_idx); if (scene_idx != -1) _discard_changes(); @@ -1825,7 +1823,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (scene && scene->get_filename() != "") { if (scene_idx != editor_data.get_edited_scene()) - _save_scene(scene->get_filename(), scene_idx); + _save_scene_with_preview(scene->get_filename(), scene_idx); else _save_scene_with_preview(scene->get_filename()); @@ -1933,6 +1931,15 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_EXPORT_TILESET: { + //Make sure that the scene has a root before trying to convert to tileset + if (!editor_data.get_edited_scene_root()) { + current_option = -1; + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("This operation can't be done without a root node.")); + accept->popup_centered_minsize(); + break; + } + List<String> extensions; Ref<TileSet> ml(memnew(TileSet)); ResourceSaver::get_recognized_extensions(ml, &extensions); @@ -3254,11 +3261,11 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorScript>(); ClassDB::register_class<EditorSelection>(); ClassDB::register_class<EditorFileDialog>(); - ClassDB::register_class<EditorSettings>(); + ClassDB::register_virtual_class<EditorSettings>(); ClassDB::register_class<EditorSpatialGizmo>(); - ClassDB::register_class<EditorResourcePreview>(); + ClassDB::register_virtual_class<EditorResourcePreview>(); ClassDB::register_class<EditorResourcePreviewGenerator>(); - ClassDB::register_class<EditorFileSystem>(); + ClassDB::register_virtual_class<EditorFileSystem>(); ClassDB::register_class<EditorFileSystemDirectory>(); ClassDB::register_virtual_class<ScriptEditor>(); ClassDB::register_virtual_class<EditorInterface>(); @@ -4217,61 +4224,53 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { return drag_data; } -Variant EditorNode::drag_files(const Vector<String> &p_files, Control *p_from) { - - VBoxContainer *files = memnew(VBoxContainer); - - int max_files = 6; - - for (int i = 0; i < MIN(max_files, p_files.size()); i++) { - - Label *label = memnew(Label); - label->set_text(p_files[i].get_file()); - files->add_child(label); +Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from) { + bool has_folder = false; + bool has_file = false; + for (int i = 0; i < p_paths.size(); i++) { + bool is_folder = p_paths[i].ends_with("/"); + has_folder |= is_folder; + has_file |= !is_folder; } - if (p_files.size() > max_files) { - + int max_rows = 6; + int num_rows = p_paths.size() > max_rows ? max_rows - 1 : p_paths.size(); //Don't waste a row to say "1 more file" - list it instead. + VBoxContainer *vbox = memnew(VBoxContainer); + for (int i = 0; i < num_rows; i++) { + HBoxContainer *hbox = memnew(HBoxContainer); + TextureRect *icon = memnew(TextureRect); Label *label = memnew(Label); - label->set_text(vformat(TTR("%d more file(s)"), p_files.size() - max_files)); - files->add_child(label); - } - Dictionary drag_data; - drag_data["type"] = "files"; - drag_data["files"] = p_files; - drag_data["from"] = p_from; - p_from->set_drag_preview(files); //wait until it enters scene - - return drag_data; -} - -Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_files, Control *p_from) { - - VBoxContainer *files = memnew(VBoxContainer); - - int max_files = 6; - - for (int i = 0; i < MIN(max_files, p_files.size()); i++) { - - Label *label = memnew(Label); - label->set_text(p_files[i].get_file()); - files->add_child(label); + if (p_paths[i].ends_with("/")) { + label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file()); + icon->set_texture(gui_base->get_icon("Folder", "EditorIcons")); + } else { + label->set_text(p_paths[i].get_file()); + icon->set_texture(gui_base->get_icon("File", "EditorIcons")); + } + icon->set_size(Size2(16, 16)); + hbox->add_child(icon); + hbox->add_child(label); + vbox->add_child(hbox); } - if (p_files.size() > max_files) { - + if (p_paths.size() > num_rows) { Label *label = memnew(Label); - label->set_text(vformat(TTR("%d more file(s) or folder(s)"), p_files.size() - max_files)); - files->add_child(label); + if (has_file && has_folder) { + label->set_text(vformat(TTR("%d more files or folders"), p_paths.size() - num_rows)); + } else if (has_folder) { + label->set_text(vformat(TTR("%d more folders"), p_paths.size() - num_rows)); + } else { + label->set_text(vformat(TTR("%d more files"), p_paths.size() - num_rows)); + } + vbox->add_child(label); } + p_from->set_drag_preview(vbox); //wait until it enters scene + Dictionary drag_data; - drag_data["type"] = "files_and_dirs"; - drag_data["files"] = p_files; + drag_data["type"] = has_folder ? "files_and_dirs" : "files"; + drag_data["files"] = p_paths; drag_data["from"] = p_from; - - p_from->set_drag_preview(files); //wait until it enters scene - return drag_data; } @@ -4690,9 +4689,9 @@ EditorNode::EditorNode() { theme_base->add_child(gui_base); gui_base->set_anchors_and_margins_preset(Control::PRESET_WIDE); - Ref<Theme> theme = create_editor_theme(); + Ref<Theme> theme = create_custom_theme(); theme_base->set_theme(theme); - gui_base->set_theme(create_custom_theme()); + gui_base->set_theme(theme); gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); resource_preview = memnew(EditorResourcePreview); @@ -5387,12 +5386,12 @@ EditorNode::EditorNode() { save_confirmation->connect("confirmed", this, "_menu_confirm_current"); save_confirmation->connect("custom_action", this, "_discard_changes"); - file_templates = memnew(FileDialog); + file_templates = memnew(EditorFileDialog); file_templates->set_title(TTR("Import Templates From ZIP File")); gui_base->add_child(file_templates); - file_templates->set_mode(FileDialog::MODE_OPEN_FILE); - file_templates->set_access(FileDialog::ACCESS_FILESYSTEM); + file_templates->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_templates->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_templates->clear_filters(); file_templates->add_filter("*.tpz ; Template Package"); @@ -5400,15 +5399,15 @@ EditorNode::EditorNode() { gui_base->add_child(file); file->set_current_dir("res://"); - file_export = memnew(FileDialog); - file_export->set_access(FileDialog::ACCESS_FILESYSTEM); + file_export = memnew(EditorFileDialog); + file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); gui_base->add_child(file_export); file_export->set_title(TTR("Export Project")); file_export->connect("file_selected", this, "_dialog_action"); - file_export_lib = memnew(FileDialog); + file_export_lib = memnew(EditorFileDialog); file_export_lib->set_title(TTR("Export Library")); - file_export_lib->set_mode(FileDialog::MODE_SAVE_FILE); + file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_export_lib->connect("file_selected", this, "_dialog_action"); file_export_lib_merge = memnew(CheckButton); file_export_lib_merge->set_text(TTR("Merge With Existing")); @@ -5421,10 +5420,10 @@ EditorNode::EditorNode() { file_export_password->set_editable(false); file_export->get_vbox()->add_margin_child(TTR("Password:"), file_export_password); - file_script = memnew(FileDialog); + file_script = memnew(EditorFileDialog); file_script->set_title(TTR("Open & Run a Script")); - file_script->set_access(FileDialog::ACCESS_FILESYSTEM); - file_script->set_mode(FileDialog::MODE_OPEN_FILE); + file_script->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_script->set_mode(EditorFileDialog::MODE_OPEN_FILE); List<String> sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); for (List<String>::Element *E = sexts.front(); E; E = E->next()) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 32d46e686b..81ff886228 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -294,10 +294,10 @@ private: ProjectSettingsEditor *project_settings; EditorFileDialog *file; ExportTemplateManager *export_template_manager; - FileDialog *file_templates; - FileDialog *file_export; - FileDialog *file_export_lib; - FileDialog *file_script; + EditorFileDialog *file_templates; + EditorFileDialog *file_export; + EditorFileDialog *file_export_lib; + EditorFileDialog *file_script; CheckButton *file_export_lib_merge; LineEdit *file_export_password; String current_path; @@ -503,7 +503,7 @@ private: void _mark_unsaved_scenes(); void _find_node_types(Node *p_node, int &count_2d, int &count_3d); - void _save_scene_with_preview(String p_file); + void _save_scene_with_preview(String p_file, int p_idx = -1); Map<String, Set<String> > dependency_errors; @@ -765,8 +765,7 @@ public: void remove_bottom_panel_item(Control *p_item); Variant drag_resource(const Ref<Resource> &p_res, Control *p_from); - Variant drag_files(const Vector<String> &p_files, Control *p_from); - Variant drag_files_and_dirs(const Vector<String> &p_files, Control *p_from); + Variant drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from); void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant()); void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index c8abc1f9db..0bd677ca1b 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -76,11 +76,11 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - RID light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + RID light = VS::get_singleton()->directional_light_create(); RID light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - RID light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + RID light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index f92962a4cb..5b4bdb59d3 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -86,7 +86,6 @@ void EditorResourcePreview::_thread_func(void *ud) { void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { - //print_line("preview is ready"); preview_mutex->lock(); String path = p_str; @@ -121,7 +120,6 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c type = p_item.resource->get_class(); else type = ResourceLoader::get_resource_type(p_item.path); - //print_line("resource type is: "+type); if (type == "") return Ref<Texture>(); //could not guess type @@ -144,7 +142,6 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c if (!p_item.resource.is_valid()) { // cache the preview in case it's a resource on disk if (generated.is_valid()) { - //print_line("was generated"); int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; //wow it generated a preview... save cache @@ -164,15 +161,11 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c void EditorResourcePreview::_thread() { - //print_line("begin thread"); while (!exit) { - //print_line("wait for semaphore"); preview_sem->wait(); preview_mutex->lock(); - //print_line("blue team go"); - if (queue.size()) { QueueItem item = queue.front()->get(); @@ -189,12 +182,11 @@ void EditorResourcePreview::_thread() { preview_mutex->unlock(); } else { + preview_mutex->unlock(); Ref<ImageTexture> texture; - //print_line("pop from queue "+item.path); - int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; @@ -304,7 +296,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p cache.erase(path_id); //erase if exists, since it will be regen - //print_line("send to thread "+p_path); QueueItem item; item.function = p_receiver_func; item.id = p_receiver->get_instance_id(); @@ -328,7 +319,6 @@ void EditorResourcePreview::queue_resource_preview(const String &p_path, Object return; } - //print_line("send to thread "+p_path); QueueItem item; item.function = p_receiver_func; item.id = p_receiver->get_instance_id(); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index bc91fcdf04..bf4ef3ae39 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -135,6 +135,7 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { void EditorSettings::_initial_set(const StringName &p_name, const Variant &p_value) { set(p_name, p_value); props[p_name].initial = p_value; + props[p_name].initial_set = true; } struct _EVCSort { @@ -214,6 +215,14 @@ void EditorSettings::_add_property_info_bind(const Dictionary &p_info) { } // Default configs +bool EditorSettings::has_default_value(const String &p_setting) const { + + _THREAD_SAFE_METHOD_ + + if (!props.has(p_setting)) + return false; + return props[p_setting].initial_set; +} void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { @@ -834,10 +843,10 @@ void EditorSettings::setup_network() { hint += ip; } - set("network/debug/remote_host", lip); + _initial_set("network/debug/remote_host", lip); add_property_hint(PropertyInfo(Variant::STRING, "network/debug/remote_host", PROPERTY_HINT_ENUM, hint)); - set("network/debug/remote_port", port); + _initial_set("network/debug/remote_port", port); add_property_hint(PropertyInfo(Variant::INT, "network/debug/remote_port", PROPERTY_HINT_RANGE, "1,65535,1")); } @@ -915,16 +924,20 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian ERR_FAIL_COND(!props.has(p_setting)); props[p_setting].initial = p_value; + props[p_setting].initial_set = true; } Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) { + Variant ret = p_default; if (EditorSettings::get_singleton()->has_setting(p_setting)) - return EditorSettings::get_singleton()->get(p_setting); - EditorSettings::get_singleton()->set(p_setting, p_default); - EditorSettings::get_singleton()->set_initial_value(p_setting, p_default); + ret = EditorSettings::get_singleton()->get(p_setting); + if (!EditorSettings::get_singleton()->has_default_value(p_setting)) { + EditorSettings::get_singleton()->set_initial_value(p_setting, p_default); + EditorSettings::get_singleton()->set(p_setting, p_default); + } - return p_default; + return ret; } Variant _EDITOR_GET(const String &p_setting) { diff --git a/editor/editor_settings.h b/editor/editor_settings.h index a74be6494a..29665369c4 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -66,11 +66,13 @@ private: int order; Variant variant; Variant initial; + bool initial_set; bool hide_from_editor; bool save; VariantContainer() { order = 0; hide_from_editor = false; + initial_set = false; save = false; } VariantContainer(const Variant &p_variant, int p_order) { @@ -128,6 +130,7 @@ public: static void destroy(); void set_optimize_save(bool p_optimize); + bool has_default_value(const String &p_setting) const; void set_setting(const String &p_setting, const Variant &p_value); Variant get_setting(const String &p_setting) const; bool has_setting(const String &p_setting) const; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 29859a1a56..0f9f50095d 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -568,6 +568,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton + theme->set_stylebox("normal", "CheckButton", style_menu); + theme->set_stylebox("pressed", "CheckButton", style_menu); + theme->set_stylebox("disabled", "CheckButton", style_menu); + theme->set_stylebox("hover", "CheckButton", style_menu); + theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons")); theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons")); @@ -577,7 +582,22 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "CheckButton", font_color_disabled); theme->set_color("icon_color_hover", "CheckButton", font_color_hl); + theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE); + theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE); + // Checkbox + Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate(); + // HACK, in reality, the checkbox draws the text over the icon by default, so the margin compensates that. + const int cb_w = theme->get_icon("GuiChecked", "EditorIcons")->get_width() + default_margin_size; + sb_checkbox->set_default_margin(MARGIN_LEFT, cb_w * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE); + + theme->set_stylebox("normal", "CheckBox", sb_checkbox); + theme->set_stylebox("pressed", "CheckBox", sb_checkbox); + theme->set_stylebox("disabled", "CheckBox", sb_checkbox); + theme->set_stylebox("hover", "CheckBox", sb_checkbox); theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons")); theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons")); theme->set_icon("radio_checked", "CheckBox", theme->get_icon("GuiRadioChecked", "EditorIcons")); @@ -589,6 +609,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "CheckBox", font_color_disabled); theme->set_color("icon_color_hover", "CheckBox", font_color_hl); + theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE); + theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE); + // PopupMenu Ref<StyleBoxFlat> style_popup_menu = style_popup; theme->set_stylebox("panel", "PopupMenu", style_popup_menu); @@ -801,6 +824,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE); theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE); theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE); + theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts")); // complex window, for now only Editor settings and Project settings Ref<StyleBoxFlat> style_complex_window = style_window->duplicate(); @@ -1043,12 +1067,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { return theme; } -Ref<Theme> create_custom_theme() { +Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) { Ref<Theme> theme; String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme"); if (custom_theme != "") { theme = ResourceLoader::load(custom_theme); + } else { + theme = create_editor_theme(p_theme); } String global_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); diff --git a/editor/editor_themes.h b/editor/editor_themes.h index a644c5936f..6f3b83e0b0 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -34,6 +34,6 @@ Ref<Theme> create_editor_theme(Ref<Theme> p_theme = NULL); -Ref<Theme> create_custom_theme(); +Ref<Theme> create_custom_theme(Ref<Theme> p_theme = NULL); #endif diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index b3c21d4e63..7abddb9f67 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1186,78 +1186,36 @@ void FileSystemDock::set_display_mode(int p_mode) { } Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) { + bool is_favorite = false; + Vector<String> paths; if (p_from == tree) { - TreeItem *selected = tree->get_selected(); if (!selected) return Variant(); - String fpath = selected->get_metadata(0); - if (fpath == String()) + String folder = selected->get_metadata(0); + if (folder == String()) return Variant(); - if (!fpath.ends_with("/")) - fpath = fpath + "/"; - Vector<String> paths; - paths.push_back(fpath); - Dictionary d = EditorNode::get_singleton()->drag_files(paths, p_from); - - if (selected->get_parent() && tree->get_root()->get_children() == selected->get_parent()) { - //a favorite.. treat as such - d["type"] = "favorite"; - } - - return d; - } - - if (p_from == files) { - - List<int> seldirs; - List<int> selfiles; + paths.push_back(folder.ends_with("/") ? folder : (folder + "/")); + is_favorite = selected->get_parent() != NULL && tree->get_root()->get_children() == selected->get_parent(); + } else if (p_from == files) { for (int i = 0; i < files->get_item_count(); i++) { if (files->is_selected(i)) { - String fpath = files->get_item_metadata(i); - if (fpath.ends_with("/")) - seldirs.push_back(i); - else - selfiles.push_back(i); + paths.push_back(files->get_item_metadata(i)); } } + } - if (seldirs.empty() && selfiles.empty()) - return Variant(); - /* - if (seldirs.size() && selfiles.size()) - return Variant(); //can't really mix files and dirs (i think?) - yes you can, commenting - */ - - /*if (selfiles.size()==1) { - Ref<Resource> resource = ResourceLoader::load(files->get_item_metadata(selfiles.front()->get())); - if (resource.is_valid()) { - return EditorNode::get_singleton()->drag_resource(resource,p_from); - } - }*/ - - Vector<String> fnames; - if (selfiles.size() > 0 || seldirs.size() > 0) { - if (selfiles.size() > 0) { - for (List<int>::Element *E = selfiles.front(); E; E = E->next()) { - fnames.push_back(files->get_item_metadata(E->get())); - } - if (seldirs.size() == 0) - return EditorNode::get_singleton()->drag_files(fnames, p_from); - } - - for (List<int>::Element *E = seldirs.front(); E; E = E->next()) { - fnames.push_back(files->get_item_metadata(E->get())); - } + if (paths.empty()) + return Variant(); - return EditorNode::get_singleton()->drag_files_and_dirs(fnames, p_from); - } + Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from); + if (is_favorite) { + drag_data["type"] = "favorite"; } - - return Variant(); + return drag_data; } bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { @@ -1288,36 +1246,25 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da } if (drag_data.has("type") && String(drag_data["type"]) == "resource") { - return true; + String to_dir = _get_drag_target_folder(p_point, p_from); + return !to_dir.empty(); } if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) { + String to_dir = _get_drag_target_folder(p_point, p_from); + if (to_dir.empty()) + 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 + to_dir = to_dir.ends_with("/") ? to_dir : (to_dir + "/"); Vector<String> fnames = drag_data["files"]; - - if (p_from == files) { - - int at_pos = files->get_item_at_position(p_point); - if (at_pos != -1) { - - String dir = files->get_item_metadata(at_pos); - if (dir.ends_with("/")) - return true; - } - } - - if (p_from == tree) { - - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return false; - - String fpath = ti->get_metadata(0); - if (fpath == String()) + for (int i = 0; i < fnames.size(); ++i) { + if (fnames[i].ends_with("/") && to_dir.begins_with(fnames[i])) return false; - - return true; } + + return true; } return false; @@ -1393,66 +1340,16 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, if (drag_data.has("type") && String(drag_data["type"]) == "resource") { Ref<Resource> res = drag_data["resource"]; - - if (!res.is_valid()) { - return; - } - - if (p_from == tree) { - - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return; - - String fpath = ti->get_metadata(0); - if (fpath == String()) - return; - - EditorNode::get_singleton()->save_resource_as(res, fpath); - return; - } - - if (p_from == files) { - String save_path = path; - - int at_pos = files->get_item_at_position(p_point); - if (at_pos != -1) { - String to_dir = files->get_item_metadata(at_pos); - if (to_dir.ends_with("/")) { - save_path = to_dir; - if (save_path != "res://") - save_path = save_path.substr(0, save_path.length() - 1); - } - } - - EditorNode::get_singleton()->save_resource_as(res, save_path); - return; + String to_dir = _get_drag_target_folder(p_point, p_from); + if (res.is_valid() && !to_dir.empty()) { + EditorNode::get_singleton()->push_item(res.ptr()); + EditorNode::get_singleton()->save_resource_as(res, to_dir); } } if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) { - - if (p_from == files || p_from == tree) { - - String to_dir; - - if (p_from == files) { - - int at_pos = files->get_item_at_position(p_point); - ERR_FAIL_COND(at_pos == -1); - to_dir = files->get_item_metadata(at_pos); - } else { - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return; - to_dir = ti->get_metadata(0); - ERR_FAIL_COND(to_dir == String()); - } - - if (to_dir != "res://" && to_dir.ends_with("/")) { - to_dir = to_dir.substr(0, to_dir.length() - 1); - } - + String to_dir = _get_drag_target_folder(p_point, p_from); + if (!to_dir.empty()) { Vector<String> fnames = drag_data["files"]; to_move.clear(); for (int i = 0; i < fnames.size(); i++) { @@ -1463,6 +1360,25 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, } } +String FileSystemDock::_get_drag_target_folder(const Point2 &p_point, Control *p_from) const { + if (p_from == files) { + int pos = files->get_item_at_position(p_point, true); + if (pos == -1) + return path; + + String target = files->get_item_metadata(pos); + return target.ends_with("/") ? target : path; + } + + if (p_from == tree) { + TreeItem *ti = tree->get_item_at_position(p_point); + if (ti && ti != tree->get_root()->get_children()) + return ti->get_metadata(0); + } + + return String(); +} + void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) { //Right clicking ".." should clear current selection diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 2cb0573a3d..249621564d 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -209,6 +209,7 @@ private: Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + String _get_drag_target_folder(const Point2 &p_point, Control *p_from) const; void _preview_invalidated(const String &p_path); void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata); diff --git a/editor/icons/icon_GUI_toggle_off.svg b/editor/icons/icon_GUI_toggle_off.svg index 0d43b158b5..aea0f85f96 100644 --- a/editor/icons/icon_GUI_toggle_off.svg +++ b/editor/icons/icon_GUI_toggle_off.svg @@ -1,5 +1,5 @@ -<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1020.4)"> -<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996v0.003906c0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12v-0.003906c0-6.6307-5.3693-11.996-12-11.996h-16zm0 2h16c5.5573 0 10 4.4388 10 9.9961v0.003906c0 5.5573-4.4427 10-10 10h-16c-5.5573 0-10-4.4427-10-10v-0.003906c0-5.5573 4.4427-9.9961 10-9.9961zm7 4.9961a1.0001 1.0001 0 0 0 -1 1v8a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm9 0a1.0001 1.0001 0 0 0 -1 1v4 4a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm-17 0.003906c-2.7496 0-5 2.2504-5 5s2.2504 5 5 5 5-2.2504 5-5-2.2504-5-5-5zm0 2c1.6687 0 3 1.3313 3 3s-1.3313 3-3 3-3-1.3313-3-3 1.3313-3 3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="filter-blend-mode:normal;filter-gaussianBlur-deviation:0;font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1026.4)"> +<path d="m13 1027.4c-6.6307 0-12 5.3663-12 11.998 0 6.6318 5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002 0-6.6317-5.3693-11.998-12-11.998zm0 2.0003h16c5.5573 0 10 4.4395 10 9.9977 0 5.5583-4.4427 10.002-10 10.002h-16c-5.5573 0-10-4.4434-10-10.002 0-5.5582 4.4427-9.9977 10-9.9977zm7 4.9969a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm9 0a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm-17 0c-2.7496 0-5 2.2508-5 5.0008 0 2.7501 2.2504 5.0009 5 5.0009s5-2.2508 5-5.0009c0-2.75-2.2504-5.0008-5-5.0008zm0 2.0004c1.6687 0 3 1.3315 3 3.0004 0 1.669-1.3313 3.0005-3 3.0005s-3-1.3315-3-3.0005c0-1.6689 1.3313-3.0004 3-3.0004z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> </g> </svg> diff --git a/editor/icons/icon_GUI_toggle_on.svg b/editor/icons/icon_GUI_toggle_on.svg index fd2b915fc3..c0a11810d4 100644 --- a/editor/icons/icon_GUI_toggle_on.svg +++ b/editor/icons/icon_GUI_toggle_on.svg @@ -1,5 +1,5 @@ -<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1020.4)"> -<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996 0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12 0-6.6307-5.3693-11.996-12-11.996h-16zm17 6.9961a1 1 0 0 1 1 1v8a1.0001 1.0001 0 0 1 -1.752 0.66211l-5.248-6v5.3379a1 1 0 0 1 -1 1 1 1 0 0 1 -1 -1v-8a1.0001 1.0001 0 0 1 1.752 -0.6582l5.248 6v-5.3418a1 1 0 0 1 1 -1zm-15 0.003906c2.7496 0 5 2.2504 5 5s-2.2504 5-5 5-5-2.2504-5-5 2.2504-5 5-5zm0 2c-1.6687 0-3 1.3313-3 3s1.3313 3 3 3 3-1.3313 3-3-1.3313-3-3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1026.4)"> +<path d="m13 1027.4c-6.6307 0-12 5.3662-12 11.998s5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002s-5.3693-11.998-12-11.998zm17 6.9972a1 1.0002 0 0 1 1 1.0001v8.0014a1.0001 1.0003 0 0 1 -1.752 0.6623l-5.248-6.001v5.3387a1 1.0002 0 0 1 -1 1.0001 1 1.0002 0 0 1 -1 -1.0001v-8.0014a1.0001 1.0003 0 0 1 1.752 -0.6583l5.248 6.001v-5.3427a1 1.0002 0 0 1 1 -1.0001zm-15 0c2.7496 0 5 2.2507 5 5.0008s-2.2504 5.0008-5 5.0008-5-2.2507-5-5.0008 2.2504-5.0008 5-5.0008zm0 2.0003c-1.6687 0-3 1.3315-3 3.0005s1.3313 3.0005 3 3.0005 3-1.3315 3-3.0005-1.3313-3.0005-3-3.0005z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> </g> </svg> diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 831eb74b66..397bb6ad68 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1,5 +1,6 @@ #include "editor_scene_importer_gltf.h" #include "io/json.h" +#include "math_defs.h" #include "os/file_access.h" #include "os/os.h" #include "scene/3d/camera.h" @@ -1378,8 +1379,8 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) { state.nodes[skin_node]->skeleton_children.push_back(i); } - state.skins.push_back(skin); } + state.skins.push_back(skin); } print_line("total skins: " + itos(state.skins.size())); @@ -1419,7 +1420,8 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) { camera.perspective = true; if (d.has("perspective")) { Dictionary ppt = d["perspective"]; - camera.fov_size = ppt["yfov"]; + // GLTF spec is in radians, Godot's camera is in degrees. + camera.fov_size = (double)ppt["yfov"] * 180.0 / Math_PI; camera.zfar = ppt["zfar"]; camera.znear = ppt["znear"]; } else { diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 77fd6d883a..df4254e2a3 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -263,6 +263,14 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { imported->set_text(itos(p_paths.size()) + TTR(" Files")); } +void ImportDock::_importer_selected(int i_idx) { + String name = import_as->get_selected_metadata(); + Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(name); + ERR_FAIL_COND(importer.is_null()); + + params->importer = importer; +} + void ImportDock::_preset_selected(int p_idx) { int item_id = preset->get_popup()->get_item_id(p_idx); @@ -336,6 +344,7 @@ void ImportDock::_reimport() { Error err = config->load(params->paths[i] + ".import"); ERR_CONTINUE(err != OK); + config->set_value("remap", "importer", params->importer->get_importer_name()); config->erase_section("params"); for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { @@ -356,12 +365,18 @@ void ImportDock::_notification(int p_what) { imported->add_style_override("normal", get_stylebox("normal", "LineEdit")); } break; + + case NOTIFICATION_ENTER_TREE: { + + import_opts->edit(params); + } break; } } void ImportDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_reimport"), &ImportDock::_reimport); ClassDB::bind_method(D_METHOD("_preset_selected"), &ImportDock::_preset_selected); + ClassDB::bind_method(D_METHOD("_importer_selected"), &ImportDock::_importer_selected); } void ImportDock::initialize_import_options() const { @@ -379,6 +394,7 @@ ImportDock::ImportDock() { HBoxContainer *hb = memnew(HBoxContainer); add_margin_child(TTR("Import As:"), hb); import_as = memnew(OptionButton); + import_as->connect("item_selected", this, "_importer_selected"); hb->add_child(import_as); import_as->set_h_size_flags(SIZE_EXPAND_FILL); preset = memnew(MenuButton); diff --git a/editor/import_dock.h b/editor/import_dock.h index 029c458320..a9bb22e568 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -54,6 +54,7 @@ class ImportDock : public VBoxContainer { ImportDockParameters *params; void _preset_selected(int p_idx); + void _importer_selected(int i_idx); void _reimport(); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index cd53264437..d2e7feb6e1 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -33,6 +33,8 @@ #include "editor_settings.h" #include "io/json.h" +#include "version_generated.gen.h" + void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost) { title->set_text(p_title); @@ -867,6 +869,8 @@ void EditorAssetLibrary::_search(int p_page) { } args += String() + "sort=" + sort_key[sort->get_selected()]; + args += "&godot_version=" + itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR); + String support_list; for (int i = 0; i < SUPPORT_MAX; i++) { if (support->get_popup()->is_item_checked(i)) { @@ -1348,13 +1352,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(memnew(Label(TTR("Site:") + " "))); repository = memnew(OptionButton); - // FIXME: Reenable me once GH-7147 is fixed. - /* repository->add_item("godotengine.org"); repository->set_item_metadata(0, "https://godotengine.org/asset-library/api"); - */ repository->add_item("localhost"); - repository->set_item_metadata(/*1*/ 0, "http://127.0.0.1/asset-library/api"); + repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api"); + repository->connect("item_selected", this, "_repository_changed"); search_hb2->add_child(repository); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 3807c8961a..38467369db 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3623,7 +3623,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "rotation_deg", Math::rad2deg(n2d->get_rotation()), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "rotation_degrees", Math::rad2deg(n2d->get_rotation()), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "scale", n2d->get_scale(), existing); @@ -3654,7 +3654,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "rotation_deg", Math::rad2deg(F->get()->get_rotation()), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "rotation_degrees", Math::rad2deg(F->get()->get_rotation()), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), existing); } @@ -3668,7 +3668,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_deg(), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_degrees(), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), existing); } @@ -4373,11 +4373,11 @@ void CanvasItemEditorViewport::_on_mouse_exit() { void CanvasItemEditorViewport::_on_select_type(Object *selected) { CheckBox *check = Object::cast_to<CheckBox>(selected); String type = check->get_text(); - selector_label->set_text(vformat(TTR("Add %s"), type)); + selector->set_title(vformat(TTR("Add %s"), type)); label->set_text(vformat(TTR("Adding %s..."), type)); } -void CanvasItemEditorViewport::_on_change_type() { +void CanvasItemEditorViewport::_on_change_type_confirmed() { if (!button_group->get_pressed_button()) return; @@ -4387,6 +4387,11 @@ void CanvasItemEditorViewport::_on_change_type() { selector->hide(); } +void CanvasItemEditorViewport::_on_change_type_closed() { + + _remove_preview(); +} + void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const { label->set_position(get_global_position() + Point2(14, 14) * EDSCALE); label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); @@ -4698,7 +4703,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); check->set_pressed(check->get_text() == default_type); } - selector_label->set_text(vformat(TTR("Add %s"), default_type)); + selector->set_title(vformat(TTR("Add %s"), default_type)); selector->popup_centered_minsize(); } else { _perform_drop_data(); @@ -4721,7 +4726,8 @@ void CanvasItemEditorViewport::_notification(int p_what) { void CanvasItemEditorViewport::_bind_methods() { ClassDB::bind_method(D_METHOD("_on_select_type"), &CanvasItemEditorViewport::_on_select_type); - ClassDB::bind_method(D_METHOD("_on_change_type"), &CanvasItemEditorViewport::_on_change_type); + ClassDB::bind_method(D_METHOD("_on_change_type_confirmed"), &CanvasItemEditorViewport::_on_change_type_confirmed); + ClassDB::bind_method(D_METHOD("_on_change_type_closed"), &CanvasItemEditorViewport::_on_change_type_closed); ClassDB::bind_method(D_METHOD("_on_mouse_exit"), &CanvasItemEditorViewport::_on_mouse_exit); } @@ -4749,7 +4755,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte selector = memnew(AcceptDialog); editor->get_gui_base()->add_child(selector); selector->set_title(TTR("Change default type")); - selector->connect("confirmed", this, "_on_change_type"); + selector->connect("confirmed", this, "_on_change_type_confirmed"); + selector->connect("popup_hide", this, "_on_change_type_closed"); VBoxContainer *vbc = memnew(VBoxContainer); selector->add_child(vbc); @@ -4757,12 +4764,6 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte vbc->set_v_size_flags(SIZE_EXPAND_FILL); vbc->set_custom_minimum_size(Size2(200, 260) * EDSCALE); - selector_label = memnew(Label); - vbc->add_child(selector_label); - selector_label->set_align(Label::ALIGN_CENTER); - selector_label->set_valign(Label::VALIGN_BOTTOM); - selector_label->set_custom_minimum_size(Size2(0, 30) * EDSCALE); - btn_group = memnew(VBoxContainer); vbc->add_child(btn_group); btn_group->set_h_size_flags(0); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 97e3b03569..457833e1a7 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -568,7 +568,8 @@ class CanvasItemEditorViewport : public Control { void _on_mouse_exit(); void _on_select_type(Object *selected); - void _on_change_type(); + void _on_change_type_confirmed(); + void _on_change_type_closed(); void _create_preview(const Vector<String> &files) const; void _remove_preview(); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index c48a241e4d..5f73d0b465 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -278,11 +278,11 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); VS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); - light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light = VS::get_singleton()->directional_light_create(); light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); @@ -850,11 +850,11 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light = VS::get_singleton()->directional_light_create(); light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index d421b3798b..3210af1433 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -43,7 +43,7 @@ void ResourcePreloaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { load->set_icon(get_icon("Folder", "EditorIcons")); - _delete->set_icon(get_icon("Del", "EditorIcons")); + _delete->set_icon(get_icon("Remove", "EditorIcons")); } if (p_what == NOTIFICATION_READY) { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 25ca2d731e..75c6961521 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1285,12 +1285,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; Vector3 motion = intersection - click; - print_line(String(intersection) + " --- " + String(click)); if (motion_mask != Vector3()) { - motion = motion_mask.dot(motion) * motion_mask; - } else { + } else { float center_click_dist = click.distance_to(_edit.center); float center_inters_dist = intersection.distance_to(_edit.center); if (center_click_dist == 0) @@ -1302,12 +1300,19 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = (spatial_editor->are_local_coords_enabled() && motion_mask != Vector3()); // Disable local transformation for TRANSFORM_VIEW + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW float snap = 0; if (_edit.snap || spatial_editor->is_snap_enabled()) { snap = spatial_editor->get_scale_snap() / 100; + + Vector3 motion_snapped = motion; + motion_snapped.snap(Vector3(snap, snap, snap)); + set_message(TTR("Scaling: ") + motion_snapped); + + } else { + set_message(TTR("Scaling: ") + motion); } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1339,6 +1344,15 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { local_scale = original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); + // Prevent scaling to 0 it would break the gizmo + Basis check = original_local.basis; + check.scale(local_scale); + if (check.determinant() != 0) { + + // Apply scale + sp->set_scale(local_scale); + } + } else { if (_edit.snap || spatial_editor->is_snap_enabled()) { @@ -1348,12 +1362,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform r; r.basis.scale(motion + Vector3(1, 1, 1)); t = base * (r * (base.inverse() * original)); - } - // Apply scale - if (local_coords) { - sp->set_scale(local_scale); - } else { + // Apply scale sp->set_global_transform(t); } } @@ -1386,17 +1396,14 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); break; case TRANSFORM_YZ: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(1); plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0)); plane_mv = true; break; case TRANSFORM_XZ: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(0); plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1)); plane_mv = true; break; case TRANSFORM_XY: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0) + spatial_editor->get_gizmo_transform().basis.get_axis(1); plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2)); plane_mv = true; break; @@ -1410,55 +1417,27 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) break; - //_validate_selection(); Vector3 motion = intersection - click; if (motion_mask != Vector3()) { - if (plane_mv) - motion *= motion_mask; - else + if (!plane_mv) { motion = motion_mask.dot(motion) * motion_mask; + } } - //set_message("Translating: "+motion); - List<Node *> &selection = editor_selection->get_selected_node_list(); - float snap = 0; + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW + float snap = 0; if (_edit.snap || spatial_editor->is_snap_enabled()) { snap = spatial_editor->get_translate_snap(); - bool local_coords = spatial_editor->are_local_coords_enabled(); - - if (local_coords) { - bool multiple = false; - Spatial *node = NULL; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - - Spatial *sp = Object::cast_to<Spatial>(E->get()); - if (!sp) { - continue; - } - if (node) { - multiple = true; - break; - } else { - node = sp; - } - } - - if (multiple) { - motion.snap(Vector3(snap, snap, snap)); - } else { - Basis b = node->get_global_transform().basis.orthonormalized(); - Vector3 local_motion = b.inverse().xform(motion); - local_motion.snap(Vector3(snap, snap, snap)); - motion = b.xform(local_motion); - } - } else { - motion.snap(Vector3(snap, snap, snap)); - } + Vector3 motion_snapped = motion; + motion_snapped.snap(Vector3(snap, snap, snap)); + set_message(TTR("Translating: ") + motion_snapped); + } else { + set_message(TTR("Translating: ") + motion); } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1473,10 +1452,34 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform t = se->original; + Transform original = se->original; + Transform t; + + if (local_coords) { + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + Basis g = original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(motion); + local_motion.snap(Vector3(snap, snap, snap)); + + motion = g.xform(local_motion); + } + + } else { + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + motion.snap(Vector3(snap, snap, snap)); + } + } + + // Apply translation + t = original; t.origin += motion; sp->set_global_transform(t); } + + surface->update(); + } break; case TRANSFORM_ROTATE: { @@ -1533,7 +1536,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = spatial_editor->are_local_coords_enabled(); + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1552,10 +1555,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform original_local = se->original_local; Basis rot = Basis(axis, angle); - t.basis = original_local.get_basis() * rot; + t.basis = original_local.get_basis().orthonormalized() * rot; t.origin = original_local.origin; + // Apply rotation sp->set_transform(t); + sp->set_scale(original_local.basis.get_scale()); // re-apply original scale } else { @@ -1566,6 +1571,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { r.basis.rotate(plane.normal, angle); t = base * r * base.inverse() * original; + // Apply rotation sp->set_global_transform(t); } } @@ -2911,7 +2917,9 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P } } - instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); + if (scene != NULL) { + instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); + } editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene); editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene()); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 8870166dba..48aed0cf6c 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -860,6 +860,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) { hb_tools->add_child(separator); icon_zoom = memnew(TextureRect); + icon_zoom->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); hb_tools->add_child(icon_zoom); zoom_out = memnew(ToolButton); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 02ead3aee8..7f956b01ff 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -427,7 +427,9 @@ void ThemeEditor::_dialog_cbk() { void ThemeEditor::_theme_menu_cbk(int p_option) { - if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY) { + if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) { + + bool import = (p_option == POPUP_IMPORT_EDITOR_THEME); Ref<Theme> base_theme; @@ -449,21 +451,21 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_icon_list(type, &icons); for (List<StringName>::Element *E = icons.front(); E; E = E->next()) { - theme->set_icon(E->get(), type, Ref<Texture>()); + theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture>()); } List<StringName> shaders; base_theme->get_shader_list(type, &shaders); for (List<StringName>::Element *E = shaders.front(); E; E = E->next()) { - theme->set_shader(E->get(), type, Ref<Shader>()); + theme->set_shader(E->get(), type, import ? base_theme->get_shader(E->get(), type) : Ref<Shader>()); } List<StringName> styleboxs; base_theme->get_stylebox_list(type, &styleboxs); for (List<StringName>::Element *E = styleboxs.front(); E; E = E->next()) { - theme->set_stylebox(E->get(), type, Ref<StyleBox>()); + theme->set_stylebox(E->get(), type, import ? base_theme->get_stylebox(E->get(), type) : Ref<StyleBox>()); } List<StringName> fonts; @@ -477,14 +479,14 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_color_list(type, &colors); for (List<StringName>::Element *E = colors.front(); E; E = E->next()) { - theme->set_color(E->get(), type, Color()); + theme->set_color(E->get(), type, import ? base_theme->get_color(E->get(), type) : Color()); } List<StringName> constants; base_theme->get_constant_list(type, &constants); for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { - theme->set_constant(E->get(), type, base_theme->get_constant(type, E->get())); + theme->set_constant(E->get(), type, base_theme->get_constant(E->get(), type)); } } } @@ -639,7 +641,7 @@ ThemeEditor::ThemeEditor() { theme_menu->get_popup()->add_separator(); theme_menu->get_popup()->add_item(TTR("Create Empty Template"), POPUP_CREATE_EMPTY); theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY); - + theme_menu->get_popup()->add_item(TTR("Create From Current Editor Theme"), POPUP_IMPORT_EDITOR_THEME); add_child(theme_menu); theme_menu->set_position(Vector2(3, 3) * EDSCALE); theme_menu->get_popup()->connect("id_pressed", this, "_theme_menu_cbk"); diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 16b2da94d1..4d46282ba1 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -69,7 +69,8 @@ class ThemeEditor : public Control { POPUP_REMOVE, POPUP_CLASS_REMOVE, POPUP_CREATE_EMPTY, - POPUP_CREATE_EDITOR_EMPTY + POPUP_CREATE_EDITOR_EMPTY, + POPUP_IMPORT_EDITOR_THEME }; int popup_mode; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 9235dafaa6..0ee0eed3a2 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -973,7 +973,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Point2i pos = points[i]; - if (!paint_undo.has(over_tile)) { + if (!paint_undo.has(pos)) { paint_undo[pos] = _get_op_from_cell(pos); } @@ -993,7 +993,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Point2i pos = points[i]; - if (!paint_undo.has(over_tile)) { + if (!paint_undo.has(pos)) { paint_undo[pos] = _get_op_from_cell(pos); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 18416868ec..5bfdd73aad 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1053,7 +1053,7 @@ void ProjectManager::_load_recent_projects() { ec->set_custom_minimum_size(Size2(0, 1)); vb->add_child(ec); Label *title = memnew(Label(project_name)); - title->add_font_override("font", gui_base->get_font("large", "Fonts")); + title->add_font_override("font", gui_base->get_font("title", "EditorFonts")); title->add_color_override("font_color", font_color); title->set_clip_text(true); vb->add_child(title); @@ -1492,7 +1492,6 @@ ProjectManager::ProjectManager() { CenterContainer *ccl = memnew(CenterContainer); Label *l = memnew(Label); l->set_text(_MKSTR(VERSION_NAME) + String(" - ") + TTR("Project Manager")); - l->add_font_override("font", gui_base->get_font("doc", "EditorFonts")); ccl->add_child(l); top_hb->add_child(ccl); top_hb->add_spacer(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 53aafac390..b07280a4cd 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1318,7 +1318,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, translations[i].replace_first("res://", "")); t->set_tooltip(0, translations[i]); t->set_metadata(0, i); - t->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); } } @@ -1436,7 +1436,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, keys[i].replace_first("res://", "")); t->set_tooltip(0, keys[i]); t->set_metadata(0, keys[i]); - t->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); if (keys[i] == remap_selected) { t->select(0); translation_res_option_add_button->set_disabled(false); @@ -1454,7 +1454,7 @@ void ProjectSettingsEditor::_update_translations() { t2->set_text(0, path.replace_first("res://", "")); t2->set_tooltip(0, path); t2->set_metadata(0, j); - t2->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t2->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); t2->set_text(1, langnames); t2->set_editable(1, true); @@ -1782,6 +1782,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { tab_container->add_child(translations); //remap for properly select language in popup translation_locales_idxs_remap = Vector<int>(); + translation_locales_list_created = false; { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f4d5530faa..002ae568ff 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4258,7 +4258,7 @@ PropertyEditor::PropertyEditor() { use_filter = false; subsection_selectable = false; property_selectable = false; - show_type_icons = EDITOR_DEF("interface/editor/show_type_icons", false); + show_type_icons = false; // maybe one day will return. } PropertyEditor::~PropertyEditor() { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 7438c7671e..6b008838e5 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -533,10 +533,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (p_confirm_override) { _delete_confirm(); - // hack, force 2d editor viewport to refresh after deletion - if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) - editor->get_viewport_control()->update(); - } else { delete_dialog->set_text(TTR("Delete Node(s)?")); delete_dialog->popup_centered_minsize(); @@ -1300,6 +1296,7 @@ void SceneTreeDock::_delete_confirm() { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)NULL); editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", edited_scene); editor_data->get_undo_redo().add_undo_method(edited_scene, "set_owner", edited_scene->get_owner()); + editor_data->get_undo_redo().add_undo_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_undo_reference(edited_scene); } else { @@ -1345,6 +1342,12 @@ void SceneTreeDock::_delete_confirm() { } } editor_data->get_undo_redo().commit_action(); + + // hack, force 2d editor viewport to refresh after deletion + if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) + editor->get_viewport_control()->update(); + + editor->push_item(NULL); } void SceneTreeDock::_selection_changed() { diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index c19b80e649..0f1712c224 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -703,9 +703,7 @@ ScriptCreateDialog::ScriptCreateDialog() { internal = memnew(CheckButton); internal->connect("pressed", this, "_built_in_pressed"); hb = memnew(HBoxContainer); - Control *empty = memnew(Control); hb->add_child(internal); - hb->add_child(empty); l = memnew(Label); l->set_text(TTR("Built-in Script")); l->set_align(Label::ALIGN_RIGHT); |