コード例 #1
0
ファイル: Entry.cs プロジェクト: larnin/Spectrum
        private TimeSpan GetBestSplitTime()
        {
            var fs = new FileSystem(typeof(SplitTimes.Entry));

            var path = Path.Combine(Defaults.PluginDataDirectory, fs.DirectoryPath);

            path = Path.Combine(path, SplitTime.GetSavePath(
                                    G.Sys.GameManager_.Level_,
                                    G.Sys.GameManager_.Mode_,
                                    G.Sys.PlayerManager_.Current_.profile_
                                    ));
            path = Path.Combine(path, "pb.txt");

            if (File.Exists(path))
            {
                try
                {
                    using (var sr = new StreamReader(path))
                    {
                        string[] line;
                        while ((line = sr.ReadLine()?.Split('\t')) != null)
                        {
                            if (line.Length == 2)
                            {
                                return(TimeSpan.Parse("00:" + line[0]));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Spectrum.Plugins.SplitTracks: Tried to load time from Spectrum.Plugins.SplitTimes and failed. Exception below:\n{ex}");
                }
            }

            return(TimeSpan.Zero);
        }