コード例 #1
0
        void InstallationStep3()
        {
            ApiGroup.Visibility       = Visibility.Visible;
            InstallButtons.Visibility = Visibility.Collapsed;

            UpdateStatus("Working on " + targetName + " ...", "Installing ReShade ...");

            if (ApiVulkan.IsChecked != true)
            {
                try
                {
                    var module = zip.GetEntry(is64Bit ? "ReShade64.dll" : "ReShade32.dll");
                    if (module == null)
                    {
                        throw new FileFormatException("Expected ReShade archive to contain ReShade DLLs");
                    }

                    using (Stream input = module.Open())
                        using (FileStream output = File.Create(modulePath))
                        {
                            input.CopyTo(output);
                        }
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Failed to install " + Path.GetFileName(modulePath) + ".", ex.Message);
                    return;
                }

                // Create a default log file for troubleshooting
                File.WriteAllText(Path.ChangeExtension(modulePath, ".log"), @"
If you are reading this after launching the game at least once, it likely means ReShade was not loaded by the game.

In that event here are some steps you can try to resolve this:

1) Make sure this file and the related DLL are really in the same directory as the game executable.
   If that is the case and it does not work regardless, check if there is a 'bin' directory, move them there and try again.

2) Try running the game with elevated user permissions by doing a right click on its executable and choosing 'Run as administrator'.

3) If the game crashes, try disabling all game overlays (like Origin), recording software (like Fraps), FPS displaying software,
   GPU overclocking and tweaking software and other proxy DLLs (like ENB, Helix or Umod).

4) If none of the above helps, you can get support on the forums at https://forum.reshade.me. But search for your problem before
   creating a new topic, as somebody else may have already found a solution.
");
            }

            // Copy potential pre-made configuration file to target
            if (File.Exists("ReShade.ini") && !File.Exists(configPath))
            {
                try
                {
                    File.Copy("ReShade.ini", configPath);
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Failed to install " + Path.GetFileName(configPath) + ".", ex.Message);
                    return;
                }
            }

            // Add default configuration
            var config = new IniFile(configPath);

            if (compatibilityIni != null && !config.HasValue("GENERAL", "PreprocessorDefinitions"))
            {
                config.SetValue("GENERAL", "PreprocessorDefinitions",
                                "RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0",
                                "RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=" + compatibilityIni.GetString(targetName, "DepthUpsideDown", "0"),
                                "RESHADE_DEPTH_INPUT_IS_REVERSED=" + compatibilityIni.GetString(targetName, "DepthReversed", "0"),
                                "RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=" + compatibilityIni.GetString(targetName, "DepthLogarithmic", "0"));

                if (compatibilityIni.HasValue(targetName, "DepthCopyBeforeClears") ||
                    compatibilityIni.HasValue(targetName, "UseAspectRatioHeuristics"))
                {
                    switch (compatibilityIni.GetString(targetName, "RenderApi"))
                    {
                    case "D3D9":
                        config.SetValue("DX9_BUFFER_DETECTION", "PreserveDepthBuffer", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX9_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;

                    case "D3D10":
                        config.SetValue("DX10_BUFFER_DETECTION", "DepthBufferRetrievalMode", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX10_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;

                    case "D3D11":
                        config.SetValue("DX11_BUFFER_DETECTION", "DepthBufferRetrievalMode", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX11_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;

                    case "D3D12":
                        config.SetValue("DX12_BUFFER_DETECTION", "DepthBufferRetrievalMode", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX12_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;
                    }
                }

                config.SaveFile();
            }

            // Only show the selection dialog if there are actually packages to choose
            if (!isHeadless && packagesIni != null && packagesIni.GetSections().Length != 0)
            {
                var dlg = new SelectEffectsDialog(packagesIni);
                dlg.Owner = this;

                if (dlg.ShowDialog() == true)
                {
                    var packages = new Queue <EffectPackage>(dlg.EnabledPackages);

                    if (packages.Count != 0)
                    {
                        InstallationStep4(packages);
                        return;
                    }
                }
            }

            // Add default search paths if no config exists
            if (!config.HasValue("GENERAL", "EffectSearchPaths") && !config.HasValue("GENERAL", "TextureSearchPaths"))
            {
                WriteSearchPaths(".\\", ".\\");
            }

            InstallationStep6();
        }
コード例 #2
0
        void InstallationStep3()
        {
            Message.Text = "Installing ReShade ...";

            if (ApiVulkan.IsChecked != true)
            {
                ApiGroup.Visibility       = Visibility.Visible;
                InstallButtons.Visibility = Visibility.Collapsed;

                try
                {
                    using (ZipArchive zip = ExtractArchive())
                    {
                        if (zip.Entries.Count != 4)
                        {
                            throw new FileFormatException("Expected ReShade archive to contain ReShade DLLs");
                        }

                        // 0: ReShade32.dll
                        // 2: ReShade64.dll
                        using (Stream input = zip.Entries[is64Bit ? 2 : 0].Open())
                            using (FileStream output = File.Create(modulePath))
                            {
                                input.CopyTo(output);
                            }
                    }
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Unable to write " + Path.GetFileName(modulePath) + ".", ex.Message);
                    return;
                }
            }

            // Copy potential pre-made configuration file to target
            if (File.Exists("ReShade.ini") && !File.Exists(configPath))
            {
                try
                {
                    File.Copy("ReShade.ini", configPath);
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Unable to write " + Path.GetFileName(configPath) + ".", ex.Message);
                    return;
                }
            }

            if (!isHeadless)
            {
                var dlg = new SelectEffectsDialog();
                dlg.Owner = this;

                if (dlg.ShowDialog() == true)
                {
                    var packages = new Queue <string>(dlg.EnabledPackageUrls);

                    if (packages.Count != 0)
                    {
                        InstallationStep4(packages);
                        return;
                    }
                }
            }

            // Add default search paths if no config exists
            if (!File.Exists(configPath))
            {
                WriteSearchPaths(".\\", ".\\");
            }

            InstallationStep6();
        }
コード例 #3
0
        void InstallationStep3()
        {
            Message.Text = "Installing ReShade ...";

            if (ApiVulkan.IsChecked != true)
            {
                ApiGroup.Visibility       = Visibility.Visible;
                InstallButtons.Visibility = Visibility.Collapsed;

                try
                {
                    using (ZipArchive zip = ExtractArchive())
                    {
                        if (zip.Entries.Count != 4)
                        {
                            throw new FileFormatException("Expected ReShade archive to contain ReShade DLLs");
                        }

                        // 0: ReShade32.dll
                        // 2: ReShade64.dll
                        using (Stream input = zip.Entries[is64Bit ? 2 : 0].Open())
                            using (FileStream output = File.Create(modulePath))
                            {
                                input.CopyTo(output);
                            }
                    }
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Unable to write " + Path.GetFileName(modulePath) + ".", ex.Message);
                    return;
                }
            }

            // Copy potential pre-made configuration file to target
            if (File.Exists("ReShade.ini") && !File.Exists(configPath))
            {
                try
                {
                    File.Copy("ReShade.ini", configPath);
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Unable to write " + Path.GetFileName(configPath) + ".", ex.Message);
                    return;
                }
            }

            if (!isHeadless)
            {
                string targetPathShaders = Path.Combine(Path.GetDirectoryName(targetPath), "reshade-shaders", "Shaders");

                string[] installedEffects = null;
                if (Directory.Exists(targetPathShaders))
                {
                    installedEffects = Directory.GetFiles(targetPathShaders).Select(x => Path.GetFileName(x)).ToArray();
                }

                var dlg = new SelectEffectsDialog();
                dlg.Owner = this;

                // If there was an existing installation, select the same effects as previously
                if (installedEffects != null)
                {
                    foreach (EffectRepositoryItem repository in dlg.EffectList.Items)
                    {
                        foreach (EffectItem item in repository.Effects)
                        {
                            item.Enabled = installedEffects.Contains(Path.GetFileName(item.Path));
                        }
                    }
                }

                if (dlg.ShowDialog() == true)
                {
                    var repositoryItems = dlg.EffectList.Items.Cast <EffectRepositoryItem>();
                    var repositoryNames = new Queue <string>(repositoryItems.Where(x => x.Enabled != false).Select(x => x.Name));

                    if (repositoryNames.Count != 0)
                    {
                        InstallationStep4(repositoryNames, repositoryItems.SelectMany(x => x.Effects).Where(x => !x.Enabled.Value).Select(x => Path.GetFileName(x.Path)).ToList());
                        return;
                    }
                }
            }

            // Add default search paths if no config exists
            if (!File.Exists(configPath))
            {
                WriteSearchPaths(".\\", ".\\");
            }

            InstallationStep6();
        }
コード例 #4
0
        void InstallationStep5(string downloadPath, EffectPackage package)
        {
            UpdateStatus("Working on " + targetName + " ...", "Extracting " + package.PackageName + " ...");

            string tempPath = Path.Combine(Path.GetTempPath(), "reshade-shaders");

            try
            {
                // Delete existing directories since extraction fails if the target is not empty
                if (Directory.Exists(tempPath))
                {
                    Directory.Delete(tempPath, true);
                }

                ZipFile.ExtractToDirectory(downloadPath, tempPath);

                // First check for a standard directory name
                string tempPathShaders    = Directory.GetDirectories(tempPath, "Shaders", SearchOption.AllDirectories).FirstOrDefault();
                string tempPathTextures   = Directory.GetDirectories(tempPath, "Textures", SearchOption.AllDirectories).FirstOrDefault();
                string targetPathShaders  = Path.Combine(Path.GetDirectoryName(targetPath), package.InstallPath);
                string targetPathTextures = Path.Combine(Path.GetDirectoryName(targetPath), package.TextureInstallPath);

                // If that does not exist, look for the first directory that contains shaders/textures
                string[] effects = Directory.GetFiles(tempPath, "*.fx", SearchOption.AllDirectories);
                if (tempPathShaders == null)
                {
                    tempPathShaders = effects.Select(x => Path.GetDirectoryName(x)).OrderBy(x => x.Length).FirstOrDefault();
                }
                if (tempPathTextures == null)
                {
                    string[] tempTextureExtensions = { "*.png", "*.jpg", "*.jpeg" };

                    foreach (string extension in tempTextureExtensions)
                    {
                        string path = Directory.GetFiles(tempPath, extension, SearchOption.AllDirectories).Select(x => Path.GetDirectoryName(x)).OrderBy(x => x.Length).FirstOrDefault();
                        tempPathTextures = tempPathTextures != null?tempPathTextures.Union(path).ToString() : path;
                    }
                }

                // Show file selection dialog
                if (!isHeadless && package.Enabled == null)
                {
                    effects = effects.Select(x => targetPathShaders + x.Remove(0, tempPathShaders.Length)).ToArray();

                    var dlg = new SelectEffectsDialog(package.PackageName, effects);
                    dlg.Owner = this;

                    if (dlg.ShowDialog() == true)
                    {
                        // Delete all unselected effect files before moving
                        foreach (string filePath in effects.Except(dlg.EnabledItems.Select(x => x.FilePath)))
                        {
                            File.Delete(tempPathShaders + filePath.Remove(0, targetPathShaders.Length));
                        }
                    }
                }

                // Move only the relevant files to the target
                if (tempPathShaders != null)
                {
                    MoveFiles(tempPathShaders, targetPathShaders);
                }
                if (tempPathTextures != null)
                {
                    MoveFiles(tempPathTextures, targetPathTextures);
                }

                File.Delete(downloadPath);
                Directory.Delete(tempPath, true);
            }
            catch (Exception ex)
            {
                UpdateStatusAndFinish(false, "Failed to extract " + package.PackageName + ".", ex.Message);
                return;
            }

            WriteSearchPaths(package.InstallPath, package.TextureInstallPath);

            InstallationStep6();
        }
コード例 #5
0
        void InstallationStep3()
        {
            ApiGroup.Visibility       = Visibility.Visible;
            InstallButtons.Visibility = Visibility.Collapsed;

            Message.Text = "Installing ReShade ...";

            if (ApiVulkan.IsChecked != true)
            {
                try
                {
                    var module = zip.GetEntry(is64Bit ? "ReShade64.dll" : "ReShade32.dll");
                    if (module == null)
                    {
                        throw new FileFormatException("Expected ReShade archive to contain ReShade DLLs");
                    }

                    using (Stream input = module.Open())
                        using (FileStream output = File.Create(modulePath))
                        {
                            input.CopyTo(output);
                        }
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Unable to write " + Path.GetFileName(modulePath) + ".", ex.Message);
                    return;
                }
            }

            // Copy potential pre-made configuration file to target
            if (File.Exists("ReShade.ini") && !File.Exists(configPath))
            {
                try
                {
                    File.Copy("ReShade.ini", configPath);
                }
                catch (Exception ex)
                {
                    UpdateStatusAndFinish(false, "Unable to write " + Path.GetFileName(configPath) + ".", ex.Message);
                    return;
                }
            }

            // Add default configuration
            var config = new IniFile(configPath);

            if (compatibilityIni != null && !config.HasValue("GENERAL", "PreprocessorDefinitions"))
            {
                config.SetValue("GENERAL", "PreprocessorDefinitions",
                                "RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0",
                                "RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=" + compatibilityIni.GetString(targetName, "DepthUpsideDown", "0"),
                                "RESHADE_DEPTH_INPUT_IS_REVERSED=" + compatibilityIni.GetString(targetName, "DepthReversed", "0"),
                                "RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=" + compatibilityIni.GetString(targetName, "DepthLogarithmic", "0"));

                if (compatibilityIni.HasValue(targetName, "DepthCopyBeforeClears") ||
                    compatibilityIni.HasValue(targetName, "UseAspectRatioHeuristics"))
                {
                    switch (compatibilityIni.GetString(targetName, "RenderApi"))
                    {
                    case "D3D9":
                        config.SetValue("DX9_BUFFER_DETECTION", "PreserveDepthBuffer", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX9_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;

                    case "D3D10":
                        config.SetValue("DX10_BUFFER_DETECTION", "DepthBufferRetrievalMode", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX10_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;

                    case "D3D11":
                        config.SetValue("DX11_BUFFER_DETECTION", "DepthBufferRetrievalMode", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX11_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;

                    case "D3D12":
                        config.SetValue("DX12_BUFFER_DETECTION", "DepthBufferRetrievalMode", compatibilityIni.GetString(targetName, "DepthCopyBeforeClears", "0"));
                        config.SetValue("DX12_BUFFER_DETECTION", "UseAspectRatioHeuristics", compatibilityIni.GetString(targetName, "UseAspectRatioHeuristics", "1"));
                        break;
                    }
                }

                config.SaveFile();
            }

            // Only show the selection dialog if there are actually packages to choose
            if (!isHeadless && packagesIni != null)
            {
                var dlg = new SelectEffectsDialog(packagesIni);
                dlg.Owner = this;

                if (dlg.ShowDialog() == true)
                {
                    var packages = new Queue <string>(dlg.EnabledPackageUrls);

                    if (packages.Count != 0)
                    {
                        InstallationStep4(packages);
                        return;
                    }
                }
            }

            // Add default search paths if no config exists
            if (!config.HasValue("GENERAL", "EffectSearchPaths") && !config.HasValue("GENERAL", "TextureSearchPaths"))
            {
                WriteSearchPaths(".\\", ".\\");
            }

            InstallationStep6();
        }