コード例 #1
0
 private void ExtractResourcesToFolder(LauncherSettings settings)
 {
     try
     {
         string root = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ResourceManager.Root);
         try
         {
             ClearRootDirectory(root);
         }
         catch (Exception e)
         {
             ErrorLogHelper.AddErrorInLog(string.Format("::ExtractResourcesToFolder (step=clearRootDirectory) - root={0}..."
                                                        , root)
                                          , string.Format("{0} | {1}", e.Message, e.StackTrace));
         }
         try
         {
             this.CreateRootDirectory(root, settings);
         }
         catch (Exception e)
         {
             ErrorLogHelper.AddErrorInLog(string.Format("::ExtractResourcesToFolder (step=createRootDirectory) - root={0}..."
                                                        , root)
                                          , string.Format("{0} | {1}", e.Message, e.StackTrace));
         }
     }
     catch
     {
     }
 }
コード例 #2
0
        public static LauncherSettings CreateTestLauncherSettings()
        {
            var settings = new LauncherSettings();

            settings.Groups.Add(CreateTestGroup("Европа - Азия"));
            return(settings);
        }
コード例 #3
0
 public ConnectionSettings(PipesSettingsReader pipesSettingsReader, LauncherSettings launcherSettings)
 {
     _pipesSettingsReader = Guard.GetNotNull(pipesSettingsReader, "pipesSettingsReader");
     Guard.CheckNotNull(launcherSettings, "launcherSettings");
     ReadFromCfg();
     ConnectionString = launcherSettings.DefaultConnectionString;
 }
コード例 #4
0
ファイル: Launcher.cs プロジェクト: vijfhoek/Sharpcraft
        /// <summary>
        /// Initializes a new instance of the Sharpcraft Launcher.
        /// </summary>
        public Launcher()
        {
            InitializeComponent();
            _log = LogManager.GetLogger(this);
            PassBox.PasswordChar = (char)0x25CF;
            _auth = new Authenticator(McVersion);
            _auth.OnLoginEvent += LoginEvent;
            if (File.Exists(Constants.GitInfoFile))
            {
                using (var reader = new StreamReader(Constants.GitInfoFile))
                {
                    string content = reader.ReadLine();
                    if (!string.IsNullOrEmpty(content))
                    {
                        string[] gitInfo = content.Split(':');
                        if (gitInfo.Length >= 4)
                        {
                            _hash      = gitInfo[0];
                            _shortHash = gitInfo[1];
                            _author    = gitInfo[2];
                            if (_author.Contains(" "))
                            {
                                _author = _author.Split(' ')[0];
                            }
                            _time = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(double.Parse(gitInfo[3])).ToLocalTime();
                        }
                    }
                }
            }

            VersionLabel.Text = VersionString;

            if (File.Exists(Constants.LauncherSettings))
            {
                _log.Info("Loading launcher settings from file...");
                var reader = new StreamReader(Constants.LauncherSettings);
                _settings = new JsonSerializer().Deserialize <LauncherSettings>(new JsonTextReader(reader));
                _log.Info("Launcher settings loaded successfully!");
                reader.Close();
            }
            else
            {
                _settings = new LauncherSettings(Constants.LauncherSettings);
            }
            if (!string.IsNullOrEmpty(_settings.Username))
            {
                _userBoxInactive  = false;
                UserBox.Text      = _settings.Username;
                UserBox.ForeColor = Color.Black;
            }
            RememberCheckbox.Checked = _settings.Remember;
            if (_settings.Remember && !string.IsNullOrEmpty(_settings.GetPassword()))
            {
                _passBoxInactive  = false;
                PassBox.Text      = _settings.GetPassword();
                PassBox.ForeColor = Color.Black;
            }
            UpdateForm();
            _log.Info("Launcher initialized.");
        }
コード例 #5
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();
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: perezdev/Decaf-Game-Launcher
        public Main()
        {
            InitializeComponent();

            Settings = new LauncherSettings().GetSettings();

            PopulateSettings();
            new Thread(PopulateGames).Start();
        }
コード例 #7
0
        private void FrameworkChanged(object sender, SelectionChangedEventArgs e)
        {
            var framework = (string)FrameworkSelector.SelectedItem;

            if (framework != null && LauncherSettings.PreferredFramework != framework)
            {
                LauncherSettings.PreferredFramework = framework;
                LauncherSettings.Save();
            }
        }
コード例 #8
0
        private ILauncherSettings CreateSettings()
        {
            var settings = new LauncherSettings();

            settings.RemoteUrl             = Data.RemoteUrl;
            settings.PatchDownloadAttempts = 3;
            settings.AppDataPath           = Application.persistentDataPath;

            OverrideSettings(settings);

            return(settings);
        }
コード例 #9
0
        public static void SaveLangauge(GameLanguage language)
        {
            if (language == null)
            {
                return;
            }

            LauncherSettings settings = LauncherSettings.Load();

            settings.Language = language.Parameter;
            LauncherSettings.Save(settings);
        }
コード例 #10
0
ファイル: SettingsFactory.cs プロジェクト: 15831944/Avtoritet
        private void CreateRootDirectory(string root, LauncherSettings settings)
        {
            string path = string.Empty;

            foreach (GroupSet set in settings.Groups)
            {
                foreach (CatalogApi.Settings.GroupBox box in set.GroupBoxs)
                {
                    foreach (CatalogApi.Settings.Brand brand in box.Brands)
                    {
                        try
                        {
                            path = Path.Combine(root, brand.NameAndFolder);

                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            if (brand.IconPathImg != null)
                            {
                                File.WriteAllBytes(string.Join(@"\", new string[] { path, brand.IconPath }), brand.IconPathImg);
                            }
                            if (brand.IconPath2Img != null)
                            {
                                File.WriteAllBytes(string.Join(@"\", new string[] { path, brand.IconPath2 }), brand.IconPath2Img);
                            }
                            foreach (BrandProvider provider in brand.Providers)
                            {
                                foreach (CatalogApi.Settings.CommandFile file in provider.CommandFiles)
                                {
                                    using (StreamWriter writer = new StreamWriter(string.Join(@"\", new string[] { path, file.FileName })))
                                    {
                                        writer.Write(file.FileContent);
                                    }
                                }
                                foreach (CatalogApi.Settings.ProviderFile file2 in provider.ProviderFiles)
                                {
                                    File.WriteAllBytes(string.Join(@"\", new string[] { path, file2.FileName }), file2.FileContent);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLogHelper.AddErrorInLog(string.Format("::CreateRootDirectory (root={0}, brand.Id={1}, brand.NameAndFolder={2}, path={3}) - ..."
                                                                       , root
                                                                       , brand.BrandId, brand.NameAndFolder
                                                                       , path)
                                                         , string.Format("{0} | {1}", e.Message, e.StackTrace));
                        }
                    }
                }
            }
        }
コード例 #11
0
        public async Task StartStudio(string argument)
        {
            if (argument == null)
            {
                throw new ArgumentNullException(nameof(argument));
            }
            if (ActiveVersion == null)
            {
                return;
            }

            if (AutoCloseLauncher)
            {
                argument = $"/LauncherWindowHandle {WindowHandle} {argument}";
            }

            MetricsClient metricsForEditorBefore120 = null;

            try
            {
                Dispatcher.Invoke(() => StartStudioCommand.IsEnabled = false);
                var packagePath    = ActiveVersion.InstallPath;
                var mainExecutable = store.LocateMainExecutable(packagePath);

                // If version is older than 1.2.0, than we need to log the usage of older version
                var activeStoreVersion = ActiveVersion as XenkoStoreVersionViewModel;
                if (activeStoreVersion != null && activeStoreVersion.Version.Version < new Version(1, 2, 0, 0))
                {
                    metricsForEditorBefore120 = new MetricsClient(CommonApps.XenkoEditorAppId, versionOverride: activeStoreVersion.Version.ToString());
                }

                Process.Start(mainExecutable, argument);
            }
            catch (Exception e)
            {
                var message = string.Format(Strings.ErrorStartingProcess, e.FormatSummary(true));
                await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                metricsForEditorBefore120?.Dispose();
            }
            await Task.Delay(5000);

            Dispatcher.Invoke(() =>
            {
                StartStudioCommand.IsEnabled = ActiveVersion != null;
                //Save settings because launcher maybe have not been closed
                LauncherSettings.ActiveVersion = ActiveVersion != null ? ActiveVersion.Name : "";
                LauncherSettings.Save();
            });
        }
コード例 #12
0
        public FirstTimeSetup(LauncherSettings setting)
        {
            InitializeComponent();

            Result = setting;

            var detectedPath = Util.TryGamePaths();

            if (detectedPath != null)
            {
                GamePathEntry.Text = detectedPath;
            }
        }
コード例 #13
0
ファイル: MainWindow.xaml.cs プロジェクト: 15831944/Avtoritet
        private static void LoadUpdates()
        {
            Exception exception;

            try
            {
                using (AvtoritetEntities entities = new AvtoritetEntities())
                {
                    //if (!(entities.Database.Connection.State == ConnectionState.Closed))
                    //{
                    int?    settingVersion = entities.SettingUpdate.FirstOrDefault().SettingVersion;
                    Version version        = new Version(entities.VersionLog.FirstOrDefault().Value)
                    , version2             = new Version(JsonConvert.DeserializeObject <VersionEntity>(FileHelper.OpenFile("Version.json")).Version);
                    if (version > version2)
                    {
                        try {
                        } catch (Exception exception1) {
                            exception = exception1;
                            ErrorLogHelper.AddErrorInLog("LoadUpdates()", exception.Message + " | " + exception.StackTrace);
                        }
                    }
                    if (!System.IO.File.Exists("settingver.txt"))
                    {
                        System.IO.File.WriteAllText("settingver.txt", "1");
                    }
                    int num       = int.Parse(System.IO.File.ReadAllText("settingver.txt"));
                    int?nullable2 = settingVersion;
                    int num2      = num;
                    if ((nullable2.GetValueOrDefault() > num2) &&
                        (nullable2.HasValue == true))
                    {
                        launcherSettings = new SettingsFactory(categoryEventHandler).DownloadSettings(true, true);
                        System.IO.File.WriteAllText("settingver.txt", settingVersion.ToString());
                        HaveNewUpdate = true;
                    }
                    //}
                    //else
                    //ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates() - ...", string.Format("Состояние БД={0}", entities.Database.Connection.State.ToString()));
                }
            }
            catch (Exception exception2)
            {
                exception = exception2;
                ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates()", exception.Message + " | " + exception.StackTrace);
                MessageBox.Show(exception.Message + " | " + exception.StackTrace);
            }
        }
コード例 #14
0
        public void HandleUpdate(LauncherSettings settings, string[] commandArgs)
        {
            if (commandArgs.Length == 0 || commandArgs.Last() != UPDATE_FLAG)
            {
                return;
            }

            // open change log
            var fileName = $"ChangeLog_{settings.Localization}.txt";

            if (File.Exists(fileName) && !settings.DisableChangelogAutoOpen)
            {
                Process.Start(fileName);
            }
            // delete update.exe
            var uProcess = Process.GetProcessesByName(_updaterName).FirstOrDefault();

            void __delUpdate()
            {
                var uFile = $"update\\{_updaterName}.exe";

                if (File.Exists(uFile))
                {
                    File.Delete(uFile);
                }
            }

            if (uProcess != null)
            {
                uProcess.EnableRaisingEvents = true;
                uProcess.Exited += (sender, args) => __delUpdate();
                try
                {
                    uProcess.Kill();
                }
                catch (Exception)
                {
                    // ignore
                }
            }
            else
            {
                __delUpdate();
            }
        }
コード例 #15
0
ファイル: SettingsFactory.cs プロジェクト: 15831944/Avtoritet
 private void CreateRootDirectory(string root, LauncherSettings settings)
 {
     foreach (GroupSet set in settings.Groups)
     {
         foreach (CatalogApi.Settings.GroupBox box in set.GroupBoxs)
         {
             foreach (CatalogApi.Settings.Brand brand in box.Brands)
             {
                 try
                 {
                     string path = Path.Combine(root, brand.NameAndFolder);
                     if (!Directory.Exists(path))
                     {
                         Directory.CreateDirectory(path);
                     }
                     if (brand.IconPathImg != null)
                     {
                         File.WriteAllBytes(string.Join(@"\", new string[] { path, brand.IconPath }), brand.IconPathImg);
                     }
                     if (brand.IconPath2Img != null)
                     {
                         File.WriteAllBytes(string.Join(@"\", new string[] { path, brand.IconPath2 }), brand.IconPath2Img);
                     }
                     foreach (BrandProvider provider in brand.Providers)
                     {
                         foreach (CatalogApi.Settings.CommandFile file in provider.CommandFiles)
                         {
                             using (StreamWriter writer = new StreamWriter(string.Join(@"\", new string[] { path, file.FileName })))
                             {
                                 writer.Write(file.FileContent);
                             }
                         }
                         foreach (CatalogApi.Settings.ProviderFile file2 in provider.ProviderFiles)
                         {
                             File.WriteAllBytes(string.Join(@"\", new string[] { path, file2.FileName }), file2.FileContent);
                         }
                     }
                 }
                 catch
                 {
                 }
             }
         }
     }
 }
コード例 #16
0
        private ILauncherSettings CreateSettings()
        {
            var settings = new LauncherSettings();

            settings.RemoteUrl             = Data.RemoteUrl;
            settings.PatchDownloadAttempts = 3;
            settings.AppDataPath           = Application.persistentDataPath;

#if DEBUG
            settings.DebugMode = true;
#else
            settings.DebugMode = false;
#endif

            OverrideSettings(settings);

            return(settings);
        }
コード例 #17
0
ファイル: MainWindow.xaml.cs プロジェクト: 15831944/Avtoritet
        private void CheckForUpdateAndStartProcess()
        {
            string nameUpdateDirectory = string.Empty
            , nameAppVersionFile       = string.Empty;
            bool fileExists            = false;

            try
            {
                CatalogApi.Logging.Info(string.Format("::CheckForUpdateAndStartProcess() - вход..."));

                nameUpdateDirectory = ResourceManager.UpdateDirectory;
                nameAppVersionFile  = new CatalogApi.Settings.File(ConfigurationManager.AppSettings["FileAppVersion"]).Name;

                if (Directory.Exists(nameUpdateDirectory))
                {
                    IoHelper.DirectoryClear(nameUpdateDirectory);
                }

                AccountManager.Account = RequestHelper.Client.GetUnoccupiedAccount();

                launcherSettings = new SettingsFactory(categoryEventHandler).DownloadSettings(false, true);
                this.BuildWindow();

                if (System.IO.File.Exists(nameAppVersionFile))
                {
                    this.RefreshTitle(new Version(JsonConvert.DeserializeObject <VersionEntity>(IoHelper.OpenFile(nameAppVersionFile, out fileExists)).Version).ToString());
                }
                else
                {
                    ;
                }

                this.SetWindowVisibility(Visibility.Visible);

                CatalogApi.Logging.Info(string.Format("::CheckForUpdateAndStartProcess() - успех..."));
            }
            catch (Exception exception)
            {
                ErrorLogHelper.AddErrorInLog("CheckForUpdateAndStartProcess()", exception.Message + " | " + exception.StackTrace);
                MessageBox.Show(exception.Message + " | " + exception.StackTrace);

                Application.Current.Shutdown(-1);
            }
        }
コード例 #18
0
        public FirstTimeSetup(LauncherSettings setting)
        {
            InitializeComponent();

            Result = 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
        }
コード例 #19
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);
        }
コード例 #20
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("\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();
        }
コード例 #21
0
        public bool LoadLauncherSettings()
        {
            //if (!Directory.Exists(_settingsDirectoryName))
            //{
            //    Directory.CreateDirectory(_settingsDirectoryName);
            //}

            var formatter            = new BinaryFormatter();
            var launcherSettingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _launcherSettingsFileName);

            var launcherSettings = _loadSettingsByPath <LauncherSettings>(formatter, launcherSettingsPath);

            if (launcherSettings != null)
            {
                _launcherSettings = launcherSettings;
                return(true);
            }
            else
            {
                _launcherSettings = LauncherSettings.Default;
                return(false);
            }
        }
コード例 #22
0
 private void CheckForUpdateAndStartProcess()
 {
     try
     {
         if (Directory.Exists("Temp"))
         {
             IoHelper.DirectoryClear("Temp");
         }
         AccountManager.Account = RequestHelper.Client.GetUnoccupiedAccount();
         launcherSettings       = new SettingsFactory(categoryEventHandler).DownloadSettings(false, true);
         this.BuildWindow();
         if (System.IO.File.Exists("Version.json"))
         {
             this.RefreshTitle(new Version(JsonConvert.DeserializeObject <VersionEntity>(FileHelper.OpenFile("Version.json")).Version).ToString());
         }
         this.SetWindowVisibility(Visibility.Visible);
     }
     catch (Exception exception)
     {
         ErrorLogHelper.AddErrorInLog("CheckForUpdateAndStartProcess()", exception.Message + " | " + exception.StackTrace);
         MessageBox.Show(exception.Message + " | " + exception.StackTrace);
     }
 }
コード例 #23
0
ファイル: SettingsFactory.cs プロジェクト: 15831944/Avtoritet
 private void ExtractResourcesToFolder(LauncherSettings settings)
 {
     try
     {
         string root = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ResourceManager.Root);
         try
         {
             ClearRootDirectory(root);
         }
         catch
         {
         }
         try
         {
             this.CreateRootDirectory(root, settings);
         }
         catch
         {
         }
     }
     catch
     {
     }
 }
コード例 #24
0
        public void RunAddons(Process gameProcess, LauncherSettings 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));
                }
            }
        }
コード例 #25
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            if (ViewModel.StrideVersions.Any(x => x.IsProcessing))
            {
                var forceClose = Launcher.DisplayMessage("Some background operations are still in progress. Force close?");

                if (!forceClose)
                {
                    e.Cancel = true;
                    return;
                }
            }

            var viewModel = (LauncherViewModel)DataContext;

            LauncherSettings.ActiveVersion = viewModel.ActiveVersion != null ? viewModel.ActiveVersion.Name : "";
            LauncherSettings.Save();
            if (ExitOnUserClose)
            {
                Environment.Exit(1);
            }
        }
コード例 #26
0
        private void InitializeWindow()
        {
            // Upgrade the stored settings if needed
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Log.Information("Settings upgrade required...");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            var gateStatus = false;

            try
            {
                gateStatus = _game.GetGateStatus();
            }
            catch
            {
                // ignored
            }

            if (!gateStatus)
            {
                WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(242, 24, 24));
            }

            var version = Util.GetAssemblyVersion();

            if (Properties.Settings.Default.LastVersion != version)
            {
                new ChangelogWindow().ShowDialog();

                Properties.Settings.Default.LastVersion = version;

                Properties.Settings.Default.Save();
            }

            _accountManager = new AccountManager(_setting);

            var savedAccount = _accountManager.CurrentAccount;

            if (savedAccount != null)
            {
                SwitchAccount(savedAccount, false);
            }

            AutoLoginCheckBox.IsChecked = _setting.AutologinEnabled;

            if (_setting.AutologinEnabled && savedAccount != null && !Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                Log.Information("Engaging Autologin...");

                try
                {
#if DEBUG
                    HandleLogin(true);
                    _setting.Save();
                    return;
#else
                    if (!gateStatus)
                    {
                        var startLauncher = MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched. Do you want to start the official launcher to check for patches?", "XIVLauncherLite", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;

                        if (startLauncher)
                        {
                            _setting.StartOfficialLauncher(SteamCheckBox.IsChecked == true);
                        }

                        _setting.AutologinEnabled = false;
                        _isLoggingIn = false;
                    }
                    else
                    {
                        HandleLogin(true);
                        _setting.Save();
                        return;
                    }
#endif
                }
                catch (Exception exc)
                {
                    new ErrorWindow(exc, "Additionally, please check your login information or try again.", "AutoLogin")
                    .ShowDialog();
                    _setting.AutologinEnabled = false;
                    _isLoggingIn = false;
                }

                _setting.Save();
            }
            else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                _setting.AutologinEnabled   = false;
                AutoLoginCheckBox.IsChecked = false;
            }

            if (_setting.GamePath?.Exists != true)
            {
                var setup = new FirstTimeSetup(_setting);
                setup.ShowDialog();
                _setting = setup.Result;
            }

            Task.Run(() => SetupHeadlines());

            Show();
            Activate();

            Log.Information("MainWindow initialized.");
        }
コード例 #27
0
 void IAddon.Setup(Process gameProcess, LauncherSettings setting)
 {
     // Ignored
 }
コード例 #28
0
            public async Task <LauncherManifest> GetLaunchManifestAsync(OperationContext context, LauncherSettings settings)
            {
                if (!settings.DeploymentParameters.ForceUpdate)
                {
                    // First query for change id to detect if deployment manifest has changed. If
                    // deployment manifest has not changed then, launcher manifest which is derived from it
                    // also has not changed, so just return prior launcher manifest in that case. This avoids
                    // a lot of unnecessary computation on the server.
                    string newChangeId = await _client.GetStringAsync($"{settings.ServiceUrl}/deploymentChangeId");

                    var lastManifest = _lastManifest;
                    if (lastManifest?.DeploymentManifestChangeId == newChangeId)
                    {
                        return(lastManifest);
                    }
                }

                // Query for launcher manifest from remote service
                var content = await PostJsonAsync(context, $"{settings.ServiceUrl}/deployment", settings.DeploymentParameters);

                var manifest = JsonSerializer.Deserialize <LauncherManifest>(content, DeploymentUtilities.ConfigurationSerializationOptions);

                if (manifest.IsComplete)
                {
                    _lastManifest = manifest;
                }

                return(manifest);
            }
コード例 #29
0
        private static void LoadUpdates()
        {
            string nameFileSettingVersion = string.Empty
            , nameFileAppVersion          = string.Empty;
            Exception exception;

            try
            {
                nameFileSettingVersion = new File(ConfigurationManager.AppSettings["FileSettingVersion"]).Name;
                nameFileAppVersion     = new File(ConfigurationManager.AppSettings["FileAppVersion"]).Name;

                if ((string.IsNullOrWhiteSpace(nameFileSettingVersion) == false) &&
                    (string.IsNullOrWhiteSpace(nameFileAppVersion) == false))
                {
                    using (AvtoritetEntities entities = new AvtoritetEntities())
                    {
                        //if (!(entities.Database.Connection.State == ConnectionState.Closed))
                        //{
                        Version version = new Version(entities.VersionLog.FirstOrDefault().Value)
                        , version2      = new Version(JsonConvert.DeserializeObject <VersionEntity>(FileHelper.OpenFile(nameFileAppVersion)).Version)
                        , version3      = new Version(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion);

                        if (version > version2)
                        {
                            try {
                            } catch (Exception exception1) {
                                exception = exception1;
                                ErrorLogHelper.AddErrorInLog("LoadUpdates()", string.Format("{0} | {1}", exception.Message, exception.StackTrace));
                            }
                        }
                        else
                        {
                            ;
                        }

                        if (!System.IO.File.Exists(nameFileSettingVersion))
                        {
                            System.IO.File.WriteAllText(nameFileSettingVersion, "1");
                        }
                        else
                        {
                            ;
                        }

                        int?settingVersion = entities.SettingUpdate.FirstOrDefault().SettingVersion;
                        int?nullable2      = settingVersion;

                        int num  = int.Parse(System.IO.File.ReadAllText(nameFileSettingVersion));
                        int num2 = num;

                        if ((nullable2.GetValueOrDefault() > num2) &&
                            (nullable2.HasValue == true))
                        {
                            launcherSettings = new SettingsFactory(categoryEventHandler).DownloadSettings(true, true);
                            System.IO.File.WriteAllText(nameFileSettingVersion, settingVersion.ToString());
                            HaveNewUpdate = true;
                        }
                        else
                        {
                            ;
                        }
                        //}
                        //else
                        //ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates() - ...", string.Format("Состояние БД={0}", entities.Database.Connection.State.ToString()));
                    }
                }
                else
                {
                    ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates() - ...", string.Format("Неизвестна версия приложения или версия конфигурация БД"));
                }
                ;
            }
            catch (Exception exception2)
            {
                exception = exception2;
                ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates()", string.Format("{0} | {1}", exception.Message, exception.StackTrace));
                MessageBox.Show(string.Format("{0}{1}{2}", Environment.NewLine, exception.Message, exception.StackTrace));
            }
        }
コード例 #30
0
        public LauncherSettings DownloadSettings(bool force, bool FullLoad = true)
        {
            string           nameFileDbSerialize = new CatalogApi.Settings.File(ConfigurationManager.AppSettings["FileDbSerialize"]).Name;
            LauncherSettings graph = new LauncherSettings();

            // режим "force" принажатии кнопки брэнда
            if ((force == true) &&
                (System.IO.File.Exists(nameFileDbSerialize) == true))
            {
                System.IO.File.Delete(nameFileDbSerialize);
            }
            else
            {
                ;
            }

            if (System.IO.File.Exists(nameFileDbSerialize) == true)
            {
                // для режима forse=false - прочитать и вернуть копию БД
                Stream          stream    = System.IO.File.OpenRead(nameFileDbSerialize);
                BinaryFormatter formatter = new BinaryFormatter();
                graph = (LauncherSettings)formatter.Deserialize(stream);
                stream.Close();

                return(graph);
            }
            else
            {
                ;
            }

            #region чтение БД, заполнение объектов значениями
            using (AvtoritetEntities entities = new AvtoritetEntities())
            {
                List <NewLauncher.DataContext.Brand> list = (from r in entities.Brand
                                                             where r.Enable
                                                             orderby r.NameAndFolder
                                                             select r).ToList <NewLauncher.DataContext.Brand>();
                List <Provider> list2 = (from r in entities.Provider
                                         where r.Enable & FullLoad
                                         orderby r.Order
                                         select r).ToList <Provider>();
                List <ProviderAccount> list3 = (from t in entities.ProviderAccount
                                                where t.Enable & FullLoad
                                                select t).ToList <ProviderAccount>();
                List <NewLauncher.DataContext.CommandFile> list4 = (from t in entities.CommandFile
                                                                    where FullLoad
                                                                    select t).ToList <NewLauncher.DataContext.CommandFile>();
                List <NewLauncher.DataContext.ProviderFile> list5 = (from t in entities.ProviderFile
                                                                     where FullLoad
                                                                     select t).ToList <NewLauncher.DataContext.ProviderFile>();
                List <Group> list6 = (from t in entities.Group
                                      where t.Enable
                                      orderby t.Order
                                      select t).ToList <Group>();
                List <NewLauncher.DataContext.GroupBox> list7 = (from r in entities.GroupBox
                                                                 where r.Enable
                                                                 orderby r.Title
                                                                 select r).ToList <NewLauncher.DataContext.GroupBox>();
                foreach (Group group in list6)
                {
                    GroupSet item = new GroupSet {
                        Name      = group.Name,
                        Width     = group.Width.Value,
                        Height    = group.Height.Value,
                        GroupBoxs = new List <CatalogApi.Settings.GroupBox>()
                    };
                    foreach (NewLauncher.DataContext.GroupBox box in list7)
                    {
                        if (box.GroupId == group.GroupId)
                        {
                            CatalogApi.Settings.GroupBox box2 = new CatalogApi.Settings.GroupBox {
                                Left          = box.Left.Value,
                                Top           = box.Top.Value,
                                Width         = box.Width.Value,
                                Height        = box.Height.Value,
                                Title         = box.Title,
                                VisibleBorder = box.VisibleBorder.Value,
                                Brands        = new List <CatalogApi.Settings.Brand>()
                            };
                            foreach (NewLauncher.DataContext.Brand brand in list)
                            {
                                if (brand.GroupBoxId == box.GroupBoxId)
                                {
                                    CatalogApi.Settings.Brand brand2 = new CatalogApi.Settings.Brand {
                                        NameAndFolder = brand.NameAndFolder,
                                        IconPath      = brand.IconPath,
                                        IconPath2     = brand.IconPath2,
                                        IconPathImg   = brand.IconPathImg,
                                        IconPath2Img  = brand.IconPath2Img
                                    };
                                    int?top = brand.Top;
                                    brand2.Top         = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Left;
                                    brand2.Left        = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Width;
                                    brand2.Width       = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Height;
                                    brand2.Height      = top.HasValue ? top.GetValueOrDefault() : 0;
                                    brand2.BrandId     = brand.BrandId;
                                    brand2.ButtonStyle = brand.ButtonStyle;
                                    brand2.MenuWindow  = brand.MenuWindow.Value;
                                    brand2.Providers   = new List <BrandProvider>();
                                    foreach (Provider provider in list2)
                                    {
                                        int providerId;
                                        if (provider.BrandId != brand.BrandId)
                                        {
                                            continue;
                                        }
                                        BrandProvider provider2 = new BrandProvider {
                                            Uri        = provider.Uri.Trim(),
                                            IconPath   = provider.IconPath,
                                            Title      = provider.Title,
                                            Commands   = provider.commandcontent,
                                            ProviderId = provider.ProviderId,
                                            Login      = "",
                                            Password   = ""
                                        };
                                        foreach (ProviderAccount account in list3)
                                        {
                                            if (account.ProviderId == provider.ProviderId)
                                            {
                                                provider2.Login    = (account != null) ? account.Login.Trim() : string.Empty;
                                                provider2.Password = (account != null) ? account.Password.Trim() : string.Empty;
                                                break;
                                            }
                                        }
                                        provider2.CommandFiles = new List <CatalogApi.Settings.CommandFile>();
                                        foreach (NewLauncher.DataContext.CommandFile file in list4)
                                        {
                                            top        = file.ProviderId;
                                            providerId = provider.ProviderId;
                                            if ((top.GetValueOrDefault() == providerId) && top.HasValue)
                                            {
                                                CatalogApi.Settings.CommandFile file2 = new CatalogApi.Settings.CommandFile {
                                                    FileName    = file.FileName,
                                                    FileContent = file.FileContent
                                                };
                                                provider2.CommandFiles.Add(file2);
                                            }
                                        }
                                        provider2.ProviderFiles = new List <CatalogApi.Settings.ProviderFile>();
                                        foreach (NewLauncher.DataContext.ProviderFile file3 in list5)
                                        {
                                            top        = file3.ProviderId;
                                            providerId = provider.ProviderId;
                                            if ((top.GetValueOrDefault() == providerId) && top.HasValue)
                                            {
                                                CatalogApi.Settings.ProviderFile file4 = new CatalogApi.Settings.ProviderFile {
                                                    FileName    = file3.FileName,
                                                    FileExt     = file3.FileExt,
                                                    FileSize    = file3.FileSize.Value,
                                                    FileContent = file3.FileContent
                                                };
                                                provider2.ProviderFiles.Add(file4);
                                            }
                                        }
                                        brand2.Providers.Add(provider2);
                                    }
                                    box2.Brands.Add(brand2);
                                }
                            }
                            item.GroupBoxs.Add(box2);
                        }
                    }
                    graph.Groups.Add(item);
                }
            }
            #endregion

            if (System.IO.File.Exists(nameFileDbSerialize) == true)
            {
                //??? никогда не выполняется
                // , если forse=true файл будет удален
                // , если forse=false произодет возврат значения и выход из функции
                System.IO.File.Delete(nameFileDbSerialize);
            }
            else
            {
                ;
            }

            Stream serializationStream = System.IO.File.Create(nameFileDbSerialize);
            new BinaryFormatter().Serialize(serializationStream, graph);
            serializationStream.Close();

            if (force == true)
            {
                this.ExtractResourcesToFolder(graph);
            }
            else
            {
                ;
            }

            return(graph);
        }