Resolve relative paths for tileset sources in tiled map importer

This commit is contained in:
Shaun McFall
2020-12-14 15:10:31 -05:00
parent 541e162887
commit 22998af007
@@ -50,16 +50,19 @@ namespace MonoGame.Extended.Content.Pipeline.Tiled
{
var tileset = map.Tilesets[i];
string getTilesetSource(string source)
=> Path.GetFullPath(Path.Combine(Path.GetDirectoryName(mapFilePath), source));
if (!string.IsNullOrWhiteSpace(tileset.Source))
{
tileset.Source = Path.Combine(Path.GetDirectoryName(mapFilePath), tileset.Source);
tileset.Source = getTilesetSource(tileset.Source);
ContentLogger.Log($"Adding dependency for {tileset.Source}");
// We depend on the tileset. If the tileset changes, the map also needs to rebuild.
context.AddDependency(tileset.Source);
}
else
{
tileset.Image.Source = Path.Combine(Path.GetDirectoryName(mapFilePath), tileset.Image.Source);
tileset.Image.Source = getTilesetSource(tileset.Image.Source);
ContentLogger.Log($"Adding dependency for {tileset.Image.Source}");
context.AddDependency(tileset.Image.Source);
}