示例#1
0
        /// <summary>Read the song conditions from disk.</summary>
        public virtual void LoadSettings()
        {
            DirectoryInfo dataFolder = new DirectoryInfo(Path.Combine(this.ContentPack.DirectoryPath, this.DataFolderName));

            if (dataFolder.Exists)
            {
                if (StardewSymphony.Config.EnableDebugLog)
                {
                    StardewSymphony.ModMonitor.Log($"Loading music for {this.Name}. This may take quite some time.");
                }

                foreach (FileInfo file in dataFolder.GetFiles())
                {
                    SongListNode node = this.ContentPack.ReadJsonFile <SongListNode>($"{this.DataFolderName}/{file.Name}");
                    foreach (string song in node.SongList)
                    {
                        try
                        {
                            this.SongInformation.addSongToTriggerList(node.Trigger, song);
                        }
                        catch { }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Load functionality.
        /// </summary>
        public virtual void readFromJson()
        {
            if (StardewSymphony.Config.EnableDebugLog)
            {
                StardewSymphony.ModMonitor.Log("Loading music for this pack:" + this.musicPackInformation.name + ". Please wait as this will take quite some time.");
            }
            string data = Path.Combine(this.directory, "data");

            if (!Directory.Exists(data))
            {
                Directory.CreateDirectory(data);
            }
            string[] files = Directory.GetFiles(data);
            foreach (var file in files)
            {
                SongListNode node = SongListNode.ReadFromJson(Path.Combine(data, file));
                var          pair = this.songInformation.getSongList(node.trigger + ".json");
                foreach (var v in node.songList)
                {
                    try
                    {
                        this.songInformation.addSongToTriggerList(node.trigger, v.name);
                    }
                    catch (Exception err)
                    {
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Save functionality.
        /// </summary>
        public virtual void writeToJson()
        {
            if (StardewSymphony.Config.EnableDebugLog)
            {
                StardewSymphony.ModMonitor.Log("Saving music for this pack:" + this.musicPackInformation.name + ". Please wait.");
            }
            string data = Path.Combine(this.directory, "data");

            if (!Directory.Exists(data))
            {
                Directory.CreateDirectory(data);
            }
            foreach (var list in this.songInformation.listOfSongsWithTriggers)
            {
                if (StardewSymphony.Config.writeAllConfigMusicOptions == false)
                {
                    if (list.Value.Count == 0)
                    {
                        continue;
                    }
                }
                if (StardewSymphony.Config.EnableDebugLog)
                {
                    StardewSymphony.ModMonitor.Log("Saving music: " + list.Key + ". Please wait.");
                }
                SongListNode node = new SongListNode(list.Key, list.Value);
                node.WriteToJson(Path.Combine(data, node.trigger + ".json"));
            }
        }
示例#4
0
 /// <summary>Write the song conditions to disk.</summary>
 public virtual void SaveSettings()
 {
     if (StardewSymphony.Config.EnableDebugLog)
     {
         StardewSymphony.ModMonitor.Log($"Saving music for {this.Name}...");
     }
     foreach (var list in this.SongInformation.listOfSongsWithTriggers)
     {
         if (!StardewSymphony.Config.WriteAllConfigMusicOptions)
         {
             if (list.Value.Count == 0)
             {
                 continue;
             }
         }
         if (StardewSymphony.Config.EnableDebugLog)
         {
             StardewSymphony.ModMonitor.Log($"   Saving song: {list.Key}...");
         }
         SongListNode node = new SongListNode(list.Key, list.Value);
         this.ContentPack.WriteJsonFile($"{this.DataFolderName}/{node.Trigger}.json", node);
     }
 }