当前位置: 首页>>代码示例>>C#>>正文


C# Score.SortTracks方法代码示例

本文整理汇总了C#中Score.SortTracks方法的典型用法代码示例。如果您正苦于以下问题:C# Score.SortTracks方法的具体用法?C# Score.SortTracks怎么用?C# Score.SortTracks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Score的用法示例。


在下文中一共展示了Score.SortTracks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportXml

        static void ExportXml(List<string> inputFiles, CmdOptions options)
        {
            Score score = new Score();
            string identifier = "none";
            foreach (var xmlFile in inputFiles)
            {
                Console.WriteLine("Processing {0} ...", xmlFile);
                Song2014 arrangement = null;
                try
                {
                    arrangement = Song2014.LoadFromFile(xmlFile);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to parse XML input file: " + e.Message);
                }

                if (arrangement != null)
                {
                    // xml files should be named "songidentifier_arrangement.xml", 
                    // extract the arrangement identifier, which we use to set
                    // the track name and track color as well as output file name
                    string baseFileName = Path.GetFileNameWithoutExtension(xmlFile);
                    var identifiers = baseFileName.Split(new char[] { '_' });
                    string arr = "";
                    if (identifiers.Length >= 2)
                        arr = identifiers.Last();
                    identifier = identifiers.First();

                    ExportArrangement(score, arrangement, arr, options.DifficultyLevel, xmlFile, null);
                    if (options.SplitArrangements)
                    {
                        baseFileName = CleanFileName(
                            ConstructFileName(options.FileNameFormat, score, identifier, identifier, null));
                        baseFileName += " (" + arr + ")";
                        SaveScore(score, baseFileName, options.OutputDirectory, options.OutputFormat);
                        // remember to remove the track from the score again
                        score.Tracks.Clear();
                    }
                }
            }

            if (!options.SplitArrangements)
            {
                score.SortTracks();
                string baseFileName = CleanFileName(
                    ConstructFileName(options.FileNameFormat, score, identifier, identifier, null));
                SaveScore(score, baseFileName, options.OutputDirectory, options.OutputFormat);
            }
        }
开发者ID:nstoker,项目名称:RocksmithToTab,代码行数:50,代码来源:Program.cs

示例2: ExportPsarc

        static void ExportPsarc(string psarcFile, CmdOptions options)
        {
            var archiveName = Path.GetFileNameWithoutExtension(psarcFile);
            try
            {
                var browser = new PsarcBrowser(psarcFile);

                var songList = browser.GetSongList();
                var toolkitInfo = browser.GetToolkitInfo();

                if (options.ListSongs)
                {
                    foreach (var song in songList)
                    {
                        Console.WriteLine("[{0}] {1} - {2}  ({3}, {4})   {{{5}}}", song.Identifier,
                            song.Artist, song.Title, song.Album, song.Year,
                            string.Join(", ", song.Arrangements));
                    }
                    return;
                }

                // collect all songs to convert
                var toConvert = new List<SongInfo>();
                if (options.Tracks == null || options.Tracks.Count == 0)
                {
                    // if nothing was specified, convert all songs
                    toConvert = toConvert.Concat(songList).ToList();
                }
                else
                {
                    foreach (var songId in options.Tracks)
                    {
                        var songInfo = songList.FirstOrDefault(x => x.Identifier == songId);
                        if (songInfo != null)
                            toConvert.Add(songInfo);
                    }
                }

                for (int i = 0; i < toConvert.Count; ++i)
                {
                    var song = toConvert[i];
                    var score = new Score();
                    // figure out which arrangements to convert
                    var arrangements = song.Arrangements;
                    if (options.Arrangements != null && options.Arrangements.Count > 0)
                        arrangements = arrangements.Intersect(options.Arrangements).ToList();

                    Console.WriteLine("({1}/{2}) Converting song {0} ...", song.Identifier, i+1, toConvert.Count);
                    foreach (var arr in arrangements)
                    {
                        var arrangement = browser.GetArrangement(song.Identifier, arr);
                        if (arrangement == null)
                        {
                            Console.WriteLine(" Failed to get arrangement {0}", arr);
                            continue;
                        }
                        if (arrangement.ArrangementProperties.Metronome == 1)
                        {
                            // CDLC feature: optional arrangements can be generated which feature only
                            // metronome ticks, no music. However, the tab is identical to the normal
                            // track, so we don't need this unless it was explicitly requested.
                            if (options.Arrangements == null || options.Arrangements.Count == 0)
                            {
                                Console.WriteLine(" Arrangement {0} is a metronome track, ignore.", arr);
                                continue;
                            }
                        }
                        ExportArrangement(score, arrangement, arr, options.DifficultyLevel, psarcFile, toolkitInfo);

                        if (options.SplitArrangements)
                        {
                            string baseFileName = ConstructFileName(options.FileNameFormat, score, song.Identifier,
                                archiveName, toolkitInfo);
                            baseFileName = CleanFileName(string.Format("{0} ({1})", baseFileName, arr));
                            SaveScore(score, baseFileName, options.OutputDirectory, options.OutputFormat);
                            // remember to remove the track from the score again
                            score.Tracks.Clear();
                        }
                    }

                    if (!options.SplitArrangements)
                    {
                        score.SortTracks();
                        string baseFileName = CleanFileName(
                            ConstructFileName(options.FileNameFormat, score, song.Identifier, archiveName, toolkitInfo));
                        SaveScore(score, baseFileName, options.OutputDirectory, options.OutputFormat);
                    }
                }
                Console.WriteLine();
            }
            catch (IOException e)
            {
                Console.WriteLine("Error encountered:");
                Console.WriteLine(e.Message);
            }

        }
开发者ID:nstoker,项目名称:RocksmithToTab,代码行数:97,代码来源:Program.cs


注:本文中的Score.SortTracks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。