Skip to content

Commit

Permalink
Merge pull request #2 from adrien-bon/fix/path_tilesheet
Browse files Browse the repository at this point in the history
fix: duplication of path in helper tilesheet loading
  • Loading branch information
stevepryde authored Jul 23, 2024
2 parents 569bdb3 + a02a43f commit 7f665d9
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,7 @@ impl AssetLoader for TiledLoader {
let mut tile_images: Vec<Handle<Image>> = Vec::new();
for (tile_id, tile) in tileset.tiles() {
if let Some(img) = &tile.image {
// The load context path is the TMX file itself. If the file is at the root of the
// assets/ directory structure then the tmx_dir will be empty, which is fine.
let tmx_dir = map_path
.parent()
.expect("The asset load context was empty.");
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path);
let asset_path = AssetPath::from(img.source.clone());
log::info!("Loading tile image from {asset_path:?} as image ({tileset_index}, {tile_id})");
let texture: Handle<Image> = load_context.load(asset_path.clone());
tile_image_offsets
Expand All @@ -215,14 +209,7 @@ impl AssetLoader for TiledLoader {
}
}
Some(img) => {
// The load context path is the TMX file itself. If the file is at the root of the
// assets/ directory structure then the tmx_dir will be empty, which is fine.
let tmx_dir = load_context
.path()
.parent()
.expect("The asset load context was empty.");
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path);
let asset_path = AssetPath::from(img.source.clone());
let texture: Handle<Image> = load_context.load(asset_path.clone());

TilemapTexture::Single(texture.clone())
Expand Down

0 comments on commit 7f665d9

Please sign in to comment.