示例#1
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            if (e.Args.Length > 0 && e.Args[0] == "--genIntegrity")
            {
                var result = IntegrityCheck.RunIntegrityCheckAsync(Settings.GamePath, null).GetAwaiter().GetResult();
                File.WriteAllText($"{result.GameVersion}.json", JsonConvert.SerializeObject(result));

                MessageBox.Show($"Successfully hashed {result.Hashes.Count} files.");
                Environment.Exit(0);
                return;
            }

            if (e.Args.Length > 0 && e.Args[0] == "--dalamudStg")
            {
                Console.Beep();
                DalamudLauncher.UseDalamudStaging = true;
            }

            // Check if the accountName parameter is provided, if yes, pass it to MainWindow
            var accountName = string.Empty;

            if (e.Args.Length > 0 && e.Args[0].StartsWith("--account="))
            {
                accountName = e.Args[0].Substring(e.Args[0].IndexOf("=", StringComparison.InvariantCulture) + 1);
            }

            Log.Information("Loading MainWindow for account '{0}'", accountName);
            _mainWindow = new MainWindow(accountName);

#if XL_NOAUTOUPDATE
            OnUpdateCheckFinished(null, null);
#endif
        }
示例#2
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            // Check if dark mode is enabled on windows, if yes, load the dark theme
            var themeUri =
                new Uri(
                    "pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml",
                    UriKind.RelativeOrAbsolute);

            if (Util.IsWindowsDarkModeEnabled())
            {
                themeUri = new Uri(
                    "pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml",
                    UriKind.RelativeOrAbsolute);
            }

            Current.Resources.MergedDictionaries.Add(new ResourceDictionary {
                Source = themeUri
            });
            Log.Information("Loaded UI theme resource.");

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += (_, args) =>
            {
                new ErrorWindow((Exception)args.ExceptionObject, "An unhandled exception occured.", "Unhandled")
                .ShowDialog();
                Log.CloseAndFlush();
                Environment.Exit(0);
            };
#endif

            if (e.Args.Length > 0 && e.Args[0] == "--backupNow")
            {
                (new CharacterBackupAddon() as INotifyAddonAfterClose).GameClosed();

                Environment.Exit(0);
                return;
            }

            if (e.Args.Length > 0 && e.Args[0] == "--genIntegrity")
            {
                var result = IntegrityCheck.RunIntegrityCheckAsync(Settings.GamePath, null).GetAwaiter().GetResult();
                File.WriteAllText($"{result.GameVersion}.json", JsonConvert.SerializeObject(result));

                MessageBox.Show($"Successfully hashed {result.Hashes.Count} files.");
                Environment.Exit(0);
                return;
            }

            // Check if the accountName parameter is provided, if yes, pass it to MainWindow
            var accountName = "";

            if (e.Args.Length > 0 && e.Args[0].StartsWith("--account="))
            {
                accountName = e.Args[0].Substring(e.Args[0].IndexOf("=", StringComparison.InvariantCulture) + 1);
            }

            Log.Information("Loading MainWindow for account '{0}'", accountName);

            var mainWindow = new MainWindow(accountName);
        }
示例#3
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            var accountName = string.Empty;

            if (e.Args.Length > 0)
            {
                foreach (string arg in e.Args)
                {
                    if (arg == "--genLocalizable")
                    {
                        Loc.ExportLocalizable();
                        Environment.Exit(0);
                        return;
                    }

                    if (arg == "--genIntegrity")
                    {
                        var result = IntegrityCheck.RunIntegrityCheckAsync(Settings.GamePath, null).GetAwaiter().GetResult();
                        File.WriteAllText($"{result.GameVersion}.json", JsonConvert.SerializeObject(result));

                        MessageBox.Show($"Successfully hashed {result.Hashes.Count} files.");
                        Environment.Exit(0);
                        return;
                    }

                    // Check if the accountName parameter is provided, if yes, pass it to MainWindow
                    if (arg.StartsWith("--account="))
                    {
                        accountName = arg.Substring(arg.IndexOf("=", StringComparison.InvariantCulture) + 1);
                        App.Settings.CurrentAccountId = accountName;
                    }

                    // Override client launch language by parameter
                    if (arg.StartsWith("--clientlang="))
                    {
                        string langarg = arg.Substring(arg.IndexOf("=", StringComparison.InvariantCulture) + 1);
                        Enum.TryParse(langarg, out ClientLanguage lang); // defaults to Japanese if the input was invalid.
                        App.Settings.Language = lang;
                        Log.Information($"Language set as {App.Settings.Language.ToString()} by launch argument.");
                    }
                }
            }

            Log.Information("Loading MainWindow for account '{0}'", accountName);

            if (Util.IsWine)
            {
                OnUpdateCheckFinished(null, null);
            }

#if XL_NOAUTOUPDATE
            OnUpdateCheckFinished(null, null);
#endif
        }
        private void RunIntegrityCheck_OnClick(object s, RoutedEventArgs e)
        {
            var window   = new IntegrityCheckProgressWindow();
            var progress = new Progress <IntegrityCheck.IntegrityCheckProgress>();

            progress.ProgressChanged += (sender, checkProgress) => window.UpdateProgress(checkProgress);

            Task.Run(async() => await IntegrityCheck.CompareIntegrityAsync(progress)).ContinueWith(task =>
            {
                window.Dispatcher.Invoke(() => window.Close());

                switch (task.Result.compareResult)
                {
                case IntegrityCheck.CompareResult.NoServer:
                    MessageBox.Show("There is no reference report yet for this game version. Please try again later.", "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    return;

                case IntegrityCheck.CompareResult.Invalid:
                    {
                        File.WriteAllText("integrityreport.txt", task.Result.report);
                        var result = MessageBox.Show(
                            $"Some game files seem to be modified or corrupted. Please check the \"integrityreport.txt\" file in the XIVLauncher folder for more information.\n\nDo you want to reset the game to the last patch? This will allow you to patch it again, likely fixing the issues you are encountering.", "XIVLauncher", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

                        if (result == MessageBoxResult.Yes)
                        {
                            var verFile = Path.Combine(Settings.GetGamePath(), "game", "ffxivgame.ver");

                            File.Delete(verFile);
                            File.WriteAllText(verFile, task.Result.remoteIntegrity.LastGameVersion);

                            Process.Start(System.IO.Path.Combine(GamePathEntry.Text, "boot", "ffxivboot.exe"));
                            Environment.Exit(0);
                        }

                        break;
                    }

                case IntegrityCheck.CompareResult.Valid:
                    MessageBox.Show("Your game install seems to be valid.", "XIVLauncher", MessageBoxButton.OK,
                                    MessageBoxImage.Asterisk);
                    break;
                }
            });

            window.ShowDialog();
        }