diff options
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/texture_region_editor_plugin.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 28 |
3 files changed, 31 insertions, 23 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d0bd57d658..f13abd47a9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1004,7 +1004,7 @@ void ScriptEditor::_menu_option(int p_option) { ScriptEditorBase *current = _get_current_editor(); switch (p_option) { case FILE_NEW: { - script_create_dialog->config("Node", "new_script", false); + script_create_dialog->config("Node", "new_script", false, false); script_create_dialog->popup_centered(); } break; case FILE_NEW_TEXTFILE: { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 294bedd598..13faeb0edb 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -233,15 +233,19 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { mtx.elements[2] = -draw_ofs * draw_zoom; mtx.scale_basis(Vector2(draw_zoom, draw_zoom)); - Vector2 endpoints[8] = { - mtx.xform(rect.position) + Vector2(-4, -4), - mtx.xform(rect.position + Vector2(rect.size.x / 2, 0)) + Vector2(0, -4), - mtx.xform(rect.position + Vector2(rect.size.x, 0)) + Vector2(4, -4), - mtx.xform(rect.position + Vector2(rect.size.x, rect.size.y / 2)) + Vector2(4, 0), - mtx.xform(rect.position + rect.size) + Vector2(4, 4), - mtx.xform(rect.position + Vector2(rect.size.x / 2, rect.size.y)) + Vector2(0, 4), - mtx.xform(rect.position + Vector2(0, rect.size.y)) + Vector2(-4, 4), - mtx.xform(rect.position + Vector2(0, rect.size.y / 2)) + Vector2(-4, 0) + const real_t handle_radius = 8 * EDSCALE; + const real_t handle_offset = 4 * EDSCALE; + + // Position of selection handles. + const Vector2 endpoints[8] = { + mtx.xform(rect.position) + Vector2(-handle_offset, -handle_offset), + mtx.xform(rect.position + Vector2(rect.size.x / 2, 0)) + Vector2(0, -handle_offset), + mtx.xform(rect.position + Vector2(rect.size.x, 0)) + Vector2(handle_offset, -handle_offset), + mtx.xform(rect.position + Vector2(rect.size.x, rect.size.y / 2)) + Vector2(handle_offset, 0), + mtx.xform(rect.position + rect.size) + Vector2(handle_offset, handle_offset), + mtx.xform(rect.position + Vector2(rect.size.x / 2, rect.size.y)) + Vector2(0, handle_offset), + mtx.xform(rect.position + Vector2(0, rect.size.y)) + Vector2(-handle_offset, handle_offset), + mtx.xform(rect.position + Vector2(0, rect.size.y / 2)) + Vector2(-handle_offset, 0) }; Ref<InputEventMouseButton> mb = p_input; @@ -354,7 +358,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { for (int i = 0; i < 8; i++) { Vector2 tuv = endpoints[i]; - if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < 8) { + if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < handle_radius) { drag_index = i; } } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index b64ff6119c..b24d5add9f 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -1303,12 +1303,14 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { Size2 tile_workspace_size = edited_region.position + edited_region.size + WORKSPACE_MARGIN * 2; Size2 workspace_minsize = workspace->get_custom_minimum_size(); - if (tile_workspace_size.x > workspace_minsize.x && tile_workspace_size.y > workspace_minsize.y) { - undo_redo->add_do_method(workspace, "set_custom_minimum_size", tile_workspace_size); + // If the new region is bigger, just directly change the workspace size to avoid checking all other tiles. + if (tile_workspace_size.x > workspace_minsize.x || tile_workspace_size.y > workspace_minsize.y) { + Size2 max_workspace_size = Size2(MAX(tile_workspace_size.x, workspace_minsize.x), MAX(tile_workspace_size.y, workspace_minsize.y)); + undo_redo->add_do_method(workspace, "set_custom_minimum_size", max_workspace_size); undo_redo->add_undo_method(workspace, "set_custom_minimum_size", workspace_minsize); - undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", tile_workspace_size); + undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", max_workspace_size); undo_redo->add_undo_method(workspace_container, "set_custom_minimum_size", workspace_minsize); - undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", tile_workspace_size); + undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", max_workspace_size); undo_redo->add_undo_method(workspace_overlay, "set_custom_minimum_size", workspace_minsize); } else if (workspace_minsize.x > get_current_texture()->get_size().x + WORKSPACE_MARGIN.x * 2 || workspace_minsize.y > get_current_texture()->get_size().y + WORKSPACE_MARGIN.y * 2) { undo_redo->add_do_method(this, "update_workspace_minsize"); @@ -1803,8 +1805,6 @@ void TileSetEditor::_on_tool_clicked(int p_tool) { Ref<ConvexPolygonShape2D> _convex = memnew(ConvexPolygonShape2D); edited_collision_shape = _convex; _set_edited_shape_points(_get_collision_shape_points(concave)); - } else { - // Shouldn't happen } for (int i = 0; i < sd.size(); i++) { if (sd[i].get("shape") == previous_shape) { @@ -3267,12 +3267,16 @@ void TileSetEditor::update_workspace_minsize() { List<int> *tiles = new List<int>(); tileset->get_tile_list(tiles); for (List<int>::Element *E = tiles->front(); E; E = E->next()) { - if (tileset->tile_get_texture(E->get())->get_rid() == current_texture_rid) { - Rect2i region = tileset->tile_get_region(E->get()); - if (region.position.x + region.size.x > workspace_min_size.x) - workspace_min_size.x = region.position.x + region.size.x; - if (region.position.y + region.size.y > workspace_min_size.y) - workspace_min_size.y = region.position.y + region.size.y; + if (tileset->tile_get_texture(E->get())->get_rid() != current_texture_rid) { + continue; + } + + Rect2i region = tileset->tile_get_region(E->get()); + if (region.position.x + region.size.x > workspace_min_size.x) { + workspace_min_size.x = region.position.x + region.size.x; + } + if (region.position.y + region.size.y > workspace_min_size.y) { + workspace_min_size.y = region.position.y + region.size.y; } } delete tiles; |