private void ConvertKSHAndOpen() { var dialog = new OpenFileDialogDesc("Open KSH Chart", new[] { new FileFilter("K-Shoot MANIA Files", "ksh") }); var dialogResult = FileSystem.ShowOpenFileDialog(dialog); if (dialogResult.DialogResult == DialogResult.OK) { string primaryKshFile = dialogResult.FilePath; var chartSetInfo = ConvertKSHAndSave(primaryKshFile, out ChartInfo selected); var serializer = BinaryTheoriChartSerializer.GetSerializerFor(NeuroSonicGameMode.Instance); using (var stream = File.OpenRead(Path.Combine(m_chartsDir, chartSetInfo.FilePath, selected.FileName))) { var chart = serializer.DeserializeChart(selected, stream); string audioFile = Path.Combine(m_chartsDir, chartSetInfo.FilePath, chart.Info.SongFileName); var audio = AudioTrack.FromFile(audioFile); audio.Channel = Host.Mixer.MasterChannel; audio.Volume = chart.Info.SongVolume / 100.0f; AutoPlay autoPlay = AutoPlay.None; if (Keyboard.IsDown(KeyCode.LCTRL) || Keyboard.IsDown(KeyCode.RCTRL)) { autoPlay = AutoPlay.ButtonsAndLasers; } var game = new GameLayer(Plugin.DefaultResourceLocator, chart, audio, autoPlay); Host.PushLayer(new GenericTransitionLayer(game, Plugin.DefaultResourceLocator)); } } }
public OpenFileResult ShowOpenFileDialog(OpenFileDialogDesc desc) { Debug.Assert(RuntimeInfo.IsWindows); string GetFilterFor(FileFilter filter) { var exts = filter.Extensions.Select(e => $"*.{ e }"); return($"{ filter.Description } ({ string.Join(", ", exts) })|{ string.Join(";", exts) }"); } var dialog = new OpenFileDialog() { Filter = string.Join("|", desc.Filters.Select(GetFilterFor)), }; var result = new OpenFileResult() { DialogResult = (DialogResult)dialog.ShowDialog(), }; if (result.DialogResult == DialogResult.OK) { result.FilePath = dialog.FileName; } return(result); }
private void ConvertKSH() { var dialog = new OpenFileDialogDesc("Open KSH Chart", new[] { new FileFilter("K-Shoot MANIA Files", "ksh") }); var dialogResult = FileSystem.ShowOpenFileDialog(dialog); if (dialogResult.DialogResult == DialogResult.OK) { string primaryKshFile = dialogResult.FilePath; var chartSetInfo = ConvertKSHAndSave(primaryKshFile, out _); Process.Start(Path.Combine(Plugin.Config.GetString(NscConfigKey.StandaloneChartsDirectory), chartSetInfo.FilePath)); } }
private void OpenKSH() { var dialog = new OpenFileDialogDesc("Open Chart", new[] { new FileFilter("K-Shoot MANIA Files", "ksh") }); var dialogResult = FileSystem.ShowOpenFileDialog(dialog); if (dialogResult.DialogResult == DialogResult.OK) { string kshChart = dialogResult.FilePath; string fileDir = Directory.GetParent(kshChart).FullName; var ksh = KshChart.CreateFromFile(kshChart); string audioFileFx = Path.Combine(fileDir, ksh.Metadata.MusicFile ?? ""); string audioFileNoFx = Path.Combine(fileDir, ksh.Metadata.MusicFileNoFx ?? ""); string audioFile = audioFileNoFx; if (File.Exists(audioFileFx)) { audioFile = audioFileFx; } var audio = AudioTrack.FromFile(audioFile); audio.Channel = Host.Mixer.MasterChannel; audio.Volume = ksh.Metadata.MusicVolume / 100.0f; var chart = ksh.ToVoltex(); AutoPlay autoPlay = AutoPlay.None; if (Keyboard.IsDown(KeyCode.LCTRL) || Keyboard.IsDown(KeyCode.RCTRL)) { autoPlay = AutoPlay.ButtonsAndLasers; } var game = new GameLayer(Plugin.DefaultResourceLocator, chart, audio, autoPlay); Host.PushLayer(new GenericTransitionLayer(game, Plugin.DefaultResourceLocator)); } }
public static OpenFileResult ShowOpenFileDialog(OpenFileDialogDesc desc) { return(Host.Platform.ShowOpenFileDialog(desc)); }
private void OpenTheori() { var dialog = new OpenFileDialogDesc("Open Theori Chart", new[] { new FileFilter("music:theori Files", "theori") }); var dialogResult = FileSystem.ShowOpenFileDialog(dialog); if (dialogResult.DialogResult == DialogResult.OK) { string theoriFile = dialogResult.FilePath; string theoriDirectory = Directory.GetParent(theoriFile).FullName; var setFiles = Directory.EnumerateFiles(theoriDirectory, "*.theori-set").ToArray(); if (setFiles.Length == 0) { Logger.Log("Failed to locate .theori-set file."); return; } else if (setFiles.Length != 1) { Logger.Log($"Too many .theori-set files, choosing the first ({ setFiles[0] })."); return; } string setFile = setFiles[0]; var setSerializer = new ChartSetSerializer(); ChartSetInfo setInfo; using (var setStream = File.OpenRead(setFile)) setInfo = setSerializer.DeserializeChartSetInfo(setStream); setInfo.FilePath = theoriDirectory; var chartInfos = (from chartInfo in setInfo.Charts where chartInfo.FileName == Path.GetFileName(theoriFile) select chartInfo).ToArray(); if (chartInfos.Length == 0) { Logger.Log($"Set file { Path.GetFileName(setFile) } did not contain meta information for given chart { Path.GetFileName(theoriFile) }."); return; } Debug.Assert(chartInfos.Length == 1, "Chart set deserialization returned multiple sets with the same file name!"); var selected = chartInfos.Single(); var serializer = BinaryTheoriChartSerializer.GetSerializerFor(NeuroSonicGameMode.Instance); using (var stream = File.OpenRead(Path.Combine(m_chartsDir, setInfo.FilePath, selected.FileName))) { var chart = serializer.DeserializeChart(selected, stream); string audioFile = Path.Combine(m_chartsDir, setInfo.FilePath, chart.Info.SongFileName); var audio = AudioTrack.FromFile(audioFile); audio.Channel = Host.Mixer.MasterChannel; audio.Volume = chart.Info.SongVolume / 100.0f; AutoPlay autoPlay = AutoPlay.None; if (Keyboard.IsDown(KeyCode.LCTRL) || Keyboard.IsDown(KeyCode.RCTRL)) { autoPlay = AutoPlay.ButtonsAndLasers; } var game = new GameLayer(Plugin.DefaultResourceLocator, chart, audio, autoPlay); Host.PushLayer(new GenericTransitionLayer(game, Plugin.DefaultResourceLocator)); } } }