Skip to content

Commit a998775

Browse files
authored
Adding tiles from project tilemaps to the cached tileset list in blocks (microsoft#7340)
1 parent e617305 commit a998775

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

pxtblocks/fields/field_utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,16 @@ namespace pxtblockly {
247247
}
248248
}
249249

250-
const allTiles = getAllBlocksWithTilesets(workspace);
251250
const project = pxt.react.getTilemapProject();
251+
const projectMaps = project.getAllTilemaps();
252+
253+
for (const projectMap of projectMaps) {
254+
for (const tile of projectMap.data.tileset.tiles) {
255+
all[tile.id] = tile;
256+
}
257+
}
258+
259+
const allTiles = getAllBlocksWithTilesets(workspace);
252260
for (const tilesetField of allTiles) {
253261
const id = tilesetField.ref.getValue();
254262

pxtlib/tilemap.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ namespace pxt {
179179
return null;
180180
}
181181

182+
public getAllTilemaps() {
183+
return this.state.projectTilemaps?.slice() || [];
184+
}
185+
182186
public updateTilemap(id: string, data: pxt.sprite.TilemapData) {
183187
for (const tm of this.state.projectTilemaps) {
184188
if (tm.id === id) {

0 commit comments

Comments
 (0)