Пример #1
0
        private void Restore(object sender, EventArgs e)
        {
            if (working)
            {
                return;
            }
            string gamePath = Path.GetDirectoryName(exe.Text);

            if (exe.Text.Trim() == "" || !Directory.Exists(gamePath) || game == FromGame.UNKNOWN)
            {
                return;
            }
            List <string> files = GameDataWriter.GetAllBaseFiles(game);
            List <string> desc  = new List <string>();

            foreach (string file in files)
            {
                string path = $@"{gamePath}\{file}";
                string bak  = path + ".bak";
                if (File.Exists(bak))
                {
                    desc.Add(path);
                }
            }
            string fullRestore = game == FromGame.DS1R
                ? "\n\nTo completely ensure restoration of vanilla files, also use Properties -> Local Files -> Verify Integrity Of Game Files in Steam."
                : "";  // Can't really recommend anything for PTDE
            DialogResult dialogResult = MessageBox.Show(string.Join("\n", desc) + fullRestore, "Restore these files?", MessageBoxButtons.YesNo);

            if (dialogResult != DialogResult.Yes)
            {
                return;
            }
            foreach (string file in files)
            {
                string path = $@"{gamePath}\{file}";
                string bak  = path + ".bak";
                if (File.Exists(bak))
                {
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                    File.Move(bak, path);
                }
            }
            UpdateExePath();
        }
Пример #2
0
        private void UpdateExePath()
        {
            bool   valid    = true;
            string gamePath = null;

            try
            {
                gamePath = Path.GetDirectoryName(exe.Text);
                if (exe.Text.Trim() == "" || !Directory.Exists(gamePath))
                {
                    valid = false;
                }
                string exeName = Path.GetFileName(exe.Text).ToLower();
                if (exeName == "darksoulsremastered.exe")
                {
                    game = FromGame.DS1R;
                }
                else if (exeName == "darksouls.exe")
                {
                    game = FromGame.DS1;
                }
                else
                {
                    valid = false;
                }
            }
            catch (ArgumentException)
            {
                valid = false;
            }
            if (!valid)
            {
                game = FromGame.UNKNOWN;
                restoreButton.Enabled = false;
                restoreL.Text         = "";
                language.DataSource   = defaultLang;
                language.Enabled      = false;
                return;
            }
            Properties.Settings.Default.Exe = exe.Text;
            Properties.Settings.Default.Save();
            List <string> languages = game == FromGame.DS1R ? ds1rLang : ptdeLang;

            language.DataSource = languages;
            language.Enabled    = true;
            if (languageToSet != null && languages.Contains(languageToSet))
            {
                language.SelectedIndex = languages.IndexOf(languageToSet);
                languageToSet          = null;
            }
            List <string> files = GameDataWriter.GetAllBaseFiles(game);

            if (files.Count == 0)
            {
                randb.Enabled = false;
                setStatus($@"Error: FogMod dist\{game} subdirectory is missing", true);
            }
            List <string> times = new List <string>();

            foreach (string file in files)
            {
                string path = $@"{gamePath}\{file}";
                string bak  = path + ".bak";
                if (File.Exists(bak))
                {
                    times.Add(File.GetLastWriteTime(bak).ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }
            if (times.Count == 0)
            {
                restoreL.Text         = "Backups will be created with randomization";
                restoreButton.Enabled = false;
            }
            else
            {
                restoreL.Text         = $"{(files.Count == times.Count ? "Backups" : "Partial backups")} from {times.Max()}";
                restoreButton.Enabled = true;
            }
        }