summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ContentManagerShim.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-05-09 23:58:58 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-05-09 23:58:58 -0400
commit61b023916eb92237b3b10b30b77792139de1097d (patch)
tree5bfca6a2061d54a2c701e5c8c4c0abcf696fc7b1 /src/SMAPI/Framework/ContentManagerShim.cs
parent1a626b34a03212809880a5c5d034bf3962d4abd7 (diff)
downloadSMAPI-61b023916eb92237b3b10b30b77792139de1097d.tar.gz
SMAPI-61b023916eb92237b3b10b30b77792139de1097d.tar.bz2
SMAPI-61b023916eb92237b3b10b30b77792139de1097d.zip
rewrite content logic to decentralise cache (#488)
This is necessary due to changes in Stardew Valley 1.3, which now changes loaded assets and expects those changes to be persisted but not propagated to other content managers.
Diffstat (limited to 'src/SMAPI/Framework/ContentManagerShim.cs')
-rw-r--r--src/SMAPI/Framework/ContentManagerShim.cs91
1 files changed, 0 insertions, 91 deletions
diff --git a/src/SMAPI/Framework/ContentManagerShim.cs b/src/SMAPI/Framework/ContentManagerShim.cs
deleted file mode 100644
index 66754fd7..00000000
--- a/src/SMAPI/Framework/ContentManagerShim.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.Globalization;
-using StardewValley;
-
-namespace StardewModdingAPI.Framework
-{
- /// <summary>A minimal content manager which defers to SMAPI's core content logic.</summary>
- internal class ContentManagerShim : LocalizedContentManager
- {
- /*********
- ** Properties
- *********/
- /// <summary>SMAPI's core content logic.</summary>
- private readonly ContentCore ContentCore;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>The content manager's name for logs (if any).</summary>
- public string Name { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="contentCore">SMAPI's core content logic.</param>
- /// <param name="name">The content manager's name for logs (if any).</param>
- /// <param name="serviceProvider">The service provider to use to locate services.</param>
- /// <param name="rootDirectory">The root directory to search for content.</param>
- /// <param name="currentCulture">The current culture for which to localise content.</param>
- public ContentManagerShim(ContentCore contentCore, string name, IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture)
- : base(serviceProvider, rootDirectory, currentCulture)
- {
- this.ContentCore = contentCore;
- this.Name = name;
- }
-
- /// <summary>Load an asset that has been processed by the content pipeline.</summary>
- /// <typeparam name="T">The type of asset to load.</typeparam>
- /// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
- public override T Load<T>(string assetName)
- {
- return this.Load<T>(assetName, LocalizedContentManager.CurrentLanguageCode);
- }
-
- /// <summary>Load an asset that has been processed by the content pipeline.</summary>
- /// <typeparam name="T">The type of asset to load.</typeparam>
- /// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
- /// <param name="language">The language code for which to load content.</param>
- public override T Load<T>(string assetName, LanguageCode language)
- {
- return this.ContentCore.Load<T>(assetName, this, language);
- }
-
- /// <summary>Load the base asset without localisation.</summary>
- /// <typeparam name="T">The type of asset to load.</typeparam>
- /// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
- public override T LoadBase<T>(string assetName)
- {
- return this.Load<T>(assetName, LanguageCode.en);
- }
-
- /// <summary>Inject an asset into the cache.</summary>
- /// <typeparam name="T">The type of asset to inject.</typeparam>
- /// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
- /// <param name="value">The asset value.</param>
- public void Inject<T>(string assetName, T value)
- {
- this.ContentCore.Inject<T>(assetName, value, this);
- }
-
- /// <summary>Create a new content manager for temporary use.</summary>
- public override LocalizedContentManager CreateTemporary()
- {
- return this.ContentCore.CreateContentManager("(temporary)");
- }
-
-
- /*********
- ** Protected methods
- *********/
- /// <summary>Dispose held resources.</summary>
- /// <param name="disposing">Whether the content manager is disposing (rather than finalising).</param>
- protected override void Dispose(bool disposing)
- {
- this.ContentCore.DisposeFor(this);
- }
- }
-}