Changes

→‎Changes: + content loading API
Line 69: Line 69:     
See the [[Modding:Modder Guide/APIs/Events#Content|content event docs]] for more info on how to use them.
 
See the [[Modding:Modder Guide/APIs/Events#Content|content event docs]] for more info on how to use them.
 +
 +
===Content loading API===
 +
The <samp>helper.Content</samp> API was confusing, since game content assets and mod files are handled differently. Some methods had an optional <samp>ContentSource</samp> parameter (which was easy to forget to specify), some only made sense for one or the other (like <samp>GetActualAssetKey</samp>), and the documentation tried to handle both by being more abstract.
 +
 +
It's been split into two APIs to fix that:
 +
* <samp>helper.GameContent</samp> loads assets from the game's <samp>Content</samp> folder or [[#Content interception API|content interception]];
 +
* <samp>helper.ModContent</samp> loads assets from your mod's files.
 +
 +
Here's how to migrate existing methods & properties:
 +
 +
{| class="wikitable"
 +
|-
 +
! old code
 +
! migration
 +
|-
 +
| <samp>helper.Content.AssetEditors</samp><br /><samp>helper.Content.AssetLoaders</samp>
 +
| Use [[Modding:Modder Guide/APIs/Events#Content|content events]].
 +
|-
 +
| <samp>helper.Content.CurrentLocale</samp><br /><samp>helper.Content.CurrentLocaleConstant</samp><br /><samp>helper.Content.InvalidateCache</samp>
 +
| Use <samp>helper.GameContent</samp>.
 +
|-
 +
| <samp>helper.Content.GetActualAssetKey</samp>
 +
| Use <samp>helper.ModContent.GetInternalAssetName</samp>, and remove the <samp>ContentSource</samp> parameter. This returns an <samp>IAssetName</samp> value; you can update your code to use that, or get the string value using its <samp>Name</samp> property.
 +
|-
 +
| <samp>helper.Content.GetPatchHelper</samp>
 +
| Use <samp>helper.GameContent</samp> or <samp>helper.ModContent</samp>.
 +
|-
 +
| <samp>helper.Content.Load</samp>
 +
| Use <samp>helper.GameContent</samp> or <samp>helper.ModContent</samp>, and remove the <samp>ContentSource</samp> parameter.
 +
|-
 +
| <samp>helper.Content.NormalizeAssetName</samp>
 +
| Use <samp>helper.GameContent.ParseAssetName</samp> instead. This returns an <samp>IAssetName</samp> value; you can update your code to use that, or get the string value using its <samp>Name</samp> property.
 +
|}
    
===Custom command triggers no longer allowed===
 
===Custom command triggers no longer allowed===
translators
8,404

edits