Exemple #1
0
        public DetailForm(string replayPath)
        {
            replaypath = replayPath;

            InitializeComponent();

            // Load split button menu
            var listOfExecs = ExecsManager.GetSavedExecs().Where(x => !x.Equals(ExecsManager.GetDefaultExecName())).ToArray();

            // No items? Don't load the menu
            if (listOfExecs.Count() > 0)
            {
                var execMenu = new ContextMenuStrip
                {
                    ShowCheckMargin = false,
                    ShowImageMargin = false,
                };

                execMenu.ItemClicked += new ToolStripItemClickedEventHandler(GeneralStartReplayMenuItem_Click);

                foreach (var item in listOfExecs)
                {
                    execMenu.Items.Add(item);
                }

                this.GeneralPlayReplaySplitButton.Menu = execMenu;
            }
        }
Exemple #2
0
        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().ShowDialog();

                if (result == DialogResult.OK)
                {
                    exec = ExecsManager.GetExec(ExecsManager.GetDefaultExecName());
                }
                else
                {
                    // Failed to get exec, stop
                    this.GeneralPlayReplaySplitButton.Enabled = true;
                    return;
                }
            }
            else
            {
                // Start update form with target
                var result = new UpdateSplashForm(execName).ShowDialog();

                if (result == DialogResult.OK)
                {
                    exec = ExecsManager.GetExec(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;
            }

            var playtask = Task.Run(() =>
            {
                ReplayManager.StartReplay(replaypath, exec.TargetPath);
            }).ContinueWith((t) =>
            {
                this.BeginInvoke((Action)(() =>
                {
                    if (t.IsFaulted)
                    {
                        MessageBox.Show("Failed to play replay: " + t.Exception.GetType().ToString() + "\n" + t.Exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    GeneralPlayReplaySplitButton.Enabled = true;
                }));
            });
        }
Exemple #3
0
        /// <summary>
        /// Actions for when main tab changes
        /// </summary>
        private void SettingsForm_SelectedIndexChanged(object sender, EventArgs e)
        {
            // If tab is now on executables
            if (this.MainTabControl.SelectedIndex == 1)
            {
                // Populate List of execs
                RefreshExecListBox();
                this.ExecDeleteButton.Enabled = false;
                this.ExecEditButton.Enabled   = false;
            }
            // If tab is now on general
            else if (this.MainTabControl.SelectedIndex == 0)
            {
                // Populate List of execs
                this.GeneralGameComboBox.Items.Clear();
                this.GeneralGameComboBox.Items.AddRange(ExecsManager.GetSavedExecs());

                // Select saved item by name
                var selectedItem = ExecsManager.GetDefaultExecName();
                if (selectedItem != null)
                {
                    this.GeneralGameComboBox.SelectedItem = selectedItem;
                }
            }
        }
Exemple #4
0
        private static void StartReplay(string replayPath, 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().ShowDialog();

                if (result == DialogResult.OK)
                {
                    exec = ExecsManager.GetExec(ExecsManager.GetDefaultExecName());
                }
                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(execName).ShowDialog();

                if (result == DialogResult.OK)
                {
                    exec = ExecsManager.GetExec(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;
            }

            ReplayManager.StartReplay(replayPath, exec.TargetPath);
        }
Exemple #5
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            // Set version text in about tab
            this.AboutVersionLabel.Text = RoflSettings.Default.VersionString;

            // Load saved executable entries for combo box
            this.GeneralGameComboBox.Items.AddRange(ExecsManager.GetSavedExecs());

            // Restore saved default entry
            var selectedItem = ExecsManager.GetDefaultExecName();

            if (selectedItem != null)
            {
                this.GeneralGameComboBox.SelectedItem = selectedItem;
            }

            // Restore saved settings
            this.GeneralLaunchComboBox.SelectedItem = this.GeneralLaunchComboBox.Items[RoflSettings.Default.StartupMode];
            this.GeneralRegionComboBox.SelectedItem = RoflSettings.Default.Region;
            this.GeneralUsernameTextBox.Text        = RoflSettings.Default.Username;
        }
Exemple #6
0
        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
            var targetExec = ExecsManager.GetExec(ExecsManager.GetDefaultExecName());

            // Choose exec to update if given
            if (!string.IsNullOrEmpty(TargetExecToUpdate))
            {
                var tempExec = ExecsManager.GetExec(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
            if (targetExec == null)
            {
                MessageBox.Show("Could not find any executables saved, ROFL Player will try to automatically locate League of Legends", "No Default Exec Found", MessageBoxButtons.OK, MessageBoxIcon.Information);

                // Result should be the name of the new exec, will be "false" if something happens
                var result = ExecsManager.FindAndAddLeagueExec();

                // Ok, failed to find exec
                if (result.StartsWith("FALSE"))
                {
                    // Failed to find install path, have user find it!
                    if (result.Contains("Could not find install path"))
                    {
                        // show browse dialog
                        MessageBox.Show("ROFL Player could not find League of Legends install folder, please select it", "Could not find install folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        var installPath = "INVALID";

                        while (installPath.Equals("INVALID"))
                        {
                            installPath = BrowseDialog();
                            // Check if result is empty
                            if (string.IsNullOrEmpty(installPath))
                            {
                                MessageBox.Show("Invalid install folder", "Could not find install folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                this.DialogResult = DialogResult.Abort;
                                this.Close();
                                return;
                            }
                        }

                        // Save using given path
                        ExecsManager.FindAndAddLeagueExec(installPath);
                    }
                    else // Some other error, besides finding install path, happened when trying to find exec
                    {
                        MessageBox.Show(result.Substring(result.IndexOf(':') + 1), "Exception occured", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0);
                        this.DialogResult = DialogResult.Abort;
                        this.Close();
                        return;
                    }
                }

                // Set new default exec we just found
                targetExec = ExecsManager.GetExec(ExecsManager.GetDefaultExecName());
            }

            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
                    var result = ExecsManager.UpdateLeaguePath(targetExec.Name);

                    // If update failed
                    if (result.StartsWith("FALSE"))
                    {
                        MessageBox.Show(result.Substring(result.IndexOf(':') + 1), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.DialogResult = DialogResult.Abort;
                        this.Close();
                        return;
                    }
                    // If update worked
                    else
                    {
                        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();
        }