예제 #1
0
        public ErrorWindow(Exception exc, string message, string context)
        {
            InitializeComponent();

            var setting = LauncherSettings.Load();

            ExceptionTextBox.AppendText(exc.ToString());
            ExceptionTextBox.AppendText("\n" + Util.GetAssemblyVersion());
            ExceptionTextBox.AppendText("\n" + Util.GetGitHash());
            ExceptionTextBox.AppendText("\nContext: " + context);
            ExceptionTextBox.AppendText("\n" + Environment.OSVersion);
            ExceptionTextBox.AppendText("\n" + Environment.Is64BitProcess);
            ExceptionTextBox.AppendText("\n" + setting.IsDx11);
            ExceptionTextBox.AppendText("\n" + setting.InGameAddonEnabled);
            ExceptionTextBox.AppendText("\n" + setting.AutologinEnabled);
            ExceptionTextBox.AppendText("\n" + setting.AutologinEnabled);
            ExceptionTextBox.AppendText("\n" + setting.Language);

            #if DEBUG
            ExceptionTextBox.AppendText("\nDebugging");
            #endif

            ExceptionTextBox.AppendText("\n\n\n" + Properties.Settings.Default.Addons);

            ContextTextBlock.Text = message;

            Serilog.Log.Error("ErrorWindow called: [{0}] [{1}]\n" + new TextRange(ExceptionTextBox.Document.ContentStart, ExceptionTextBox.Document.ContentEnd).Text, message, context);

            SystemSounds.Hand.Play();

            Activate();
            Topmost = true;
            Topmost = false;
            Focus();
        }
예제 #2
0
        public static void SaveLangauge(GameLanguage language)
        {
            if (language == null)
            {
                return;
            }

            LauncherSettings settings = LauncherSettings.Load();

            settings.Language = language.Parameter;
            LauncherSettings.Save(settings);
        }
예제 #3
0
        public static GameLanguage LoadLanguage()
        {
            LauncherSettings settings = LauncherSettings.Load();

            if (settings.Language == null)
            {
                LauncherSettings clean = new LauncherSettings();
                LauncherSettings.Save(clean);
                settings = LauncherSettings.Load();
            }

            GameLanguage loadedLanguage = Languages.Where(language => language.Parameter == settings.Language).FirstOrDefault();

            if (loadedLanguage == null)
            {
                loadedLanguage = GetDefaultLanguage();
            }

            return(loadedLanguage);
        }
        public ErrorWindow(Exception exc, string message, string context)
        {
            InitializeComponent();

            var setting = LauncherSettings.Load();

            ExceptionTextBox.AppendText(exc.ToString());
            ExceptionTextBox.AppendText("\n" + Util.GetAssemblyVersion());
            ExceptionTextBox.AppendText("\n" + Util.GetGitHash());
            ExceptionTextBox.AppendText("\nContext: " + context);
            ExceptionTextBox.AppendText("\nOS: " + Environment.OSVersion);
            ExceptionTextBox.AppendText("\n" + Environment.Is64BitProcess);

            if (setting != null)
            {
                ExceptionTextBox.AppendText("\nDX11? " + setting.IsDx11);
                ExceptionTextBox.AppendText("\nAuto Login Enabled? " + setting.AutologinEnabled);
                ExceptionTextBox.AppendText("\nLanguage: " + setting.Language);
                ExceptionTextBox.AppendText("\nGame path: " + setting.GamePath);

                // When this happens we probably don't want them to run into it again, in case it's an issue with a moved game for example
                setting.AutologinEnabled = false;
            }

#if DEBUG
            ExceptionTextBox.AppendText("\nDebugging");
#endif

            ContextTextBlock.Text = message;

            Serilog.Log.Error("ErrorWindow called: [{0}] [{1}]\n" + new TextRange(ExceptionTextBox.Document.ContentStart, ExceptionTextBox.Document.ContentEnd).Text, message, context);

            SystemSounds.Hand.Play();

            Activate();
            Topmost = true;
            Topmost = false;
            Focus();
        }
예제 #5
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 setting = LauncherSettings.Load();
                var result  = IntegrityCheck.RunIntegrityCheckAsync(setting.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 = "";

            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);
        }