From c64ab9706303cae0841cfd7b93f276bb500b75f8 Mon Sep 17 00:00:00 2001 From: Mariano Javier Suligoy Date: Sun, 26 Aug 2018 17:10:01 -0300 Subject: TileSet editor Fixes Properly draw navigation and oclusion polygons for SINGLE type tiles. Fixes #21398 Add some checks for TileID validation before accessing to it's properties. Fixes #21397 Fix 'Keep inside region' snap option for tiles with SINGLE_TILE mode. Fixes #21402 Restore hability to asign/unasign an script to a tileset. Fixes #20886 --- editor/plugins/tile_map_editor_plugin.cpp | 42 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'editor/plugins/tile_map_editor_plugin.cpp') diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 34dd36692c..598f7034d8 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -457,36 +457,38 @@ void TileMapEditor::_update_palette() { palette->select(0); } - if ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE) { + 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) { - const Map &tiles = tileset->autotile_get_bitmask_map(sel_tile); + const Map &tiles = tileset->autotile_get_bitmask_map(sel_tile); - Vector entries; - for (const Map::Element *E = tiles.front(); E; E = E->next()) { - entries.push_back(E->key()); - } - entries.sort(); + Vector entries; + for (const Map::Element *E = tiles.front(); E; E = E->next()) { + entries.push_back(E->key()); + } + entries.sort(); - Ref tex = tileset->tile_get_texture(sel_tile); + Ref tex = tileset->tile_get_texture(sel_tile); - for (int i = 0; i < entries.size(); i++) { + for (int i = 0; i < entries.size(); i++) { - manual_palette->add_item(String()); + manual_palette->add_item(String()); - if (tex.is_valid()) { + if (tex.is_valid()) { - Rect2 region = tileset->tile_get_region(sel_tile); - int spacing = tileset->autotile_get_spacing(sel_tile); - region.size = tileset->autotile_get_size(sel_tile); // !! - region.position += (region.size + Vector2(spacing, spacing)) * entries[i]; + Rect2 region = tileset->tile_get_region(sel_tile); + int spacing = tileset->autotile_get_spacing(sel_tile); + region.size = tileset->autotile_get_size(sel_tile); // !! + region.position += (region.size + Vector2(spacing, spacing)) * entries[i]; - if (!region.has_no_area()) - manual_palette->set_item_icon_region(manual_palette->get_item_count() - 1, region); + if (!region.has_no_area()) + manual_palette->set_item_icon_region(manual_palette->get_item_count() - 1, region); - manual_palette->set_item_icon(manual_palette->get_item_count() - 1, tex); - } + manual_palette->set_item_icon(manual_palette->get_item_count() - 1, tex); + } - manual_palette->set_item_metadata(manual_palette->get_item_count() - 1, entries[i]); + manual_palette->set_item_metadata(manual_palette->get_item_count() - 1, entries[i]); + } } } -- cgit v1.2.3