예제 #1
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.");
        }