Ejemplo n.º 1
0
        private void buttonSelect_Click(object sender, EventArgs e)
        {
            var cb = _checkboxes.FirstOrDefault(m => m.Checked);

            if (cb != null)
            {
                var package = cb.Tag.ToString();

                if (package != _settings.GetLocal().LocalizationFile)
                {
                    Logger.Info($"Loading localization file at {package}");
                    _settings.GetLocal().LocalizationFile = package;

                    if (!string.IsNullOrEmpty(_settings.GetLocal().LocalizationFile))
                    {
                        var loader = new LocalizationLoader();
                        RuntimeSettings.Language = loader.LoadLanguage(package, new EnglishLanguage(new Dictionary <string, string>()));

                        // TODO: Grab tags from loader and save to sql
                        _itemTagDao.Save(loader.GetItemTags(), new ProgressTracker());

                        var x = new UpdatingPlayerItemsScreen(_playerItemDao);
                        x.ShowDialog();
                    }
                    // Load the GD one
                    else
                    {
                        // Override timestamp to force an update
                        RuntimeSettings.InitializeLanguage(string.Empty, new Dictionary <string, string>()); // TODO: Not ideal, will need a restart

                        foreach (var location in _paths)
                        {
                            if (!string.IsNullOrEmpty(location) && Directory.Exists(location))
                            {
                                _parsingService.Update(location, string.Empty);
                                _parsingService.Execute();
                                break;
                            }

                            Logger.Warn("Could not find the Grim Dawn install location");
                        }

                        // Update item stats as well
                        var x = new UpdatingPlayerItemsScreen(_playerItemDao);
                        x.ShowDialog();
                    }
                }
            }

            Close();
        }
Ejemplo n.º 2
0
        private static void Run(string[] args, ThreadExecuter threadExecuter)
        {
            var factory = new SessionFactory();

            // Settings should be upgraded early, it contains the language pack etc and some services depends on settings.
            var            settingsService = StartupService.LoadSettingsService();
            IPlayerItemDao playerItemDao   = new PlayerItemRepo(threadExecuter, factory);

            IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory);

            RuntimeSettings.InitializeLanguage(settingsService.GetLocal().LocalizationFile, databaseItemDao.GetTagDictionary());
            DumpTranslationTemplate();

            threadExecuter.Execute(() => new MigrationHandler(factory).Migrate());

            IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory);

            LoadUuid(databaseSettingDao);
            var azurePartitionDao = new AzurePartitionRepo(threadExecuter, factory);
            IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory);
            IItemTagDao          itemTagDao          = new ItemTagRepo(threadExecuter, factory);


            IBuddyItemDao         buddyItemDao         = new BuddyItemRepo(threadExecuter, factory);
            IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory);
            IRecipeItemDao        recipeItemDao        = new RecipeItemRepo(threadExecuter, factory);
            IItemSkillDao         itemSkillDao         = new ItemSkillRepo(threadExecuter, factory);
            AugmentationItemRepo  augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory));
            var grimDawnDetector = new GrimDawnDetector(settingsService);

            Logger.Debug("Updating augment state..");
            augmentationItemRepo.UpdateState();

            // TODO: GD Path has to be an input param, as does potentially mods.
            ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, settingsService.GetLocal().LocalizationFile);

            StartupService.PrintStartupInfo(factory, settingsService);



            if (RuntimeSettings.Language is EnglishLanguage language)
            {
                foreach (var tag in itemTagDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }

            if (args != null && args.Any(m => m.Contains("-logout")))
            {
                Logger.Info("Started with -logout specified, logging out of online backups.");
                settingsService.GetPersistent().AzureAuthToken = null;
            }

            using (CefBrowserHandler browser = new CefBrowserHandler())
            {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     azurePartitionDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     recipeItemDao,
                                     itemSkillDao,
                                     itemTagDao,
                                     parsingService,
                                     augmentationItemRepo,
                                     settingsService,
                                     grimDawnDetector
                                     );

                Logger.Info("Checking for database updates..");

                StartupService.PerformIconCheck(databaseSettingDao, grimDawnDetector);
                playerItemDao.DeleteDuplidates();

                _mw.Visible = false;
                if (new DonateNagScreen(settingsService).CanNag)
                {
                    Application.Run(new DonateNagScreen(settingsService));
                }

                Logger.Info("Running the main application..");

                StartupService.PerformGrimUpdateCheck(settingsService);
                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }
Ejemplo n.º 3
0
        private static void Run(string[] args, ThreadExecuter threadExecuter)
        {
            var dialect         = SqlDialect.Sqlite;
            var factory         = new SessionFactory(dialect);
            var serviceProvider = ServiceProvider.Initialize(threadExecuter, dialect);

            var settingsService      = serviceProvider.Get <SettingsService>();
            var databaseItemDao      = serviceProvider.Get <IDatabaseItemDao>();
            var augmentationItemRepo = serviceProvider.Get <IAugmentationItemDao>();

            RuntimeSettings.InitializeLanguage(settingsService.GetLocal().LocalizationFile, databaseItemDao.GetTagDictionary());
            DumpTranslationTemplate();

            Logger.Debug("Executing DB migrations..");
            threadExecuter.Execute(() => new MigrationHandler(factory).Migrate());

            Logger.Debug("Loading UUID");
            LoadUuid(settingsService);

            Logger.Debug("Updating augment state..");
            augmentationItemRepo.UpdateState();

            var            itemTagDao          = serviceProvider.Get <IItemTagDao>();
            var            databaseItemStatDao = serviceProvider.Get <IDatabaseItemStatDao>();
            var            itemSkillDao        = serviceProvider.Get <IItemSkillDao>();
            ParsingService parsingService      = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, settingsService.GetLocal().LocalizationFile);

            StartupService.PrintStartupInfo(factory, settingsService, dialect);


            // TODO: Offload to the new language loader
            if (RuntimeSettings.Language is EnglishLanguage language)
            {
                foreach (var tag in itemTagDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }

            using (CefBrowserHandler browser = new CefBrowserHandler(settingsService)) {
                _mw = new MainWindow(
                    serviceProvider,
                    browser,
                    parsingService
                    );

                Logger.Info("Checking for database updates..");

                var grimDawnDetector = serviceProvider.Get <GrimDawnDetector>();
                StartupService.PerformIconCheck(grimDawnDetector, settingsService);


                try {
                    var playerItemDao = serviceProvider.Get <IPlayerItemDao>();
                    playerItemDao.DeleteDuplicates();
                }
                catch (Exception ex) {
                    Logger.Warn("Something went terribly wrong trying to ensure no duplicate items are found, however we'll just ignore it instead of blocking you access to your items.. sigh..", ex);
                }

                _mw.Visible = false;
                if (new DonateNagScreen(settingsService).CanNag)
                {
                    Application.Run(new DonateNagScreen(settingsService));
                }

                Logger.Info("Running the main application..");

                StartupService.PerformGrimUpdateCheck(settingsService);
                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }