Exemplo n.º 1
0
        public void ModListIndexCanBeHigherThanMaxInt()
        {
            var modList = new ModList <int>();

            modList.Add(1);

            Assert.AreEqual(1, modList[500_000_000_000_000]);
Exemplo n.º 2
0
        public void ModListIsCircular()
        {
            var modList = new ModList <int>();

            for (int n = 0; n < 10; n++)
            {
                modList.Add(n);
            }

            Assert.AreEqual(1, modList[1]);
            Assert.AreEqual(1, modList[11]);
            Assert.AreEqual(1, modList[-9]);
        }
        public void FileDict()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            IEnumerable <string> modFiles   = new List <string>();
            IEnumerable <string> modConfigs = new List <string>();

            try
            {
                modFiles =
                    Directory.EnumerateFiles(@"mods", "", SearchOption.TopDirectoryOnly);
            } catch (DirectoryNotFoundException)
            {
                Console.WriteLine("Mods folder doesn't exist.");
            }

            try
            {
                modConfigs =
                    Directory.EnumerateFiles(@"config", "", SearchOption.AllDirectories);
            } catch (DirectoryNotFoundException)
            {
                Console.WriteLine("Config folder doesn't exist.");
            }

            foreach (var file in modFiles)
            {
#if DEBUG
                Console.WriteLine($"Generating hash: {file}");
#endif
                ModList.Add(new FileHash()
                {
                    Id = GuidUtility.Create(NamespaceId, file), Path = file, Hash = CalculateMd5(file)
                });
            }

            foreach (var config in modConfigs)
            {
#if DEBUG
                Console.WriteLine($"Generating hash: {config}");
#endif
                ConfigList.Add(new FileHash()
                {
                    Id = GuidUtility.Create(NamespaceId, config), Path = config, Hash = CalculateMd5(config)
                });
            }

            stopwatch.Stop();
            Console.WriteLine("Generating " + (ModList.Count + ConfigList.Count) + " hashes took: " + stopwatch.ElapsedMilliseconds + "ms");
        }
Exemplo n.º 4
0
        public static void DisableSubmission(string mod)
        {
            if (disabled == false)
            {
                Plugin.ApplyHarmonyPatches();
                disabled = true;
                ModList.Clear();
                if (!eventSubscribed)
                {
                    Plugin.LevelDidFinishEvent += LevelData_didFinishEvent;
                    eventSubscribed             = true;
                }
            }

            if (!ModList.Contains(mod))
            {
                ModList.Add(mod);
            }
        }
Exemplo n.º 5
0
        public static void DisableSubmission(string mod)
        {
            if (disabled == false)
            {
                //Utilities.Logger.log.Warn($"First DisableSubmission by {mod}");
                Plugin.ApplyHarmonyPatches();

                disabled = true;
                ModList.Clear();

                if (!eventSubscribed)
                {
                    Plugin.LevelDidFinishEvent += LevelData_didFinishEvent;
                    eventSubscribed             = true;
                }
            }

            if (!ModList.Contains(mod))
            {
                ModList.Add(mod);
            }
        }
Exemplo n.º 6
0
        static void CollectMods()
        {
            var directories = Directory.GetDirectories(Paths.ModDirectory);

            foreach (var directory in directories)
            {
                var manifestPath = Path.Combine(directory, "manifest.yaml");
                if (File.Exists(manifestPath))
                {
                    var manifest = deserializer.Deserialize <ModManifest>(File.ReadAllText(manifestPath));
                    manifest.Path = directory;
                    if (!string.IsNullOrWhiteSpace(manifest.ModId) && !string.IsNullOrWhiteSpace(manifest.Main) && !string.IsNullOrWhiteSpace(manifest.MainClass))
                    {
                        definitions.Add(new ModDefinition()
                        {
                            manifest = manifest, path = directory
                        });
                        ModList.Add(manifest.ModId, manifest);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public ShellViewModel(IRegionManager InRegionManager, IEventAggregator InEventAggregator)
        {
            inRegionManager   = InRegionManager;
            inEventAggregator = InEventAggregator;

            MouseDownCommand       = new RelayCommand(MouseDown_Callback);
            ClosingCommand         = new RelayCommand <CancelEventArgs>(Closing_Callback);
            ContentRenderedCommand = new RelayCommand(ContentRendered_Callback);
            SelectFolderCommand    = new RelayCommand(SelectFolder_Callback);
            SearchCommand          = new RelayCommand(Search_Callback);
            AutoSetFolderCommand   = new RelayCommand(AutoSetFolder_Callback);
            AboutMenuClickCommand  = new RelayCommand(AboutMenuClicked);

            //默认语言选择
            IsChinese = LanguageModel.Instance.CurLanguage.CurLanguage == NET.Common.Enum.LanguageEnum.Chinese;
            IsEnglish = LanguageModel.Instance.CurLanguage.CurLanguage == NET.Common.Enum.LanguageEnum.English;

            ModList.Add(MOD_ID.MOD_ID_ALL, "ALL");
            ModList.Add(MOD_ID.MOD_ID_LOADLOCK_A, "LL A");
            ModList.Add(MOD_ID.MOD_ID_LOADLOCK_B, "LL B");
            ModList.Add(MOD_ID.MOD_ID_PROCESS_MODULE_A1, "A1");
            ModList.Add(MOD_ID.MOD_ID_PROCESS_MODULE_A2, "A2");
            ModList.Add(MOD_ID.MOD_ID_PROCESS_MODULE_B1, "B1");
            ModList.Add(MOD_ID.MOD_ID_PROCESS_MODULE_B2, "B2");
            ModList.Add(MOD_ID.MOD_ID_PROCESS_MODULE_C1, "C1");
            ModList.Add(MOD_ID.MOD_ID_PROCESS_MODULE_C2, "C2");

            RecipeTypeList.Add(RecipeType.Process, "Process");
            RecipeTypeList.Add(RecipeType.Clean, "Clean");

            LWIR.NET.Framework.Utility.ThreadPool.Instance.LastMsgCountEvent += LastMsgCount_Callback;
            inEventAggregator.GetEvent <FilesCountEvent>().Subscribe(ReceiveFilesCount);

            if (Properties.Settings.Default.ShowTips)
            {
                AboutMenuClicked();
            }
        }
        public static void DisableSubmission(string mod)
        {
            if (disabled == false)
            {
                Plugin.ApplyHarmonyPatches();
                disabled = true;
                ModList.Clear();

                if (Plugin.LevelData == null)
                {
                    Plugin.LevelData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>()?.FirstOrDefault();
                    if (Plugin.LevelData != null)
                    {
                        Plugin.LevelData.didFinishEvent += LevelData_didFinishEvent;
                    }
                }
            }

            if (!ModList.Contains(mod))
            {
                ModList.Add(mod);
            }
        }
Exemplo n.º 9
0
        private static void LoadModsFromFolder(string folderPath)
        {
            foreach (var modFile in (new DirectoryInfo(folderPath)).GetFiles("*.dll"))
            {
                if (Utils.ModsBlacklist.BlacklistedMods.Contains(modFile.Name))
                {
                    Logger.InfoLog($"-{modFile.Name} is in blacklist, skipping it");
                    continue;
                }

                Mod modToAdd = LoadMod(modFile);
                modToAdd.CurrentlyEnabled = folderPath != PathList.ModsFolderPath;
                modToAdd.IsEnabled        = modToAdd.CurrentlyEnabled;

                bool isDuplicate = false;
                foreach (var mod in ModList)
                {
                    //if added mod is already applied
                    if (mod.Meta.ModName == modToAdd.Meta.ModName)
                    {
                        Logger.InfoLog($"-{modToAdd.Meta.ModName} is already applied, overriding it with newer version");
                        isDuplicate          = true;
                        mod.IsEnabled        = true;
                        mod.CurrentlyEnabled = true;
                        EnableMod(modToAdd);
                        break;
                    }
                }

                if (isDuplicate)
                {
                    continue;
                }
                ModList.Add(modToAdd);
            }
        }