Пример #1
0
        public static void RestoreAllBaksBtn_Click(object sender, EventArgs e)
        {
            EnsureBackupFolderExists();
            List <string> bakList = new List <string>();

            foreach (KeyValuePair <string, string> b in _baks)
            {
                bakList.Add(b.Key);
            }

            Dictionary <string, List <string> > x = checkForPartialRestores(bakList);

            if (x["partials"].Any())
            {
                DialogResult ans = Utility.ShowMsg("Restoring the selected backups will partially unpatch at least one modpack. All files within a modpack " +
                                                   "are intended to be patched and unpatched together. This may cause issues with your game.\r\nContinue?", "Question");
                if (ans == DialogResult.No)
                {
                    return;
                }
            }
            int r = RestoreBaks(bakList);

            MyMods.setModpacksDisabled(x["disable"]);
            MyMods.setModpacksPartial(x["partials"]);

            if (r == 0)
            {
                Utility.ShowMsg("Files have been restored.", "Info");
            }
            else if (r == 1 || r == 2)
            {
                Utility.ShowMsg("At least one file restore failed. Your game may be in an unstable state.", "Warning");
            }
        }
Пример #2
0
        public static void RestoreSelectedBtn_Click(object sender, EventArgs e)
        {
            IEnumerable <Panel> bakList     = Program.MasterForm.bakListPanel.Controls.OfType <Panel>();
            List <string>       backupPaths = new List <string>();

            foreach (Panel p in bakList)
            {
                CheckBox chb = (CheckBox)p.GetChildAtPoint(Config.BackupsChbPoint);
                if (chb.Checked)
                {
                    if (Program.MasterForm.fullBakPath_chb.Checked)
                    {
                        backupPaths.Add(chb.Text.Replace(Config.dirtyPadding, ""));
                    }
                    else
                    {
                        backupPaths.Add(GetBakKey(chb.Text.Replace(Config.dirtyPadding, "")));
                    }
                    chb.Checked = false;
                }
            }

            if (!backupPaths.Any())
            {
                Utility.ShowMsg("No items selected from the list.", "Error");
                return;
            }
            Dictionary <string, List <string> > x = checkForPartialRestores(backupPaths);

            if (x["partials"].Any())
            {
                DialogResult ans = Utility.ShowMsg("Restoring the selected backups will partially unpatch at least one modpack. All files within a modpack " +
                                                   "are intended to be patched and unpatched together. This may cause issues with your game.\r\nContinue?", "Question");
                if (ans == DialogResult.No)
                {
                    return;
                }
            }
            int r = RestoreBaks(backupPaths);

            MyMods.setModpacksDisabled(x["disable"]);
            MyMods.setModpacksPartial(x["partials"]);

            if (r == 0)
            {
                Utility.ShowMsg("Selected files have been restored.", "Info");
            }
            else if (r == 1 || r == 2)
            {
                Utility.ShowMsg("At least one file restore failed. Your game may be in an unstable state.", "Warning");
            }
        }