Exemple #1
0
        /// <summary>Save the configuration file for a content pack.</summary>
        /// <param name="contentPack">The content pack.</param>
        /// <param name="config">The configuration to save.</param>
        /// <param name="modHelper">The mod helper through which to save the file.</param>
        public void Save(IContentPack contentPack, InvariantDictionary <ConfigField> config, IModHelper modHelper)
        {
            string configPath = Path.Combine(contentPack.DirectoryPath, this.Filename);

            // save if settings valid
            if (config.Any())
            {
                InvariantDictionary <string> data = new InvariantDictionary <string>(config.ToDictionary(p => p.Key, p => string.Join(", ", p.Value.Value)));
                modHelper.WriteJsonFile(configPath, data);
            }

            // delete if no settings
            else if (File.Exists(configPath))
            {
                File.Delete(configPath);
            }
        }
Exemple #2
0
        /// <summary>Save the configuration file for a content pack.</summary>
        /// <param name="contentPack">The content pack.</param>
        /// <param name="config">The configuration to save.</param>
        /// <param name="modHelper">The mod helper through which to save the file.</param>
        public void Save(ManagedContentPack contentPack, InvariantDictionary <ConfigField> config, IModHelper modHelper)
        {
            // save if settings valid
            if (config.Any())
            {
                InvariantDictionary <string> data = new InvariantDictionary <string>(config.ToDictionary(p => p.Key, p => string.Join(", ", p.Value.Value)));
                contentPack.WriteJsonFile(this.Filename, data);
            }

            // delete if no settings
            else
            {
                FileInfo file = new FileInfo(Path.Combine(contentPack.GetFullPath(this.Filename)));
                if (file.Exists)
                {
                    file.Delete();
                }
            }
        }