SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

Add per-mod content managers

Pathoschild opened this issue ยท 5 comments

commented

Give each mod its own content manager, which should let it...

  • load any of the game's content;
  • load XNB files from its own folder for its own use;
  • (bonus) load unpacked *.png files from its own folder.

(Split from #173; see also #255.)

commented

Split #273 into a separate ticket.

commented

Two possible APIs:

  • Option 1:

    // load XNB from the mod folder
    helper.Content.Load<Texture2D>("foo.xnb", ContentSource.ModFolder);
    
    // load unpacked image from the mod folder
    helper.Content.Load<Texture2D>("foo.png", ContentSource.ModFolder);
    
    // load 'foo' asset from the game's content manager
    helper.Content.Load<Texture2D>("foo", ContentSource.GameContent);
  • Option 2:

    // load XNB from the mod folder
    helper.Content.LoadFromModFolder<Texture2D>("foo.xnb");
    
    // load unpacked image from the mod folder
    helper.Content.LoadFromModFolder<Texture2D>("foo.png");
    
    // load 'foo' asset from the game's content manager
    helper.Content.LoadFromGameContent<Texture2D>("foo");
commented

Option 1 is unanimously preferred per discussion on Discord, so I'll go with that.

commented

Done in develop for the upcoming SMAPI 1.11; pending beta feedback.

commented

Released with SMAPI 1.11.