Exemplo n.º 1
0
        private bool SwitchStoryboard(string path)
        {
            try
            {
                var info = BeatmapFolderInfo.Parse(path);
                StatusOutput.ChangeText($"正在切换{Path.GetFileName(info.osb_file_path)}...");
                StoryboardPlayerHelper.PlayStoryboard(info);
                StatusOutput.ChangeText($"");
            }
            catch (Exception e)
            {
                logger.LogError($"无法切换SB:原因 {e.Message}");
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private Task DownloadBeatmap(int beatmap_setid)
        {
            return(Task.Run(() => {
                WebClient client = new WebClient();
                var file_name = $"{beatmap_setid}.osz";
                StatusOutput.ChangeText($"正在下载{beatmap_setid}...");

                client.DownloadFile(new Uri($"https://mikirasora.moe/api/osu/dl_map?beatmap_setid={beatmap_setid}&api=98D037CD"), file_name);

                using (ZipArchive archive = ZipFile.Open(file_name, ZipArchiveMode.Update))
                {
                    var output_path = Path.Combine(Setting.Instance.StoryboardFolders, $"{beatmap_setid}");
                    Directory.CreateDirectory(output_path);

                    archive.ExtractToDirectory(output_path);
                }
            }));
        }
Exemplo n.º 3
0
        private async void SwitchStoryboard(int beatmap_setid)
        {
            var path = Directory.EnumerateDirectories(Setting.Instance.StoryboardFolders, $"{beatmap_setid}*").FirstOrDefault();

            if (string.IsNullOrWhiteSpace(path))
            {
                try
                {
                    await DownloadBeatmap(beatmap_setid);

                    path = Directory.EnumerateDirectories(Setting.Instance.StoryboardFolders, $"{beatmap_setid}*").FirstOrDefault();
                }
                catch (Exception e)
                {
                    StatusOutput.ChangeText($"下载{beatmap_setid}失败!{e.Message}", 5000);
                }
            }

            if (!SwitchStoryboard(path))
            {
                RequestSwitch();
            }
        }