static void Main(string[] args) { //path of standard beatmap folder which contains storyboard. Console.Write("Input beatmap folder path. > "); var beatmap_folder = Console.ReadLine(); //time we need to update. Console.Write("Input time value. > "); var update_time = int.Parse(Console.ReadLine()); //not allow lib output anything. Setting.AllowLog = false; #region Get beatmap info about osb file and osu file. //for convenience var beatmap_info = BeatmapFolderInfo.Parse(beatmap_folder); #endregion #region Get storyboard objects and create updater for controling objects in timeline. //get storyboard objects from .osb file var osb_object_list = GetStoryboardObjectsFromFile(beatmap_info.osb_file_path); osb_object_list.Sort((a, b) => (int)(a.FileLine - b.FileLine)); //get storyboard objects from first .osu file in folder var osu_object_list = GetStoryboardObjectsFromFile(beatmap_info.DifficultFiles.First().Value); osu_object_list.Sort((a, b) => (int)(a.FileLine - b.FileLine)); //combine .osu objects and .osb objects var storyboard_objects = CombineStoryboardObjects(osb_object_list, osu_object_list); //add optimzer and use StoryboardOptimzerManager.AddOptimzer <RuntimeOptimzer>(); // or StoryboardOptimzerManager.AddOptimzer(new RuntimeOptimzer()); StoryboardOptimzerManager.AddOptimzer <ParserStaticOptimzer>(); StoryboardOptimzerManager.Optimze(4, storyboard_objects); //create updater var updater = new StoryboardUpdater(storyboard_objects); #endregion //Update storyboard to the specified time , and then you could take UpdatingStoryboardObjects and render them. updater.Update(update_time); //Maybe collection element is different if you call Update() within difference time. var updating_objects = updater.UpdatingStoryboardObjects; //draw them. foreach (var obj in updating_objects) { Draw(obj); } Console.ReadLine(); }
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); }
static void Main(string[] args) { var dir_path = "ssss"; BeatmapFolderInfo folder_info = BeatmapFolderInfo.Parse(dir_path, null); Setting.EnableSplitMoveScaleCommand = false; var sb_instance = StoryboardInstance.Load(folder_info); CSSInstance css = new CSSInstance(); var objects = sb_instance.Updater.StoryboardObjectList; foreach (var sbo in objects) { sbo.CalculateAndApplyBaseFrameTime(); var result = StoryboardConverter.ConvertStoryboardObject(sbo, dir_path); css.FormatableCSSElements.AddRange(result.keyframes); css.FormatableCSSElements.Add(result.selector); } AppendVisualField(css); var css_content = css.FormatAsCSSSupport(null); var css_save_path = Path.Combine(folder_info.folder_path, "result.css"); File.WriteAllText(css_save_path, css_content); var html_content = GenerateHtml(css_save_path, css, objects); var html_save_path = Path.Combine(folder_info.folder_path, "result_html.html"); File.WriteAllText(html_save_path, html_content); //Console.ReadLine(); }
public static BeatmapFolderInfoEx Parse(string folder_path, Parameters args) { string explicitly_osu_diff_name = ""; if (args != null && args.TryGetArg("diff", out var diff_name)) { explicitly_osu_diff_name = diff_name; } var info = BeatmapFolderInfo.Parse <BeatmapFolderInfoEx>(folder_path); if (!string.IsNullOrWhiteSpace(explicitly_osu_diff_name)) { int index = -1; index = int.TryParse(explicitly_osu_diff_name, out index) ? index : -1; if (index > 0) { info.osu_file_path = info.DifficultFiles.OrderBy(x => x.Key).FirstOrDefault().Value; } else { info.osu_file_path = info.DifficultFiles.Where(x => x.Key.Contains(explicitly_osu_diff_name)).OrderBy(x => x.Key.Length).FirstOrDefault().Value; } } else { //优先选std铺面的.一些图其他模式谱面会有阻挡 53925 fripSide - Hesitation Snow info.osu_file_path = info.DifficultFiles.FirstOrDefault(x => { var lines = File.ReadAllLines(x.Value); foreach (var line in lines) { if (line.StartsWith("Mode")) { try { var mode = line.Split(':').Last().ToInt(); if (mode == 0) { return(true); } } catch { } } } return(false); }).Value; if (!File.Exists(info.osu_file_path)) { info.osu_file_path = info.DifficultFiles.FirstOrDefault().Value; } } if ((!string.IsNullOrWhiteSpace(info.osu_file_path)) && File.Exists(info.osu_file_path)) { info.reader = new OsuFileReader(info.osu_file_path); var section = new SectionReader(Section.General, info.reader); info.audio_file_path = Path.Combine(folder_path, section.ReadProperty("AudioFilename")); Log.User($"audio file path={info.audio_file_path}"); var wideMatch = section.ReadProperty("WidescreenStoryboard"); if (!string.IsNullOrWhiteSpace(wideMatch)) { info.IsWidescreenStoryboard = wideMatch.ToInt() == 1; } } /* * if (string.IsNullOrWhiteSpace(info.osu_file_path) || (!File.Exists(info.osu_file_path))) * { * info.audio_file_path = Directory * .GetFiles(info.folder_path, "*.mp3") * .Select(x => new FileInfo(x)) * .OrderByDescending(x => x.Length) * .FirstOrDefault() * ?.FullName; * } */ if (string.IsNullOrWhiteSpace(info.osu_file_path) || !File.Exists(info.osu_file_path)) { Log.Warn("No .osu load"); } if (string.IsNullOrWhiteSpace(info.audio_file_path) || !File.Exists(info.audio_file_path)) { throw new Exception("Audio file not found."); } return(info); }