diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-08-27 17:49:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-27 17:49:02 +0200 |
commit | 9df5ddae296fcdf4788e525f6898f4faa0cd36dd (patch) | |
tree | fa13fe9991a1b70b24737e3af151d22ca0db8e63 /editor/plugins/tile_map_editor_plugin.cpp | |
parent | 66778eae7123ddc25f1686066a54e4d2e3f9d76a (diff) | |
parent | c64ab9706303cae0841cfd7b93f276bb500b75f8 (diff) |
Merge pull request #21456 from MarianoGnu/tileset_editor
TileSet editor Fixes
Diffstat (limited to 'editor/plugins/tile_map_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
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<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(sel_tile); + const Map<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(sel_tile); - Vector<Vector2> entries; - for (const Map<Vector2, uint16_t>::Element *E = tiles.front(); E; E = E->next()) { - entries.push_back(E->key()); - } - entries.sort(); + Vector<Vector2> entries; + for (const Map<Vector2, uint16_t>::Element *E = tiles.front(); E; E = E->next()) { + entries.push_back(E->key()); + } + entries.sort(); - Ref<Texture> tex = tileset->tile_get_texture(sel_tile); + Ref<Texture> 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]); + } } } |