コード例 #1
0
        [STAThread] // This is required for system dialogs
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Scribe logger = new Scribe();

            //*/
            try
            {
                ExeManager exeManager = null;
                try
                {
                    exeManager = new ExeManager();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ROFLPlayer was not able to find League of Legends. Please add it now.", "First time setup", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    logger.Info(_className, $"First time setup kicked off by exception:\n{ex.ToString()}");
                    // Start add exec form
                    var addForm    = new ExecAddForm(new ExeTools());
                    var formResult = addForm.ShowDialog();

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

                        // Save execinfo file
                        exeManager = new ExeManager(newExec);
                        exeManager.Save();
                    }
                    else
                    {
                        // Exit if form exited any other way
                        Environment.Exit(1);
                    }

                    addForm.Dispose();
                }

                ReplayPlayer replayPlayer = new ReplayPlayer(exeManager);

                if (args.Length == 0)
                {
                    // Update default exec
                    Application.Run(new UpdateSplashForm(exeManager));
                    Application.Run(new SettingsForm(exeManager));
                }
                else
                {
                    // StartupMode, 1  = show detailed information, 0 = launch replay immediately
                    if (RoflSettings.Default.StartupMode == 0)
                    {
                        StartReplay(args[0], exeManager, replayPlayer);
                    }
                    else
                    {
                        var replayFile = Task.Run(() => SetupReplayFileAsync(args[0]));

                        replayFile.Wait();

                        RequestManager requestManager = new RequestManager();

                        Application.Run(new DetailForm(replayFile.Result, requestManager, exeManager, replayPlayer, logger));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"ROFLPlayer encountered an unhandled exception, please record this message and report it here https://github.com/andrew1421lee/ROFL-Player/issues" + "\n\n" + ex.ToString(), "Critical Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                logger.Error(_className, "Unhandled exception: " + ex.ToString());
                Environment.Exit(1);
            }
            //*/
        }