summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorMichael Alexsander Silva Dias <michaelalexsander@protonmail.com>2019-06-04 11:27:00 -0300
committerMichael Alexsander Silva Dias <michaelalexsander@protonmail.com>2019-06-04 11:36:05 -0300
commit6be7fea798e5559f3df31ba58f2ca8e59f91ce53 (patch)
treeff55a03e658b684d59c812d27d033cef951d4d2d /editor/plugins
parent328805ae313dea7467c255954a6b78b2bbd17b4e (diff)
Fix subtile picking in TileMap editor
Fixes #29445.
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 7aa3d69bfa..433a18a516 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -567,23 +567,25 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) {
if (id == TileMap::INVALID_CELL)
return;
- if (search_box->get_text().strip_edges() != "") {
-
+ if (search_box->get_text() != "") {
search_box->set_text("");
_update_palette();
}
- Vector<int> selected;
-
- selected.push_back(id);
- set_selected_tiles(selected);
-
flip_h = node->is_cell_x_flipped(p_pos.x, p_pos.y);
flip_v = node->is_cell_y_flipped(p_pos.x, p_pos.y);
transpose = node->is_cell_transposed(p_pos.x, p_pos.y);
autotile_coord = node->get_cell_autotile_coord(p_pos.x, p_pos.y);
+ Vector<int> selected;
+ selected.push_back(id);
+ set_selected_tiles(selected);
_update_palette();
+
+ if ((manual_autotile && node->get_tileset()->tile_get_tile_mode(id) == TileSet::AUTO_TILE) || (!priority_atlastile && node->get_tileset()->tile_get_tile_mode(id) == TileSet::ATLAS_TILE)) {
+ manual_palette->select(manual_palette->find_metadata((Point2)autotile_coord));
+ }
+
CanvasItemEditor::get_singleton()->update_viewport();
}
@@ -975,7 +977,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
} else {
- // Mousebutton was released
+ // Mousebutton was released.
if (tool != TOOL_NONE) {
if (tool == TOOL_PAINTING) {
@@ -1039,7 +1041,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
- return true; // We want to keep the Pasting tool
+ return true; // We want to keep the Pasting tool.
} else if (tool == TOOL_SELECTING) {
CanvasItemEditor::get_singleton()->update_viewport();
@@ -1063,7 +1065,10 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_finish_undo();
- // We want to keep the bucket-tool active
+ // So the fill preview is cleared right after the click.
+ CanvasItemEditor::get_singleton()->update_viewport();
+
+ // We want to keep the bucket-tool active.
return true;
}
@@ -1190,7 +1195,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_PAINTING) {
- // Paint using bresenham line to prevent holes in painting if the user moves fast
+ // Paint using bresenham line to prevent holes in painting if the user moves fast.
Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
Vector<int> ids = get_selected_tiles();
@@ -1211,7 +1216,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_ERASING) {
- // erase using bresenham line to prevent holes in painting if the user moves fast
+ // Erase using bresenham line to prevent holes in painting if the user moves fast.
Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
@@ -1336,13 +1341,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (!mouse_over) {
- // Editor shortcuts should not fire if mouse not in viewport
+ // Editor shortcuts should not fire if mouse not in viewport.
return false;
}
if (ED_IS_SHORTCUT("tile_map_editor/paint_tile", p_event)) {
// NOTE: We do not set tool = TOOL_PAINTING as this begins painting
- // immediately without pressing the left mouse button first
+ // immediately without pressing the left mouse button first.
tool = TOOL_NONE;
CanvasItemEditor::get_singleton()->update_viewport();
@@ -1424,7 +1429,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
- } else if (k.is_valid()) { // release event
+ } else if (k.is_valid()) { // Release event.
if (tool == TOOL_NONE) {
@@ -1440,7 +1445,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
#else
if (k->get_scancode() == KEY_CONTROL) {
#endif
- // go back to that last tool if KEY_CONTROL was released
+ // Go back to that last tool if KEY_CONTROL was released.
tool = last_tool;
CanvasItemEditor::get_singleton()->update_viewport();