示例#1
0
        private void confirmBTN_Click(object sender, EventArgs e)
        {
            //Ensure valid paths.  If not valid, try again.

            try
            {
                Path.GetFullPath(shadersTB.Text + @"\shaders");
                Path.GetFullPath(shadersTB.Text + @"\textures");
                Path.GetFullPath(presetsTB.Text);
                Path.GetFullPath(screenshotsTB.Text);
            }
            catch
            {
                MessageBox.Show(@"Invalid path(s) entered.  Please double check your paths and fix any errors.");
                return;
            }

            //Update variables in memory and write variables to config file.

            Program.shaders     = Path.GetFullPath(shadersTB.Text + @"\shaders");
            Program.textures    = Path.GetFullPath(shadersTB.Text + @"\textures");
            Program.presets     = Path.GetFullPath(presetsTB.Text);
            Program.screenshots = Path.GetFullPath(screenshotsTB.Text);
            Functions.overwriteIni("ReShadeCentralized.ini", new List <string> {
                "shaders=", "textures=", "presets=", "screenshots="
            }, new List <string> {
                Program.shaders, Program.textures, Program.presets, Program.screenshots
            });

            //Move files from old directory to new directory
            DirectoryExtensions.MoveDirectoryOverwrite(oldReshadeShaders, Path.GetFullPath(shadersTB.Text));
            DirectoryExtensions.MoveDirectoryOverwrite(oldPresets, Program.presets);
            DirectoryExtensions.MoveDirectoryOverwrite(oldScreenshots, Program.screenshots);
            this.Close();
        }
示例#2
0
        //Update Shaders Thread
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            worker.ReportProgress(0);
            var items = Prompt.ShowCheckBoxes(new string[] { "Standard - Crosire (REQUIRED)", "Legacy - Crosire", "qUINT - Marty McFly", "SweetFX - CeeJayDK", "Color Effects - prod80", "Depth3D - BlueSkyDefender", "AstrayFX - BlueSkyDefender", "OtisFX - Otis Inf", "Pirate Shaders - Heathen", "Shaders - Brussell1", "Shaders - Daodan317081", "CorgiFX - originalnicoder", "Fubax - Fubaxiusz", "FXShaders - luluco250", "Shaders - Radegast", "Insane Shaders - Lord of Lunacy", "MLUT - TheGordinho", "RSRetroArch - Matsilagi", "Shaders - MadCake", "CobraFX - LordKobra", "FGFX - AlexTuduran", "Glamarye Fast Effects - rj200" }, @"Select shader repos to download.", 200, 400, 178).CheckedItems;

            using (var client = new WebClient())
            {
                bool   legacy             = false;
                bool   fxshaders          = false;
                bool   lunacy             = false;
                bool   radegast           = false;
                bool   matsilagi          = false;
                bool   lordkobra          = false;
                var    rand               = new Random();
                string randTempRootFolder = @".\temp" + rand.Next().ToString();
                while (Directory.Exists(randTempRootFolder))
                {
                    randTempRootFolder = @".\temp" + rand.Next().ToString();
                }
                Directory.CreateDirectory(randTempRootFolder);
                int    pbarInc   = 100 / (items.Count + 1); //split progress bar increments into how many repos get downloaded + extraction step (and prevents divide by 0)
                int    pbarValue = 0;
                string dlFail    = @"Download failed for "; //just to save me time typing if I want to change the wording
                for (int i = 0; i < items.Count; i++)
                {
                    switch (items[i])
                    {
                    case "Standard - Crosire (REQUIRED)":
                        try
                        {
                            client.DownloadFile(@"https://github.com/crosire/reshade-shaders/archive/slim.zip", randTempRootFolder + @"\crosire.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Legacy - Crosire":
                        try
                        {
                            client.DownloadFile(@"https://github.com/crosire/reshade-shaders/archive/master.zip", randTempRootFolder + @"\legacy.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        legacy     = true;
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "qUINT - Marty McFly":
                        try
                        {
                            client.DownloadFile(@"https://github.com/martymcmodding/qUINT/archive/master.zip", randTempRootFolder + @"\quint.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "SweetFX - CeeJayDK":
                        try
                        {
                            client.DownloadFile(@"https://github.com/CeeJayDK/SweetFX/archive/master.zip", randTempRootFolder + @"\sweetfx.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Color Effects - prod80":
                        try
                        {
                            client.DownloadFile(@"https://github.com/prod80/prod80-ReShade-Repository/archive/master.zip", randTempRootFolder + @"\prod80.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Depth3D - BlueSkyDefender":
                        try
                        {
                            client.DownloadFile(@"https://github.com/BlueSkyDefender/Depth3D/archive/master.zip", randTempRootFolder + @"\depth3d.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "AstrayFX - BlueSkyDefender":
                        try
                        {
                            client.DownloadFile(@"https://github.com/BlueSkyDefender/AstrayFX/archive/master.zip", randTempRootFolder + @"\astrayfx.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "OtisFX - Otis Inf":
                        try
                        {
                            client.DownloadFile(@"https://github.com/FransBouma/OtisFX/archive/master.zip", randTempRootFolder + @"\otisfx.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Pirate Shaders - Heathen":
                        try
                        {
                            client.DownloadFile(@"https://github.com/Heathen/Pirate-Shaders/archive/master.zip", randTempRootFolder + @"\pirate.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Shaders - Brussell1":
                        try
                        {
                            client.DownloadFile(@"https://github.com/brussell1/Shaders/archive/master.zip", randTempRootFolder + @"\brussell1.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Shaders - Daodan317081":
                        try
                        {
                            client.DownloadFile(@"https://github.com/Daodan317081/reshade-shaders/archive/master.zip", randTempRootFolder + @"\daodan.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "CorgiFX - originalnicoder":
                        try
                        {
                            client.DownloadFile(@"https://github.com/originalnicodr/CorgiFX/archive/master.zip", randTempRootFolder + @"\corgifx.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;


                    case "Fubax - Fubaxiusz":
                        try
                        {
                            client.DownloadFile(@"https://github.com/Fubaxiusz/fubax-shaders/archive/master.zip", randTempRootFolder + @"\fubax.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "FXShaders - luluco250":
                        try
                        {
                            client.DownloadFile(@"https://github.com/luluco250/FXShaders/archive/master.zip", randTempRootFolder + @"\fxshaders.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        fxshaders  = true;
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Shaders - Radegast":
                        try
                        {
                            client.DownloadFile(@"https://github.com/Radegast-FFXIV/reshade-shaders/archive/master.zip", randTempRootFolder + @"\radegast.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        radegast   = true;
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Insane Shaders - Lord of Lunacy":
                        try
                        {
                            client.DownloadFile(@"https://github.com/LordOfLunacy/Insane-Shaders/archive/master.zip", randTempRootFolder + @"\insane.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        lunacy     = true;
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "MLUT - TheGordinho":
                        try
                        {
                            client.DownloadFile(@"https://github.com/TheGordinho/MLUT/archive/refs/heads/master.zip", randTempRootFolder + @"\mlut.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "RSRetroArch - Matsilagi":
                        try
                        {
                            client.DownloadFile(@"https://github.com/Matsilagi/RSRetroArch/archive/refs/heads/main.zip", randTempRootFolder + @"\RSRetroArch.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        matsilagi  = true;
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Shaders - MadCake":
                        try
                        {
                            client.DownloadFile(@"https://github.com/ConstantineRudenko/Shaders/archive/refs/heads/master.zip", randTempRootFolder + @"\MadCake.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "CobraFX - LordKobra":
                        try
                        {
                            client.DownloadFile(@"https://github.com/LordKobra/CobraFX/archive/refs/heads/master.zip", randTempRootFolder + @"\CobraFX.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        lordkobra  = true;
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "FGFX - AlexTuduran":
                        try
                        {
                            client.DownloadFile(@"https://github.com/AlexTuduran/FGFX/archive/refs/heads/main.zip", randTempRootFolder + @"\FGFX.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;

                    case "Glamarye Fast Effects - rj200":
                        try
                        {
                            client.DownloadFile(@"https://github.com/rj200/Glamarye_Fast_Effects_for_ReShade/archive/refs/heads/main.zip", randTempRootFolder + @"\Glamarye.zip");
                        }
                        catch
                        {
                            MessageBox.Show(dlFail + items[i]);
                        }
                        pbarValue += pbarInc;
                        worker.ReportProgress(pbarValue);
                        break;
                    }
                }
                client.Dispose();
                string[] shaderExtensions  = { ".fx", ".cfg", ".fxh" };
                string[] textureExtensions = { ".png", ".dds", ".bmp", ".jpg", ".jpeg" };

                //Zip Extraction + Special cases----------------

                //Legacy repo, contains old shaders that have been updated in other repos, but also many shaders that are abandoned.
                //Move this repo first so that newer repos can overwrite when necessary.
                if (legacy == true)
                {
                    try
                    {
                        ZipFile.ExtractToDirectory(randTempRootFolder + @"\legacy.zip", randTempRootFolder + @"\legacy");
                    }
                    catch
                    {
                        Directory.Delete(randTempRootFolder + @"\legacy", true);
                        ZipFile.ExtractToDirectory(randTempRootFolder + @"\legacy.zip", randTempRootFolder + @"\legacy");
                    }
                    File.Delete(randTempRootFolder + @"\legacy.zip");
                    File.Delete(randTempRootFolder + @"\legacy\reshade-shaders-master\Shaders\MXAO.fx"); //outdated mxao, causes issues with quint so delete
                    Functions.moveFiles(randTempRootFolder + @"\legacy", Program.shaders, shaderExtensions);
                    Functions.moveFiles(randTempRootFolder + @"\legacy", Program.textures, textureExtensions);
                }

                //Extract all repos for processing
                Functions.extractAllZip(randTempRootFolder, randTempRootFolder, new string[] { ".zip" });

                //FXShaders requires additional files in a specific folder, move that folder now.
                if (fxshaders == true)
                {
                    Directory.CreateDirectory(Program.shaders + @"\" + "FXShaders");
                    DirectoryExtensions.MoveDirectoryOverwrite(randTempRootFolder + @"\FXShaders-master\Shaders\FXShaders", Program.shaders + @"\FXShaders");
                }

                //Lord of Lunacy has folders that contain in-development/deprecated shaders.  Delete those now.
                if (lunacy == true)
                {
                    Directory.Delete(randTempRootFolder + @"\Insane-Shaders-master\Shaders\DevShaders", true);
                    Directory.Delete(randTempRootFolder + @"\Insane-Shaders-master\Shaders\OldShaders", true);
                }

                if (radegast == true)
                {
                    Directory.CreateDirectory(Program.shaders + @"\" + "Include");
                    DirectoryExtensions.MoveDirectoryOverwrite(randTempRootFolder + @"\reshade-shaders-master\Shaders\Include", Program.shaders + @"\Include");
                }

                if (matsilagi == true)
                {
                    Directory.CreateDirectory(Program.textures + @"\crt-cx");
                    Directory.CreateDirectory(Program.textures + @"\crt-newpixie");
                    Directory.CreateDirectory(Program.textures + @"\crt_potato");
                    Directory.CreateDirectory(Program.textures + @"\crtsim");

                    DirectoryExtensions.MoveDirectoryOverwrite(randTempRootFolder + @"\RSRetroArch-main\Textures\crt-cx", Program.textures + @"\crt-cx");
                    DirectoryExtensions.MoveDirectoryOverwrite(randTempRootFolder + @"\RSRetroArch-main\Textures\crt-newpixie", Program.textures + @"\crt-newpixie");
                    DirectoryExtensions.MoveDirectoryOverwrite(randTempRootFolder + @"\RSRetroArch-main\Textures\crt_potato", Program.textures + @"\crt_potato");
                    DirectoryExtensions.MoveDirectoryOverwrite(randTempRootFolder + @"\RSRetroArch-main\Textures\crtsim", Program.textures + @"\crtsim");
                }

                if (lordkobra == true)
                {
                    Directory.Delete(randTempRootFolder + @"\CobraFX-master\Shaders\outdated", true);
                }

                //End special cases------------

                Functions.copyFiles(randTempRootFolder, Program.shaders, shaderExtensions);
                Functions.copyFiles(randTempRootFolder, Program.textures, textureExtensions);
                if (File.Exists(randTempRootFolder + @"\reshade-shaders-slim\Shaders\ReShade.fxh"))
                {
                    File.Copy(randTempRootFolder + @"\reshade-shaders-slim\Shaders\ReShade.fxh", Program.shaders + @"\ReShade.fxh", true); //Some repos contain outdated ReShade.fxh/ReShadeUI.fxh files.  Copy the correct one and overwrite.
                }

                if (File.Exists(randTempRootFolder + @"\reshade-shaders-slim\Shaders\ReShadeUI.fxh"))
                {
                    File.Copy(randTempRootFolder + @"\reshade-shaders-slim\Shaders\ReShadeUI.fxh", Program.shaders + @"\ReShadeUI.fxh", true); //Some repos contain outdated ReShade.fxh/ReShadeUI.fxh files.  Copy the correct one and overwrite.
                }

                Directory.Delete(randTempRootFolder, true);

                worker.ReportProgress(100);
            }
        }