diff options
Diffstat (limited to 'src/StardewModdingAPI/Framework/SGame.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/SGame.cs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index 997e0c8c..76c106d7 100644 --- a/src/StardewModdingAPI/Framework/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -38,9 +38,6 @@ namespace StardewModdingAPI.Framework /// <summary>Encapsulates monitoring and logging.</summary> private readonly IMonitor Monitor; - /// <summary>SMAPI's content manager.</summary> - private readonly SContentManager SContentManager; - /// <summary>The maximum number of consecutive attempts SMAPI should make to recover from a draw error.</summary> private readonly Countdown DrawCrashTimer = new Countdown(60); // 60 ticks = roughly one second @@ -177,6 +174,9 @@ namespace StardewModdingAPI.Framework /********* ** Accessors *********/ + /// <summary>SMAPI's content manager.</summary> + public SContentManager SContentManager { get; } + /// <summary>Whether SMAPI should log more information about the game context.</summary> public bool VerboseLogging { get; set; } @@ -201,8 +201,9 @@ 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); - this.Content = this.SContentManager; - Game1.content = this.SContentManager; + this.Content = new ContentManagerShim(this.SContentManager, "SGame.Content"); + Game1.content = new ContentManagerShim(this.SContentManager, "Game1.content"); + reflection.GetPrivateField<LocalizedContentManager>(typeof(Game1), "_temporaryContent").SetValue(new ContentManagerShim(this.SContentManager, "Game1._temporaryContent")); // regenerate value with new content manager } /**** @@ -225,7 +226,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 this.SContentManager; + return new ContentManagerShim(this.SContentManager, "(generated instance)"); } /// <summary>The method called when the game is updating its state. This happens roughly 60 times per second.</summary> |