Ejemplo n.º 1
0
        public void LoadItems(
            string itemsfileVanilla,
            string itemsfileExpansion1,
            string itemsfileMod,
            ProgressTracker tracker
        ) {
            int numFiles = GrimFolderUtility.CountExisting(itemsfileVanilla, itemsfileExpansion1, itemsfileMod);
            tracker.MaxValue = numFiles;

            ItemAccumulator accumulator = new ItemAccumulator();
            if (File.Exists(itemsfileVanilla)) {
                Parser.Arz.ArzParser.LoadItemRecords(itemsfileVanilla, true).ForEach(accumulator.Add);
                tracker.Increment();
            }
            if (File.Exists(itemsfileExpansion1)) {
                Parser.Arz.ArzParser.LoadItemRecords(itemsfileExpansion1, true).ForEach(accumulator.Add);
                tracker.Increment();
            }
            if (File.Exists(itemsfileMod)) {
                Parser.Arz.ArzParser.LoadItemRecords(itemsfileMod, true).ForEach(accumulator.Add);
                tracker.Increment();
            }

            Items = accumulator.Items;
        }
Ejemplo n.º 2
0
        public static long GetHighestTimestamp(string install)
        {
            try {
                List <string> arzFiles = new List <string> {
                    GrimFolderUtility.FindArzFile(install)
                };

                foreach (string path in GrimFolderUtility.GetGrimExpansionFolders(install))
                {
                    string expansionItems = GrimFolderUtility.FindArzFile(path);

                    if (!string.IsNullOrEmpty(expansionItems))
                    {
                        arzFiles.Add(GrimFolderUtility.FindArzFile(expansionItems));
                    }
                }

                return(arzFiles
                       .Select(File.GetLastWriteTimeUtc)
                       .Select(ts => ts.ToTimestamp())
                       .Max());
            }
            catch (Exception e) {
                Logger.Warn("Error fetching timestamp, defaulting to unchanged", e);
                return(0);
            }
        }
Ejemplo n.º 3
0
        public void Execute()
        {
            var form   = new ParsingDatabaseProgressView();
            var parser = new ArzParsingWrapper();


            string vanillaTags    = GrimFolderUtility.FindArcFile(_grimdawnLocation, "text_en.arc");
            string expansion1Tags = GrimFolderUtility.FindArcFile(Path.Combine(_grimdawnLocation, "gdx1"), "text_en.arc");
            string modTags        = string.IsNullOrEmpty(_modLocation) ? "" : GrimFolderUtility.FindArcFile(_modLocation, "text_en.arc");

            List <Action> actions = new List <Action>();

            actions.Add(() => parser.LoadTags(vanillaTags, expansion1Tags, modTags, _localizationFile, new WinformsProgressBar(form.LoadingTags).Tracker));
            actions.Add(() => _itemTagDao.Save(parser.Tags, new WinformsProgressBar(form.SavingTags).Tracker));

            string vanillaItems    = GrimFolderUtility.FindArzFile(_grimdawnLocation);
            string expansion1Items = GrimFolderUtility.FindArzFile(Path.Combine(_grimdawnLocation, "gdx1"));
            string modItems        = string.IsNullOrEmpty(_modLocation) ? "" : GrimFolderUtility.FindArzFile(_modLocation);

            actions.Add(() => parser.LoadItems(vanillaItems, expansion1Items, modItems, new WinformsProgressBar(form.LoadingItems).Tracker));

            // TODO:
            actions.Add(() => parser.MapItemNames(new WinformsProgressBar(form.MappingItemNames).Tracker));
            actions.Add(() => parser.RenamePetStats(new WinformsProgressBar(form.MappingPetStats).Tracker));

            actions.Add(() => _databaseItemDao.Save(parser.Items, new WinformsProgressBar(form.SavingItems).Tracker));

            // TODO: This depends on the DB item name.. which is in english, not localized
            actions.Add(() => {
                var records = parser.GenerateSpecialRecords(new WinformsProgressBar(form.GeneratingSpecialStats).Tracker);
                _databaseItemStatDao.Save(records, new WinformsProgressBar(form.SavingSpecialStats).Tracker);
            });


            actions.Add(() => parser.ParseComplexItems(_itemSkillDao, new WinformsProgressBar(form.GeneratingSkills).Tracker));
            actions.Add(() => {
                var tracker      = new WinformsProgressBar(form.SkillCorrectnessCheck).Tracker;
                tracker.MaxValue = 1;
                _itemSkillDao.EnsureCorrectSkillRecords();
                tracker.MaxProgress();
            });

            // Invoke the background thread & show progress UI
            Thread t = new Thread(() => {
                foreach (var action in actions)
                {
                    action.Invoke();
                }

                Action close = () => form.OverrideClose();
                form.Invoke(close);
            });

            t.Start();
            form.ShowDialog();
        }
Ejemplo n.º 4
0
        public static long GetHighestTimestamp(string install)
        {
            List <string> arzFiles = new List <string> {
                GrimFolderUtility.FindArzFile(install)
            };

            foreach (string path in GrimFolderUtility.GetGrimExpansionFolders(install))
            {
                string expansionItems = GrimFolderUtility.FindArzFile(path);

                if (!string.IsNullOrEmpty(expansionItems))
                {
                    arzFiles.Add(GrimFolderUtility.FindArzFile(expansionItems));
                }
            }

            return(arzFiles
                   .Select(File.GetLastWriteTimeUtc)
                   .Select(ts => ts.ToTimestamp())
                   .Max());
        }
Ejemplo n.º 5
0
        public void Execute()
        {
            var form   = new ParsingDatabaseProgressView();
            var parser = new ArzParsingWrapper();


            List <string> tagfiles    = new List <string>();
            string        vanillaTags = GrimFolderUtility.FindArcFile(_grimdawnLocation, "text_en.arc");

            if (!string.IsNullOrEmpty(vanillaTags))
            {
                tagfiles.Add(vanillaTags);
            }

            foreach (string path in GrimFolderUtility.GetGrimExpansionFolders(_grimdawnLocation))
            {
                string expansionTags = GrimFolderUtility.FindArcFile(path, "text_en.arc");
                if (!string.IsNullOrEmpty(expansionTags))
                {
                    tagfiles.Add(expansionTags);
                }
            }

            string modTags = string.IsNullOrEmpty(_modLocation) ? "" : GrimFolderUtility.FindArcFile(_modLocation, "text_en.arc");

            if (!string.IsNullOrEmpty(modTags))
            {
                tagfiles.Add(modTags);
            }

            List <Action> actions = new List <Action>();


            actions.Add(() => parser.LoadTags(tagfiles, _localizationFile, new WinformsProgressBar(form.LoadingTags).Tracker));
            actions.Add(() => _itemTagDao.Save(parser.Tags, new WinformsProgressBar(form.SavingTags).Tracker));

            List <string> arzFiles = new List <string> {
                GrimFolderUtility.FindArzFile(_grimdawnLocation)
            };

            foreach (string path in GrimFolderUtility.GetGrimExpansionFolders(_grimdawnLocation))
            {
                string expansionItems = GrimFolderUtility.FindArzFile(path);

                if (!string.IsNullOrEmpty(expansionItems))
                {
                    arzFiles.Add(GrimFolderUtility.FindArzFile(expansionItems));
                }
            }

            if (!string.IsNullOrEmpty(_modLocation))
            {
                arzFiles.Add(GrimFolderUtility.FindArzFile(_modLocation));
            }

            actions.Add(() => parser.LoadItems(arzFiles, new WinformsProgressBar(form.LoadingItems).Tracker));
            actions.Add(() => parser.MapItemNames(new WinformsProgressBar(form.MappingItemNames).Tracker));
            actions.Add(() => parser.RenamePetStats(new WinformsProgressBar(form.MappingPetStats).Tracker));
            actions.Add(() => _databaseItemDao.Save(parser.Items, new WinformsProgressBar(form.SavingItems).Tracker));

            // TODO: This depends on the DB item name.. which is in english, not localized
            actions.Add(() => {
                var records = parser.GenerateSpecialRecords(new WinformsProgressBar(form.GeneratingSpecialStats).Tracker);
                _databaseItemStatDao.Save(records, new WinformsProgressBar(form.SavingSpecialStats).Tracker);
            });


            actions.Add(() => parser.ParseComplexItems(_itemSkillDao, new WinformsProgressBar(form.GeneratingSkills).Tracker));
            actions.Add(() => {
                var tracker      = new WinformsProgressBar(form.SkillCorrectnessCheck).Tracker;
                tracker.MaxValue = 1;
                _itemSkillDao.EnsureCorrectSkillRecords();
                tracker.MaxProgress();
            });

            // Invoke the background thread & show progress UI
            Thread t = new Thread(() => {
                ExceptionReporter.EnableLogUnhandledOnThread();
                foreach (var action in actions)
                {
                    action.Invoke();
                }

                Action close = () => form.OverrideClose();
                form.Invoke(close);
            });

            t.Start();
            form.ShowDialog();

            OnParseComplete?.Invoke(this, null);
        }