diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/SCsub | 30 | ||||
-rw-r--r-- | editor/editor_export.cpp | 6 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 56 | ||||
-rw-r--r-- | editor/icons/icon_GUI_tree_updown.svg | 5 | ||||
-rw-r--r-- | editor/icons/icon_mini_color.svg | 6 | ||||
-rw-r--r-- | editor/icons/icon_mini_image.svg | 5 | ||||
-rw-r--r-- | editor/icons/icon_mini_input.svg | 5 | ||||
-rw-r--r-- | editor/plugins/curve_editor_plugin.cpp | 18 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 40 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 12 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 238 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 6 | ||||
-rw-r--r-- | editor/project_settings_editor.cpp | 2 |
14 files changed, 324 insertions, 108 deletions
diff --git a/editor/SCsub b/editor/SCsub index bf88ebb1b5..11cdb471a8 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -6,6 +6,16 @@ env.editor_sources = [] import os from compat import encode_utf8, byte_to_str, open_utf8 +def escape_string(s, encoding='ascii'): + if isinstance(s, unicode): + s = s.encode(encoding) + result = '' + for c in s: + if not (32 <= ord(c) < 127) or c in ('\\', '"'): + result += '\\%03o' % ord(c) + else: + result += c + return result def make_certs_header(target, source, env): @@ -162,7 +172,7 @@ def make_authors_header(target, source, env): for line in f: if reading: if line.startswith(" "): - g.write("\t\"" + line.strip() + "\",\n") + g.write("\t\"" + escape_string(line.strip()) + "\",\n") continue if line.startswith("## "): if reading: @@ -170,7 +180,7 @@ def make_authors_header(target, source, env): reading = False for i in range(len(sections)): if line.strip().endswith(sections[i]): - current_section = sections_id[i] + current_section = escape_string(sections_id[i]) reading = True g.write("static const char *" + current_section + "[] = {\n") break @@ -204,7 +214,7 @@ def make_donors_header(target, source, env): for line in f: if reading >= 0: if line.startswith(" "): - g.write("\t\"" + line.strip() + "\",\n") + g.write("\t\"" + escape_string(line.strip()) + "\",\n") continue if line.startswith("## "): if reading: @@ -212,7 +222,7 @@ def make_donors_header(target, source, env): reading = False for i in range(len(sections)): if line.strip().endswith(sections[i]): - current_section = sections_id[i] + current_section = escape_string(sections_id[i]) reading = True g.write("static const char *" + current_section + "[] = {\n") break @@ -237,7 +247,8 @@ def make_license_header(target, source, env): g.write("static const char *about_license =") for line in f: - g.write("\n\t\"" + line.strip().replace("\"", "\\\"") + "\\n\"") + escaped_string = escape_string(line.strip().replace("\"", "\\\"")) + g.write("\n\t\"" + escaped_string + "\\n\"") g.write(";\n") @@ -322,11 +333,13 @@ def make_license_header(target, source, env): for k in j[0].split("\n"): if file_body != "": file_body += "\\n\"\n" - file_body += "\t\"" + k.strip().replace("\"", "\\\"") + escaped_string = escape_string(k.strip().replace("\"", "\\\"")) + file_body += "\t\"" + escaped_string for k in j[1].split("\n"): if copyright_body != "": copyright_body += "\\n\"\n" - copyright_body += "\t\"" + k.strip().replace("\"", "\\\"") + escaped_string = escape_string(k.strip().replace("\"", "\\\"")) + copyright_body += "\t\"" + escaped_string about_tp_file += "\t" + file_body + "\",\n" about_tp_copyright += "\t" + copyright_body + "\",\n" @@ -340,7 +353,8 @@ def make_license_header(target, source, env): for j in i[1].split("\n"): if body != "": body += "\\n\"\n" - body += "\t\"" + j.strip().replace("\"", "\\\"") + escaped_string = escape_string(j.strip().replace("\"", "\\\"")) + body += "\t\"" + escaped_string about_license_name += "\t\"" + i[0] + "\",\n" about_license_body += "\t" + body + "\",\n" diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index db12998dd2..bc20a99809 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1141,6 +1141,12 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> & if (p_preset->get("texture_format/etc2")) { r_features->push_back("etc2"); } + + if (p_preset->get("binary_format/64_bits")) { + r_features->push_back("64"); + } else { + r_features->push_back("32"); + } } void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index b51fc7c362..0436ac78df 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -146,6 +146,25 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84c2ff", "#5caeff"); // selection (blue) ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ea686c", "#e3383d"); // key xform (red) + + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ecbd", "#25e3a0"); // VS variant + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#8da6f0", "#6d8eeb"); // VS bool + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#7dc6ef", "#4fb2e9"); // VS int + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#61daf4", "#27ccf0"); // VS float + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6ba7ec", "#4690e7"); // VS string + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#bd91f1", "#ad76ee"); // VS vector2 + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f191a5", "#ee758e"); // VS rect + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e286f0", "#dc6aed"); // VS vector3 + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c4ec69", "#96ce1a"); // VS transform2D + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f77070", "#f77070"); // VS plane + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ec69a3", "#ec69a3"); // VS quat + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ee7991", "#ee7991"); // VS aabb + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e3ec69", "#b2bb19"); // VS basis + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f6a86e", "#f49047"); // VS transform + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6993ec", "#6993ec"); // VS path + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ec9a", "#2ce573"); // VS rid + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#79f3e8", "#12d5c3"); // VS object + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#77edb1", "#57e99f"); // VS dict } // these ones should be converted even if we are using a dark theme @@ -393,7 +412,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_default->set_draw_center(true); // Button and widgets - const float extra_spacing = EDITOR_DEF("interface/theme/additional_spacing", 0.0); + const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing"); Ref<StyleBoxFlat> style_widget = style_default->duplicate(); style_widget->set_default_margin(MARGIN_LEFT, (extra_spacing + 6) * EDSCALE); @@ -437,14 +456,20 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size); // Tabs + + const int tab_default_margin_side = 10 * EDSCALE + extra_spacing * EDSCALE; + const int tab_default_margin_vertical = 5 * EDSCALE + extra_spacing * EDSCALE; + Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate(); style_tab_selected->set_border_width_all(border_width); style_tab_selected->set_border_width(MARGIN_BOTTOM, 0); style_tab_selected->set_border_color_all(dark_color_3); style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width); - style_tab_selected->set_default_margin(MARGIN_LEFT, 10 * EDSCALE); - style_tab_selected->set_default_margin(MARGIN_RIGHT, 10 * EDSCALE); + style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side); + style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side); + style_tab_selected->set_default_margin(MARGIN_BOTTOM, tab_default_margin_vertical); + style_tab_selected->set_default_margin(MARGIN_TOP, tab_default_margin_vertical); style_tab_selected->set_bg_color(tab_color); Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate(); @@ -468,7 +493,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("MenuPanel", "EditorStyles", style_menu); // Script Editor - theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(4, 0, 4, 4)); + theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size)); theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); // Play button group @@ -539,7 +564,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "OptionButton", font_color_disabled); theme->set_color("icon_color_hover", "OptionButton", font_color_hl); theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons")); - theme->set_constant("arrow_margin", "OptionButton", 4 * EDSCALE); + theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE); theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton @@ -591,6 +616,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons")); theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons")); theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons")); + theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons")); theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons")); theme->set_icon("select_option", "Tree", theme->get_icon("GuiTreeOption", "EditorIcons")); theme->set_stylebox("bg_focus", "Tree", style_focus); @@ -666,8 +692,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "ItemList", font_color); theme->set_color("font_color_selected", "ItemList", mono_color); theme->set_color("guide_color", "ItemList", guide_color); - theme->set_constant("vseparation", "ItemList", 2); - theme->set_constant("hseparation", "ItemList", 2); + theme->set_constant("vseparation", "ItemList", 2 * EDSCALE); + theme->set_constant("hseparation", "ItemList", 2 * EDSCALE); theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE); theme->set_constant("line_separation", "ItemList", 2 * EDSCALE); @@ -874,21 +900,23 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // GraphNode + const float mv = dark_theme ? 0.0 : 1.0; + const float mv2 = 1.0 - mv; const int gn_margin_side = 28; - Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(0, 0, 0, 0.3), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5); graphsb->set_border_width_all(border_width); - graphsb->set_border_color_all(Color(1, 1, 1, 0.9)); - Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(0, 0, 0, 0.6), gn_margin_side, 24, gn_margin_side, 5); + graphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); + Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5); graphsbselected->set_border_width_all(border_width); graphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9)); graphsbselected->set_shadow_size(8 * EDSCALE); graphsbselected->set_shadow_color(shadow_color); - Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(0, 0, 0, 0.3), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5); graphsbcomment->set_border_width_all(border_width); - graphsbcomment->set_border_color_all(Color(1, 1, 1, 0.9)); - Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(0, 0, 0, 0.4), gn_margin_side, 24, gn_margin_side, 5); + graphsbcomment->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); + Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5); graphsbcommentselected->set_border_width_all(border_width); - graphsbcommentselected->set_border_color_all(Color(1, 1, 1, 0.9)); + graphsbcommentselected->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate(); graphsbbreakpoint->set_draw_center(false); graphsbbreakpoint->set_border_color_all(warning_color); diff --git a/editor/icons/icon_GUI_tree_updown.svg b/editor/icons/icon_GUI_tree_updown.svg new file mode 100644 index 0000000000..cdcd6c2441 --- /dev/null +++ b/editor/icons/icon_GUI_tree_updown.svg @@ -0,0 +1,5 @@ +<svg width="14" height="14" version="1.1" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1038.4)"> +<path transform="translate(0 1038.4)" d="m6.9844 1.002a1.0001 1.0001 0 0 0 -0.69141 0.29102l-3 3a1 1 0 0 0 0 1.4141 1 1 0 0 0 1.4141 0l2.293-2.293 2.293 2.293a1 1 0 0 0 1.4141 0 1 1 0 0 0 0 -1.4141l-3-3a1.0001 1.0001 0 0 0 -0.72266 -0.29102zm3 6.998a1 1 0 0 0 -0.69141 0.29297l-2.293 2.293-2.293-2.293a1 1 0 0 0 -0.7207 -0.29102 1 1 0 0 0 -0.69336 0.29102 1 1 0 0 0 0 1.4141l3 3a1.0001 1.0001 0 0 0 1.4141 0l3-3a1 1 0 0 0 0 -1.4141 1 1 0 0 0 -0.72266 -0.29297z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#fff" fill-opacity=".58824" 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"/> +</g> +</svg> diff --git a/editor/icons/icon_mini_color.svg b/editor/icons/icon_mini_color.svg index b70015a05d..623f922158 100644 --- a/editor/icons/icon_mini_color.svg +++ b/editor/icons/icon_mini_color.svg @@ -1,7 +1,7 @@ <svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> <g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m4 4a3 3 0 0 0 -3 3 3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1h1v-2h-1z" fill="#ff7070"/> -<path transform="translate(0 1040.4)" d="m14 4a3 3 0 0 0 -3 3v3h2v-3a1 1 0 0 1 1 -1h1v-2h-1z" fill="#70bfff"/> -<path transform="translate(0 1040.4)" d="m6 2v5a3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1v-5h-2z" fill="#7aff70"/> +<path transform="translate(0 1040.4)" d="m4 4a3 3 0 0 0 -3 3 3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1h1v-2h-1z" fill="#ff8484"/> +<path transform="translate(0 1040.4)" d="m14 4a3 3 0 0 0 -3 3v3h2v-3a1 1 0 0 1 1 -1h1v-2h-1z" fill="#84c2ff"/> +<path transform="translate(0 1040.4)" d="m6 2v5a3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1v-5h-2z" fill="#84ffb1"/> </g> </svg> diff --git a/editor/icons/icon_mini_image.svg b/editor/icons/icon_mini_image.svg deleted file mode 100644 index 735cb563cb..0000000000 --- a/editor/icons/icon_mini_image.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m0 1v2h2v-2h-2zm3 2v6h2v-4a1 1 0 0 1 1 1v3h2v-3-1a1 1 0 0 1 1 1v3h2v-3a3 3 0 0 0 -3 -3h-2v0.17578a3 3 0 0 0 -1 -0.17578h-2zm8 3a3 3 0 0 0 3 3 1 1 0 0 1 -1 1h-1v2h1a3 3 0 0 0 3 -3v-6h-2a3 3 0 0 0 -3 3zm-11-1v4h2v-4h-2zm14 0v2a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1z" fill="#93f1b9"/> -</g> -</svg> diff --git a/editor/icons/icon_mini_input.svg b/editor/icons/icon_mini_input.svg deleted file mode 100644 index 92cf763cf8..0000000000 --- a/editor/icons/icon_mini_input.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m0 2v2h2v-2h-2zm13 0v5a3 3 0 0 0 3 3v-2a1 1 0 0 1 -1 -1v-1h1v-2h-1v-2h-2zm0 5a3 3 0 0 0 -3 -3h-2v3a3 3 0 0 0 -3 -3h-2v6h2v-4a1 1 0 0 1 1 1v3h2v2h2v-2a3 3 0 0 0 3 -3zm-13-1v4h2v-4h-2zm10 0a1 1 0 0 1 1 1 1 1 0 0 1 -1 1v-2z" fill="#adf18f"/> -</g> -</svg> diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 067629c460..2754aeed06 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -53,12 +53,12 @@ CurveEditor::CurveEditor() { _presets_menu = memnew(PopupMenu); _presets_menu->set_name("_presets_menu"); - _presets_menu->add_item("Flat0", PRESET_FLAT0); - _presets_menu->add_item("Flat1", PRESET_FLAT1); - _presets_menu->add_item("Linear", PRESET_LINEAR); - _presets_menu->add_item("Ease in", PRESET_EASE_IN); - _presets_menu->add_item("Ease out", PRESET_EASE_OUT); - _presets_menu->add_item("Smoothstep", PRESET_SMOOTHSTEP); + _presets_menu->add_item(TTR("Flat0"), PRESET_FLAT0); + _presets_menu->add_item(TTR("Flat1"), PRESET_FLAT1); + _presets_menu->add_item(TTR("Linear"), PRESET_LINEAR); + _presets_menu->add_item(TTR("Ease in"), PRESET_EASE_IN); + _presets_menu->add_item(TTR("Ease out"), PRESET_EASE_OUT); + _presets_menu->add_item(TTR("Smoothstep"), PRESET_SMOOTHSTEP); _presets_menu->connect("id_pressed", this, "_on_preset_item_selected"); _context_menu->add_child(_presets_menu); } @@ -344,19 +344,19 @@ void CurveEditor::open_context_menu(Vector2 pos) { _curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR : _curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR; - _context_menu->set_item_checked(CONTEXT_LINEAR, is_linear); + _context_menu->set_item_checked(_context_menu->get_item_index(CONTEXT_LINEAR), is_linear); } else { _context_menu->add_separator(); if (_selected_point > 0) { _context_menu->add_check_item(TTR("Left linear"), CONTEXT_LEFT_LINEAR); - _context_menu->set_item_checked(CONTEXT_LEFT_LINEAR, + _context_menu->set_item_checked(_context_menu->get_item_index(CONTEXT_LEFT_LINEAR), _curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR); } if (_selected_point + 1 < _curve_ref->get_point_count()) { _context_menu->add_check_item(TTR("Right linear"), CONTEXT_RIGHT_LINEAR); - _context_menu->set_item_checked(CONTEXT_RIGHT_LINEAR, + _context_menu->set_item_checked(_context_menu->get_item_index(CONTEXT_RIGHT_LINEAR), _curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 9af5885a17..5e66488afb 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1683,9 +1683,8 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool } ERR_FAIL_COND_V(!se, false); - // load script before adding as child else editor will crash at theme loading - se->set_edited_script(p_script); tab_container->add_child(se); + se->set_edited_script(p_script); se->set_tooltip_request_func("_get_debug_tooltip", this); if (se->get_edit_menu()) { se->get_edit_menu()->hide(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index b66e9598f9..a24856dad7 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -168,14 +168,34 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4)); + colors_cache.symbol_color = symbol_color; + colors_cache.keyword_color = keyword_color; + colors_cache.basetype_color = basetype_color; + colors_cache.type_color = type_color; + colors_cache.comment_color = comment_color; + colors_cache.string_color = string_color; + + theme_loaded = true; + if (!script.is_null()) + _set_theme_for_script(); +} + +void ScriptTextEditor::_set_theme_for_script() { + + if (!theme_loaded) + return; + + TextEdit *text_edit = code_editor->get_text_edit(); + List<String> keywords; script->get_language()->get_reserved_words(&keywords); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - text_edit->add_keyword_color(E->get(), keyword_color); + text_edit->add_keyword_color(E->get(), colors_cache.keyword_color); } //colorize core types + const Color basetype_color = colors_cache.basetype_color; text_edit->add_keyword_color("String", basetype_color); text_edit->add_keyword_color("Vector2", basetype_color); text_edit->add_keyword_color("Rect2", basetype_color); @@ -210,7 +230,7 @@ void ScriptTextEditor::_load_theme_settings() { if (n.begins_with("_")) n = n.substr(1, n.length()); - text_edit->add_keyword_color(n, type_color); + text_edit->add_keyword_color(n, colors_cache.type_color); } //colorize comments @@ -223,7 +243,7 @@ void ScriptTextEditor::_load_theme_settings() { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); - text_edit->add_color_region(beg, end, comment_color, end == ""); + text_edit->add_color_region(beg, end, colors_cache.comment_color, end == ""); } //colorize strings @@ -235,7 +255,7 @@ void ScriptTextEditor::_load_theme_settings() { String string = E->get(); String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); - text_edit->add_color_region(beg, end, string_color, end == ""); + text_edit->add_color_region(beg, end, colors_cache.string_color, end == ""); } } @@ -263,10 +283,10 @@ void ScriptTextEditor::reload_text() { void ScriptTextEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - - //emit_signal("name_changed"); - _load_theme_settings(); + switch (p_what) { + case NOTIFICATION_READY: + _load_theme_settings(); + break; } } @@ -556,6 +576,8 @@ void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) { emit_signal("name_changed"); code_editor->update_line_and_column(); + + _set_theme_for_script(); } void ScriptTextEditor::_validate_script() { @@ -1452,6 +1474,8 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { ScriptTextEditor::ScriptTextEditor() { + theme_loaded = false; + code_editor = memnew(CodeTextEditor); add_child(code_editor); code_editor->add_constant_override("separation", 0); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index f8b7470ec8..83f3ea57c0 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -57,6 +57,17 @@ class ScriptTextEditor : public ScriptEditorBase { int color_line; String color_args; + struct ColorsCache { + Color symbol_color; + Color keyword_color; + Color basetype_color; + Color type_color; + Color comment_color; + Color string_color; + } colors_cache; + + bool theme_loaded; + enum { EDIT_UNDO, EDIT_REDO, @@ -101,6 +112,7 @@ protected: void _validate_script(); void _code_complete_script(const String &p_code, List<String> *r_options, bool &r_force); void _load_theme_settings(); + void _set_theme_for_script(); void _notification(int p_what); static void _bind_methods(); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 69cfc05e2b..425390723c 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -49,13 +49,15 @@ #define DISTANCE_DEFAULT 4 -#define GIZMO_ARROW_SIZE 0.3 +#define GIZMO_ARROW_SIZE 0.35 #define GIZMO_RING_HALF_WIDTH 0.1 //#define GIZMO_SCALE_DEFAULT 0.28 #define GIZMO_SCALE_DEFAULT 0.15 #define GIZMO_PLANE_SIZE 0.2 #define GIZMO_PLANE_DST 0.3 -#define GIZMO_CIRCLE_SIZE 0.9 +#define GIZMO_CIRCLE_SIZE 1.1 +#define GIZMO_SCALE_OFFSET (GIZMO_CIRCLE_SIZE + 0.3) +#define GIZMO_ARROW_OFFSET (GIZMO_CIRCLE_SIZE + 0.3) #define ZOOM_MIN_DISTANCE 0.001 #define ZOOM_MULTIPLIER 1.08 @@ -538,8 +540,6 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) { List<Node *> &selection = editor_selection->get_selected_node_list(); - //Vector3 center; - //int nc=0; for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Spatial *sp = Object::cast_to<Spatial>(E->get()); @@ -551,14 +551,8 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) { continue; se->original = se->sp->get_global_transform(); - //center+=se->original.origin; - //nc++; + se->original_local = se->sp->get_transform(); } - - /* - if (nc) - _edit.center=center/float(nc); - */ } static int _get_key_modifier_setting(const String &p_property) { @@ -609,7 +603,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig for (int i = 0; i < 3; i++) { - Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs; + Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs * (GIZMO_ARROW_OFFSET + (GIZMO_ARROW_SIZE * 0.5)); float grabber_radius = gs * GIZMO_ARROW_SIZE; Vector3 r; @@ -624,7 +618,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig } bool is_plane_translate = false; - // second try + // plane select if (col_axis == -1) { col_d = 1e20; @@ -710,6 +704,43 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig } } + if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE) { + + int col_axis = -1; + float col_d = 1e20; + + for (int i = 0; i < 3; i++) { + + Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs * GIZMO_SCALE_OFFSET; + float grabber_radius = gs * GIZMO_ARROW_SIZE; + + Vector3 r; + + if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * 10000.0, grabber_pos, grabber_radius, &r)) { + float d = r.distance_to(ray_pos); + if (d < col_d) { + col_d = d; + col_axis = i; + } + } + } + + if (col_axis != -1) { + + if (p_highlight_only) { + + spatial_editor->select_gizmo_highlight_axis(col_axis + 9); + + } else { + //handle scale + _edit.mode = TRANSFORM_SCALE; + _compute_edit(Point2(p_screenpos.x, p_screenpos.y)); + _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis); + } + return true; + } + } + if (p_highlight_only) spatial_editor->select_gizmo_highlight_axis(-1); @@ -1182,7 +1213,28 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { case TRANSFORM_SCALE: { - Plane plane = Plane(_edit.center, _get_camera_normal()); + Vector3 motion_mask; + Plane plane; + bool plane_mv; + + switch (_edit.plane) { + case TRANSFORM_VIEW: + motion_mask = Vector3(0, 0, 0); + plane = Plane(_edit.center, _get_camera_normal()); + break; + case TRANSFORM_X_AXIS: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0); + plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); + break; + case TRANSFORM_Y_AXIS: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); + break; + case TRANSFORM_Z_AXIS: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2); + plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); + break; + } Vector3 intersection; if (!plane.intersects_ray(ray_pos, ray, &intersection)) @@ -1192,42 +1244,78 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) break; - float center_click_dist = click.distance_to(_edit.center); - float center_inters_dist = intersection.distance_to(_edit.center); - if (center_click_dist == 0) - break; + Vector3 motion = intersection - click; + print_line(String(intersection) + " --- " + String(click)); + if (motion_mask != Vector3()) { - float scale = (center_inters_dist / center_click_dist) * 100.0; + motion = motion_mask.dot(motion) * motion_mask; + } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { + float center_click_dist = click.distance_to(_edit.center); + float center_inters_dist = intersection.distance_to(_edit.center); + if (center_click_dist == 0) + break; - scale = Math::stepify(scale, spatial_editor->get_scale_snap()); + float scale = center_inters_dist - center_click_dist; + motion = Vector3(scale, scale, scale); } - set_message(vformat(TTR("Scaling to %s%%."), String::num(scale, 1))); - scale /= 100.0; + List<Node *> &selection = editor_selection->get_selected_node_list(); - Transform r; - r.basis.scale(Vector3(scale, scale, scale)); + bool local_coords = (spatial_editor->are_local_coords_enabled() && motion_mask != Vector3()); // Disable local transformation for TRANSFORM_VIEW - List<Node *> &selection = editor_selection->get_selected_node_list(); + float snap = 0; + if (_edit.snap || spatial_editor->is_snap_enabled()) { + + snap = spatial_editor->get_scale_snap() / 100; + } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Spatial *sp = Object::cast_to<Spatial>(E->get()); - if (!sp) + if (!sp) { continue; + } SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); - if (!se) + if (!se) { continue; + } Transform original = se->original; - + Transform original_local = se->original_local; Transform base = Transform(Basis(), _edit.center); - Transform t = base * (r * (base.inverse() * original)); + Transform t; + Vector3 local_scale; - sp->set_global_transform(t); + if (local_coords) { + + Basis g = original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(motion); + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + local_motion.snap(Vector3(snap, snap, snap)); + } + + local_scale = original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); + + } else { + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + motion.snap(Vector3(snap, snap, snap)); + } + + 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 { + sp->set_global_transform(t); + } } surface->update(); @@ -2271,6 +2359,14 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) { //VS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); VS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer); + + scale_gizmo_instance[i] = VS::get_singleton()->instance_create(); + VS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid()); + VS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + VS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); + //VS::get_singleton()->instance_geometry_set_flag(scale_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true); + VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); + VS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer); } } @@ -2280,6 +2376,7 @@ void SpatialEditorViewport::_finish_gizmo_instances() { VS::get_singleton()->free(move_gizmo_instance[i]); VS::get_singleton()->free(move_plane_gizmo_instance[i]); VS::get_singleton()->free(rotate_gizmo_instance[i]); + VS::get_singleton()->free(scale_gizmo_instance[i]); } } void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { @@ -2374,6 +2471,8 @@ void SpatialEditorViewport::update_transform_gizmo_view() { VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE)); VisualServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform); VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE)); + VisualServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); + VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE)); } } @@ -3259,6 +3358,7 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) { move_gizmo[i]->surface_set_material(0, i == p_axis ? gizmo_hl : gizmo_color[i]); move_plane_gizmo[i]->surface_set_material(0, (i + 6) == p_axis ? gizmo_hl : plane_gizmo_color[i]); rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_hl : gizmo_color[i]); + scale_gizmo[i]->surface_set_material(0, (i + 9) == p_axis ? gizmo_hl : gizmo_color[i]); } } @@ -3269,7 +3369,7 @@ void SpatialEditor::update_transform_gizmo() { bool first = true; Basis gizmo_basis; - bool local_gizmo_coords = transform_menu->get_popup()->is_item_checked(transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS)); + bool local_gizmo_coords = are_local_coords_enabled(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -3720,10 +3820,6 @@ void SpatialEditor::_menu_item_pressed(int p_option) { void SpatialEditor::_init_indicators() { - //RID mat = VisualServer::get_singleton()->fixed_material_create(); - ///VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); - //VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); - { indicator_mat.instance(); @@ -3835,6 +3931,7 @@ void SpatialEditor::_init_indicators() { move_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); move_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); rotate_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); + scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); Ref<SpatialMaterial> mat = memnew(SpatialMaterial); mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); @@ -3857,25 +3954,25 @@ void SpatialEditor::_init_indicators() { Vector3 ivec3; ivec3[(i + 2) % 3] = 1; + //translate { Ref<SurfaceTool> surftool = memnew(SurfaceTool); surftool->begin(Mesh::PRIMITIVE_TRIANGLES); - //translate - + // Arrow profile const int arrow_points = 5; Vector3 arrow[5] = { nivec * 0.0 + ivec * 0.0, nivec * 0.01 + ivec * 0.0, - nivec * 0.01 + ivec * 1.0, - nivec * 0.1 + ivec * 1.0, - nivec * 0.0 + ivec * (1 + GIZMO_ARROW_SIZE), + nivec * 0.01 + ivec * GIZMO_ARROW_OFFSET, + nivec * 0.065 + ivec * GIZMO_ARROW_OFFSET, + nivec * 0.0 + ivec * (GIZMO_ARROW_OFFSET + GIZMO_ARROW_SIZE), }; int arrow_sides = 6; - for (int k = 0; k < 7; k++) { + for (int k = 0; k < 6; k++) { Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides); Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides); @@ -3902,7 +3999,7 @@ void SpatialEditor::_init_indicators() { surftool->commit(move_gizmo[i]); } - // plane translation + // Plane Translation { Ref<SurfaceTool> surftool = memnew(SurfaceTool); surftool->begin(Mesh::PRIMITIVE_TRIANGLES); @@ -3945,6 +4042,7 @@ void SpatialEditor::_init_indicators() { surftool->commit(move_plane_gizmo[i]); } + // Rotate { Ref<SurfaceTool> surftool = memnew(SurfaceTool); @@ -3958,7 +4056,7 @@ void SpatialEditor::_init_indicators() { ivec * 0.02 + ivec2 * 0.02 + ivec2 * GIZMO_CIRCLE_SIZE, }; - for (int k = 0; k < 33; k++) { + for (int k = 0; k < 32; k++) { Basis ma(ivec, Math_PI * 2 * float(k) / 32); Basis mb(ivec, Math_PI * 2 * float(k + 1) / 32); @@ -3984,19 +4082,55 @@ void SpatialEditor::_init_indicators() { surftool->set_material(mat); surftool->commit(rotate_gizmo[i]); } - } - } - /*for(int i=0;i<4;i++) { + // Scale + { + Ref<SurfaceTool> surftool = memnew(SurfaceTool); + surftool->begin(Mesh::PRIMITIVE_TRIANGLES); - viewports[i]->init_gizmo_instance(i); - }*/ + // Cube arrow profile + const int arrow_points = 6; + Vector3 arrow[6] = { + nivec * 0.0 + ivec * 0.0, + nivec * 0.01 + ivec * 0.0, + nivec * 0.01 + ivec * 1.0 * GIZMO_SCALE_OFFSET, + nivec * 0.07 + ivec * 1.0 * GIZMO_SCALE_OFFSET, + nivec * 0.07 + ivec * 1.11 * GIZMO_SCALE_OFFSET, + nivec * 0.0 + ivec * 1.11 * GIZMO_SCALE_OFFSET, + }; - _generate_selection_box(); + int arrow_sides = 4; + + for (int k = 0; k < 4; k++) { - //Object::cast_to<EditorNode>(get_scene()->get_root_node())->get_scene_root()->add_child(camera); + Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides); + Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides); - //current_camera=camera; + for (int j = 0; j < arrow_points - 1; j++) { + + Vector3 points[4] = { + ma.xform(arrow[j]), + mb.xform(arrow[j]), + mb.xform(arrow[j + 1]), + ma.xform(arrow[j + 1]), + }; + surftool->add_vertex(points[0]); + surftool->add_vertex(points[1]); + surftool->add_vertex(points[2]); + + surftool->add_vertex(points[0]); + surftool->add_vertex(points[2]); + surftool->add_vertex(points[3]); + } + } + + surftool->set_material(mat); + surftool->commit(scale_gizmo[i]); + } + } + } + + _generate_selection_box(); } void SpatialEditor::_finish_indicators() { diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index e0ded6e646..4f4c540048 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -245,7 +245,7 @@ private: real_t zoom_indicator_delay; - RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3]; + RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3], scale_gizmo_instance[3]; String last_message; String message; @@ -319,6 +319,7 @@ class SpatialEditorSelectedItem : public Object { public: Rect3 aabb; Transform original; // original location when moving + Transform original_local; Transform last_xform; // last transform Spatial *sp; RID sbox_instance; @@ -407,7 +408,7 @@ private: bool grid_enable[3]; //should be always visible if true bool grid_enabled; - Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3]; + Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3]; Ref<SpatialMaterial> gizmo_color[3]; Ref<SpatialMaterial> plane_gizmo_color[3]; Ref<SpatialMaterial> gizmo_hl; @@ -557,6 +558,7 @@ public: Ref<ArrayMesh> get_move_gizmo(int idx) const { return move_gizmo[idx]; } Ref<ArrayMesh> get_move_plane_gizmo(int idx) const { return move_plane_gizmo[idx]; } Ref<ArrayMesh> get_rotate_gizmo(int idx) const { return rotate_gizmo[idx]; } + Ref<ArrayMesh> get_scale_gizmo(int idx) const { return scale_gizmo[idx]; } void update_transform_gizmo(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 56e593e34b..288328c7ed 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -907,6 +907,8 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { presets.insert("pvrtc"); presets.insert("debug"); presets.insert("release"); + presets.insert("32"); + presets.insert("64"); for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { List<String> p; |