Example #1
0
        /// <summary>
        ///     使用MD5搜索谱面
        /// </summary>
        /// <param name="md5"></param>
        /// <param name="md5Type">指定谱面或录像的MD5</param>
        /// <returns></returns>
        public ReplayCollection Find(string md5, Md5Type md5Type)
        {
            var r = new ReplayCollection();

            foreach (var replay in _rdata)
            {
                if (md5Type == Md5Type.BeatmapMd5)
                {
                    if (replay.BeatmapMd5 == md5)
                    {
                        r.Add(replay);
                    }
                }
                if (md5Type == Md5Type.ReplayMd5)
                {
                    if (replay.ReplayMd5 == md5)
                    {
                        r.Add(replay);
                    }
                }
                if (r.Replays.Count == 0)
                {
                    throw new ReplayNotFoundException("找不到与指定MD5匹配的录像");
                }
            }

            return(r);
        }
Example #2
0
        /// <summary>
        ///     使用游戏模式匹配录像
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public ReplayCollection Find(OsuGameMode mode)
        {
            var r = new ReplayCollection();

            foreach (var replay in _rdata)
            {
                if (replay.Mode == mode)
                {
                    r._rdata.Add(replay);
                }
            }
            return(r);
        }
Example #3
0
        /// <summary>
        ///     使用Mod匹配录像
        /// </summary>
        /// <param name="mod"></param>
        /// <returns></returns>
        public ReplayCollection Find(OsuGameMod mod)
        {
            var r = new ReplayCollection();

            foreach (var replay in _rdata)
            {
                if (replay.Mods.Contains(mod))
                {
                    r._rdata.Add(replay);
                }
            }
            return(r);
        }
Example #4
0
        /// <summary>
        ///     在指定文件夹中搜索录像
        /// </summary>
        /// <param name="replaydir"></param>
        /// <returns></returns>
        public static ReplayCollection GetAllReplays(string replaydir)
        {
            var rc   = new ReplayCollection();
            var dirs = Directory.GetFiles(replaydir, "*.osr", SearchOption.AllDirectories);

            foreach (var osrfile in dirs)
            {
                var stream = File.OpenRead(osrfile);
                var bin    = new BinaryReader(stream);
                var osr    = new Replay(bin, osrfile);
                rc.Add(osr);
            }

            return(rc);
        }