diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-02-13 13:11:39 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-02-13 13:11:39 -0300 |
commit | 419fb45a3eea68516828fe4541a62f8641cf13ef (patch) | |
tree | 921a86a3dd4cb4ea3b6c5fc2c9ae693aa3411b1e | |
parent | 7f69da488e971b035fbdf044536db1ce9a100d50 (diff) |
Disallow polygon2D editing if internal vertices exists, as suggested in #24853
-rw-r--r-- | editor/plugins/abstract_polygon_2d_editor.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/abstract_polygon_2d_editor.h | 2 | ||||
-rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.h | 1 |
4 files changed, 19 insertions, 0 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 41e2062ab2..8f6f244e8f 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -297,6 +297,12 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) if (mb.is_valid()) { + String cant_edit = _why_cant_edit_polygon(); + if (cant_edit != String()) { + EditorNode::get_singleton()->show_warning(cant_edit); + return true; + } + Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); Vector2 gpoint = mb->get_position(); diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h index 289c2785b1..f10af4ee6e 100644 --- a/editor/plugins/abstract_polygon_2d_editor.h +++ b/editor/plugins/abstract_polygon_2d_editor.h @@ -134,6 +134,8 @@ protected: virtual bool _has_resource() const; virtual void _create_resource(); + virtual String _why_cant_edit_polygon() const { return String(); } + public: bool forward_gui_input(const Ref<InputEvent> &p_event); void forward_canvas_draw_over_viewport(Control *p_overlay); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index b879bc99c7..28a17d0bef 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -52,6 +52,16 @@ Vector2 Polygon2DEditor::_get_offset(int p_idx) const { return node->get_offset(); } +String Polygon2DEditor::_why_cant_edit_polygon() const { + + if (node->get_internal_vertex_count() > 0) { + + return TTR("Polygon 2D has internal vertices, so it can no longer be edited in the viewport."); + } + + return String(); +} + int Polygon2DEditor::_get_polygon_count() const { if (node->get_internal_vertex_count() > 0) { return 0; //do not edit if internal vertices exist diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index d1849dd09b..d3277e90f7 100644 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h @@ -152,6 +152,7 @@ protected: virtual void _set_node(Node *p_polygon); virtual Vector2 _get_offset(int p_idx) const; + virtual String _why_cant_edit_polygon() const; virtual bool _has_uv() const { return true; }; virtual void _commit_action(); |