コード例 #1
0
        private static void LoadFrom(ModDirSpec modDir)
        {
            var modsBaseDirFull = Path.GetFullPath(modDir.baseDir);

            if (!Directory.Exists(modsBaseDirFull))
            {
                MultiFolderLoader.Logger.LogWarning("No mod folder found!");
                return;
            }

            foreach (var dir in Directory.GetDirectories(modsBaseDirFull))
            {
                var dirName = Path.GetFileName(dir);
                if (modDir.blockedMods != null && modDir.blockedMods.Contains(dirName))
                {
                    MultiFolderLoader.Logger.LogWarning(
                        $"Skipping loading [{dirName}] because it's marked as disabled");
                    continue;
                }

                if (modDir.enabledMods != null && !modDir.enabledMods.Contains(dirName))
                {
                    MultiFolderLoader.Logger.LogWarning(
                        $"Skipping loading [{dirName}] because it's not enabled");
                    continue;
                }

                AddMod(dir);
            }

            // Also resolve assemblies like bepin does
            AppDomain.CurrentDomain.AssemblyResolve += ResolveModDirectories;
        }
コード例 #2
0
        private static void InitSection(GhettoIni.Section section)
        {
            var spec = new ModDirSpec();

            if (section.Entries.TryGetValue("baseDir", out var baseDir))
            {
                spec.baseDir = Path.GetFullPath(Environment.ExpandEnvironmentVariables(baseDir));
            }
            else
            {
                MultiFolderLoader.Logger.LogWarning(
                    $"No [{section.Name}].baseDir found in {CONFIG_NAME}, no mods to load!");
                return;
            }

            if (section.Entries.TryGetValue("disabledModsListPath", out var disabledModsListPath))
            {
                MultiFolderLoader.Logger.LogInfo(
                    $"[{section.Name}].disabledModsListPath found in {CONFIG_NAME}, enabling disabled mods list");
                spec.blockedMods = GetModList(Path.GetFullPath(Environment.ExpandEnvironmentVariables(disabledModsListPath)));
            }

            if (section.Entries.TryGetValue("enabledModsListPath", out var enabledModsListPath))
            {
                MultiFolderLoader.Logger.LogInfo(
                    $"[{section.Name}].enabledModsListPath found in {CONFIG_NAME}, enabling enabled mods list");
                spec.enabledMods = GetModList(Path.GetFullPath(Environment.ExpandEnvironmentVariables(enabledModsListPath)));
            }

            ModDirs.Add(spec);
        }