Edit TileMap only with TOOL_SELECT

This commit is contained in:
Tomasz Chabora 2019-08-21 15:34:06 +02:00
parent 48eaf14030
commit 9520d9706a
3 changed files with 8 additions and 2 deletions

View File

@ -3321,6 +3321,10 @@ void CanvasItemEditor::update_viewport() {
viewport->update(); viewport->update();
} }
void CanvasItemEditor::set_current_tool(Tool p_tool) {
_button_tool_select(p_tool);
}
void CanvasItemEditor::_notification(int p_what) { void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_PHYSICS_PROCESS) { if (p_what == NOTIFICATION_PHYSICS_PROCESS) {

View File

@ -581,6 +581,7 @@ public:
void update_viewport(); void update_viewport();
Tool get_current_tool() { return tool; } Tool get_current_tool() { return tool; }
void set_current_tool(Tool p_tool);
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
void edit(CanvasItem *p_canvas_item); void edit(CanvasItem *p_canvas_item);

View File

@ -972,7 +972,7 @@ static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree()) if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree() || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT)
return false; return false;
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform(); Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
@ -1533,7 +1533,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
if (!node) if (!node || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT)
return; return;
Transform2D cell_xf = node->get_cell_transform(); Transform2D cell_xf = node->get_cell_transform();
@ -2136,6 +2136,7 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
tile_map_editor->show(); tile_map_editor->show();
tile_map_editor->get_toolbar()->show(); tile_map_editor->get_toolbar()->show();
tile_map_editor->get_toolbar_right()->show(); tile_map_editor->get_toolbar_right()->show();
CanvasItemEditor::get_singleton()->set_current_tool(CanvasItemEditor::TOOL_SELECT); //Change to TOOL_SELECT when TileMap node is selected, to prevent accidental movement.
} else { } else {
tile_map_editor->hide(); tile_map_editor->hide();