コード例 #1
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <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>
 /// <param name="monitor">Encapsulates monitoring and logging.</param>
 /// <param name="reflection">Simplifies access to private code.</param>
 public ContentCoordinator(IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture, IMonitor monitor, Reflector reflection)
 {
     this.Monitor           = monitor ?? throw new ArgumentNullException(nameof(monitor));
     this.Reflection        = reflection;
     this.FullRootDirectory = Path.Combine(Constants.ExecutionPath, rootDirectory);
     this.ContentManagers.Add(
         this.MainContentManager = new SContentManager("Game1.content", serviceProvider, rootDirectory, currentCulture, this, monitor, reflection, this.OnDisposing, isModFolder: false)
         );
     this.CoreAssets = new CoreAssetPropagator(this.MainContentManager.NormaliseAssetName, reflection);
 }
コード例 #2
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <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 localize content.</param>
 /// <param name="monitor">Encapsulates monitoring and logging.</param>
 /// <param name="reflection">Simplifies access to private code.</param>
 /// <param name="jsonHelper">Encapsulates SMAPI's JSON file parsing.</param>
 /// <param name="onLoadingFirstAsset">A callback to invoke the first time *any* game content manager loads an asset.</param>
 public ContentCoordinator(IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture, IMonitor monitor, Reflector reflection, JsonHelper jsonHelper, Action onLoadingFirstAsset)
 {
     this.Monitor             = monitor ?? throw new ArgumentNullException(nameof(monitor));
     this.Reflection          = reflection;
     this.JsonHelper          = jsonHelper;
     this.OnLoadingFirstAsset = onLoadingFirstAsset;
     this.FullRootDirectory   = Path.Combine(Constants.ExecutionPath, rootDirectory);
     this.ContentManagers.Add(
         this.MainContentManager = new GameContentManager("Game1.content", serviceProvider, rootDirectory, currentCulture, this, monitor, reflection, this.OnDisposing, onLoadingFirstAsset)
         );
     this.CoreAssets = new CoreAssetPropagator(this.MainContentManager.AssertAndNormalizeAssetName, reflection, monitor);
 }
コード例 #3
0
ファイル: ContentCore.cs プロジェクト: WhiteMinds/SMAPI
        /*********
        ** Public methods
        *********/
        /****
        ** Constructor
        ****/
        /// <summary>Construct an instance.</summary>
        /// <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>
        /// <param name="monitor">Encapsulates monitoring and logging.</param>
        /// <param name="reflection">Simplifies access to private code.</param>
        public ContentCore(IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture, IMonitor monitor, Reflector reflection)
        {
            // init
            this.Monitor          = monitor ?? throw new ArgumentNullException(nameof(monitor));
            this.Content          = new LocalizedContentManager(serviceProvider, rootDirectory, currentCulture);
            this.Cache            = new ContentCache(this.Content, reflection);
            this.ModContentPrefix = this.GetAssetNameFromFilePath(Constants.ModPath);

            // get asset data
            this.CoreAssets          = new CoreAssetPropagator(this.NormaliseAssetName, reflection);
            this.LanguageCodes       = this.GetKeyLocales().ToDictionary(p => p.Value, p => p.Key, StringComparer.InvariantCultureIgnoreCase);
            this.IsLocalisableLookup = reflection.GetField <IDictionary <string, bool> >(this.Content, "_localizedAsset").GetValue();
        }
コード例 #4
0
ファイル: ContentCoordinator.cs プロジェクト: kurumushi/SMAPI
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <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 localize content.</param>
        /// <param name="monitor">Encapsulates monitoring and logging.</param>
        /// <param name="reflection">Simplifies access to private code.</param>
        /// <param name="jsonHelper">Encapsulates SMAPI's JSON file parsing.</param>
        /// <param name="onLoadingFirstAsset">A callback to invoke the first time *any* game content manager loads an asset.</param>
        /// <param name="aggressiveMemoryOptimizations">Whether to enable more aggressive memory optimizations.</param>
        public ContentCoordinator(IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture, IMonitor monitor, Reflector reflection, JsonHelper jsonHelper, Action onLoadingFirstAsset, bool aggressiveMemoryOptimizations)
        {
            this.AggressiveMemoryOptimizations = aggressiveMemoryOptimizations;
            this.Monitor             = monitor ?? throw new ArgumentNullException(nameof(monitor));
            this.Reflection          = reflection;
            this.JsonHelper          = jsonHelper;
            this.OnLoadingFirstAsset = onLoadingFirstAsset;
            this.FullRootDirectory   = Path.Combine(Constants.ExecutionPath, rootDirectory);
            this.ContentManagers.Add(
                this.MainContentManager = new GameContentManager(
                    name: "Game1.content",
                    serviceProvider: serviceProvider,
                    rootDirectory: rootDirectory,
                    currentCulture: currentCulture,
                    coordinator: this,
                    monitor: monitor,
                    reflection: reflection,
                    onDisposing: this.OnDisposing,
                    onLoadingFirstAsset: onLoadingFirstAsset,
                    aggressiveMemoryOptimizations: aggressiveMemoryOptimizations
                    )
                );
            var contentManagerForAssetPropagation = new GameContentManagerForAssetPropagation(
                name: nameof(GameContentManagerForAssetPropagation),
                serviceProvider: serviceProvider,
                rootDirectory: rootDirectory,
                currentCulture: currentCulture,
                coordinator: this,
                monitor: monitor,
                reflection: reflection,
                onDisposing: this.OnDisposing,
                onLoadingFirstAsset: onLoadingFirstAsset,
                aggressiveMemoryOptimizations: aggressiveMemoryOptimizations
                );

            this.ContentManagers.Add(contentManagerForAssetPropagation);
            this.VanillaContentManager = new LocalizedContentManager(serviceProvider, rootDirectory);
            this.CoreAssets            = new CoreAssetPropagator(this.MainContentManager, contentManagerForAssetPropagation, this.Monitor, reflection, aggressiveMemoryOptimizations);
            this.LocaleCodes           = new Lazy <IDictionary <string, LocalizedContentManager.LanguageCode> >(this.GetLocaleCodes);
        }