Ejemplo n.º 1
0
        internal static void LoadAll(string folderpath, bool is_plugins = false)
        {
            string[] filearr = Directory.GetFiles(folderpath).ToArray();
            if (filearr.Length <= 0)
            {
                return;
            }

            MelonLaunchOptions.Core.LoadModeEnum loadMode = is_plugins
                  ? MelonLaunchOptions.Core.LoadMode_Plugins
                  : MelonLaunchOptions.Core.LoadMode_Mods;

            for (int i = 0; i < filearr.Length; i++)
            {
                string filepath = filearr[i];
                if (string.IsNullOrEmpty(filepath))
                {
                    continue;
                }

                if (IsExtensionBlacklisted(filepath))
                {
                    MelonLogger.Error($"Invalid File Extension for {filepath}");
                    continue;
                }

                string lowerFilePath = filepath.ToLowerInvariant();

                if ((loadMode == MelonLaunchOptions.Core.LoadModeEnum.NORMAL) &&
                    !lowerFilePath.EndsWith(".dll"))
                {
                    continue;
                }

                if ((loadMode == MelonLaunchOptions.Core.LoadModeEnum.DEV) &&
                    !lowerFilePath.EndsWith(".dev.dll"))
                {
                    continue;
                }

                // To-Do: File Type Check

                string melonname = MelonUtils.GetFileProductName(filepath);
                if (string.IsNullOrEmpty(melonname))
                {
                    melonname = Path.GetFileNameWithoutExtension(filepath);
                }

                if (is_plugins
                    ? MelonHandler.IsPluginAlreadyLoaded(melonname)
                    : MelonHandler.IsModAlreadyLoaded(melonname))
                {
                    MelonLogger.Error($"Duplicate File: {filepath}");
                    continue;
                }

                LoadFromFile(filepath);
            }
        }
Ejemplo n.º 2
0
        internal static void LoadAll(string folderpath, bool is_plugins = false)
        {
            MelonLaunchOptions.Core.LoadModeEnum loadMode = is_plugins
                ? MelonLaunchOptions.Core.LoadMode_Plugins
                : MelonLaunchOptions.Core.LoadMode_Mods;
            string[] filearr = Directory.GetFiles(folderpath).Where(x =>
                                                                    Path.GetExtension(x).ToLowerInvariant().Equals(".dll") &&
                                                                    ((loadMode == MelonLaunchOptions.Core.LoadModeEnum.DEV) ? x.ToLowerInvariant().EndsWith(".dev.dll")
                : ((loadMode == MelonLaunchOptions.Core.LoadModeEnum.NORMAL) ? !x.ToLowerInvariant().EndsWith(".dev.dll")
                : true))
                                                                    ).ToArray();
            if (filearr.Length <= 0)
            {
                return;
            }

            for (int i = 0; i < filearr.Length; i++)
            {
                string filepath = filearr[i];
                if (string.IsNullOrEmpty(filepath))
                {
                    continue;
                }

                string melonname = MelonUtils.GetFileProductName(filepath);
                if (string.IsNullOrEmpty(melonname))
                {
                    melonname = Path.GetFileNameWithoutExtension(filepath);
                }

                if (is_plugins
                    ? MelonHandler.IsPluginAlreadyLoaded(melonname)
                    : MelonHandler.IsModAlreadyLoaded(melonname))
                {
                    MelonLogger.Error($"Duplicate File: {filepath}");
                    continue;
                }

                LoadFromFile(filepath);
            }
        }