summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp36
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp97
-rw-r--r--editor/plugins/tile_set_editor_plugin.h1
4 files changed, 70 insertions, 66 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index a186782128..2a46aba207 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -340,7 +340,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, const
// Grid
Point2 offset = grid_offset;
if (snap_relative) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) {
offset = Object::cast_to<Node2D>(selection[0])->get_global_position();
} else {
@@ -382,7 +382,7 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
drag = DRAG_PIVOT;
} else if (set_pivot_shortcut.is_valid() && set_pivot_shortcut->is_shortcut(p_ev) && drag == DRAG_NONE && can_move_pivot) {
if (!Input::get_singleton()->is_mouse_button_pressed(0)) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
Vector2 mouse_pos = viewport->get_local_mouse_position();
if (selection.size() && viewport->get_rect().has_point(mouse_pos)) {
//just in case, make it work if over viewport
@@ -751,7 +751,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
undo_redo->create_action(TTR("Move Action"), UndoRedo::MERGE_ENDS);
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -811,7 +811,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
Rect2 r2;
r2.position = tl;
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -835,7 +835,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
int CanvasItemEditor::get_item_count() {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
int ic = 0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1002,7 +1002,7 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_anchor_handle_drag_type(const
void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1527,7 +1527,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
bone_ik_list.clear();
} else {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
@@ -1608,7 +1608,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
} else {
undo_redo->create_action(TTR("Edit CanvasItem"));
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1905,7 +1905,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
return;
}
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
@@ -2921,7 +2921,7 @@ void CanvasItemEditor::_draw_viewport() {
// hide/show buttons depending on the selection
bool all_locked = true;
bool all_group = true;
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
all_locked = false;
all_group = false;
@@ -2976,7 +2976,7 @@ void CanvasItemEditor::_notification(int p_what) {
EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
bool all_control = true;
bool has_control = false;
@@ -3277,7 +3277,7 @@ void CanvasItemEditor::_update_scroll(float) {
}
void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_preset) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Change Anchors and Margins"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3321,7 +3321,7 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p
}
void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3464,7 +3464,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
case LOCK_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3482,7 +3482,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case UNLOCK_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3502,7 +3502,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case GROUP_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3520,7 +3520,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case UNGROUP_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3878,7 +3878,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_SET_IK_CHAIN: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 73aff8cba1..bc986cee9c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -636,7 +636,7 @@ void ScriptEditor::_close_all_tabs() {
}
void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) {
- erase_tab_confirm->set_text(TTR("Close and save changes?\n\"") + current->get_name() + "\"");
+ erase_tab_confirm->set_text(TTR("Close and save changes?") + "\n\"" + current->get_name() + "\"");
erase_tab_confirm->popup_centered_minsize();
}
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index b5ff94a056..08679b781a 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -618,8 +618,10 @@ void AutotileEditor::_on_edit_mode_changed(int p_edit_mode) {
tool_containers[TOOLBAR_BITMASK]->hide();
tool_containers[TOOLBAR_SHAPE]->show();
tools[TOOL_SELECT]->set_tooltip(TTR("Select current edited sub-tile."));
- current_shape = PoolVector2Array();
spin_priority->hide();
+
+ current_shape = PoolVector2Array();
+ select_coord(edited_shape_coord);
} break;
default: {
tool_containers[TOOLBAR_DUMMY]->show();
@@ -629,7 +631,7 @@ void AutotileEditor::_on_edit_mode_changed(int p_edit_mode) {
tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to use as icon, this will be also used on invalid autotile bindings."));
spin_priority->hide();
} else {
- tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to change it's priority."));
+ tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to change its priority."));
spin_priority->show();
}
} break;
@@ -931,50 +933,18 @@ void AutotileEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
edited_shape_coord = coord;
edited_occlusion_shape = tile_set->autotile_get_light_occluder(get_current_tile(), edited_shape_coord);
edited_navigation_shape = tile_set->autotile_get_navigation_polygon(get_current_tile(), edited_shape_coord);
- shape_anchor = edited_shape_coord;
- shape_anchor.x *= (size.x + spacing);
- shape_anchor.y *= (size.y + spacing);
- if (edit_mode == EDITMODE_OCCLUSION) {
- current_shape.resize(0);
- if (edited_occlusion_shape.is_valid()) {
- for (int i = 0; i < edited_occlusion_shape->get_polygon().size(); i++) {
- current_shape.push_back(edited_occlusion_shape->get_polygon()[i] + shape_anchor);
- }
- }
- } else if (edit_mode == EDITMODE_NAVIGATION) {
- current_shape.resize(0);
- if (edited_navigation_shape.is_valid()) {
- if (edited_navigation_shape->get_polygon_count() > 0) {
- PoolVector<Vector2> vertices = edited_navigation_shape->get_vertices();
- for (int i = 0; i < edited_navigation_shape->get_polygon(0).size(); i++) {
- current_shape.push_back(vertices[edited_navigation_shape->get_polygon(0)[i]] + shape_anchor);
- }
- }
- }
- }
- } else {
- if (edit_mode == EDITMODE_COLLISION) {
- Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(get_current_tile());
- for (int i = 0; i < sd.size(); i++) {
- if (sd[i].autotile_coord == coord) {
- Ref<ConvexPolygonShape2D> shape = sd[i].shape;
- if (shape.is_valid()) {
-
- Rect2 bounding_rect;
- PoolVector2Array polygon;
- bounding_rect.position = shape->get_points()[0];
- for (int j = 0; j < shape->get_points().size(); j++) {
- polygon.push_back(shape->get_points()[j] + shape_anchor);
- bounding_rect.expand_to(shape->get_points()[j] + shape_anchor);
- }
- if (bounding_rect.has_point(mb->get_position())) {
- current_shape = polygon;
- edited_collision_shape = shape;
- }
- }
- }
+ Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(get_current_tile());
+ bool found_collision_shape = false;
+ for (int i = 0; i < sd.size(); i++) {
+ if (sd[i].autotile_coord == coord) {
+ edited_collision_shape = sd[i].shape;
+ found_collision_shape = true;
+ break;
}
}
+ if (!found_collision_shape)
+ edited_collision_shape = Ref<ConvexPolygonShape2D>(NULL);
+ select_coord(edited_shape_coord);
}
workspace->update();
} else if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
@@ -1341,7 +1311,7 @@ void AutotileEditor::draw_polygon_shapes() {
}
Vector<Vector2> polygon;
Vector<Color> colors;
- if (shape == edited_collision_shape) {
+ if (shape == edited_collision_shape && current_shape.size() > 2) {
for (int j = 0; j < current_shape.size(); j++) {
polygon.push_back(current_shape[j]);
colors.push_back(c_bg);
@@ -1391,7 +1361,7 @@ void AutotileEditor::draw_polygon_shapes() {
}
Vector<Vector2> polygon;
Vector<Color> colors;
- if (shape == edited_occlusion_shape) {
+ if (shape == edited_occlusion_shape && current_shape.size() > 2) {
for (int j = 0; j < current_shape.size(); j++) {
polygon.push_back(current_shape[j]);
colors.push_back(c_bg);
@@ -1439,7 +1409,7 @@ void AutotileEditor::draw_polygon_shapes() {
}
Vector<Vector2> polygon;
Vector<Color> colors;
- if (shape == edited_navigation_shape) {
+ if (shape == edited_navigation_shape && current_shape.size() > 2) {
for (int j = 0; j < current_shape.size(); j++) {
polygon.push_back(current_shape[j]);
colors.push_back(c_bg);
@@ -1549,6 +1519,39 @@ void AutotileEditor::close_shape(const Vector2 &shape_anchor) {
}
}
+void AutotileEditor::select_coord(const Vector2 &coord) {
+ int spacing = tile_set->autotile_get_spacing(get_current_tile());
+ Vector2 size = tile_set->autotile_get_size(get_current_tile());
+ Vector2 shape_anchor = coord;
+ shape_anchor.x *= (size.x + spacing);
+ shape_anchor.y *= (size.y + spacing);
+ if (edit_mode == EDITMODE_COLLISION) {
+ current_shape.resize(0);
+ if (edited_collision_shape.is_valid()) {
+ for (int j = 0; j < edited_collision_shape->get_points().size(); j++) {
+ current_shape.push_back(edited_collision_shape->get_points()[j] + shape_anchor);
+ }
+ }
+ } else if (edit_mode == EDITMODE_OCCLUSION) {
+ current_shape.resize(0);
+ if (edited_occlusion_shape.is_valid()) {
+ for (int i = 0; i < edited_occlusion_shape->get_polygon().size(); i++) {
+ current_shape.push_back(edited_occlusion_shape->get_polygon()[i] + shape_anchor);
+ }
+ }
+ } else if (edit_mode == EDITMODE_NAVIGATION) {
+ current_shape.resize(0);
+ if (edited_navigation_shape.is_valid()) {
+ if (edited_navigation_shape->get_polygon_count() > 0) {
+ PoolVector<Vector2> vertices = edited_navigation_shape->get_vertices();
+ for (int i = 0; i < edited_navigation_shape->get_polygon(0).size(); i++) {
+ current_shape.push_back(vertices[edited_navigation_shape->get_polygon(0)[i]] + shape_anchor);
+ }
+ }
+ }
+ }
+}
+
Vector2 AutotileEditor::snap_point(const Vector2 &point) {
Vector2 p = point;
Vector2 coord = edited_shape_coord;
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index de989a11e8..9bd3e23181 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -144,6 +144,7 @@ private:
void draw_grid_snap();
void draw_polygon_shapes();
void close_shape(const Vector2 &shape_anchor);
+ void select_coord(const Vector2 &coord);
Vector2 snap_point(const Vector2 &point);
void edit(Object *p_node);