diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 17 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.cpp | 22 |
3 files changed, 35 insertions, 5 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c376efca34..a8edeca931 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -908,8 +908,10 @@ void EditorNode::_save_all_scenes() { for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *scene = editor_data.get_edited_scene_root(i); if (scene && scene->get_filename() != "") { - // save in background if in the script editor - _save_scene_with_preview(scene->get_filename()); + if (i != editor_data.get_edited_scene()) + _save_scene(scene->get_filename(), i); + else + _save_scene_with_preview(scene->get_filename()); } // else: ignore new scenes } @@ -983,7 +985,10 @@ void EditorNode::_dialog_action(String p_file) { if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { _save_default_environment(); - _save_scene_with_preview(p_file); + if (scene_idx != editor_data.get_edited_scene()) + _save_scene(p_file, scene_idx); + else + _save_scene_with_preview(p_file); if (scene_idx != -1) _discard_changes(); @@ -1660,8 +1665,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { Node *scene = editor_data.get_edited_scene_root(scene_idx); if (scene && scene->get_filename() != "") { - // save in background if in the script editor - _save_scene_with_preview(scene->get_filename()); + if (scene_idx != editor_data.get_edited_scene()) + _save_scene(scene->get_filename(), scene_idx); + else + _save_scene_with_preview(scene->get_filename()); if (scene_idx != -1) _discard_changes(); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b9a6414b08..6398bd1623 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -694,6 +694,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("editors/2d/pan_speed", 20); set("editors/poly_editor/point_grab_radius", 8); + set("editors/poly_editor/show_previous_outline", true); set("run/window_placement/rect", 1); hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen"); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 88158d4b20..d04184f055 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -402,6 +402,11 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { cpoint = canvas_item_editor->snap_point(cpoint); edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint); + Vector<Vector2> poly = Variant(node->get_polygon()); + ERR_FAIL_INDEX_V(edited_point, poly.size(), false); + poly[edited_point] = edited_point_pos - node->get_offset(); + node->set_polygon(Variant(poly)); + canvas_item_editor->get_viewport_control()->update(); } } @@ -425,6 +430,23 @@ void Polygon2DEditor::_canvas_draw() { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons"); + if (edited_point >= 0 && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) { + + const Color col = node->get_color().contrasted(); + const int n = pre_move_edit.size(); + for (int i = 0; i < n; i++) { + + Vector2 p, p2; + p = pre_move_edit[i] + node->get_offset(); + p2 = pre_move_edit[(i + 1) % n] + node->get_offset(); + + Vector2 point = xform.xform(p); + Vector2 next_point = xform.xform(p2); + + vpc->draw_line(point, next_point, col, 2); + } + } + for (int i = 0; i < poly.size(); i++) { Vector2 p, p2; |