コード例 #1
0
        public MainWindow(
            CefBrowserHandler browser,
            IDatabaseItemDao databaseItemDao,
            IDatabaseItemStatDao databaseItemStatDao,
            IPlayerItemDao playerItemDao,
            IDatabaseSettingDao databaseSettingDao,
            IBuddyItemDao buddyItemDao,
            IBuddySubscriptionDao buddySubscriptionDao,
            ArzParser arzParser,
            IRecipeItemDao recipeItemDao,
            IItemSkillDao itemSkillDao
            )
        {
            _cefBrowserHandler = browser;
            InitializeComponent();
            FormClosing += MainWindow_FormClosing;
            Instance     = this;

            _reportUsageStatistics = new Stopwatch();
            _reportUsageStatistics.Start();

            _dynamicPacker        = new DynamicPacker(databaseItemStatDao);
            _databaseItemDao      = databaseItemDao;
            _databaseItemStatDao  = databaseItemStatDao;
            _playerItemDao        = playerItemDao;
            _databaseSettingDao   = databaseSettingDao;
            _buddyItemDao         = buddyItemDao;
            _buddySubscriptionDao = buddySubscriptionDao;
            _arzParser            = arzParser;
            _recipeParser         = new RecipeParser(recipeItemDao);
            _itemSkillDao         = itemSkillDao;
        }
コード例 #2
0
ファイル: SettingsWindow.cs プロジェクト: desophos/iagd
        public SettingsWindow(
            CefBrowserHandler cefBrowserHandler,
            IItemTagDao itemTagDao,
            TooltipHelper tooltipHelper,
            Action itemViewUpdateTrigger,
            IDatabaseSettingDao settingsDao,
            IPlayerItemDao playerItemDao,
            ArzParser parser,
            GDTransferFile[] modFilter,
            StashManager stashManager, ParsingService parsingService)
        {
            InitializeComponent();
            this._cefBrowserHandler     = cefBrowserHandler;
            this._tooltipHelper         = tooltipHelper;
            this._itemViewUpdateTrigger = itemViewUpdateTrigger;
            this._settingsDao           = settingsDao;
            this._playerItemDao         = playerItemDao;
            this._parser       = parser;
            this._modFilter    = modFilter;
            this._stashManager = stashManager;
            _parsingService    = parsingService;
            _itemTagDao        = itemTagDao;

            _controller.BindCheckbox(cbMinimizeToTray);

            _controller.BindCheckbox(cbMergeDuplicates);
            _controller.BindCheckbox(cbTransferAnyMod);
            _controller.BindCheckbox(cbSecureTransfers);
            _controller.BindCheckbox(cbShowRecipesAsItems);
            _controller.BindCheckbox(cbAutoUpdateModSettings);
            _controller.BindCheckbox(cbAutoSearch);
            _controller.BindCheckbox(cbDisplaySkills);
            _controller.LoadDefaults();
        }
コード例 #3
0
        public ParsingDatabaseScreen(
            IDatabaseSettingDao databaseSettingDao,
            ArzParser parser,
            string grimdawnInstallPath,
            string localizationFile,
            bool tagsOnly,
            bool expansionOnlyMod
            )
        {
            InitializeComponent();
            CanClose = false;
            this._grimdawnInstallPath = grimdawnInstallPath;
            this._databaseSettingDao  = databaseSettingDao;

            var arg = new IAGrim.Parsers.Arz.ParsingUiBackgroundWorker.ParsingUiBackgroundWorkerArgument {
                Path             = grimdawnInstallPath,
                ExpansionOnlyMod = expansionOnlyMod,
                LocalizationFile = localizationFile,
                TagsOnly         = tagsOnly
            };

            _worker = new ParsingUiBackgroundWorker(bw_RunWorkerCompleted, arg, parser);


            var tag = GlobalSettings.Language.GetTag("iatag_ui_popup_parsing_header");

            if (!string.IsNullOrEmpty(tag))
            {
                this.firefoxH11.Text = tag;
            }
        }
コード例 #4
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");
            }
        }
コード例 #5
0
        private void buttonForceUpdate_Click(object sender, EventArgs e)
        {
            _databaseItemDao.Clean();

            var mod   = GetFirst(listViewMods);
            var entry = GetFirst(listViewInstalls);

            if (mod != null)
            {
                // Load selected mod icons
                ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadSelectedModIcons(mod.Path));
            }

            ForceDatabaseUpdate(entry.Path, mod?.Path);
            _settingsService.GetLocal().CurrentGrimdawnLocation = entry.Path;

            // Store the loaded GD path, so we can poll it for updates later.
            //_settingsService.GetLocal().GrimDawnLocation = new List<string> { entry.Path }; // TODO: Wtf is this? Why overwrite any existing?
            _settingsService.GetLocal().GrimDawnLocationLastModified = ParsingService.GetHighestTimestamp(entry.Path);
            _settingsService.GetLocal().HasWarnedGrimDawnUpdate      = false;

            var isGdParsed = _databaseItemDao.GetRowCount() > 0;

            _settingsService.GetLocal().IsGrimDawnParsed = isGdParsed;
            _helpService.SetIsGrimParsed(isGdParsed);
        }
コード例 #6
0
 public ModsDatabaseConfig(Action itemViewUpdateTrigger, IDatabaseSettingDao databaseSettingDao, ArzParser arzParser, IPlayerItemDao playerItemDao)
 {
     InitializeComponent();
     this._itemViewUpdateTrigger = itemViewUpdateTrigger;
     this._databaseSettingDao    = databaseSettingDao;
     this._arzParser             = arzParser;
     this._playerItemDao         = playerItemDao;
 }
コード例 #7
0
ファイル: ModsDatabaseConfig.cs プロジェクト: johngibbs/iagd
 public ModsDatabaseConfig(Action itemViewUpdateTrigger, IDatabaseSettingDao databaseSettingDao, ArzParser arzParser, IPlayerItemDao playerItemDao, ParsingService parsingService)
 {
     InitializeComponent();
     this._itemViewUpdateTrigger  = itemViewUpdateTrigger;
     this._databaseSettingDao     = databaseSettingDao;
     this._arzParser              = arzParser;
     this._playerItemDao          = playerItemDao;
     _parsingService              = parsingService;
     _databaseModSelectionService = new DatabaseModSelectionService();
 }
コード例 #8
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);
            }
        }
コード例 #9
0
ファイル: ArzParsingWrapper.cs プロジェクト: johngibbs/iagd
        public List<DatabaseItemStat> GenerateSpecialRecords(ProgressTracker tracker) {
            var skills = Items
                .Where(m => m.Record.Contains("/skills/"))
                .ToList();
            List<DatabaseItemStat> result = new List<DatabaseItemStat>();

            var filtered = Items.Where(m => m.Id != 0).ToList();
            tracker.MaxValue = filtered.Count;
            foreach (var item in filtered) {
                ArzParser.GetSpecialMasteryStats(result, item, Items);
                ArzParser.GetSpecialSkillAugments(result, item, Items, skills, _tagAccumulator.MappedTags);
                tracker.Increment();
            }

            return result;
        }
コード例 #10
0
ファイル: MainWindow.cs プロジェクト: hallgeirl/iagd
        public MainWindow(
            CefBrowserHandler browser,
            IDatabaseItemDao databaseItemDao,
            IDatabaseItemStatDao databaseItemStatDao,
            IPlayerItemDao playerItemDao,
            IAzurePartitionDao azurePartitionDao,
            IDatabaseSettingDao databaseSettingDao,
            IBuddyItemDao buddyItemDao,
            IBuddySubscriptionDao buddySubscriptionDao,
            ArzParser arzParser,
            IRecipeItemDao recipeItemDao,
            IItemSkillDao itemSkillDao,
            IItemTagDao itemTagDao,
            ParsingService parsingService,
            bool requestedDevtools,
            AugmentationItemRepo augmentationItemRepo
            )
        {
            _cefBrowserHandler = browser;
            InitializeComponent();
            FormClosing += MainWindow_FormClosing;

            _reportUsageStatistics = new Stopwatch();
            _reportUsageStatistics.Start();

            _dynamicPacker          = new DynamicPacker(databaseItemStatDao);
            _databaseItemDao        = databaseItemDao;
            _databaseItemStatDao    = databaseItemStatDao;
            _playerItemDao          = playerItemDao;
            _azurePartitionDao      = azurePartitionDao;
            _databaseSettingDao     = databaseSettingDao;
            _buddyItemDao           = buddyItemDao;
            _buddySubscriptionDao   = buddySubscriptionDao;
            _arzParser              = arzParser;
            _recipeParser           = new RecipeParser(recipeItemDao);
            _itemSkillDao           = itemSkillDao;
            _itemTagDao             = itemTagDao;
            _parsingService         = parsingService;
            this._requestedDevtools = requestedDevtools;
            _augmentationItemRepo   = augmentationItemRepo;
        }
コード例 #11
0
ファイル: LanguagePackPicker.cs プロジェクト: johngibbs/iagd
        /// <summary>
        ///
        /// </summary>
        /// <param name="path">Path to Grim Dawn install</param>
        public LanguagePackPicker(
            IItemTagDao itemTagDao,
            IDatabaseSettingDao databaseSettingDao,
            IPlayerItemDao playerItemDao,
            ArzParser parser,
            string path, ParsingService parsingService)
        {
            InitializeComponent();
            this._path               = path;
            _parsingService          = parsingService;
            this._itemTagDao         = itemTagDao;
            this._databaseSettingDao = databaseSettingDao;
            this._playerItemDao      = playerItemDao;
            this._parser             = parser;

            var buttonTag = GlobalSettings.Language.GetTag("iatag_ui_lang_button_change_language");

            if (!string.IsNullOrEmpty(buttonTag))
            {
                buttonSelect.Text += $" ({buttonTag})";
            }
        }
コード例 #12
0
ファイル: SettingsWindow.cs プロジェクト: johngibbs/iagd
        public SettingsWindow(
            IItemTagDao itemTagDao,
            TooltipHelper tooltipHelper,
            Action itemViewUpdateTrigger,
            IDatabaseSettingDao settingsDao,
            IDatabaseItemDao itemDao,
            IPlayerItemDao playerItemDao,
            ArzParser parser,
            GDTransferFile[] modFilter,
            StashManager stashManager, ParsingService parsingService)
        {
            InitializeComponent();
            this._tooltipHelper         = tooltipHelper;
            this._itemViewUpdateTrigger = itemViewUpdateTrigger;
            this._settingsDao           = settingsDao;
            this._itemDao       = itemDao;
            this._playerItemDao = playerItemDao;
            this._parser        = parser;
            this._modFilter     = modFilter;
            this._stashManager  = stashManager;
            _parsingService     = parsingService;
            _itemTagDao         = itemTagDao;

            _controller.BindCheckbox(cbMinimizeToTray);

            _controller.BindCheckbox(cbMergeDuplicates);
            _controller.BindCheckbox(cbTransferAnyMod);
            _controller.BindCheckbox(cbSecureTransfers);
            _controller.BindCheckbox(cbShowRecipesAsItems);
            _controller.BindCheckbox(cbAutoUpdateModSettings);
            //_controller.BindCheckbox(cbInstalootDisabled);
            _controller.BindCheckbox(cbInstaTransfer);
            _controller.BindCheckbox(cbAutoSearch);
            _controller.BindCheckbox(cbDisplaySkills);
            _controller.LoadDefaults();

            cbInstalootEnabled.Checked = (InstalootSettingType)Properties.Settings.Default.InstalootSetting == InstalootSettingType.Enabled;
        }
コード例 #13
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.");
        }
コード例 #14
0
        private void ApplyMythicalBonuses(List <PlayerHeldItem> items)
        {
            if (_xpacSkills == null)
            {
                Logger.Warn("Not applying mythical bonuses, still loading stats.");
                return;
            }

            var skillTiers        = _databaseItemStatDao.GetSkillTiers();
            var itemsWithXpacStat = items.Where(m => m.Tags != null && m.Tags.Any(s => s.Stat == "modifiedSkillName1"));

            foreach (var item in itemsWithXpacStat)
            {
                for (int i = 0; i < 5; i++)
                {
                    var affectedSkill  = item.Tags.FirstOrDefault(m => m.Stat == $"modifiedSkillName{i}");
                    var recordForStats = item.Tags.FirstOrDefault(m => m.Stat == $"modifierSkillName{i}")?.TextValue;

                    if (recordForStats == null || !_xpacSkills.ContainsKey(recordForStats))
                    {
                        continue;
                    }

                    var name = affectedSkill?.TextValue;
                    if (!string.IsNullOrEmpty(name))
                    {
                        name = _databaseItemStatDao.GetSkillName(name);
                    }

                    // For pet skills we got _xpacSkills layer to hop trough
                    var petSkillRecord = _xpacSkills[recordForStats].Where(s => s.Stat == "petSkillName")
                                         .Select(s => s.TextValue).FirstOrDefault();

                    float?tier = null;
                    if (skillTiers.ContainsKey(affectedSkill?.TextValue))
                    {
                        tier = skillTiers[affectedSkill?.TextValue];
                    }

                    // TODO: Mark monster infrequents

                    /*
                     * if (recordForStats.IndexOf("/mi/") != -1) {
                     *
                     * }*/

                    if (petSkillRecord != null)
                    {
                        if (_xpacSkills.ContainsKey(petSkillRecord))
                        {
                            item.ModifiedSkills.Add(new SkillModifierStat {
                                Class = ArzParser.ExtractClassFromRecord(petSkillRecord),
                                Tags  = _xpacSkills[petSkillRecord],
                                Name  = name,
                                Tier  = tier,
                                IsMonsterInfrequent = recordForStats?.IndexOf("/mi/") != -1
                            });
                        }
                    }

                    // TODO: What's this? May be the cause of all the "no stats found" shit.. does it ever DO anything?
                    item.ModifiedSkills.Add(new SkillModifierStat {
                        Tags = _xpacSkills[recordForStats],
                        Name = name
                    });
                }
            }
        }
コード例 #15
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.");
        }
コード例 #16
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.");
        }