private static void StartReplay(string replayPath, ExeManager exeManager, ReplayPlayer replayPlayer, string execName = "default") { LeagueExecutable exec = null; // Get default exec or specified exec if (execName.Equals("default")) { // Start update form with default var result = new UpdateSplashForm(exeManager).ShowDialog(); if (result == DialogResult.OK) { exec = exeManager.GetDefaultExecutable(); } else { // Failed to get exec, stop MessageBox.Show("Failed to start replay", $"Could not find executable data {execName}", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { // Start update form with target var result = new UpdateSplashForm(exeManager, execName).ShowDialog(); if (result == DialogResult.OK) { exec = exeManager.GetExecutable(execName); } else { // Failed to get exec, stop MessageBox.Show("Failed to start replay", $"Could not find executable data {execName}", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (exec == null) { MessageBox.Show("Failed to start replay", $"Could not find executable data {execName}", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } replayPlayer.Play(exec, replayPath); }
private void StartReplay(string execName = "default") { LeagueExecutable exec = null; // Get default exec or specified exec if (execName.Equals("default")) { // Start update form with default var result = new UpdateSplashForm(_exeManager).ShowDialog(); if (result == DialogResult.OK) { exec = _exeManager.GetDefaultExecutable(); } else { // Failed to get exec, stop this.GeneralPlayReplaySplitButton.Enabled = true; return; } } else { // Start update form with target var result = new UpdateSplashForm(_exeManager, execName).ShowDialog(); if (result == DialogResult.OK) { exec = _exeManager.GetExecutable(execName); } else { // Failed to get exec, stop this.GeneralPlayReplaySplitButton.Enabled = true; return; } } // This really shouldn't happen, but just to be safe if (exec == null) { MessageBox.Show($"Could not find executable data {execName}\nPlease run ROFL Player and check the executables", "Failed to start replay", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Start League of Legends, var playtask = Task.Run(() => { //ReplayManager.StartReplay(_fileInfo.Location, exec.TargetPath); _replayPlayer.Play(exec, _replayFile.Location); }).ContinueWith((t) => // When the user closes the game { this.BeginInvoke((Action)(() => { if (t.IsFaulted) { _logger.Error(this.GetType().ToString(), t.Exception.ToString()); MessageBox.Show("Failed to play replay! Check logs for detailed information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } GeneralPlayReplaySplitButton.Enabled = true; })); }); }