コード例 #1
0
        public void PerformIconCheck(IDatabaseSettingDao databaseSettingDao, GrimDawnDetector grimDawnDetector)
        {
            // Load the GD database (or mod, if any)
            string gdPath = databaseSettingDao.GetCurrentDatabasePath();

            if (string.IsNullOrEmpty(gdPath) || !Directory.Exists(gdPath))
            {
                gdPath = grimDawnDetector.GetGrimLocation();
            }

            if (!string.IsNullOrEmpty(gdPath) && Directory.Exists(gdPath))
            {
                var numFiles         = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                int numFilesExpected = 2100;
                if (Directory.Exists(Path.Combine(gdPath, "gdx2")))
                {
                    numFilesExpected += 580;
                }
                if (Directory.Exists(Path.Combine(gdPath, "gdx1")))
                {
                    numFilesExpected += 890;
                }

                if (numFiles < numFilesExpected)
                {
                    Logger.Debug($"Only found {numFiles} in storage, expected ~{numFilesExpected}+, parsing item icons.");
                    ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(gdPath));
                }
            }
            else
            {
                Logger.Warn("Could not find the Grim Dawn install location");
            }
        }
コード例 #2
0
ファイル: StartupService.cs プロジェクト: marius00/iagd
        public void PerformIconCheck(GrimDawnDetector grimDawnDetector, SettingsService settings)
        {
            try {
                // Load the GD database (or mod, if any)
                string gdPath = settings.GetLocal().CurrentGrimdawnLocation;

                if (string.IsNullOrEmpty(gdPath) || !Directory.Exists(gdPath))
                {
                    gdPath = grimDawnDetector.GetGrimLocations().FirstOrDefault();
                }

                if (!string.IsNullOrEmpty(gdPath) && Directory.Exists(gdPath))
                {
                    int  numFiles           = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                    int  numFilesExpected   = 2100;
                    bool missingLokarrIcons = false;

                    if (Directory.Exists(Path.Combine(gdPath, "gdx2")))
                    {
                        numFilesExpected += 850;
                    }

                    if (Directory.Exists(Path.Combine(gdPath, "gdx1")))
                    {
                        numFilesExpected += 890;

                        // Lokarr boots. Need a re-parse if missing.
                        if (!File.Exists(Path.Combine(GlobalPaths.StorageFolder, "sign_f01a_dif.tex.png")))
                        {
                            missingLokarrIcons = true;
                        }
                    }

                    if (numFiles >= numFilesExpected && !missingLokarrIcons)
                    {
                        return;
                    }

                    Logger.Debug($"Only found {numFiles} in storage, expected ~{numFilesExpected}+, parsing item icons.");
                    ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(gdPath));
                }
                else
                {
                    Logger.Warn("Could not find the Grim Dawn install location");
                }
            }
            catch (Exception ex) {
                // Keep things moving, if icons are messed up its unfortunate, items should still be accessible.
                Logger.Warn("Error parsing icons", ex);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: MartinRohrbach/iagd
        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.");
        }
コード例 #4
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.
            IPlayerItemDao playerItemDao     = new PlayerItemRepo(threadExecuter, factory);
            var            statUpgradeNeeded = UpgradeSettings();

            // X
            IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory);

            GlobalSettings.InitializeLanguage(Properties.Settings.Default.LocalizationFile, databaseItemDao.GetTagDictionary());
            DumpTranslationTemplate();

            // Prohibited for now
            Properties.Settings.Default.InstaTransfer = false;
            Properties.Settings.Default.Save();
            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);


#if !DEBUG
            if (statUpgradeNeeded)
            {
                // If we don't also update item stats, a lot of whining will ensue.
                // This accounts for most database updates (new fields added that needs to get populated etc)
                UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao);
                x.ShowDialog();
            }
#endif


            IBuddyItemDao         buddyItemDao         = new BuddyItemRepo(threadExecuter, factory);
            IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory);
            IRecipeItemDao        recipeItemDao        = new RecipeItemRepo(threadExecuter, factory);
            IItemSkillDao         itemSkillDao         = new ItemSkillRepo(threadExecuter, factory);
            ArzParser             arzParser            = new ArzParser(databaseSettingDao);
            AugmentationItemRepo  augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory));

            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, Properties.Settings.Default.LocalizationFile);

            PrintStartupInfo(factory);



            if (GlobalSettings.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.");
                Settings.Default.AzureAuthToken = null;
                Settings.Default.Save();
            }

            // TODO: Urgent, introduce DI and have MainWindow receive premade objects, not create them itself.
            using (CefBrowserHandler browser = new CefBrowserHandler())
            {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     azurePartitionDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     arzParser,
                                     recipeItemDao,
                                     itemSkillDao,
                                     itemTagDao,
                                     parsingService,
                                     augmentationItemRepo
                                     );

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


                // Load the GD database (or mod, if any)
                string GDPath = databaseSettingDao.GetCurrentDatabasePath();
                if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath))
                {
                    GDPath = GrimDawnDetector.GetGrimLocation();
                }

                if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath))
                {
                    var numFiles         = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                    int numFilesExpected = 2100;
                    if (Directory.Exists(Path.Combine(GDPath, "gdx2")))
                    {
                        numFilesExpected += 580;
                    }
                    if (Directory.Exists(Path.Combine(GDPath, "gdx1")))
                    {
                        numFilesExpected += 890;
                    }

                    if (numFiles < numFilesExpected)
                    {
                        Logger.Debug($"Only found {numFiles} in storage, expected ~{numFilesExpected}+, parsing item icons.");
                        ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath));
                    }
                }
                else
                {
                    Logger.Warn("Could not find the Grim Dawn install location");
                }

                playerItemDao.UpdateHardcoreSettings();

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

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


                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: kakikakeks/iagd
        private static void Run(ThreadExecuter threadExecuter)
        {
            var factory = new SessionFactory();

            // Prohibited for now
            Properties.Settings.Default.InstaTransfer = false;
            Properties.Settings.Default.Save();

            new MigrationHandler(factory).Migrate();
            IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory);

            LoadUuid(databaseSettingDao);
            IPlayerItemDao       playerItemDao       = new PlayerItemRepo(threadExecuter, factory);
            IDatabaseItemDao     databaseItemDao     = new DatabaseItemRepo(threadExecuter, factory);
            IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(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);
            ArzParser             arzParser            = new ArzParser(databaseItemDao, databaseItemStatDao, databaseSettingDao, itemSkillDao);

            PrintStartupInfo(factory);



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Logger.Info("Visual styles enabled..");
            UpgradeSettings(playerItemDao);

            var language = GlobalSettings.Language as StatTranslator.EnglishLanguage;

            if (language != null)
            {
                foreach (var tag in databaseItemDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }


            using (CefBrowserHandler browser = new CefBrowserHandler()) {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     arzParser,
                                     recipeItemDao,
                                     itemSkillDao
                                     );

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


                // Load the GD database (or mod, if any)
                string GDPath = databaseSettingDao.GetCurrentDatabasePath();
                bool   isVanilla;
                if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath))
                {
                    GDPath    = GrimDawnDetector.GetGrimLocation();
                    isVanilla = true;
                }
                else
                {
                    isVanilla = GDPath.Equals(GrimDawnDetector.GetGrimLocation());
                }

                if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath))
                {
                    if (arzParser.NeedUpdate(GDPath))
                    {
                        ParsingDatabaseScreen parserUI = new ParsingDatabaseScreen(
                            databaseSettingDao,
                            arzParser,
                            GDPath,
                            Properties.Settings.Default.LocalizationFile,
                            false,
                            !isVanilla);
                        parserUI.ShowDialog();
                    }

                    if (playerItemDao.RequiresStatUpdate())
                    {
                        UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao);
                        x.ShowDialog();
                    }



                    var numFiles = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                    if (numFiles < 2000)
                    {
                        Logger.Debug($"Only found {numFiles} in storage, expected ~3200+, parsing item icons.");
                        ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath));
                    }
                }
                else
                {
                    Logger.Warn("Could not find the Grim Dawn install location");
                }

                playerItemDao.UpdateHardcoreSettings();

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

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


                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: hallgeirl/iagd
        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.
            IPlayerItemDao playerItemDao = new PlayerItemRepo(threadExecuter, factory);

            UpgradeSettings(playerItemDao);

            // X
            IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory);

            GlobalSettings.InitializeLanguage(Properties.Settings.Default.LocalizationFile, databaseItemDao.GetTagDictionary());

            // Prohibited for now
            Properties.Settings.Default.InstaTransfer = false;
            Properties.Settings.Default.Save();
            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);
            ArzParser             arzParser            = new ArzParser(databaseSettingDao);
            AugmentationItemRepo  augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory));

            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, Properties.Settings.Default.LocalizationFile);

            PrintStartupInfo(factory);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Logger.Info("Visual styles enabled..");

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


            bool showDevtools = args != null && args.Any(m => m.Contains("-devtools"));

            // TODO: Urgent, introduce DI and have MainWindow receive premade objects, not create them itself.
            using (CefBrowserHandler browser = new CefBrowserHandler()) {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     azurePartitionDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     arzParser,
                                     recipeItemDao,
                                     itemSkillDao,
                                     itemTagDao,
                                     parsingService,
                                     showDevtools,
                                     augmentationItemRepo
                                     );

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


                // Load the GD database (or mod, if any)
                string GDPath = databaseSettingDao.GetCurrentDatabasePath();
                if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath))
                {
                    GDPath = GrimDawnDetector.GetGrimLocation();
                }

                if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath))
                {
                    var numFiles = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                    if (numFiles < 2000)
                    {
                        Logger.Debug($"Only found {numFiles} in storage, expected ~3200+, parsing item icons.");
                        ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath));
                    }
                }
                else
                {
                    Logger.Warn("Could not find the Grim Dawn install location");
                }

                playerItemDao.UpdateHardcoreSettings();

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

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


                Application.Run(_mw);
            }

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