Esempio n. 1
0
 private void ListenerManager_OnBeatmapChanged(OsuRTDataProvider.BeatmapInfo.Beatmap map)
 {
     Application.Current.Dispatcher?.BeginInvoke(new Action(() =>
     {
         LblSongInfo.Content = map.TitleUnicode;
     }));
 }
        public void SetBeatmap(OsuRTDataProvider.BeatmapInfo.Beatmap beatmap)
        {
            if (beatmap == null)
            {
                Log.Error("Can't get OsuRTDataProvider.BeatmapInfo.Beatmap object from SourceWrapper");
                return;
            }

            ctb_pp_calc.Beatmap = new RealTimePPDisplayer.Beatmap.BeatmapReader(beatmap, (int)OsuRTDataProvider.Listen.OsuPlayMode.CatchTheBeat);
        }
Esempio n. 3
0
        public BeatmapReader(OsuRTDataProvider.BeatmapInfo.Beatmap beatmap, OsuPlayMode mode = OsuPlayMode.Unknown)
        {
            m_beatmap_header_span.Offset = 0;
            m_beatmap_header_span.Length = 0;
            Mode = mode;

            using (var fs = File.OpenRead(beatmap.FilenameFull))
            {
                RawData = new byte[fs.Length];
                fs.Read(RawData, 0, (int)fs.Length);
            }
            Parse();
        }
Esempio n. 4
0
        public BeatmapReader(OsuRTDataProvider.BeatmapInfo.Beatmap beatmap, int mode)
        {
            OrtdpBeatmap = beatmap;
            _beatmapHeaderSpan.Offset = 0;
            _beatmapHeaderSpan.Length = 0;
            Mode = mode;

            StringBuilder sb = new StringBuilder();

            foreach (var line in File.ReadAllLines(beatmap.FilenameFull))
            {
                sb.Append($"{line}\n");
            }

            RawData = Encoding.UTF8.GetBytes(sb.ToString());
            Parse();
        }
        private void RtppOnBeatmapChanged(OsuRTDataProvider.BeatmapInfo.Beatmap beatmap)
        {
            string file = beatmap.FilenameFull;

            if (string.IsNullOrWhiteSpace(file))
            {
                CurrentIO.WriteColor($"[RealTimePPDisplayer]No found .osu file(Set:{beatmap.BeatmapSetID} Beatmap:{beatmap.BeatmapID}])", ConsoleColor.Yellow);
                _beatmapReader = null;
                return;
            }

            if (Setting.DebugMode)
            {
                CurrentIO.WriteColor($"[RealTimePPDisplayer]File:{file}", ConsoleColor.Blue);
            }
            _beatmapReader = new BeatmapReader(beatmap, _mode);
            _ppCalculator.ClearCache();
        }
        private void RTPPOnBeatmapChanged(OsuRTDataProvider.BeatmapInfo.Beatmap beatmap)
        {
            if (string.IsNullOrWhiteSpace(beatmap.Difficulty))
            {
                m_beatmap_reader = null;
                return;
            }

            string file = beatmap.FilenameFull;

            if (string.IsNullOrWhiteSpace(file))
            {
                Sync.Tools.IO.CurrentIO.WriteColor($"[RealTimePPDisplayer]No found .osu file(Set:{beatmap.BeatmapSetID} Beatmap:{beatmap.BeatmapID}])", ConsoleColor.Yellow);
                m_beatmap_reader = null;
                return;
            }

            if (Setting.DebugMode)
            {
                Sync.Tools.IO.CurrentIO.WriteColor($"[RealTimePPDisplayer]File:{file}", ConsoleColor.Blue);
            }
            m_beatmap_reader = new BeatmapReader(file);
        }
 private void ListenerManager_OnBeatmapChanged(OsuRTDataProvider.BeatmapInfo.Beatmap map)
 {
     beatmap = map;
 }
Esempio n. 8
0
 public void OnBeatmapChanged(OrtdpBeatmap map)
 {
     NowMap = map;
 }
Esempio n. 9
0
        /// <summary>
        ///     通过OsuRTDataProvider.BeatmapInfo.Beatmap构造Beatmap对象。
        /// </summary>
        /// <param name="x"></param>
        public Beatmap(OsuRTDataProvider.BeatmapInfo.Beatmap x)
        {
            //bmap = x;

            var rt = new DisplayerBase();

            Title              = x.Title;
            BeatmapId          = x.BeatmapID;
            TitleUnicode       = x.TitleUnicode;
            Artist             = x.Artist;
            ArtistUnicode      = x.ArtistUnicode;
            Creator            = x.Creator;
            Difficulty         = x.Difficulty;
            Version            = x.Version;
            FileName           = x.Filename;
            FullPath           = x.FilenameFull;
            DownloadLink       = x.DownloadLink;
            BackgroundFileName = x.BackgroundFilename;
            BeatmapId          = x.BeatmapID;
            VideoFileName      = x.VideoFilename;
            Source             = "";
            Tags          = "";
            Maker         = "";
            AudioFileName = x.AudioFilename;
            _md5Calc.ComputeHash(File.ReadAllBytes(x.FilenameFull));
            Md5   = _md5Calc.GetMd5String();
            Stars = rt.BeatmapTuple.Stars;
            _b    = new StringBuilder(FullPath);
            _b.Replace(FileName, VideoFileName);
            FullVideoFileName = _b.ToString();
            _b = new StringBuilder(FullPath);
            _b.Replace(FileName, BackgroundFileName);
            FullBackgroundFileName = _b.ToString();
            var alllines = File.ReadAllLines(x.FilenameFull);

            if (!alllines[0].Contains("osu file format"))
            {
                NotValid = true;

                throw new InvalidBeatmapFileException($"文件{x.FilenameFull}不是谱面文件。");
            }

            StringBuilder b = new StringBuilder();

            foreach (var c in alllines[0])
            {
                if (char.IsDigit(c))
                {
                    b.Append(c);
                }
            }
            BeatmapVersion = int.Parse(b.ToString());
            foreach (var line in alllines)
            {
                var temparr = line.Split(':');
                if (temparr[0].Contains("CircleSize"))
                {
                    double.TryParse(temparr[1].Trim(), out var c);
                    CircleSize = c;
                    continue;
                }

                if (temparr[0].Contains("OverallDifficulty"))
                {
                    double.TryParse(temparr[1].Trim(), out var o);
                    OverallDifficulty = o;
                    continue;
                }

                if (temparr[0].Contains("ApproachRate"))
                {
                    double.TryParse(temparr[1].Trim(), out var a);
                    ApproachRate = a;
                    continue;
                }

                if (temparr[0].Contains("HPDrainRate"))
                {
                    double.TryParse(temparr[1].Trim(), out var h);
                    HpDrain = h;
                    continue;
                }

                if (temparr[0].Contains("Maker:"))
                {
                    Maker = line.Replace("Maker:", "").Trim();
                    continue;
                }

                if (temparr[0].Contains("Source:"))
                {
                    Source = line.Replace("Source:", "").Trim();
                    continue;
                }

                if (temparr[0].Contains("Tags:"))
                {
                    Tags = line.Replace("Tags:", "").Trim();
                    continue;
                }

                if (temparr[0].StartsWith("0,0,\""))
                {
                    if (string.IsNullOrEmpty(BackgroundFileName))
                    {
                        BackgroundFileName = temparr[0].Split(',')[2].Replace("\"", "").Trim();
                    }
                    FullBackgroundFileName = Path.Combine(BeatmapFolder, BackgroundFileName);
                    continue;
                }

                if (temparr[0].StartsWith("Video,"))
                {
                    if (!string.IsNullOrEmpty(VideoFileName))
                    {
                        VideoFileName     = temparr[0].Split(',')[2].Replace("\"", "").Trim();
                        FullVideoFileName = Path.Combine(BeatmapFolder, VideoFileName);
                        HasVideo          = true;
                    }
                    else
                    {
                        HasVideo = false;
                    }

                    continue;
                }

                if (temparr[0].Contains("Mode"))
                {
                    if (!_modeHasSet)
                    {
                        int.TryParse(temparr[1].Trim(), out _m);
                        Mode        = (OsuGameMode)_m;
                        _modeHasSet = true;
                    }

                    continue;
                }

                if (line.Contains("TimingPoints"))
                {
                    break;
                }
            }

            FullAudioFileName = x.FilenameFull.Replace(x.Filename, x.AudioFilename);
            FullVideoFileName = x.FilenameFull.Replace(x.Filename, x.VideoFilename);
            getAddtionalInfo(alllines);
        }