normalise custom map's tilesheet paths for the OS
This commit is contained in:
parent
673ef91cc7
commit
dc1c9bf036
|
@ -40,6 +40,7 @@ These changes have not been released yet.
|
||||||
* The installer now recognises custom game paths stored in `stardewvalley.targets`, if any.
|
* The installer now recognises custom game paths stored in `stardewvalley.targets`, if any.
|
||||||
* Trace logs for a broken mod now list all detected issues (instead of the first one).
|
* Trace logs for a broken mod now list all detected issues (instead of the first one).
|
||||||
* Trace logs when loading mods are now more clear.
|
* Trace logs when loading mods are now more clear.
|
||||||
|
* Fixed custom maps loaded from the mod folder with tilesheets in a subfolder not working crossplatform. All tilesheet paths are now normalised for the OS automatically.
|
||||||
* Removed all deprecated APIs.
|
* Removed all deprecated APIs.
|
||||||
* Removed the `Monitor.ExitGameImmediately` method.
|
* Removed the `Monitor.ExitGameImmediately` method.
|
||||||
* Updated dependencies (including Json.NET 11.0.2 → 12.0.2, Mono.Cecil 0.10.1 → 0.10.4).
|
* Updated dependencies (including Json.NET 11.0.2 → 12.0.2, Mono.Cecil 0.10.1 → 0.10.4).
|
||||||
|
|
|
@ -117,7 +117,9 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
||||||
{
|
{
|
||||||
// XNB file
|
// XNB file
|
||||||
case ".xnb":
|
case ".xnb":
|
||||||
|
{
|
||||||
return this.RawLoad<T>(assetName, useCache: false);
|
return this.RawLoad<T>(assetName, useCache: false);
|
||||||
|
}
|
||||||
|
|
||||||
// unpacked data
|
// unpacked data
|
||||||
case ".json":
|
case ".json":
|
||||||
|
@ -129,6 +131,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
||||||
|
|
||||||
// unpacked image
|
// unpacked image
|
||||||
case ".png":
|
case ".png":
|
||||||
|
{
|
||||||
// validate
|
// validate
|
||||||
if (typeof(T) != typeof(Texture2D))
|
if (typeof(T) != typeof(Texture2D))
|
||||||
throw GetContentError($"can't read file with extension '{file.Extension}' as type '{typeof(T)}'; must be type '{typeof(Texture2D)}'.");
|
throw GetContentError($"can't read file with extension '{file.Extension}' as type '{typeof(T)}'; must be type '{typeof(Texture2D)}'.");
|
||||||
|
@ -140,9 +143,11 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
||||||
texture = this.PremultiplyTransparency(texture);
|
texture = this.PremultiplyTransparency(texture);
|
||||||
return (T)(object)texture;
|
return (T)(object)texture;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// unpacked map
|
// unpacked map
|
||||||
case ".tbin":
|
case ".tbin":
|
||||||
|
{
|
||||||
// validate
|
// validate
|
||||||
if (typeof(T) != typeof(Map))
|
if (typeof(T) != typeof(Map))
|
||||||
throw GetContentError($"can't read file with extension '{file.Extension}' as type '{typeof(T)}'; must be type '{typeof(Map)}'.");
|
throw GetContentError($"can't read file with extension '{file.Extension}' as type '{typeof(T)}'; must be type '{typeof(Map)}'.");
|
||||||
|
@ -151,7 +156,9 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
||||||
FormatManager formatManager = FormatManager.Instance;
|
FormatManager formatManager = FormatManager.Instance;
|
||||||
Map map = formatManager.LoadMap(file.FullName);
|
Map map = formatManager.LoadMap(file.FullName);
|
||||||
this.FixCustomTilesheetPaths(map, relativeMapPath: assetName);
|
this.FixCustomTilesheetPaths(map, relativeMapPath: assetName);
|
||||||
|
this.NormaliseTilesheetPaths(map);
|
||||||
return (T)(object)map;
|
return (T)(object)map;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw GetContentError($"unknown file extension '{file.Extension}'; must be one of '.json', '.png', '.tbin', or '.xnb'.");
|
throw GetContentError($"unknown file extension '{file.Extension}'; must be one of '.json', '.png', '.tbin', or '.xnb'.");
|
||||||
|
@ -232,6 +239,14 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Normalise map tilesheet paths for the current platform.</summary>
|
||||||
|
/// <param name="map">The map whose tilesheets to fix.</param>
|
||||||
|
private void NormaliseTilesheetPaths(Map map)
|
||||||
|
{
|
||||||
|
foreach (TileSheet tilesheet in map.TileSheets)
|
||||||
|
tilesheet.ImageSource = this.NormalisePathSeparators(tilesheet.ImageSource);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Fix custom map tilesheet paths so they can be found by the content manager.</summary>
|
/// <summary>Fix custom map tilesheet paths so they can be found by the content manager.</summary>
|
||||||
/// <param name="map">The map whose tilesheets to fix.</param>
|
/// <param name="map">The map whose tilesheets to fix.</param>
|
||||||
/// <param name="relativeMapPath">The relative map path within the mod folder.</param>
|
/// <param name="relativeMapPath">The relative map path within the mod folder.</param>
|
||||||
|
|
Loading…
Reference in New Issue