diff options
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/abstract_polygon_2d_editor.cpp | 18 | ||||
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.h | 6 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/collision_polygon_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/path_2d_editor_plugin.cpp | 94 | ||||
-rw-r--r-- | editor/plugins/path_2d_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/text_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 40 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.h | 3 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 26 |
14 files changed, 187 insertions, 51 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index a85f4456f7..dfdf56a2ef 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -425,7 +425,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) return true; } else { - const real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); if (!_is_line() && wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) { //wip closed @@ -565,7 +565,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl offset = _get_offset(j); } - if (!wip_active && j == edited_point.polygon && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) { + if (!wip_active && j == edited_point.polygon && EDITOR_GET("editors/poly_editor/show_previous_outline")) { const Color col = Color(0.5, 0.5, 0.5); // FIXME polygon->get_outline_color(); const int n = pre_move_edit.size(); @@ -695,7 +695,7 @@ AbstractPolygon2DEditor::Vertex AbstractPolygon2DEditor::get_active_point() cons AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const Vector2 &p_pos) const { - const real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); const int n_polygons = _get_polygon_count(); const Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); @@ -726,7 +726,7 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(const Vector2 &p_pos) const { - const real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); const real_t eps = grab_threshold * 2; const real_t eps2 = eps * eps; @@ -826,13 +826,11 @@ void AbstractPolygon2DEditorPlugin::make_visible(bool p_visible) { } } -AbstractPolygon2DEditorPlugin::AbstractPolygon2DEditorPlugin(EditorNode *p_node, AbstractPolygon2DEditor *p_polygon_editor, String p_class) { - - editor = p_node; - polygon_editor = p_polygon_editor; - klass = p_class; +AbstractPolygon2DEditorPlugin::AbstractPolygon2DEditorPlugin(EditorNode *p_node, AbstractPolygon2DEditor *p_polygon_editor, String p_class) : + polygon_editor(p_polygon_editor), + editor(p_node), + klass(p_class) { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(polygon_editor); - polygon_editor->hide(); } diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index e2daefdec6..e7934ea3a0 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -70,9 +70,9 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { String name; String type; Ref<Script> script; - AddOption(const String &p_name = String(), const String &p_type = String()) { - name = p_name; - type = p_type; + AddOption(const String &p_name = String(), const String &p_type = String()) : + name(p_name), + type(p_type) { } }; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 8d9872236c..c272f8d756 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -456,7 +456,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no if (Object::cast_to<Viewport>(p_node)) return; - const real_t grab_distance = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + const real_t grab_distance = EDITOR_GET("editors/poly_editor/point_grab_radius"); CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); for (int i = p_node->get_child_count() - 1; i >= 0; i--) { diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index e92a91db7c..9b31f2e24d 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -144,7 +144,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu Vector<Vector2> poly = node->call("get_polygon"); //first check if a point is to be added (segment split) - real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); switch (mode) { diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index c67c96798a..3d4816b17b 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -70,8 +70,9 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (!node->get_curve().is_valid()) return false; - Ref<InputEventMouseButton> mb = p_event; + real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); + Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); @@ -79,8 +80,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 gpoint = mb->get_position(); Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); - real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); - if (mb->is_pressed() && action == ACTION_NONE) { Ref<Curve2D> curve = node->get_curve(); @@ -179,6 +178,41 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } + // Check for segment split. + if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && mode == MODE_EDIT && on_edge == true) { + Vector2 gpoint = mb->get_position(); + Ref<Curve2D> curve = node->get_curve(); + + int insertion_point = -1; + float mbLength = curve->get_closest_offset(xform.affine_inverse().xform(gpoint)); + int len = curve->get_point_count(); + for (int i = 0; i < len - 1; i++) { + float compareLength = curve->get_closest_offset(curve->get_point_position(i + 1)); + if (mbLength >= curve->get_closest_offset(curve->get_point_position(i)) && mbLength <= compareLength) + insertion_point = i; + } + if (insertion_point == -1) + insertion_point = curve->get_point_count() - 2; + + undo_redo->create_action(TTR("Split Curve")); + undo_redo->add_do_method(curve.ptr(), "add_point", xform.affine_inverse().xform(gpoint), Vector2(0, 0), Vector2(0, 0), insertion_point + 1); + undo_redo->add_undo_method(curve.ptr(), "remove_point", insertion_point + 1); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); + undo_redo->commit_action(); + + action = ACTION_MOVING_POINT; + action_point = insertion_point + 1; + moving_from = curve->get_point_position(action_point); + moving_screen_from = gpoint; + + canvas_item_editor->update_viewport(); + + on_edge = false; + + return true; + } + // Check for point movement completion. if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && action != ACTION_NONE) { @@ -245,6 +279,49 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid()) { + if (action == ACTION_NONE && mode == MODE_EDIT) { + // Handle Edge Follow + bool old_edge = on_edge; + + Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); + Vector2 gpoint = mm->get_position(); + + Ref<Curve2D> curve = node->get_curve(); + if (curve == NULL) return true; + if (curve->get_point_count() < 2) return true; + + // Find edge + edge_point = xform.xform(curve->get_closest_point(xform.affine_inverse().xform(mm->get_position()))); + on_edge = false; + if (edge_point.distance_to(gpoint) <= grab_threshold) { + on_edge = true; + } + // However, if near a control point or its in-out handles then not on edge + int len = curve->get_point_count(); + for (int i = 0; i < len; i++) { + Vector2 pp = curve->get_point_position(i); + Vector2 p = xform.xform(pp); + if (p.distance_to(gpoint) <= grab_threshold) { + on_edge = false; + break; + } + p = xform.xform(pp + curve->get_point_in(i)); + if (p.distance_to(gpoint) <= grab_threshold) { + on_edge = false; + break; + } + p = xform.xform(pp + curve->get_point_out(i)); + if (p.distance_to(gpoint) <= grab_threshold) { + on_edge = false; + break; + } + } + if (on_edge || old_edge != on_edge) { + canvas_item_editor->update_viewport(); + return true; + } + } + if (action != ACTION_NONE) { // Handle point/control movement. Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); @@ -309,7 +386,6 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Control *vpc = canvas_item_editor->get_viewport_control(); for (int i = 0; i < len; i++) { - Vector2 point = xform.xform(curve->get_point_position(i)); vpc->draw_texture_rect(handle, Rect2(point - handle_size * 0.5, handle_size), false, Color(1, 1, 1, 1)); @@ -325,6 +401,11 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { vpc->draw_texture_rect(handle, Rect2(pointin - handle_size * 0.5, handle_size), false, Color(1, 0.5, 1, 0.3)); } } + + if (on_edge) { + Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); + p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5); + } } void Path2DEditor::_node_visibility_changed() { @@ -442,6 +523,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { undo_redo = editor->get_undo_redo(); mirror_handle_angle = true; mirror_handle_length = true; + on_edge = false; mode = MODE_EDIT; action = ACTION_NONE; @@ -455,7 +537,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons")); curve_edit->set_toggle_mode(true); curve_edit->set_focus_mode(Control::FOCUS_NONE); - curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point")); + curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Left Click: Split Segment (in curve)") + "\n" + TTR("Right Click: Delete Point")); curve_edit->connect("pressed", this, "_mode_selected", varray(MODE_EDIT)); base_hb->add_child(curve_edit); curve_edit_curve = memnew(ToolButton); @@ -469,7 +551,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons")); curve_create->set_toggle_mode(true); curve_create->set_focus_mode(Control::FOCUS_NONE); - curve_create->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)")); + curve_create->set_tooltip(TTR("Add Point (in empty space)")); curve_create->connect("pressed", this, "_mode_selected", varray(MODE_CREATE)); base_hb->add_child(curve_create); curve_del = memnew(ToolButton); diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h index 3a78657746..34952b473a 100644 --- a/editor/plugins/path_2d_editor_plugin.h +++ b/editor/plugins/path_2d_editor_plugin.h @@ -73,6 +73,7 @@ class Path2DEditor : public HBoxContainer { bool mirror_handle_angle; bool mirror_handle_length; + bool on_edge; enum HandleOption { HANDLE_OPTION_ANGLE, @@ -93,6 +94,7 @@ class Path2DEditor : public HBoxContainer { Point2 moving_screen_from; float orig_in_length; float orig_out_length; + Vector2 edge_point; void _mode_selected(int p_mode); void _handle_option_pressed(int p_option); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 75529d6007..44f1625d06 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -897,12 +897,12 @@ void ScriptEditor::_file_dialog_action(String p_file) { } break; case THEME_SAVE_AS: { if (!EditorSettings::get_singleton()->save_text_editor_theme_as(p_file)) { - editor->show_warning(TTR("Error while saving theme"), TTR("Error saving")); + editor->show_warning(TTR("Error while saving theme."), TTR("Error Saving")); } } break; case THEME_IMPORT: { if (!EditorSettings::get_singleton()->import_text_editor_theme(p_file)) { - editor->show_warning(TTR("Error importing theme"), TTR("Error importing")); + editor->show_warning(TTR("Error importing theme."), TTR("Error Importing")); } } break; } @@ -1090,7 +1090,7 @@ void ScriptEditor::_menu_option(int p_option) { Ref<Script> scr = current->get_edited_resource(); if (scr == NULL || scr.is_null()) { - EditorNode::get_singleton()->show_warning("Can't obtain the script for running"); + EditorNode::get_singleton()->show_warning("Can't obtain the script for running."); break; } @@ -1103,13 +1103,13 @@ void ScriptEditor::_menu_option(int p_option) { } if (!scr->is_tool()) { - EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run"); + EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run."); return; } if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) { - EditorNode::get_singleton()->show_warning("To run this script, it must inherit EditorScript and be set to tool mode"); + EditorNode::get_singleton()->show_warning("To run this script, it must inherit EditorScript and be set to tool mode."); return; } @@ -2977,10 +2977,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu = memnew(MenuButton); menu_hb->add_child(file_menu); file_menu->set_text(TTR("File")); + file_menu->set_switch_on_hover(true); file_menu->get_popup()->set_hide_on_window_lose_focus(true); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New Script")), FILE_NEW); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new_textfile", TTR("New TextFile")), FILE_NEW_TEXTFILE); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open")), FILE_OPEN); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New Script...")), FILE_NEW); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new_textfile", TTR("New TextFile...")), FILE_NEW_TEXTFILE); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open...")), FILE_OPEN); file_menu->get_popup()->add_submenu_item(TTR("Open Recent"), "RecentScripts", FILE_OPEN_RECENT); recent_scripts = memnew(PopupMenu); @@ -3009,10 +3010,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { theme_submenu->set_name("Theme"); file_menu->get_popup()->add_child(theme_submenu); theme_submenu->connect("id_pressed", this, "_theme_option"); - theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/import_theme", TTR("Import Theme")), THEME_IMPORT); + theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/import_theme", TTR("Import Theme...")), THEME_IMPORT); theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/reload_theme", TTR("Reload Theme")), THEME_RELOAD); + theme_submenu->add_separator(); theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/save_theme", TTR("Save Theme")), THEME_SAVE); - theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/save_theme_as", TTR("Save Theme As")), THEME_SAVE_AS); + theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/save_theme_as", TTR("Save Theme As...")), THEME_SAVE_AS); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS); @@ -3028,6 +3030,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { script_search_menu = memnew(MenuButton); menu_hb->add_child(script_search_menu); script_search_menu->set_text(TTR("Search")); + script_search_menu->set_switch_on_hover(true); script_search_menu->get_popup()->set_hide_on_window_lose_focus(true); script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F), HELP_SEARCH_FIND); script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), HELP_SEARCH_FIND_NEXT); @@ -3037,6 +3040,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debug_menu = memnew(MenuButton); menu_hb->add_child(debug_menu); debug_menu->set_text(TTR("Debug")); + debug_menu->set_switch_on_hover(true); debug_menu->get_popup()->set_hide_on_window_lose_focus(true); debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10), DEBUG_NEXT); debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11), DEBUG_STEP); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index e6bb8b24a9..6d4b1d1b9c 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -131,6 +131,7 @@ void ScriptTextEditor::_load_theme_settings() { Color safe_line_number_color = EDITOR_GET("text_editor/highlighting/safe_line_number_color"); Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color"); Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color"); + Color indent_guide_color = EDITOR_GET("text_editor/highlighting/indent_guide_color"); Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color"); Color selection_color = EDITOR_GET("text_editor/highlighting/selection_color"); Color brace_mismatch_color = EDITOR_GET("text_editor/highlighting/brace_mismatch_color"); @@ -163,6 +164,7 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_color_override("safe_line_number_color", safe_line_number_color); text_edit->add_color_override("caret_color", caret_color); text_edit->add_color_override("caret_background_color", caret_background_color); + text_edit->add_color_override("indent_guide_color", indent_guide_color); text_edit->add_color_override("font_selected_color", text_selected_color); text_edit->add_color_override("selection_color", selection_color); text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color); @@ -1076,7 +1078,7 @@ void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) if (p_highlighter != NULL) highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true); else - highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text("Standard"), true); + highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(TTR("Standard")), true); } void ScriptTextEditor::_change_syntax_highlighter(int p_idx) { @@ -1466,6 +1468,7 @@ ScriptTextEditor::ScriptTextEditor() { edit_menu = memnew(MenuButton); edit_menu->set_text(TTR("Edit")); + edit_menu->set_switch_on_hover(true); edit_menu->get_popup()->set_hide_on_window_lose_focus(true); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); @@ -1509,7 +1512,7 @@ ScriptTextEditor::ScriptTextEditor() { convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KEY_MASK_SHIFT | KEY_F6), EDIT_CAPITALIZE); convert_case->connect("id_pressed", this, "_edit_option"); - highlighters["Standard"] = NULL; + highlighters[TTR("Standard")] = NULL; highlighter_menu = memnew(PopupMenu); highlighter_menu->set_name("highlighter_menu"); edit_menu->get_popup()->add_child(highlighter_menu); @@ -1520,6 +1523,7 @@ ScriptTextEditor::ScriptTextEditor() { search_menu = memnew(MenuButton); edit_hb->add_child(search_menu); search_menu->set_text(TTR("Search")); + search_menu->set_switch_on_hover(true); search_menu->get_popup()->set_hide_on_window_lose_focus(true); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 914901b29a..e3389f25cf 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -70,6 +70,7 @@ void ShaderTextEditor::_load_theme_settings() { Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color"); Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color"); Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color"); + Color indent_guide_color = EDITOR_GET("text_editor/highlighting/indent_guide_color"); Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color"); Color selection_color = EDITOR_GET("text_editor/highlighting/selection_color"); Color brace_mismatch_color = EDITOR_GET("text_editor/highlighting/brace_mismatch_color"); @@ -98,6 +99,7 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->add_color_override("line_number_color", line_number_color); get_text_edit()->add_color_override("caret_color", caret_color); get_text_edit()->add_color_override("caret_background_color", caret_background_color); + get_text_edit()->add_color_override("indent_guide_color", indent_guide_color); get_text_edit()->add_color_override("font_selected_color", text_selected_color); get_text_edit()->add_color_override("selection_color", selection_color); get_text_edit()->add_color_override("brace_mismatch_color", brace_mismatch_color); @@ -368,6 +370,7 @@ void ShaderEditor::_editor_settings_changed() { shader_editor->get_text_edit()->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size")); shader_editor->get_text_edit()->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type")); shader_editor->get_text_edit()->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent")); + shader_editor->get_text_edit()->set_draw_indent_guides(EditorSettings::get_singleton()->get("text_editor/indent/draw_indent_guides")); shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs")); shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers")); shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting")); @@ -531,9 +534,8 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { HBoxContainer *hbc = memnew(HBoxContainer); edit_menu = memnew(MenuButton); - //edit_menu->set_position(Point2(5, -1)); edit_menu->set_text(TTR("Edit")); - + edit_menu->set_switch_on_hover(true); edit_menu->get_popup()->set_hide_on_window_lose_focus(true); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); @@ -553,12 +555,11 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/complete_symbol"), EDIT_COMPLETE); - edit_menu->get_popup()->connect("id_pressed", this, "_menu_option"); search_menu = memnew(MenuButton); - //search_menu->set_position(Point2(38, -1)); search_menu->set_text(TTR("Search")); + search_menu->set_switch_on_hover(true); search_menu->get_popup()->set_hide_on_window_lose_focus(true); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index cc5f50a834..4fe278d005 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -5475,6 +5475,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { transform_menu = memnew(MenuButton); transform_menu->set_text(TTR("Transform")); + transform_menu->set_switch_on_hover(true); hbc_menu->add_child(transform_menu); p = transform_menu->get_popup(); @@ -5487,6 +5488,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { view_menu = memnew(MenuButton); view_menu->set_text(TTR("View")); + view_menu->set_switch_on_hover(true); hbc_menu->add_child(view_menu); p = view_menu->get_popup(); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 4a8eae1ba4..52dd115b3e 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -84,6 +84,7 @@ void TextEditor::_load_theme_settings() { Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color"); Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color"); Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color"); + Color indent_guide_color = EDITOR_GET("text_editor/highlighting/indent_guide_color"); Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color"); Color selection_color = EDITOR_GET("text_editor/highlighting/selection_color"); Color brace_mismatch_color = EDITOR_GET("text_editor/highlighting/brace_mismatch_color"); @@ -115,6 +116,7 @@ void TextEditor::_load_theme_settings() { text_edit->add_color_override("line_number_color", line_number_color); text_edit->add_color_override("caret_color", caret_color); text_edit->add_color_override("caret_background_color", caret_background_color); + text_edit->add_color_override("indent_guide_color", indent_guide_color); text_edit->add_color_override("font_selected_color", text_selected_color); text_edit->add_color_override("selection_color", selection_color); text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color); diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index fe896e12ff..cab9a4297d 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -185,6 +185,7 @@ void TileSetEditor::_bind_methods() { ClassDB::bind_method("_on_workspace_input", &TileSetEditor::_on_workspace_input); ClassDB::bind_method("_on_tool_clicked", &TileSetEditor::_on_tool_clicked); ClassDB::bind_method("_on_priority_changed", &TileSetEditor::_on_priority_changed); + ClassDB::bind_method("_on_z_index_changed", &TileSetEditor::_on_z_index_changed); ClassDB::bind_method("_on_grid_snap_toggled", &TileSetEditor::_on_grid_snap_toggled); ClassDB::bind_method("_set_snap_step", &TileSetEditor::_set_snap_step); ClassDB::bind_method("_set_snap_off", &TileSetEditor::_set_snap_off); @@ -233,6 +234,7 @@ void TileSetEditor::_notification(int p_what) { tool_editmode[EDITMODE_BITMASK]->set_icon(get_icon("PackedDataContainer", "EditorIcons")); tool_editmode[EDITMODE_PRIORITY]->set_icon(get_icon("MaterialPreviewLight1", "EditorIcons")); tool_editmode[EDITMODE_ICON]->set_icon(get_icon("LargeTexture", "EditorIcons")); + tool_editmode[EDITMODE_Z_INDEX]->set_icon(get_icon("Sort", "EditorIcons")); scroll->add_style_override("bg", get_stylebox("bg", "Tree")); } break; @@ -320,7 +322,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { tool_hb = memnew(HBoxContainer); g = Ref<ButtonGroup>(memnew(ButtonGroup)); - String label[EDITMODE_MAX] = { "Region", "Collision", "Occlusion", "Navigation", "Bitmask", "Priority", "Icon" }; + String label[EDITMODE_MAX] = { "Region", "Collision", "Occlusion", "Navigation", "Bitmask", "Priority", "Icon", "Z Index" }; for (int i = 0; i < (int)EDITMODE_MAX; i++) { tool_editmode[i] = memnew(Button); tool_editmode[i]->set_text(label[i]); @@ -395,6 +397,15 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { spin_priority->hide(); toolbar->add_child(spin_priority); + spin_z_index = memnew(SpinBox); + spin_z_index->set_min(VS::CANVAS_ITEM_Z_MIN); + spin_z_index->set_max(VS::CANVAS_ITEM_Z_MAX); + spin_z_index->set_step(1); + spin_z_index->set_custom_minimum_size(Size2(100, 0)); + spin_z_index->connect("value_changed", this, "_on_z_index_changed"); + spin_z_index->hide(); + toolbar->add_child(spin_z_index); + Control *separator = memnew(Control); separator->set_h_size_flags(SIZE_EXPAND_FILL); toolbar->add_child(separator); @@ -617,6 +628,7 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) { tools[TOOL_SELECT]->set_tooltip(TTR("Drag handles to edit Rect.\nClick on another Tile to edit it.")); tools[SHAPE_DELETE]->set_tooltip(TTR("Delete selected Rect.")); spin_priority->hide(); + spin_z_index->hide(); } break; case EDITMODE_COLLISION: case EDITMODE_NAVIGATION: @@ -639,6 +651,8 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) { tools[TOOL_SELECT]->set_tooltip(TTR("Select current edited sub-tile.\nClick on another Tile to edit it.")); tools[SHAPE_DELETE]->set_tooltip(TTR("Delete polygon.")); spin_priority->hide(); + spin_z_index->hide(); + select_coord(edited_shape_coord); } break; case EDITMODE_BITMASK: { @@ -661,6 +675,7 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) { tools[TOOL_SELECT]->set_tooltip(TTR("LMB: Set bit on.\nRMB: Set bit off.\nClick on another Tile to edit it.")); spin_priority->hide(); } break; + case EDITMODE_Z_INDEX: case EDITMODE_PRIORITY: case EDITMODE_ICON: { tools[TOOL_SELECT]->show(); @@ -681,9 +696,15 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) { if (edit_mode == EDITMODE_ICON) { tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to use as icon, this will be also used on invalid autotile bindings.\nClick on another Tile to edit it.")); spin_priority->hide(); - } else { + spin_z_index->hide(); + } else if (edit_mode == EDITMODE_PRIORITY) { tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to change its priority.\nClick on another Tile to edit it.")); spin_priority->show(); + spin_z_index->hide(); + } else { + tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to change its z index.\nClick on another Tile to edit it.")); + spin_priority->hide(); + spin_z_index->show(); } } break; default: {} @@ -811,6 +832,10 @@ void TileSetEditor::_on_workspace_draw() { spin_priority->set_suffix(" / " + String::num(total, 0)); draw_highlight_subtile(edited_shape_coord, queue_others); } break; + case EDITMODE_Z_INDEX: { + spin_z_index->set_value(tileset->autotile_get_z_index(get_current_tile(), edited_shape_coord)); + draw_highlight_subtile(edited_shape_coord); + } break; default: {} } } @@ -1205,7 +1230,8 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { case EDITMODE_COLLISION: case EDITMODE_OCCLUSION: case EDITMODE_NAVIGATION: - case EDITMODE_PRIORITY: { + case EDITMODE_PRIORITY: + case EDITMODE_Z_INDEX: { Vector2 shape_anchor = Vector2(0, 0); if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) { shape_anchor = edited_shape_coord; @@ -1481,6 +1507,11 @@ void TileSetEditor::_on_priority_changed(float val) { workspace->update(); } +void TileSetEditor::_on_z_index_changed(float val) { + tileset->autotile_set_z_index(get_current_tile(), edited_shape_coord, (int)val); + workspace->update(); +} + void TileSetEditor::_on_grid_snap_toggled(bool p_val) { helper->set_snap_options_visible(p_val); workspace->update(); @@ -2219,7 +2250,7 @@ void TileSetEditor::update_workspace_tile_mode() { separator_editmode->show(); if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) { - if (tool_editmode[EDITMODE_ICON]->is_pressed() || tool_editmode[EDITMODE_PRIORITY]->is_pressed() || tool_editmode[EDITMODE_BITMASK]->is_pressed()) { + if (tool_editmode[EDITMODE_ICON]->is_pressed() || tool_editmode[EDITMODE_PRIORITY]->is_pressed() || tool_editmode[EDITMODE_BITMASK]->is_pressed() || tool_editmode[EDITMODE_Z_INDEX]->is_pressed()) { tool_editmode[EDITMODE_COLLISION]->set_pressed(true); edit_mode = EDITMODE_COLLISION; } @@ -2228,6 +2259,7 @@ void TileSetEditor::update_workspace_tile_mode() { tool_editmode[EDITMODE_ICON]->hide(); tool_editmode[EDITMODE_BITMASK]->hide(); tool_editmode[EDITMODE_PRIORITY]->hide(); + tool_editmode[EDITMODE_Z_INDEX]->hide(); } else if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) { if (edit_mode == EDITMODE_ICON) select_coord(tileset->autotile_get_icon_coordinate(get_current_tile())); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index e713818c70..276e23f9ee 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -71,6 +71,7 @@ class TileSetEditor : public HSplitContainer { EDITMODE_BITMASK, EDITMODE_PRIORITY, EDITMODE_ICON, + EDITMODE_Z_INDEX, EDITMODE_MAX }; @@ -138,6 +139,7 @@ class TileSetEditor : public HSplitContainer { VSeparator *separator_delete; VSeparator *separator_grid; SpinBox *spin_priority; + SpinBox *spin_z_index; WorkspaceMode workspace_mode; EditMode edit_mode; int current_tile; @@ -178,6 +180,7 @@ private: void _on_workspace_input(const Ref<InputEvent> &p_ie); void _on_tool_clicked(int p_tool); void _on_priority_changed(float val); + void _on_z_index_changed(float val); void _on_grid_snap_toggled(bool p_val); void _set_snap_step(Vector2 p_val); void _set_snap_off(Vector2 p_val); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index b084fe1915..d3295c0f51 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -633,18 +633,23 @@ void VisualShaderEditor::_duplicate_nodes() { VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); List<int> nodes; + Set<int> excluded; for (int i = 0; i < graph->get_child_count(); i++) { - if (Object::cast_to<GraphNode>(graph->get_child(i))) { - int id = String(graph->get_child(i)->get_name()).to_int(); + GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); + if (gn) { + int id = String(gn->get_name()).to_int(); Ref<VisualShaderNode> node = visual_shader->get_node(type, id); Ref<VisualShaderNodeOutput> output = node; - if (output.is_valid()) //can't duplicate output + if (output.is_valid()) { // can't duplicate output + excluded.insert(id); continue; - if (node.is_valid()) { + } + if (node.is_valid() && gn->is_selected()) { nodes.push_back(id); } + excluded.insert(id); } } @@ -683,15 +688,16 @@ void VisualShaderEditor::_duplicate_nodes() { undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); - //reselect + // reselect duplicated nodes by excluding the other ones for (int i = 0; i < graph->get_child_count(); i++) { - if (Object::cast_to<GraphNode>(graph->get_child(i))) { - int id = String(graph->get_child(i)->get_name()).to_int(); - if (nodes.find(id)) { - Object::cast_to<GraphNode>(graph->get_child(i))->set_selected(true); + GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); + if (gn) { + int id = String(gn->get_name()).to_int(); + if (!excluded.has(id)) { + gn->set_selected(true); } else { - Object::cast_to<GraphNode>(graph->get_child(i))->set_selected(false); + gn->set_selected(false); } } } |