/// <summary> /// Actions for ok button /// </summary> private void MainOkButton_Click(object sender, EventArgs e) { // Save selected default exec if (this.GeneralGameComboBox.SelectedItem != null) { string defaultExeName = this.GeneralGameComboBox.SelectedItem.ToString(); LeagueExecutable leagueExecutable = _exeManager.GetExecutable(defaultExeName); _exeManager.SetDefaultExectuable(this.GeneralGameComboBox.SelectedItem.ToString()); } _exeManager.Save(); // Save double click launch option RoflSettings.Default.StartupMode = this.GeneralLaunchComboBox.SelectedIndex; // Save username RoflSettings.Default.Username = this.GeneralUsernameTextBox.Text; // Save region RoflSettings.Default.Region = this.GeneralRegionComboBox.Text; // Save config RoflSettings.Default.Save(); Environment.Exit(1); }
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; })); }); }
private async void UpdateSplashForm_Load(object sender, EventArgs e) { this.TitleLabel.Text = "Getting League of Legends executable..."; await WaitDelay(100); // Get default exec, as default exec LeagueExecutable targetExec = _exeManager.GetDefaultExecutable(); // Choose exec to update if given if (!string.IsNullOrEmpty(TargetExecToUpdate)) { //var tempExec = ExecsManager.GetExec(TargetExecToUpdate); var tempExec = _exeManager.GetExecutable(TargetExecToUpdate); // target by that name does not exist, do not do anything and close the form if (tempExec == null) { MessageBox.Show("Could not find executable with name: " + targetExec.Name + ". Please try again", "No Exec Found", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Abort; this.Close(); return; } else // set target to new exec { targetExec = tempExec; } } this.LoadingProgressBar.Value = 20; this.TitleLabel.Text = "Checking executable..."; await WaitDelay(100); // This should only happen if there is NO default exec, will be skipped on target exec // Should pretty much NEVER happen now with new ExeManager if (targetExec == null) { MessageBox.Show("Could not find any executables saved, ROFL Player was not able to find League of Legends", "No Default Exec Found", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.Abort; this.Close(); return; } this.LoadingProgressBar.Value = 40; this.TitleLabel.Text = "Checking if executable needs updating..."; await WaitDelay(100); // Double check if target exists if (!File.Exists(targetExec.TargetPath)) { // Check if entry allows updates if it doesn't exist if (targetExec.AllowUpdates) { // Update exec path try { _exeManager.UpdateExecutableTarget(targetExec.Name); } catch (Exception ex) { MessageBox.Show($"{ex.GetType().ToString()} - {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } this.TitleLabel.Text = "Successfully updated League executable"; this.LoadingProgressBar.Value = 100; } // Entry does not allow updates else { MessageBox.Show("League executable could not be found, entry does not allow updating", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Abort; this.Close(); return; } } else { this.TitleLabel.Text = "Found League executable"; this.LoadingProgressBar.Value = 100; } await WaitDelay(200); this.DialogResult = DialogResult.OK; this.Close(); }