diff options
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 30 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.h | 3 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 1 |
3 files changed, 29 insertions, 5 deletions
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index c9367edec6..8f7d6a9875 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -303,6 +303,12 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p if (manual_autotile || (p_value != -1 && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE)) { if (current != -1) { node->set_cell_autotile_coord(p_pos.x, p_pos.y, position); + + } else if (tool != TOOL_PASTING && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE && priority_atlastile) { + + // BIND_CENTER is used to indicate that bitmask should not update for this tile cell + node->get_tileset()->autotile_set_bitmask(p_value, Vector2(p_pos.x, p_pos.y), TileSet::BIND_CENTER); + node->update_cell_bitmask(p_pos.x, p_pos.y); } } else { // manually placing tiles should not update bitmasks @@ -317,6 +323,11 @@ void TileMapEditor::_manual_toggled(bool p_enabled) { _update_palette(); } +void TileMapEditor::_priority_toggled(bool p_enabled) { + priority_atlastile = p_enabled; + _update_palette(); +} + void TileMapEditor::_text_entered(const String &p_text) { canvas_item_editor_viewport->grab_focus(); @@ -475,7 +486,8 @@ void TileMapEditor::_update_palette() { } if (sel_tile != TileMap::INVALID_CELL) { - if ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE) { + if ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || + (!priority_atlastile && tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE)) { const Map<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(sel_tile); @@ -519,8 +531,10 @@ void TileMapEditor::_update_palette() { if (tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) { manual_button->show(); + priority_button->hide(); } else { manual_button->hide(); + priority_button->show(); } } @@ -664,7 +678,8 @@ void TileMapEditor::_fill_points(const PoolVector<Vector2> p_points, const Dicti _set_cell(pr[i], ids, xf, yf, tr); node->make_bitmask_area_dirty(pr[i]); } - node->update_dirty_bitmask(); + if (!manual_autotile) + node->update_dirty_bitmask(); } void TileMapEditor::_erase_points(const PoolVector<Vector2> p_points) { @@ -723,7 +738,7 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p if (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::AUTO_TILE || node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE) { Vector2 offset; int selected = manual_palette->get_current(); - if ((manual_autotile || node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE) && selected != -1) { + if ((manual_autotile || (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE && !priority_atlastile)) && selected != -1) { offset = manual_palette->get_item_metadata(selected); } else { if (tool != TOOL_PASTING) { @@ -1683,6 +1698,7 @@ void TileMapEditor::_icon_size_changed(float p_value) { void TileMapEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_manual_toggled"), &TileMapEditor::_manual_toggled); + ClassDB::bind_method(D_METHOD("_priority_toggled"), &TileMapEditor::_priority_toggled); ClassDB::bind_method(D_METHOD("_text_entered"), &TileMapEditor::_text_entered); ClassDB::bind_method(D_METHOD("_text_changed"), &TileMapEditor::_text_changed); ClassDB::bind_method(D_METHOD("_sbox_input"), &TileMapEditor::_sbox_input); @@ -1785,6 +1801,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { node = NULL; manual_autotile = false; + priority_atlastile = false; manual_position = Vector2(0, 0); canvas_item_editor_viewport = NULL; editor = p_editor; @@ -1815,10 +1832,15 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { add_child(tool_hb); manual_button = memnew(CheckBox); - manual_button->set_text("Disable Autotile"); + manual_button->set_text(TTR("Disable Autotile")); manual_button->connect("toggled", this, "_manual_toggled"); add_child(manual_button); + priority_button = memnew(CheckBox); + priority_button->set_text(TTR("Enable Priority")); + priority_button->connect("toggled", this, "_priority_toggled"); + add_child(priority_button); + search_box = memnew(LineEdit); search_box->set_h_size_flags(SIZE_EXPAND_FILL); search_box->connect("text_entered", this, "_text_entered"); diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index 8356d3af10..ca3b6ef567 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -78,6 +78,7 @@ class TileMapEditor : public VBoxContainer { TileMap *node; bool manual_autotile; + bool priority_atlastile; Vector2 manual_position; EditorNode *editor; @@ -101,6 +102,7 @@ class TileMapEditor : public VBoxContainer { ToolButton *clear_transform_button; CheckBox *manual_button; + CheckBox *priority_button; Tool tool; @@ -180,6 +182,7 @@ class TileMapEditor : public VBoxContainer { void set_selected_tiles(Vector<int> p_tile); void _manual_toggled(bool p_enabled); + void _priority_toggled(bool p_enabled); void _text_entered(const String &p_text); void _text_changed(const String &p_text); void _sbox_input(const Ref<InputEvent> &p_ie); diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index e5551d385b..8cb19d73be 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -2279,7 +2279,6 @@ void TileSetEditor::update_workspace_tile_mode() { select_coord(edited_shape_coord); tool_editmode[EDITMODE_BITMASK]->hide(); - tool_editmode[EDITMODE_PRIORITY]->hide(); } _on_edit_mode_changed(edit_mode); } |