Changes

Jump to navigation Jump to search
→‎Compare asset names: update for SMAPI 3.7 release
Line 357: Line 357:  
To check for an exact match when you have an <tt>IAssetData</tt> instance (e.g. from the content API), just call <code>asset.AssetNameEquals("Characters/Abigail")</code> and SMAPI will normalize the asset names internally.
 
To check for an exact match when you have an <tt>IAssetData</tt> instance (e.g. from the content API), just call <code>asset.AssetNameEquals("Characters/Abigail")</code> and SMAPI will normalize the asset names internally.
   −
{{SMAPI upcoming|3.7|If you need to check manually, you should normalize directory separators and compare case-insensitively. For example:
+
If you need to check manually, you should normalize the asset names using [[Modding:Modder Guide/APIs/Utilities#File paths|<tt>PathUtilities</tt>]] and compare case-insensitively. For example:
 
<source lang="c#">
 
<source lang="c#">
string dialoguePrefix = PathUtilities.NormalizePathSeparators(@"Characters\Dialogue\");
+
string dialoguePrefix = PathUtilities.NormalizePath(@"Characters\Dialogue\");
 
bool isDialogue = asset.AssetName.StartsWith(dialoguePrefix, StringComparison.OrdinalIgnoreCase);
 
bool isDialogue = asset.AssetName.StartsWith(dialoguePrefix, StringComparison.OrdinalIgnoreCase);
</source>}}
+
</source>
    
===Cache invalidation===
 
===Cache invalidation===
translators
8,404

edits

Navigation menu