Merge pull request #713 from merthsoft/bug/712

Resolve relative paths for tileset sources in tiled map importer
This commit is contained in:
Lucas Girouard-Stranks
2020-12-15 18:30:13 -05:00
committed by GitHub
@@ -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);
}