diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-03-11 20:03:52 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-03-11 20:03:52 -0400 |
commit | 9c49d090a06c96ff2c1f4978da67e864177c2a2e (patch) | |
tree | 837b352382a81e1d5257354b9d36b8a6a134070f /src/SMAPI/Framework/SGame.cs | |
parent | 6db91f832998ab07e7a937c25b32f1151a0274bc (diff) | |
download | SMAPI-9c49d090a06c96ff2c1f4978da67e864177c2a2e.tar.gz SMAPI-9c49d090a06c96ff2c1f4978da67e864177c2a2e.tar.bz2 SMAPI-9c49d090a06c96ff2c1f4978da67e864177c2a2e.zip |
reorganise and update core content logic for Stardew Valley 1.3 (#453)
Diffstat (limited to 'src/SMAPI/Framework/SGame.cs')
-rw-r--r-- | src/SMAPI/Framework/SGame.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index acb3e794..aeaab9ea 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -161,7 +161,7 @@ namespace StardewModdingAPI.Framework ** Accessors *********/ /// <summary>SMAPI's content manager.</summary> - public SContentManager SContentManager { get; } + public ContentCore ContentCore { get; } /// <summary>Whether SMAPI should log more information about the game context.</summary> public bool VerboseLogging { get; set; } @@ -190,10 +190,12 @@ namespace StardewModdingAPI.Framework // override content manager this.Monitor?.Log("Overriding content manager...", LogLevel.Trace); - this.SContentManager = new SContentManager(this.Content.ServiceProvider, this.Content.RootDirectory, Thread.CurrentThread.CurrentUICulture, null, this.Monitor, reflection); - this.Content = new ContentManagerShim(this.SContentManager, "SGame.Content"); - Game1.content = new ContentManagerShim(this.SContentManager, "Game1.content"); - reflection.GetField<LocalizedContentManager>(typeof(Game1), "_temporaryContent").SetValue(new ContentManagerShim(this.SContentManager, "Game1._temporaryContent")); // regenerate value with new content manager + this.ContentCore = new ContentCore(this.Content.ServiceProvider, this.Content.RootDirectory, Thread.CurrentThread.CurrentUICulture, null, this.Monitor, reflection); + this.Content = this.ContentCore.CreateContentManager("SGame.Content"); + Game1.content = this.ContentCore.CreateContentManager("Game1.content"); + + // replace already-created temporary content managers + reflection.GetField<LocalizedContentManager>(typeof(Game1), "_temporaryContent").SetValue(this.ContentCore.CreateContentManager("Game1._temporaryContent")); // regenerate value with new content manager } /**** @@ -205,7 +207,7 @@ namespace StardewModdingAPI.Framework protected override LocalizedContentManager CreateContentManager(IServiceProvider serviceProvider, string rootDirectory) { // return default if SMAPI's content manager isn't initialised yet - if (this.SContentManager == null) + if (this.ContentCore == null) { this.Monitor?.Log("SMAPI's content manager isn't initialised; skipping content manager interception.", LogLevel.Trace); return base.CreateContentManager(serviceProvider, rootDirectory); @@ -216,7 +218,7 @@ namespace StardewModdingAPI.Framework throw new InvalidOperationException("SMAPI uses a single content manager internally. You can't get a new content manager with a different service provider."); if (rootDirectory != this.Content.RootDirectory) throw new InvalidOperationException($"SMAPI uses a single content manager internally. You can't get a new content manager with a different root directory (current is {this.Content.RootDirectory}, requested {rootDirectory})."); - return new ContentManagerShim(this.SContentManager, "(generated instance)"); + return this.ContentCore.CreateContentManager("(generated instance)"); } /// <summary>The method called when the game is updating its state. This happens roughly 60 times per second.</summary> |