예제 #1
0
        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);
        }
예제 #2
0
        public void PlayReplay(ReplayPreview preview)
        {
            _log.Information($"Playing replay...");

            if (preview == null)
            {
                throw new ArgumentNullException(nameof(preview));
            }

            var replay = FileResults[preview.Location];

            var executables = SettingsManager.Executables.GetExecutablesByPatch(preview.GameVersion);

            if (!executables.Any())
            {
                _log.Information($"No executables found to play replay");

                // No executable found that can be used to play
                MessageBox.Show
                (
                    Application.Current.TryFindResource("ExecutableNotFoundErrorText") as String + " " + preview.GameVersion,
                    Application.Current.TryFindResource("ExecutableNotFoundErrorTitle") as String,
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                );
                return;
            }

            LeagueExecutable target;

            if (executables.Count > 1)
            {
                _log.Information($"More than one possible executable, asking user...");
                // More than one?????
                target = ShowChooseReplayDialog(executables);
                if (target == null)
                {
                    return;
                }
            }
            else
            {
                target = executables.First();
            }

            if (SettingsManager.Settings.PlayConfirmation)
            {
                _log.Information($"Asking user for confirmation");
                // Show confirmation dialog
                var msgResult = MessageBox.Show
                                (
                    Application.Current.TryFindResource("ReplayPlayConfirmationText") as String,
                    Application.Current.TryFindResource("ReplayPlayConfirmationText") as String,
                    MessageBoxButton.OKCancel,
                    MessageBoxImage.Question
                                );

                if (msgResult != MessageBoxResult.OK)
                {
                    return;
                }
            }

            _log.Information($"Using {target.Name} to play replay {replay.FileInfo.Path}");
            ReplayPlayer.Play(target, replay.FileInfo.Path);
        }
예제 #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(_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;
                }));
            });
        }