private static void UpdateSng2014(string songDirectory, Platform targetPlatform, bool fixShowlights = true)
        {
            var xmlFiles  = Directory.EnumerateFiles(Path.Combine(songDirectory, "songs", "arr"), "*_*.xml", SearchOption.AllDirectories).ToList();
            var sngFolder = Path.Combine(songDirectory, "songs", "bin", targetPlatform.GetPathName()[1].ToLower()); //-3 or more times re-calculation

            foreach (var xmlFile in xmlFiles)
            {
                if (File.Exists(xmlFile))
                {
                    var  xmlName      = Path.GetFileNameWithoutExtension(xmlFile);
                    bool noShowlights = true;

                    //Update Showlights
                    if (xmlName.ToLower().Contains("_showlights"))
                    {
                        UpdateShl(xmlFile, fixShowlights: fixShowlights);
                    }
                    else
                    {
                        var sngFile = Path.Combine(sngFolder, xmlName + ".sng");
                        var arrType = ArrangementType.Guitar;
                        if (Path.GetFileName(xmlFile).ToLower().Contains("vocal"))
                        {
                            arrType = ArrangementType.Vocal;
                        }

                        // Handle custom fonts
                        string fontSng = null;
                        if (arrType == ArrangementType.Vocal)
                        {
                            var vocSng = Sng2014File.LoadFromFile(sngFile, TryGetPlatformByEndName(songDirectory));
                            if (vocSng.IsCustomFont())
                            {
                                vocSng.WriteChartData((fontSng = Path.GetTempFileName()), new Platform(GamePlatform.Pc, GameVersion.None));
                            }
                        }

                        using (var fs = new FileStream(sngFile, FileMode.Create))
                        {
                            var sng = Sng2014File.ConvertXML(xmlFile, arrType, fontSng);
                            sng.WriteSng(fs, targetPlatform);
                        }

                        noShowlights &= !xmlFiles.Any(x => Path.GetFileName(x).Contains(xmlName.Split('_')[0].ToLower() + "_showlights"));
                        //Create Showlights
                        if (noShowlights && arrType != ArrangementType.Vocal)
                        {
                            var shlName = Path.Combine(Path.GetDirectoryName(xmlFile), xmlName.Split('_')[0] + "_showlights.xml");
                            var shl     = new Showlight.Showlights(xmlFile);
                            if (shl.FixShowlights(shl))
                            {
                                using (var fs = new FileStream(shlName, FileMode.Create))
                                    shl.Serialize(fs);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Fixes showlights and updates existing xml.
        /// </summary>
        /// <param name="shlPath"></param>
        /// <returns></returns>
        internal static void UpdateShl(string shlPath, bool fixShowlights = true)
        {
            var shl = new Showlight.Showlights(shlPath);

            if (fixShowlights && shl.FixShowlights(shl))
            {
                using (var fs = new FileStream(shlPath, FileMode.Create))
                    shl.Serialize(fs);
            }
        }
        /// <summary>
        /// Fixes showlights and updates existing xml.
        /// </summary>
        /// <param name="shlPath"></param>
        /// <param name = "fixShowlights"></param>
        internal static void UpdateShl(string shlPath, bool fixShowlights = true)
        {//TODO:FIXME
            if (!fixShowlights)
            {
                return;
            }
            var shl = new Showlight.Showlights(shlPath);

            if (shl.FixShowlights(shl))
            {
                using (var fs = new FileStream(shlPath, FileMode.Create))
                    shl.Serialize(fs);
            }
        }
        /// <summary>
        /// Fixes showlights and updates existing xml.
        /// </summary>
        /// <param name="shlPath"></param>
        /// <param name = "fixShowlights"></param>
        internal static void UpdateShl(string shlPath, bool fixShowlights = true)
        {
            // TODO: seems to be working now, continue to monitor output
            if (!fixShowlights)
            {
                return;
            }
            var shl = new Showlight.Showlights(shlPath);

            if (shl.FixShowlights(shl))
            {
                using (var fs = new FileStream(shlPath, FileMode.Create))
                    shl.Serialize(fs);
            }
        }
        private static void UpdateSng2014(string songDirectory, Platform targetPlatform, bool fixShowlights = true)
        {
            var xmlFiles = Directory.EnumerateFiles(Path.Combine(songDirectory, "songs", "arr"), "*_*.xml", SearchOption.AllDirectories).ToList();
            var sngFolder = Path.Combine(songDirectory, "songs", "bin", targetPlatform.GetPathName()[1].ToLower()); //-3 or more times re-calculation
            foreach (var xmlFile in xmlFiles)
            {
                if (File.Exists(xmlFile))
                {
                    var xmlName = Path.GetFileNameWithoutExtension(xmlFile);
                    bool noShowlights = true;

                    //Update Showlights
                    if (xmlName.ToLower().Contains("_showlights"))
                        UpdateShl(xmlFile, fixShowlights: fixShowlights);
                    else
                    {
                        var sngFile = Path.Combine(sngFolder, xmlName + ".sng");
                        var arrType = ArrangementType.Guitar;
                        if (Path.GetFileName(xmlFile).ToLower().Contains("vocal"))
                            arrType = ArrangementType.Vocal;

                        // Handle custom fonts
                        string fontSng = null;
                        if (arrType == ArrangementType.Vocal)
                        {
                            var vocSng = Sng2014File.LoadFromFile(sngFile, TryGetPlatformByEndName(songDirectory));
                            if (vocSng.IsCustomFont())
                            {
                                vocSng.WriteChartData((fontSng = Path.GetTempFileName()), new Platform(GamePlatform.Pc, GameVersion.None));
                            }
                        }

                        using (var fs = new FileStream(sngFile, FileMode.Create))
                        {
                            var sng = Sng2014File.ConvertXML(xmlFile, arrType, fontSng);
                            sng.WriteSng(fs, targetPlatform);
                        }

                        noShowlights &= !xmlFiles.Any(x => Path.GetFileName(x).Contains(xmlName.Split('_')[0].ToLower() + "_showlights"));
                        //Create Showlights
                        if (noShowlights && arrType != ArrangementType.Vocal)
                        {
                            var shlName = Path.Combine(Path.GetDirectoryName(xmlFile), xmlName.Split('_')[0] + "_showlights.xml");
                            var shl = new Showlight.Showlights(xmlFile);
                            if (shl.FixShowlights(shl))
                            {
                                using (var fs = new FileStream(shlName, FileMode.Create))
                                    shl.Serialize(fs);
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Fixes showlights and updates existing xml.
 /// </summary>
 /// <param name="shlPath"></param>
 /// <param name = "fixShowlights"></param>
 internal static void UpdateShl(string shlPath, bool fixShowlights = true)
 {
     //TODO:FIXME
     if (!fixShowlights) return;
     var shl = new Showlight.Showlights(shlPath);
     if (shl.FixShowlights(shl))
     {
         using (var fs = new FileStream(shlPath, FileMode.Create))
             shl.Serialize(fs);
     }
 }
 /// <summary>
 /// Fixes showlights and updates existing xml.
 /// </summary>
 /// <param name="shlPath"></param>
 /// <param name = "fixShowlights"></param>
 internal static void UpdateShl(string shlPath, bool fixShowlights = true)
 {
     // TODO: seems to be working now, continue to monitor output
     if (!fixShowlights) return;
     var shl = new Showlight.Showlights(shlPath);
     if (shl.FixShowlights(shl))
     {
         using (var fs = new FileStream(shlPath, FileMode.Create))
             shl.Serialize(fs);
     }
 }