Exemplo n.º 1
0
        public bool AddSwapData(string key, string VanillaFilePath, string NewFilePath, string ModdedFilePath)
        {
            if (!File.Exists(VanillaFilePath) || !File.Exists(ModdedFilePath))
            {
                return(false);
            }

            string[] temp            = VanillaFilePath.Split('\\');
            string   VanillaFileName = temp[temp.Length - 1];

            temp = ModdedFilePath.Split('\\');
            string ModdedFileName = temp[temp.Length - 1];

            SwapData data = new SwapData();

            data.VanillaFileName = VanillaFileName;
            data.VanillaFilePath = VanillaFilePath;

            data.NewFileName = VanillaFileName;
            data.NewFilePath = NewFilePath;

            data.ModdedFileName = ModdedFileName;
            data.ModdedFilePath = ModdedFilePath;

            data.OtherFile = true;

            return(AddSwapData(key, data));
        }
Exemplo n.º 2
0
        public bool AddMapSwapData(string key, string VanillaFileName, string ModdedFileName)
        {
            SwapData data = new SwapData();

            data.VanillaFileName = VanillaFileName;
            data.VanillaFilePath = VanillaMapLocation + "\\" + VanillaFileName;

            data.NewFileName = VanillaFileName;
            data.NewFilePath = VanillaBackupMapLocation + "\\" + VanillaFileName;

            data.ModdedFileName = ModdedFileName;
            data.ModdedFilePath = ModdedMapLocation + "\\" + ModdedFileName;

            return(AddSwapData(key, data));
        }
Exemplo n.º 3
0
        public bool AddSwapData(string key, SwapData data)
        {
            if (SwapData.ContainsKey(key))
            {
                return(false);
            }

            //move og file
            if (!File.Exists(data.NewFilePath))
            {
                File.Move(data.VanillaFilePath, data.NewFilePath);
            }
            FileUtil.CreateHardLink(data.VanillaFilePath, data.NewFilePath);

            SwapData.Add(key, data);

            return(true);
        }
Exemplo n.º 4
0
        private void Setup()
        {
            //Logger.Logger.Logger.Logger.Log("things");

            bool installed = CheckInstallMCCLocation();

            if (!installed)
            {
                Logger.LogLine("MCC not installed at");
                Logger.LogLine(Settings.MCCLocation);
                Logger.LogLine("please change it in settings.");

                //disable all buttons
                DisableButtonControls(this);
                return;
            }
            else
            {
                Logger.LogLine("MCC is installed. " + Settings.MCCLocation);
            }
            EnableButtonControls(this);
            Logger.LogLine("Mods is installed. " + Settings.MCCLocation);

            //create mods folders
            Directory.CreateDirectory(Settings.HR_ModdedMapLocation);
            Directory.CreateDirectory(Settings.HR_VanillaMapLocation);

            //general tab setup
            //start up video
            if (File.Exists(Settings.StartupMovieLocation))
            {
                btnStartupVideo.Text = "Disable Startup Video";
            }
            else
            {
                btnStartupVideo.Text = "Enable Startup Video";
            }

            //enable forge swap
            ForgeFileSwap = new SwapData(Settings.PakLocation,
                                         Settings.ModsLocation + "\\Vanilla\\" + FileUtil.GetFileName(Settings.PakLocation),
                                         Settings.ModsLocation + "\\Mods\\" + FileUtil.GetFileName(Settings.PakLocation));

            if (File.Exists(ForgeFileSwap.ModdedFilePath) && File.Exists(ForgeFileSwap.NewFilePath))
            {
                btnForge.Enabled = false;                //forge has already been setup
            }
            //halo reach tab setup
            HaloReach = new GameData("HaloReach.json", Settings.HR_OriginalMapLocation, Settings.HR_VanillaMapLocation, Settings.HR_ModdedMapLocation);
            HaloReach.LoadSwapData();

            //populate the vanilla list
            lstHRVanillaMaps.Items.Clear();
            foreach (var item in HaloReach.VanillaMaps)
            {
                lstHRVanillaMaps.Items.Add(item.Key);
            }
            //select first item
            if (HaloReach.VanillaMaps.Count > 0)
            {
                lstHRVanillaMaps.SelectedIndex = 0;
            }

            //populate the mods list
            lstHRModdedMaps.Items.Clear();
            foreach (var item in HaloReach.ModdedMaps)
            {
                lstHRModdedMaps.Items.Add(item.Key);
            }
            //select first item
            if (HaloReach.ModdedMaps.Count > 0)
            {
                lstHRModdedMaps.SelectedIndex = 0;
            }

            UpdateSwapList();
        }
Exemplo n.º 5
0
        private void btnHROtherQuickSwap_Click(object sender, EventArgs e)
        {
            string ogFile  = txtHROriginalFile.Text;
            string modFile = txtHRModdedFile.Text;

            if (ogFile == "" || modFile == "")
            {
                Logger.LogLine("Please select both files.");
                return;
            }
            else if (ogFile == modFile)
            {
                Logger.LogLine("The files are the same.");
                return;
            }
            else if (!File.Exists(ogFile) || !File.Exists(modFile))
            {
                Logger.LogLine("Can't find one of the files.");
                return;
            }
            else if (ogFile[0] != modFile[0])
            {
                Logger.LogLine("Files have to be on the same drive.");
                return;
            }

            btnHRMod.Enabled = false;

            string[] temp       = ogFile.Split('\\');
            string   ogFilename = temp[temp.Length - 1];

            temp = modFile.Split('\\');
            string modFilename = temp[temp.Length - 1];

            SwapData swap = new SwapData();

            swap.ModdedFileName  = modFilename;
            swap.ModdedFilePath  = modFile;
            swap.VanillaFileName = ogFilename;
            swap.VanillaFilePath = ogFile;
            swap.NewFileName     = ogFilename;
            swap.NewFilePath     = Settings.ModsLocation + "\\Vanilla\\Halo Reach\\" + ogFilename;
            swap.OtherFile       = true;

            //backup Vanilla file
            if (!File.Exists(Settings.ModsLocation + "\\Vanilla\\Halo Reach\\" + ogFilename))
            {
                Logger.Log("Backing up \"" + ogFilename + "\"");
                File.Move(ogFile, Settings.ModsLocation + "\\Vanilla\\Halo Reach\\" + ogFilename);
                Logger.LogLine(". Done");
            }
            else
            {
                Logger.LogLine("Backup file already exist, restore the backup to it original location and try again. Located at \""
                               + Settings.ModsLocation + "\\Vanilla\\Halo Reach\\" + ogFilename + "\"");
                btnHRMod.Enabled = true;
                return;
            }

            HaloReach.AddSwapData(ogFilename, swap);

            //HaloReach.SwapData.Add(ogFilename, swap);

            //bool t = FileUtil.CreateHardLink(ogFile, modFile);
            HaloReach.SaveSwapData();

            UpdateSwapList();

            Logger.LogLine("Files swaped.");
            btnHRMod.Enabled = true;
        }