Esempio n. 1
0
        private static void parseDelArgs(ModFile mf)
        {
            if (mf.DelInfo == null)
            {
                mf = ModParsing.GetSpecificMod(mf.ModId);
                if (string.IsNullOrEmpty(mf.DelInfo))
                {
                    Console.WriteLine(
                        "There's no info on how to delete this mod! Please ask the creators to add that in!");
                    return;
                }
            }

            var args = mf.DelInfo.Split('?');

            foreach (var target in args)
            {
                // If something is broken, skip this target since continuing would delete the h3 directory.
                if (string.IsNullOrEmpty(target))
                {
                    continue;
                }

                var path = Path.Combine(Utilities.GameDirectoryOrThrow, target);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                else if (Directory.Exists(path))
                {
                    Directory.Delete(path, true);
                }
            }
        }
Esempio n. 2
0
        public static void DisableMod(string modid)
        {
            ModFile mf = ModParsing.GetSpecificMod(modid); //get modfile

            string[] delinfos = mf.DelInfo.Split('?');
            for (int i = 0; i < delinfos.Length; i++)
            {
                Installer.MoveToFolder(Path.Combine(delinfos[i]), Path.Combine(Utilities.DisableCache, mf.ModId)); //move to cache
            }
        }
Esempio n. 3
0
        public static void EnableMod(string modid)
        {
            ModFile mf = ModParsing.GetSpecificMod(modid); //get modfile

            string[] delinfos = mf.DelInfo.Split('?');
            for (int i = 0; i < delinfos.Length; i++)
            {
                string delinfopath = Path.Combine(Utilities.GameDirectoryOrThrow + delinfos[i]);
                //get last part of file name (e.g VirtualObjects/asdf to asdf)
                string delinfotrimmed = new DirectoryInfo(delinfos[i]).Name;
                //get path to disabledmods cache file
                string path = Path.Combine(Utilities.DisableCache, mf.ModId, delinfotrimmed);
                Installer.MoveToFolder(path, Directory.GetParent(delinfopath).ToString() + "/"); //move back to loc
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     Takes modid, enables if disabled and disables if enabled
        /// </summary>
        /// <param name="modid">modid to disable/enable</param>
        public static void EnableDisableMod(string modid)
        {
            ModFile mf   = ModParsing.GetSpecificMod(modid);
            string  path = Path.Combine(Utilities.GameDirectory, mf.DelInfo.Split('?')[0]);

            Console.WriteLine("Detecting if {0} exists...", path);
            if (File.Exists(path) || Directory.Exists(path))
            {
                DisableMod(modid);
            }
            else
            {
                EnableMod(modid);
            }
        }