예제 #1
0
        /// <summary>
        /// Replaces occurences of "{attributes}" within the supplied file name templates with
        /// their gathered values. Note that this is just doing simple string replacement, so there
        /// is no fancy character escaping like "{{attributes}}" or something similar.
        /// </summary>
        static string ConstructFileName(string template, Score score, string identifier, string archive, ToolkitInfo toolkitInfo)
        {
            var attributes = new Dictionary<string, string>();
            attributes.Add("title", score.Title);
            attributes.Add("artist", score.Artist);
            attributes.Add("artist_sort", score.ArtistSort);
            attributes.Add("album", score.Album);
            attributes.Add("year", score.Year);
            attributes.Add("tabber", score.Tabber);
            attributes.Add("identifier", identifier);
            attributes.Add("archive", archive);
            if (toolkitInfo != null && toolkitInfo.ToolkitVersion != string.Empty)
                attributes.Add("toolkit", toolkitInfo.ToolkitVersion);
            else
                attributes.Add("toolkit", "none");
            if (toolkitInfo != null && toolkitInfo.PackageVersion != string.Empty)
                attributes.Add("version", toolkitInfo.PackageVersion);
            else
                attributes.Add("version", "1.0");

            string output = template;

            foreach (var kvp in attributes)
                output = output.Replace("{"+kvp.Key+"}", kvp.Value);

            return output;
        }
예제 #2
0
 static void ExportArrangement(Score score, Song2014 arrangement, string identifier, int difficulty, 
     string originalFile, ToolkitInfo toolkitInfo)
 {
     var track = Converter.ConvertArrangement(arrangement, identifier, difficulty);
     score.Tracks.Add(track);
     score.Title = arrangement.Title;
     score.Artist = arrangement.ArtistName;
     score.ArtistSort = arrangement.ArtistNameSort;
     score.Album = arrangement.AlbumName;
     score.Year = arrangement.AlbumYear;
     score.Comments = new List<string>();
     score.Comments.Add("Generated by RocksmithToTab v" + VersionInfo.VERSION);
     score.Comments.Add("=> http://www.rocksmithtotab.de");
     score.Comments.Add("Created from archive: " + Path.GetFileName(originalFile));
     if (toolkitInfo != null && toolkitInfo.PackageAuthor != string.Empty)
     {
         score.Comments.Add("CDLC author:  " + toolkitInfo.PackageAuthor);
         score.Tabber = toolkitInfo.PackageAuthor;
     }
     if (toolkitInfo != null && toolkitInfo.PackageVersion != string.Empty)
         score.Comments.Add("CDLC version: " + toolkitInfo.PackageVersion);
 }
예제 #3
0
        public ToolkitInfo GetToolkitInfo()
        {
            // see if there's a toolkit.version file inside the archive.
            // this will only be the case for CDLCs
            var infoFile = archive.Entries.FirstOrDefault(x => x.Name == "toolkit.version");

            if (infoFile == null)
            {
                return(null);
            }

            var info = new ToolkitInfo();

            using (var reader = new StreamReader(infoFile.Data.OpenStream()))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    // we need to decipher what this line contains;
                    // older toolkit versions just put a single line with the version number
                    // newer versions put several lines in the format "key : value"
                    var tokens = line.Split(new char[] { ':' });
                    // trim all tokens of surrounding whitespaces
                    for (int i = 0; i < tokens.Length; ++i)
                    {
                        tokens[i] = tokens[i].Trim();
                    }

                    if (tokens.Length == 1)
                    {
                        // this is probably just the version number
                        info.ToolkitVersion = tokens[0];
                    }
                    else if (tokens.Length == 2)
                    {
                        // key/value attribute
                        var key = tokens[0].ToLower();
                        switch (key)
                        {
                        case "toolkit version":
                            info.ToolkitVersion = tokens[1]; break;

                        case "package author":
                            info.PackageAuthor = tokens[1]; break;

                        case "package version":
                            info.PackageVersion = tokens[1]; break;

                        default:
                            Console.WriteLine("  Notice: Unknown key in toolkit.version: {0}", key);
                            break;
                        }
                    }
                    else
                    {
                        // ???
                        Console.WriteLine("  Notice: Unrecognized line in toolkit.version: {0}", line);
                    }
                }
            }

            return(info);
        }
        /// <summary>
        /// Load a XML arrangment into memory and
        /// convert to GuitarPro file
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <param name="outputDir"></param>
        /// <param name="outputFormat"></param>
        /// <param name="allDif"></param>
        public void XmlToGp5(string inputFilePath, string outputDir, string outputFormat = "gp5", bool allDif = false)
        {
            Console.WriteLine("Opening arrangement {0} ...", inputFilePath);
            Console.WriteLine();
            var score = new Score();
            var arrangement = Song2014.LoadFromFile(inputFilePath);
            var toolkitInfo = new ToolkitInfo();
            toolkitInfo.ToolkitVersion = String.Format("CST v{0}", ToolkitVersion.version);
            toolkitInfo.PackageAuthor = "XML To GP5 Converter";
            toolkitInfo.PackageVersion = arrangement.LastConversionDateTime;

            var comments = Song2014.ReadXmlComments(inputFilePath);
            foreach (var xComment in comments)
            {
                if (xComment.Value.Contains("CST"))
                {
                    toolkitInfo.ToolkitVersion = xComment.Value.Trim();
                    break;
                }
            }

            // get maximum difficulty for the arrangement
            var mf = new ManifestFunctions(GameVersion.RS2014);
            int maxDif = mf.GetMaxDifficulty(arrangement);

            if (allDif) // create separate file for each difficulty
            {
                for (int difLevel = 0; difLevel <= maxDif; difLevel++)
                {
                    ExportArrangement(score, arrangement, difLevel, inputFilePath, toolkitInfo);
                    Console.WriteLine("Difficulty Level: {0}", difLevel);

                    var baseFileName = CleanFileName(
                        String.Format("{0} - {1}", score.Artist, score.Title));
                    baseFileName += String.Format(" ({0})", arrangement.Arrangement);
                    baseFileName += String.Format(" (level {0:D2})", difLevel);

                    SaveScore(score, baseFileName, outputDir, outputFormat);
                    // remember to remove the track from the score again
                    score.Tracks.Clear();
                }
            }
            else // combine maximum difficulty arrangements into one file
            {
                Console.WriteLine("Maximum Difficulty Level: {0}", maxDif);
                ExportArrangement(score, arrangement, maxDif, inputFilePath, toolkitInfo);
            }

            if (!allDif) // only maximum difficulty
            {
                var baseFileName = CleanFileName(
                    String.Format("{0} - {1}", score.Artist, score.Title));
                SaveScore(score, baseFileName, outputDir, outputFormat);
            }
        }