コード例 #1
0
ファイル: MainForm.cs プロジェクト: PaddyWilson/HaloMods
        private void btnResetEveryThing_Click(object sender, EventArgs e)
        {
            btnResetEveryThing.Enabled = false;
            Logger.LogLine("Restoring install to vanilla.");
            //restore startup video
            string og = Settings.StartupMovieLocation;
            string rn = Settings.StartupMovieLocation + ".bk";

            //justs renames the video file
            if (File.Exists(rn))
            {
                Logger.Log("Enabling start up video");
                File.Move(rn, og);
                btnStartupVideo.Text = "Disable Startup Video";
            }

            //restore MMC.pak
            if (File.Exists(ForgeFileSwap.NewFilePath))
            {
                Logger.LogLine("Restoring \"MCC-WindowsNoEditor.pak\".");
                if (ForgeFileSwap.RestoreOriginalFiles())
                {
                    if (File.Exists(ForgeFileSwap.ModdedFilePath))
                    {
                        File.Delete(ForgeFileSwap.ModdedFilePath);
                    }
                }
                else
                {
                    Logger.LogLine("Can't restore \"MCC-WindowsNoEditor.pak\" back to original state. The game is running or the backup file is missing.");
                }
            }

            //restore maps
            Logger.LogLine("Restoring " + HaloReach.VanillaBackupMaps.Count + " Map Files.");
            HaloReach.ReloadMaps();
            foreach (var item in HaloReach.VanillaBackupMaps)
            {
                if (File.Exists(item.Value))
                {
                    if (File.Exists(HaloReach.VanillaMapLocation + "\\" + item.Key))
                    {
                        File.Delete(HaloReach.VanillaMapLocation + "\\" + item.Key);
                    }
                    File.Move(item.Value, HaloReach.VanillaMapLocation + "\\" + item.Key);
                    HaloReach.SwapData.Remove(item.Key);
                }
            }

            HaloReach.RestoreAllOrigianlFiles();
            HaloReach.ReloadMaps();
            HaloReach.SaveSwapData();

            Logger.LogLine("Restoring Temp Files.");
            foreach (var item in TempSwap)
            {
                item.Value.RestoreOriginalFiles();
            }

            Setup();

            Logger.LogLine("Restoring is finished.");
            btnResetEveryThing.Enabled = true;
        }