Beispiel #1
0
        private static GridModItem ToGridItem(ModEntry mod)
        {
            try {
                var modPath = mod.Path;
                var order   = ModScanner.EnabledMods.Contains(mod) ? -1f : float.PositiveInfinity;
                if (string.IsNullOrWhiteSpace(modPath))
                {
                    return new GridModItem(mod)
                           {
                               _Order = order
                           }
                }
                ;
                var doc = new Dictionary <ModDoc, string>();
                var dir = Path.GetDirectoryName(modPath);
                AppControl.Instance.Log("Scanning docs in " + dir);
                foreach (var file in Directory.EnumerateFiles(dir))
                {
                    var name = Path.GetFileName(file).ToLowerInvariant();

                    if (!doc.ContainsKey(ModDoc.README) && ReadmeFiles.Contains(name))
                    {
                        doc.Add(ModDoc.README, file);
                    }
                    else if (!doc.ContainsKey(ModDoc.README) && ChangeFiles.Contains(name))
                    {
                        doc.Add(ModDoc.CHANGELOG, file);
                    }
                    else if (!doc.ContainsKey(ModDoc.README) && LicenseFiles.Contains(name))
                    {
                        doc.Add(ModDoc.LICENSE, file);
                    }
                }
                if (modPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                {
                    AppControl.Instance.Log("Scanning embedded docs in " + modPath);
                    if (!doc.ContainsKey(ModDoc.README) && (ModScanner.FindEmbeddedFile(modPath, null, ReadmeFiles)))
                    {
                        doc.Add(ModDoc.README, "embedded");
                    }
                    if (!doc.ContainsKey(ModDoc.CHANGELOG) && (ModScanner.FindEmbeddedFile(modPath, null, ChangeFiles)))
                    {
                        doc.Add(ModDoc.CHANGELOG, "embedded");
                    }
                    if (!doc.ContainsKey(ModDoc.LICENSE) && (ModScanner.FindEmbeddedFile(modPath, null, LicenseFiles)))
                    {
                        doc.Add(ModDoc.LICENSE, "embedded");
                    }
                }
                return(new GridModItem(mod)
                {
                    _Order = order, Docs = doc.Count == 0 ? null : doc
                });
            } catch (Exception ex) {
                AppControl.Instance.Log(ex);
                return(new GridModItem(mod));
            }
        }
Beispiel #2
0
        internal ModInfo[] LoadModList()
        {
            CheckSetup();
            App.Log("Building mod list");
            ModScanner.BuildModList();
            var result = Task.WhenAll(ModScanner.AllMods.Select(ConvertModTask).ToArray()).Result;

            return(SetModOrders(result));
        }
Beispiel #3
0
 public ActivityItemCache(ModScanner scanner, string cacheFile)
 {
     this.scanner   = scanner;
     this.cacheFile = cacheFile;
     if (File.Exists(cacheFile))
     {
         LoadCacheFile();
     }
     else
     {
         CreateAndLoadCacheFile();
     }
 }
 public ActivityItemCache(ModScanner scanner, string cacheFile)
 {
     this.scanner = scanner;
     this.cacheFile = cacheFile;
     if (File.Exists(cacheFile))
     {
         LoadCacheFile();
     }
     else
     {
         CreateAndLoadCacheFile();
     }
 }
Beispiel #5
0
        [TestMethod()] public void NameMatchTest()
        {
            Assert.IsTrue(ModScanner.NameMatch("abc", "ABC"), "ignore case");
            Assert.IsTrue(ModScanner.NameMatch("ExampleMod", "Example Mod"), "ignore space");
            Assert.IsTrue(ModScanner.NameMatch("Mod", "Mod - Copy"), "One copy");
            Assert.IsTrue(ModScanner.NameMatch("Mod", "Mod - Copy - Copy"), "Two copy");
            Assert.IsTrue(ModScanner.NameMatch("Mod", "Mod(123)"), "Browser copy A");
            Assert.IsTrue(ModScanner.NameMatch("Mod", "Mod (123)"), "Browser copy B");
            Assert.IsTrue(ModScanner.NameMatch("AIM-2-3", "AIM-0-1-1234568"), "nexus id");
            Assert.IsTrue(ModScanner.NameMatch("ExampleMod", "ExampleMod-1-2-345 - Copy(123)"), "Multiple copy");
            Assert.IsTrue(ModScanner.NameMatch("Mod.tar", "Mod"), "Manual extraction");

            Assert.IsFalse(ModScanner.NameMatch("a", "A"), "Too short");
            Assert.IsFalse(ModScanner.NameMatch("abc", "def"), "diff name");
            Assert.IsFalse(ModScanner.NameMatch("DebugConsole", "EnableConsole"), "console mods");
        }
 public ModActivityItemsLoader(ModScanner scanner)
 {
     this.scanner = scanner;
 }
 public ModActivityItemsLoader(ModScanner scanner)
 {
     this.scanner = scanner;
 }