void InstallationStep4() { string targetDirectory = Path.GetDirectoryName(_targetPath); string shadersDirectoryFinal = Path.Combine(targetDirectory, "reshade-shaders"); string shadersDirectoryExtracted = Path.Combine(targetDirectory, "reshade-shaders-master"); try { if (Directory.Exists(shadersDirectoryFinal)) { Directory.Delete(shadersDirectoryFinal, true); } if (Directory.Exists(shadersDirectoryExtracted)) { Directory.Delete(shadersDirectoryExtracted, true); } ZipFile.ExtractToDirectory(_tempDownloadPath, targetDirectory); File.Delete(_tempDownloadPath); Directory.Move(shadersDirectoryExtracted, shadersDirectoryFinal); } catch { Title += " Failed!"; Message.Content = "Unable to extract downloaded archive."; Glass.HideSystemMenu(this, false); return; } var wnd = new SelectWindow(Directory.GetFiles(Path.Combine(shadersDirectoryFinal, "Shaders"))); wnd.Owner = this; wnd.ShowDialog(); foreach (var item in wnd.GetSelection()) { if (item.IsChecked) { continue; } File.Delete(item.Path); } string configFilePath = Path.ChangeExtension(_targetModulePath, ".ini"); var effectSearchPaths = new HashSet <string>(IniFile.ReadValue(configFilePath, "GENERAL", "EffectSearchPaths", targetDirectory).Split(',')); var textureSearchPaths = new HashSet <string>(IniFile.ReadValue(configFilePath, "GENERAL", "TextureSearchPaths", targetDirectory).Split(',')); effectSearchPaths.Add(Path.Combine(shadersDirectoryFinal, "Shaders")); textureSearchPaths.Add(Path.Combine(shadersDirectoryFinal, "Textures")); IniFile.WriteValue(configFilePath, "GENERAL", "EffectSearchPaths", string.Join(",", effectSearchPaths)); IniFile.WriteValue(configFilePath, "GENERAL", "TextureSearchPaths", string.Join(",", textureSearchPaths)); Title += " Succeeded!"; Message.Content = "Done"; Glass.HideSystemMenu(this, false); }
void InstallationStep4() { Message.Text = "Extracting ..."; string tempPath = Path.Combine(Path.GetTempPath(), "reshade-shaders-master"); string tempPathShaders = Path.Combine(tempPath, "Shaders"); string tempPathTextures = Path.Combine(tempPath, "Textures"); string targetPath = Path.Combine(Path.GetDirectoryName(_targetPath), "reshade-shaders"); string targetPathShaders = Path.Combine(targetPath, "Shaders"); string targetPathTextures = Path.Combine(targetPath, "Textures"); string[] installedEffects = null; if (Directory.Exists(targetPath)) { installedEffects = Directory.GetFiles(targetPathShaders).ToArray(); } try { if (Directory.Exists(tempPath)) // Delete existing directories since extraction fails if the target is not empty { Directory.Delete(tempPath, true); } ZipFile.ExtractToDirectory(_tempDownloadPath, Path.GetTempPath()); MoveFiles(tempPathShaders, targetPathShaders); MoveFiles(tempPathTextures, targetPathTextures); File.Delete(_tempDownloadPath); Directory.Delete(tempPath, true); } catch (Exception ex) { ShowMessage("Failed!", "Unable to extract downloaded archive.", ex.Message, true, 1); return; } if (!_isHeadless) { var wnd = new SelectWindow(Directory.GetFiles(targetPathShaders)); wnd.Owner = this; // If there was an existing installation, select the same effects as previously if (installedEffects != null) { foreach (var item in wnd.GetSelection()) { item.IsChecked = installedEffects.Contains(item.Path); } } wnd.ShowDialog(); foreach (var item in wnd.GetSelection()) { if (!item.IsChecked) { try { File.Delete(item.Path); } catch { continue; } } } } WriteSearchPaths(".\\reshade-shaders\\Shaders", ".\\reshade-shaders\\Textures"); ShowMessage("Succeeded!", null, null, true, 0); }
void InstallationStep4() { Message.Text = "Extracting ..."; string tempPath = Path.Combine(Path.GetTempPath(), "reshade-shaders-master"); string tempPathShaders = Path.Combine(tempPath, "Shaders"); string tempPathTextures = Path.Combine(tempPath, "Textures"); string targetPath = Path.Combine(Path.GetDirectoryName(_targetPath), "reshade-shaders"); string targetPathShaders = Path.Combine(targetPath, "Shaders"); string targetPathTextures = Path.Combine(targetPath, "Textures"); string[] installedEffects = null; if (Directory.Exists(targetPath)) { installedEffects = Directory.GetFiles(targetPathShaders).ToArray(); } try { if (Directory.Exists(tempPath)) // Delete existing directories since extraction fails if the target is not empty { Directory.Delete(tempPath, true); } ZipFile.ExtractToDirectory(_tempDownloadPath, Path.GetTempPath()); MoveFiles(tempPathShaders, targetPathShaders); MoveFiles(tempPathTextures, targetPathTextures); File.Delete(_tempDownloadPath); Directory.Delete(tempPath, true); } catch (Exception ex) { Title += " Failed!"; Message.Text = "Unable to extract downloaded archive."; MessageDescription.Visibility = Visibility.Visible; MessageDescription.Text = ex.Message; Glass.HideSystemMenu(this, false); if (_isHeadless) { Environment.Exit(1); } return; } if (!_isHeadless) { var wnd = new SelectWindow(Directory.GetFiles(targetPathShaders)); wnd.Owner = this; // If there was an existing installation, select the same effects as previously if (installedEffects != null) { foreach (var item in wnd.GetSelection()) { item.IsChecked = installedEffects.Contains(item.Path); } } wnd.ShowDialog(); foreach (var item in wnd.GetSelection()) { if (!item.IsChecked) { try { File.Delete(item.Path); } catch { continue; } } } } var effectSearchPaths = IniFile.ReadValue(ConfigFilePath, "GENERAL", "EffectSearchPaths").Split(',').Where(x => x.Length != 0).ToList(); var textureSearchPaths = IniFile.ReadValue(ConfigFilePath, "GENERAL", "TextureSearchPaths").Split(',').Where(x => x.Length != 0).ToList(); AddSearchPath(effectSearchPaths, targetPathShaders); AddSearchPath(textureSearchPaths, targetPathTextures); IniFile.WriteValue(ConfigFilePath, "GENERAL", "EffectSearchPaths", string.Join(",", effectSearchPaths)); IniFile.WriteValue(ConfigFilePath, "GENERAL", "TextureSearchPaths", string.Join(",", textureSearchPaths)); Title += " Succeeded!"; Glass.HideSystemMenu(this, false); if (_isHeadless) { Environment.Exit(0); } EnableSettingsWindow(); }
void InstallationStep4() { string targetDirectory = Path.GetDirectoryName(_targetPath); string shadersDirectoryFinal = Path.Combine(targetDirectory, "reshade-shaders"); string shadersDirectoryExtracted = Path.Combine(targetDirectory, "reshade-shaders-master"); try { if (Directory.Exists(shadersDirectoryFinal)) { Directory.Delete(shadersDirectoryFinal, true); } if (Directory.Exists(shadersDirectoryExtracted)) { Directory.Delete(shadersDirectoryExtracted, true); } ZipFile.ExtractToDirectory(_tempDownloadPath, targetDirectory); File.Delete(_tempDownloadPath); Directory.Move(shadersDirectoryExtracted, shadersDirectoryFinal); } catch (Exception ex) { Title += " Failed!"; Message.Content = "Unable to extract downloaded archive."; MessageDescription.Visibility = Visibility.Visible; MessageDescription.Content = ex.Message; Glass.HideSystemMenu(this, false); if (_isHeadless) { Environment.Exit(1); } return; } if (!_isHeadless) { var wnd = new SelectWindow(Directory.GetFiles(Path.Combine(shadersDirectoryFinal, "Shaders"))); wnd.Owner = this; wnd.ShowDialog(); foreach (var item in wnd.GetSelection()) { if (!item.IsChecked) { try { File.Delete(item.Path); } catch { continue; } } } } string configFilePath = ConfigFilePath; var effectSearchPaths = new HashSet <string>(IniFile.ReadValue(configFilePath, "GENERAL", "EffectSearchPaths").Split(',').Where(x => x.Length != 0)); var textureSearchPaths = new HashSet <string>(IniFile.ReadValue(configFilePath, "GENERAL", "TextureSearchPaths").Split(',').Where(x => x.Length != 0)); effectSearchPaths.Add(Path.Combine(shadersDirectoryFinal, "Shaders")); textureSearchPaths.Add(Path.Combine(shadersDirectoryFinal, "Textures")); IniFile.WriteValue(configFilePath, "GENERAL", "EffectSearchPaths", string.Join(",", effectSearchPaths)); IniFile.WriteValue(configFilePath, "GENERAL", "TextureSearchPaths", string.Join(",", textureSearchPaths)); Title += " Succeeded!"; EnableConfigEditor(); Glass.HideSystemMenu(this, false); if (_isHeadless) { Environment.Exit(0); } }