Beispiel #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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Actions for delete exec button
        /// </summary>
        private void ExecDeleteButton_Click(object sender, EventArgs e)
        {
            // Get exec that is selected
            var selectedName = (string)this.ExecItemsList.SelectedItem;

            // Attempt to delete
            var result = ExecsManager.DeleteExecFile(selectedName);

            // Check for error/result
            if (result.StartsWith("FALSE"))
            {
                MessageBox.Show(result.Substring(result.IndexOf(':') + 1), "Error deleting entry", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result.StartsWith("TRUE"))
            {
                // Repopulate list
                RefreshExecListBox();

                // Reset info box
                this.GBoxExecNameTextBox.Text       = "";
                this.GBoxTargetLocationTextBox.Text = "";
                this.GBoxPatchVersTextBox.Text      = "";
                this.GBoxLastModifTextBox.Text      = "";

                // turn off context buttons
                ExecDeleteButton.Enabled = false;
                ExecEditButton.Enabled   = false;
            }
        }
Beispiel #3
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;
                }));
            });
        }
Beispiel #4
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;
                }
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
        /// <summary>
        /// Actions for edit exec button, also called on double click action
        /// </summary>
        private void ExecEditButton_Click(object sender, EventArgs e)
        {
            // Get exec that is selected
            var selectedName = (string)this.ExecItemsList.SelectedItem;
            var exec         = ExecsManager.GetExec(selectedName);

            // Check is gotten exec
            if (exec == null)
            {
                // This happens when nothing is selected
                //MessageBox.Show("Specified entry does not exist. Delete and re-add", "Error reading entry", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // Start add form, but in edit mode
                var editForm   = new ExecAddForm(exec);
                var formResult = editForm.ShowDialog();

                // if form exited with ok
                if (formResult == DialogResult.OK)
                {
                    // Get edited exec
                    var newExec = editForm.NewLeagueExec;

                    // Save exec file
                    ExecsManager.DeleteExecFile(selectedName);
                    ExecsManager.SaveExecFile(newExec);

                    // Refresh list of execs
                    RefreshExecListBox();

                    // Clear info box
                    this.GBoxExecNameTextBox.Text       = "";
                    this.GBoxTargetLocationTextBox.Text = "";
                    this.GBoxPatchVersTextBox.Text      = "";
                    this.GBoxLastModifTextBox.Text      = "";

                    // disable context buttons
                    ExecDeleteButton.Enabled = false;
                    ExecEditButton.Enabled   = false;
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Actions for add exec button
        /// </summary>
        private void ExecAddButton_Click(object sender, EventArgs e)
        {
            // Start add exec form
            var addForm    = new ExecAddForm();
            var formResult = addForm.ShowDialog();

            // If form exited with ok
            if (formResult == DialogResult.OK)
            {
                // Get new exec
                var newExec = addForm.NewLeagueExec;

                // Save execinfo file
                ExecsManager.SaveExecFile(newExec);

                // Add to exec items list
                RefreshExecListBox();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Actions for ok button
        /// </summary>
        private void MainOkButton_Click(object sender, EventArgs e)
        {
            // Save selected default exec
            if (this.GeneralGameComboBox.SelectedItem != null)
            {
                ExecsManager.SetDefaultExecByName(this.GeneralGameComboBox.SelectedItem.ToString());
            }

            // 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);
        }
Beispiel #9
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;
        }
Beispiel #10
0
        /// <summary>
        /// Actions for selecting exec
        /// </summary>
        private void ExecItemsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Get exec that is selected
            var selectedItemName = (string)this.ExecItemsList.SelectedItem;
            var selectedExec     = ExecsManager.GetExec(selectedItemName);

            // Nothing? Weird, just return
            if (selectedExec == null)
            {
                return;
            }

            // Enable selected context buttons
            this.ExecDeleteButton.Enabled = true;
            this.ExecEditButton.Enabled   = true;

            // Update groupbox
            this.GBoxExecNameTextBox.Text       = selectedExec.Name;
            this.GBoxTargetLocationTextBox.Text = selectedExec.TargetPath;
            this.GBoxPatchVersTextBox.Text      = selectedExec.PatchVersion;
            this.GBoxLastModifTextBox.Text      = selectedExec.ModifiedDate.ToString("yyyy/MM/dd");
            this.GBoxAllowUpdatesTextBox.Text   = selectedExec.AllowUpdates.ToString();
        }
Beispiel #11
0
 /// <summary>
 /// Refresh execs list
 /// </summary>
 private void RefreshExecListBox()
 {
     this.ExecItemsList.Items.Clear();
     this.ExecItemsList.Items.AddRange(ExecsManager.GetSavedExecs());
 }
Beispiel #12
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();
        }