Exemplo n.º 1
0
        public App()
        {
            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

            var release = $"xivlauncher-{Util.GetAssemblyVersion()}-{Util.GetGitHash()}";

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Async(a =>
                                        a.File(Path.Combine(Paths.RoamingPath, "output.log")))
#if DEBUG
                         .WriteTo.Debug()
                         .MinimumLevel.Verbose()
#else
                         .MinimumLevel.Information()
#endif
                         .CreateLogger();

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += EarlyInitExceptionHandler;
            TaskScheduler.UnobservedTaskException      += TaskSchedulerOnUnobservedTaskException;
#endif

            CustomMessageBox.InvokableApp = this;

            try
            {
                SetupSettings();
            }
            catch (Exception e)
            {
                Log.Error(e, "Settings were corrupted, resetting");
                File.Delete(GetConfigPath("launcher"));
                SetupSettings();
            }

#if !XL_LOC_FORCEFALLBACKS
            try
            {
                if (App.Settings.LauncherLanguage == null)
                {
                    var currentUiLang = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
                    App.Settings.LauncherLanguage = App.Settings.LauncherLanguage.GetLangFromTwoLetterISO(currentUiLang);
                }

                Log.Information("Trying to set up Loc for language code {0}", App.Settings.LauncherLanguage.GetLocalizationCode());
                if (!App.Settings.LauncherLanguage.IsDefault())
                {
                    Loc.Setup(Util.GetFromResources($"XIVLauncher.Resources.Loc.xl.xl_{App.Settings.LauncherLanguage.GetLocalizationCode()}.json"));
                }
                else
                {
                    Loc.SetupWithFallbacks();
                }
            }
            catch (Exception ex) {
                Log.Error(ex, "Could not get language information. Setting up fallbacks.");
                Loc.Setup("{}");
            }
#else
            // Force all fallbacks
            Loc.Setup("{}");
#endif

            Log.Information(
                $"XIVLauncher started as {release}");

#if !XL_NOAUTOUPDATE
            if (!EnvironmentSettings.IsDisableUpdates)
            {
                try
                {
                    Log.Information("Starting update check...");

                    _updateWindow = new UpdateLoadingDialog();
                    _updateWindow.Show();

                    var updateMgr = new Updates();
                    updateMgr.OnUpdateCheckFinished += OnUpdateCheckFinished;

                    updateMgr.Run(EnvironmentSettings.IsPreRelease);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        "XIVLauncher could not contact the update server. Please check your internet connection or try again.\n\n" + ex,
                        "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Environment.Exit(0);
                }
            }
#endif
        }
Exemplo n.º 2
0
        public App()
        {
            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

            var release = $"xivlauncher-{Util.GetAssemblyVersion()}-{Util.GetGitHash()}";

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Async(a =>
                                        a.File(Path.Combine(Paths.RoamingPath, "output.log")))
#if DEBUG
                         .WriteTo.Debug()
                         .MinimumLevel.Verbose()
#else
                         .MinimumLevel.Information()
                         .WriteTo.Sentry(o =>
            {
                o.MinimumBreadcrumbLevel = LogEventLevel.Debug; // Debug and higher are stored as breadcrumbs (default is Information)
                o.MinimumEventLevel      = LogEventLevel.Error; // Error and higher is sent as event (default is Error)
                // If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If nothing is found, SDK is disabled.
                o.Dsn = new Dsn("https://[email protected]/1548116");
                o.AttachStacktrace = true;
                o.SendDefaultPii   = false;   // send PII like the username of the user logged in to the device

                o.Release = release;
            })
#endif
                         .CreateLogger();

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += EarlyInitExceptionHandler;
            TaskScheduler.UnobservedTaskException      += TaskSchedulerOnUnobservedTaskException;
#endif

            try
            {
                SetupSettings();
            }
            catch (Exception e)
            {
                Log.Error(e, "Settings were corrupted, resetting");
                File.Delete(GetConfigPath("launcher"));
                SetupSettings();
            }

#if !XL_LOC_FORCEFALLBACKS
            try
            {
                var currentUiLang = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
                Log.Information("Trying to set up Loc for culture {0}", currentUiLang);

                if (_allowedLang.Any(x => currentUiLang == x))
                {
                    Loc.Setup(Util.GetFromResources($"XIVLauncher.Resources.Loc.xl.xl_{currentUiLang}.json"));
                }
                else
                {
                    Loc.SetupWithFallbacks();
                }
            }
            catch (Exception ex) {
                Log.Error(ex, "Could not get language information. Setting up fallbacks.");
                Loc.Setup("{}");
            }
#else
            // Force all fallbacks
            Loc.Setup("{}");
#endif

            Log.Information(
                $"XIVLauncher started as {release}");

#if !XL_NOAUTOUPDATE
            if (!Util.IsWine)
            {
                try
                {
                    Log.Information("Starting update check...");

                    _updateWindow = new UpdateLoadingDialog();
                    _updateWindow.Show();

                    var updateMgr = new Updates();
                    updateMgr.OnUpdateCheckFinished += OnUpdateCheckFinished;

                    updateMgr.Run(Environment.GetEnvironmentVariable("XL_PRERELEASE") == "True");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        "XIVLauncher could not contact the update server. Please check your internet connection or try again.\n\n" + ex,
                        "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Environment.Exit(0);
                }
            }
#endif
        }
Exemplo n.º 3
0
        public App()
        {
            Settings = new ConfigurationBuilder <ILauncherSettingsV3>()
                       .UseCommandLineArgs()
                       .UseJsonFile(GetConfigPath("launcher"))
                       .UseTypeParser(new DirectoryInfoParser())
                       .UseTypeParser(new AddonListParser())
                       .Build();

            var release = $"xivlauncher-{Util.GetAssemblyVersion()}-{Util.GetGitHash()}";

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Async(a =>
                                        a.File(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                            "XIVLauncher", "output.log")))
#if DEBUG
                         .WriteTo.Debug()
                         .MinimumLevel.Verbose()
#else
                         .MinimumLevel.Information()
                         .WriteTo.Sentry(o =>
            {
                o.MinimumBreadcrumbLevel = LogEventLevel.Debug; // Debug and higher are stored as breadcrumbs (default is Information)
                o.MinimumEventLevel      = LogEventLevel.Error; // Error and higher is sent as event (default is Error)
                // If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If nothing is found, SDK is disabled.
                o.Dsn = new Dsn("https://[email protected]/1548116");
                o.AttachStacktrace = true;
                o.SendDefaultPii   = false;   // send PII like the username of the user logged in to the device

                o.Release = release;
            })
#endif
                         .CreateLogger();


#if !XL_LOC_FORCEFALLBACKS
            try
            {
                var currentUiLang = CultureInfo.CurrentUICulture;
                Log.Information("Trying to set up Loc for culture {0}", currentUiLang.TwoLetterISOLanguageName);

                Loc.Setup(_allowedLang.Any(x => currentUiLang.TwoLetterISOLanguageName == x)
                    ? $"Loc.xl.xl_{currentUiLang.TwoLetterISOLanguageName}.json"
                    : "{}");
            }
            catch (Exception ex) {
                Log.Error(ex, "Could not get language information. Setting up fallbacks.");
                Loc.Setup("{}");
            }
#else
            // Force all fallbacks
            Loc.Setup("{}");
#endif

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += EarlyInitExceptionHandler;
#endif

            Log.Information(
                $"XIVLauncher started as {release}");

#if !XL_NOAUTOUPDATE
            try
            {
                Log.Information("Starting update check...");

                _updateWindow = new UpdateLoadingDialog();
                _updateWindow.Show();

                var updateMgr = new Updates();
                updateMgr.OnUpdateCheckFinished += OnUpdateCheckFinished;

                updateMgr.Run(Environment.GetEnvironmentVariable("XL_PRERELEASE") == "True");
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "XIVLauncher could not contact the update server. Please check your internet connection or try again.\n\n" + ex,
                    "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
#endif
        }