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)); } } }
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)); } }
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)); } } }
public override bool AsyncLoad() { m_script["game"] = m_gameTable = m_script.NewTable(); m_script["scoring"] = m_scoringTable = m_script.NewTable(); //m_script["game"] = m_gameTable; m_gameTable["chart"] = new ChartInfoHandle(new ChartSetInfoHandle(m_resources, m_script, Client.DatabaseWorker, m_chartInfo.Set), m_chartInfo); if (!base.AsyncLoad()) { return(false); } string chartsDir = TheoriConfig.ChartsDirectory; var setInfo = m_chartInfo.Set; if (m_chart == null) { if (ChartDatabaseService.TryLoadChart(m_chartInfo) is Chart chart) { m_chart = chart; string audioFile = Path.Combine(chartsDir, setInfo.FilePath, m_chart.Info.SongFileName); m_audio = AudioTrack.FromFile(audioFile); m_audio.Channel = Mixer.MasterChannel; m_audio.Volume = m_chart.Info.SongVolume / 100.0f; } else { Logger.Log($"Failed to load chart {m_chartInfo.SongTitle}"); Pop(); return(false); } } m_audioPlayback = new SlidingChartPlayback(m_chart, false); m_visualPlayback = new SlidingChartPlayback(m_chart, true); m_highwayView = new HighwayView(m_locator, m_visualPlayback); //m_script = new ScriptProgram(m_locator); #if false m_gameTable["meta"] = m_metaTable = m_script.NewTable(); m_gameTable["scoring"] = m_scoringTable = m_script.NewTable(); m_metaTable["songTitle"] = m_chart.Info.SongTitle; m_metaTable["songArtist"] = m_chart.Info.SongArtist; m_metaTable["difficultyName"] = m_chart.Info.DifficultyName; m_metaTable["difficultyNameShort"] = m_chart.Info.DifficultyNameShort; m_metaTable["difficultyLevel"] = m_chart.Info.DifficultyLevel; m_metaTable["difficultyColor"] = (m_chart.Info.DifficultyColor ?? new Vector3(1, 1, 1)) * 255; #endif //m_guiScript.LoadFile(m_locator.OpenFileStream("scripts/generic-layer.lua")); //m_script.LoadFile(m_locator.OpenFileStream("scripts/game/main.lua")!, "scripts/game/main.lua"); //if (!m_script.LuaAsyncLoad()) return false; if (!m_highwayView.AsyncLoad()) { return(false); } if (!m_background.AsyncLoad()) { return(false); } m_slamSample = m_resources.QueueAudioLoad("audio/slam"); m_hitSounds["clap"] = m_resources.QueueAudioLoad("audio/sample_clap"); m_hitSounds["clap_punchy"] = m_resources.QueueAudioLoad("audio/sample_clap"); m_hitSounds["clap_impact"] = m_resources.QueueAudioLoad("audio/sample_kick"); m_hitSounds["snare"] = m_resources.QueueAudioLoad("audio/sample_snare"); m_hitSounds["snare_lo"] = m_resources.QueueAudioLoad("audio/sample_snare_lo"); foreach (var lane in m_chart.Lanes) { foreach (var entity in lane) { switch (entity) { case ButtonEntity button: { if (!button.HasSample) { break; } if (!m_hitSounds.ContainsKey(button.Sample)) { string samplePath = Path.Combine(chartsDir, setInfo.FilePath, button.Sample); if (!File.Exists(samplePath)) { break; } var sample = AudioTrack.FromFile(samplePath); m_resources.Manage(sample); m_hitSounds[button.Sample] = sample; } } break; } } } ForegroundGui = new Panel() { Children = new GuiElement[] { m_critRootUi = new CriticalLineUi(m_resources), m_critRootWorld = new CriticalLineWorld(m_resources), m_comboDisplay = new ComboDisplay(m_resources) { RelativePositionAxes = Axes.Both, Position = new Vector2(0.5f, 0.7f) }, } }; if (!m_critRootUi.AsyncLoad()) { return(false); } if (!m_critRootWorld.AsyncLoad()) { return(false); } if (!m_comboDisplay.AsyncLoad()) { return(false); } if (!m_resources.LoadAll()) { return(false); } return(true); }