public static bool StabilizeGame()   // used after update is detected to uninstall half clobbered mods
        {
            Dictionary <string, List <string> > restoreMap = GetFilesToRestore();

            foreach (KeyValuePair <string, List <string> > modpack in restoreMap)
            {
                foreach (KeyValuePair <string, string> entry in Config.Patched[modpack.Key].files)
                {
                    if (modpack.Value.Contains(entry.Key))
                    {
                        Backups.RestoreBak(Utility.ExpandPath(entry.Key));
                    }
                    else
                    {
                        Backups.DeleteBak(Utility.ExpandPath(entry.Key));
                    }
                }

                Config.RmPatched(modpack.Key);
            }
            Config.MCC_version = Config.GetCurrentBuild();
            Config.SaveCfg();
            Backups.SaveBackups();

            return(true);
        }
示例#2
0
        public static int UnpatchModpacks(List <CheckBox> toUnpatch)
        {
            bool packErr = false;

            Program.MasterForm.PBar_show(toUnpatch.Count);
            foreach (CheckBox chb in toUnpatch)
            {
                Program.MasterForm.PBar_update();
                string modpackname = chb.Text.Replace(Config.dirtyPadding, "");
                int    ret         = UnpatchModpack(modpackname);
                if (ret == 2)
                {
                    packErr     = true;
                    chb.Checked = true;
                }
                else if (ret == 3)
                {
                    setModpackStatePartial((Panel)chb.Parent);
                }
                else        // modpack was unpatched
                {
                    Config.RmPatched(modpackname);
                    ((PictureBox)chb.Parent.GetChildAtPoint(Config.MyModsEnabledPoint)).Image = Properties.Resources.redDot_15px;
                }
            }

            if (Config.DeleteOldBaks)   // update backup pane because backups will have been deleted
            {
                Backups.SaveBackups();
                Backups.UpdateBackupList();
            }

            Program.MasterForm.PBar_hide();
            if (packErr)   // fail / partial success - At least one modpack was not patched
            {
                return(2);
            }
            else        // success, no errors
            {
                return(0);
            }
        }