Exemple #1
0
 public void Setup(Process gameProcess, ILauncherSettingsV3 setting)
 {
     _gameProcess        = gameProcess;
     _gamePath           = setting.GamePath;
     _language           = setting.Language.GetValueOrDefault(ClientLanguage.English);
     _optOutMbCollection = setting.OptOutMbCollection.GetValueOrDefault();;
 }
 private void SetupSettings()
 {
     Settings = new ConfigurationBuilder <ILauncherSettingsV3>()
                .UseCommandLineArgs()
                .UseJsonFile(GetConfigPath("launcher"))
                .UseTypeParser(new DirectoryInfoParser())
                .UseTypeParser(new AddonListParser())
                .Build();
 }
        public App()
        {
            _globalSetting = new ConfigurationBuilder <ILauncherSettingsV3>()
                             .UseCommandLineArgs()
                             .UseJsonFile(GetConfigPath("launcher"))
                             .UseTypeParser(new DirectoryInfoParser())
                             .UseTypeParser(new AddonListParser())
                             .Build();

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

#if !XL_NOAUTOUPDATE
            try
            {
                Updates.Run(Environment.GetEnvironmentVariable("XL_PRERELEASE") == "True").GetAwaiter().GetResult();
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    "XIVLauncher could not contact the update server. Please check your internet connection or try again.\n\n" + e,
                    "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
#endif

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

            Log.Information(
                $"XIVLauncher started as {release}");
        }
Exemple #4
0
        public FirstTimeSetup(ILauncherSettingsV3 setting)
        {
            InitializeComponent();

            _setting = setting;

            var detectedPath = Util.TryGamePaths();

            if (detectedPath != null)
            {
                GamePathEntry.Text = detectedPath;
            }

#if XL_NOAUTOUPDATE
            MessageBox.Show(
                "You're running an unsupported version of XIVLauncher.\n\nThis can be unsafe and a danger to your SE account. If you have not gotten this unsupported version on purpose, please reinstall a clean version from https://github.com/goaaats/FFXIVQuickLauncher/releases.",
                "XIVLauncher Problem", MessageBoxButton.OK, MessageBoxImage.Exclamation);
#endif
        }
Exemple #5
0
        public static void TryMigrate(ILauncherSettingsV3 newSetting)
        {
            if (!File.Exists(ConfigPath))
            {
                return;
            }

            var oldSetting = Load();

            newSetting.AdditionalLaunchArgs    = oldSetting.AdditionalLaunchArgs;
            newSetting.AutologinEnabled        = oldSetting.AutologinEnabled;
            newSetting.CharacterSyncEnabled    = oldSetting.CharacterSyncEnabled;
            newSetting.GamePath                = oldSetting.GamePath;
            newSetting.InGameAddonEnabled      = oldSetting.InGameAddonEnabled;
            newSetting.CurrentAccountId        = oldSetting.CurrentAccountId;
            newSetting.SteamIntegrationEnabled = oldSetting.SteamIntegrationEnabled;
            newSetting.IsDx11               = oldSetting.IsDx11;
            newSetting.Language             = oldSetting.Language;
            newSetting.UniqueIdCacheEnabled = oldSetting.UniqueIdCacheEnabled;
            newSetting.AddonList            = oldSetting.AddonList;

            File.Delete(ConfigPath);
        }
Exemple #6
0
        public ErrorWindow(Exception exc, string message, string context, ILauncherSettingsV3 setting = null)
        {
            InitializeComponent();

            ExceptionTextBox.AppendText(exc.ToString());
            ExceptionTextBox.AppendText("\nVersion: " + Util.GetAssemblyVersion());
            ExceptionTextBox.AppendText("\nGit Hash: " + Util.GetGitHash());
            ExceptionTextBox.AppendText("\nContext: " + context);
            ExceptionTextBox.AppendText("\nOS: " + Environment.OSVersion);
            ExceptionTextBox.AppendText("\n64bit? " + Environment.Is64BitProcess);

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

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

            ExceptionTextBox.AppendText("\n\n\nAddons: " + 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();
        }
        public void RunAddons(Process gameProcess, ILauncherSettingsV3 setting, List <AddonEntry> addonEntries)
        {
            if (_runningAddons != null)
            {
                throw new Exception("Addons still running?");
            }

            _runningAddons = new List <Tuple <IAddon, Thread, CancellationTokenSource> >();

            foreach (var addonEntry in addonEntries)
            {
                addonEntry.Addon.Setup(gameProcess, setting);

                if (addonEntry.Addon is IPersistentAddon persistentAddon)
                {
                    Log.Information("Starting PersistentAddon {0}", persistentAddon.Name);
                    var cancellationTokenSource = new CancellationTokenSource();

                    var addonThread = new Thread(persistentAddon.DoWork);
                    addonThread.Start(cancellationTokenSource.Token);

                    _runningAddons.Add(new Tuple <IAddon, Thread, CancellationTokenSource>(persistentAddon, addonThread, cancellationTokenSource));
                }

                if (addonEntry.Addon is IRunnableAddon runnableAddon)
                {
                    Log.Information("Starting RunnableAddon {0}", runnableAddon.Name);
                    runnableAddon.Run();
                }

                if (addonEntry.Addon is INotifyAddonAfterClose notifiedAddon)
                {
                    _runningAddons.Add(new Tuple <IAddon, Thread, CancellationTokenSource>(notifiedAddon, null, null));
                }
            }
        }
        public XivGame(ILauncherSettingsV3 setting)
        {
            Task.Run(() =>
            {
                using (var client = new WebClient())
                {
                    client.Headers.Add("User-Agent", _userAgent);

                    client.Headers.Add("Accept", "image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*");

                    client.Headers.Add("Accept-Encoding", "gzip, deflate");
                    client.Headers.Add("Accept-Language", "en-US,en;q=0.8,ja;q=0.6,de-DE;q=0.4,de;q=0.2");

                    client.DownloadString(GenerateFrontierReferer(setting.Language));

                    DownloadAsLauncher($"https://frontier.ffxiv.com/v2/world/status.json?_={Util.GetUnixMillis()}",
                                       setting.Language, "application/json, text/plain, */*");
                    DownloadAsLauncher($"https://frontier.ffxiv.com/worldStatus/login_status.json?_={Util.GetUnixMillis()}",
                                       setting.Language, "application/json, text/plain, */*");
                    DownloadAsLauncher($"https://frontier.ffxiv.com/worldStatus/login_status.json?_={Util.GetUnixMillis() + 50}",
                                       setting.Language, "application/json, text/plain, */*");
                }
            });
        }
        public MainWindow(ILauncherSettingsV3 setting, string accountName)
        {
            _setting = setting;
            _game    = new XivGame(setting);

            InitializeComponent();

#if !XL_NOAUTOUPDATE
            Title += " v" + Util.GetAssemblyVersion();
#else
            Title += " " + Util.GetGitHash();
#endif

            if (!string.IsNullOrEmpty(accountName))
            {
                Properties.Settings.Default.CurrentAccount = accountName;
            }

#if XL_NOAUTOUPDATE
            Title += " - UNSUPPORTED VERSION - NO UPDATES - COULD DO BAD THINGS";
#endif

            InitializeWindow();
        }
Exemple #10
0
 public void Setup(Process gameProcess, ILauncherSettingsV3 setting)
 {
     _gameProcess = gameProcess;
     _gamePath    = setting.GamePath;
     _language    = setting.Language;
 }
 void IAddon.Setup(Process gameProcess, ILauncherSettingsV3 setting)
 {
     _gameProcess = gameProcess;
 }
 void IAddon.Setup(Process gameProcess, ILauncherSettingsV3 setting)
 {
     // Ignored
 }
 public void Setup(Process gameProcess, ILauncherSettingsV3 setting)
 {
     _gameProcess = gameProcess;
     _gamePath    = setting.GamePath;
     _language    = setting.Language.GetValueOrDefault(ClientLanguage.English);
 }
Exemple #14
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;
            TaskScheduler.UnobservedTaskException      += TaskSchedulerOnUnobservedTaskException;
#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
        }
Exemple #15
0
 public void Setup(Process gameProcess, ILauncherSettingsV3 setting)
 {
     _gameProcess = gameProcess;
     _isDx11      = setting.IsDx11;
     _gamePath    = setting.GamePath;
 }