From b6c08c5246143ecf976e3bbc487812ae8c453edd Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 24 Jan 2016 04:18:37 -0500 Subject: [PATCH] Push release for Custom paths, Battle Net and Desura --- SteamCleaner/Clients/Battlenet.cs | 2 +- SteamCleaner/Clients/CustomPaths.cs | 34 +++++++++++++++++++ SteamCleaner/Clients/Desura.cs | 38 ++++++++++++++++++++++ SteamCleaner/Clients/Gog.cs | 27 ++------------- SteamCleaner/Clients/Origin.cs | 24 ++------------ SteamCleaner/Clients/Steam.cs | 13 +------- SteamCleaner/Clients/Uplay.cs | 26 ++------------- SteamCleaner/MainWindowViewModel.cs | 14 +++++--- SteamCleaner/SteamCleaner.csproj | 2 ++ SteamCleaner/Utilities/CleanerUtilities.cs | 35 ++++++++++++++------ version.xml | 2 +- 11 files changed, 118 insertions(+), 99 deletions(-) create mode 100644 SteamCleaner/Clients/CustomPaths.cs create mode 100644 SteamCleaner/Clients/Desura.cs diff --git a/SteamCleaner/Clients/Battlenet.cs b/SteamCleaner/Clients/Battlenet.cs index 68f3c31..5aa8527 100644 --- a/SteamCleaner/Clients/Battlenet.cs +++ b/SteamCleaner/Clients/Battlenet.cs @@ -14,7 +14,7 @@ namespace SteamCleaner.Clients internal class Battlenet { - public static bool Exisit() + public static bool Exist() { return Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +"\\Battle.net"); diff --git a/SteamCleaner/Clients/CustomPaths.cs b/SteamCleaner/Clients/CustomPaths.cs new file mode 100644 index 0000000..778ffd8 --- /dev/null +++ b/SteamCleaner/Clients/CustomPaths.cs @@ -0,0 +1,34 @@ +#region + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +#endregion + +namespace SteamCleaner.Clients +{ + internal class Custom + { + public static bool Exist() + { + try + { + var lines = File.ReadLines("custom.txt"); + return lines.Any(); + } + catch (Exception) + { + return false; + } + } + + public static List GetGames() + { + var lines = File.ReadAllLines("custom.txt"); + List games = new List(lines); + return games; + } + } +} \ No newline at end of file diff --git a/SteamCleaner/Clients/Desura.cs b/SteamCleaner/Clients/Desura.cs new file mode 100644 index 0000000..00034dc --- /dev/null +++ b/SteamCleaner/Clients/Desura.cs @@ -0,0 +1,38 @@ +#region + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows; +using Microsoft.Win32; + +#endregion + +namespace SteamCleaner.Clients +{ + internal class Desura + { + + public static bool Exist() + { + var is64Bit = Environment.Is64BitOperatingSystem; + var regPath = is64Bit ? @"Software\Wow6432Node\Microsoft\\Windows\CurrentVersion\Uninstall" : @"Software\Microsoft\Windows\CurrentVersion\Uninstall"; + var root = Registry.LocalMachine.OpenSubKey(regPath); + return root != null; + } + + public static List GetGames() + { + var paths = new List(); + var is64Bit = Environment.Is64BitOperatingSystem; + var regPath = is64Bit ? @"Software\Wow6432Node\Microsoft\\Windows\CurrentVersion\Uninstall" : @"Software\Microsoft\Windows\CurrentVersion\Uninstall"; + var root = Registry.LocalMachine.OpenSubKey(regPath); + if (root != null) + { + paths.AddRange(from subkeyName in root.GetSubKeyNames() where subkeyName.StartsWith("Desura_", StringComparison.Ordinal) select Registry.LocalMachine.OpenSubKey(regPath + "\\" + subkeyName) into subKey select subKey?.GetValue("InstallLocation").ToString()); + } + return paths; + } + } +} \ No newline at end of file diff --git a/SteamCleaner/Clients/Gog.cs b/SteamCleaner/Clients/Gog.cs index 66a153e..6b885c4 100644 --- a/SteamCleaner/Clients/Gog.cs +++ b/SteamCleaner/Clients/Gog.cs @@ -15,19 +15,9 @@ internal class Gog { public static bool Exisit() { - var regPath = ""; + var is64Bit = Environment.Is64BitOperatingSystem; - if (is64Bit) - { - Console.WriteLine("64 Bit operating system detected"); - regPath = @"SOFTWARE\Wow6432Node\GOG.com\Games"; - } - else - { - Console.WriteLine("32 Bit operating system detected"); - regPath = @"SOFTWARE\GOG.com\Games"; - } - + var regPath = is64Bit ? @"SOFTWARE\Wow6432Node\GOG.com\Games" : @"SOFTWARE\GOG.com\Games"; var root = Registry.LocalMachine.OpenSubKey(regPath); return root != null; } @@ -35,19 +25,8 @@ public static bool Exisit() public static List GetGames() { var paths = new List(); - var regPath = ""; var is64Bit = Environment.Is64BitOperatingSystem; - if (is64Bit) - { - Console.WriteLine("64 Bit operating system detected"); - regPath = @"SOFTWARE\Wow6432Node\GOG.com\Games"; - } - else - { - Console.WriteLine("32 Bit operating system detected"); - regPath = @"SOFTWARE\GOG.com\Games"; - } - + var regPath = is64Bit ? @"SOFTWARE\Wow6432Node\GOG.com\Games" : @"SOFTWARE\GOG.com\Games"; var root = Registry.LocalMachine.OpenSubKey(regPath); if (root != null) paths.AddRange( diff --git a/SteamCleaner/Clients/Origin.cs b/SteamCleaner/Clients/Origin.cs index c98758c..f1cae14 100644 --- a/SteamCleaner/Clients/Origin.cs +++ b/SteamCleaner/Clients/Origin.cs @@ -35,19 +35,8 @@ public static List GetGames() { if (!Exist()) return null; var paths = new List(); - var regPath = ""; var is64Bit = Environment.Is64BitOperatingSystem; - if (is64Bit) - { - Console.WriteLine("64 Bit operating system detected"); - regPath = @"SOFTWARE\Wow6432Node\Electronic Arts"; - } - else - { - Console.WriteLine("32 Bit operating system detected"); - regPath = @"SOFTWARE\Electronic Arts"; - } - + var regPath = is64Bit ? @"SOFTWARE\Wow6432Node\Electronic Arts" : @"SOFTWARE\Electronic Arts"; var root = Registry.LocalMachine.OpenSubKey(regPath); if (root != null) paths.AddRange( @@ -57,16 +46,7 @@ public static List GetGames() .Select(key => key.GetValue(@"Install Dir")) .Select(o => o?.ToString()) .Where(Directory.Exists)); - if (is64Bit) - { - Console.WriteLine("64 Bit operating system detected"); - regPath = @"SOFTWARE\Wow6432Node\EA Games"; - } - else - { - Console.WriteLine("32 Bit operating system detected"); - regPath = @"SOFTWARE\EA Games"; - } + regPath = is64Bit ? @"SOFTWARE\Wow6432Node\EA Games" : @"SOFTWARE\EA Games"; var legacyRoot = Registry.LocalMachine.OpenSubKey(regPath); if (legacyRoot != null) paths.AddRange( diff --git a/SteamCleaner/Clients/Steam.cs b/SteamCleaner/Clients/Steam.cs index 5e3f6e8..c5089c1 100644 --- a/SteamCleaner/Clients/Steam.cs +++ b/SteamCleaner/Clients/Steam.cs @@ -23,20 +23,9 @@ public static string FixPath(string dir) public static string GetSteamPath() { - var regPath = ""; var steamPath = ""; var is64Bit = Environment.Is64BitOperatingSystem; - if (is64Bit) - { - Console.WriteLine("64 Bit operating system detected"); - regPath = "SOFTWARE\\Wow6432Node\\Valve\\Steam"; - } - else - { - Console.WriteLine("32 Bit operating system detected"); - regPath = "SOFTWARE\\Valve\\Steam"; - } - + var regPath = is64Bit ? @"SOFTWARE\Wow6432Node\Valve\Steam" : @"SOFTWARE\Valve\Steam"; var key = Registry.LocalMachine.OpenSubKey(regPath); if (key != null) { diff --git a/SteamCleaner/Clients/Uplay.cs b/SteamCleaner/Clients/Uplay.cs index 359f62f..5d52092 100644 --- a/SteamCleaner/Clients/Uplay.cs +++ b/SteamCleaner/Clients/Uplay.cs @@ -13,19 +13,8 @@ class Uplay public static bool Exist() { - var regPath = ""; var is64Bit = Environment.Is64BitOperatingSystem; - if (is64Bit) - { - Console.WriteLine("64 Bit operating system detected"); - regPath = @"Software\Wow6432Node\Ubisoft\Launcher"; - } - else - { - Console.WriteLine("32 Bit operating system detected"); - regPath = @"Software\Ubisoft\Launcher"; - } - + var regPath = is64Bit ? @"Software\Wow6432Node\Ubisoft\Launcher" : @"Software\Ubisoft\Launcher"; var key = Registry.LocalMachine.OpenSubKey(regPath); return key?.GetValue("InstallDir") != null; } @@ -33,19 +22,8 @@ public static bool Exist() public static List GetGames() { var paths = new List(); - var regPath = ""; var is64Bit = Environment.Is64BitOperatingSystem; - if (is64Bit) - { - Console.WriteLine("64 Bit operating system detected"); - regPath = @"SOFTWARE\Wow6432Node\Ubisoft\Launcher\Installs"; - } - else - { - Console.WriteLine("32 Bit operating system detected"); - regPath = @"SOFTWARE\Ubisoft\Launcher\Installs"; - } - + var regPath = is64Bit ? @"Software\Wow6432Node\Ubisoft\Launcher" : @"Software\Ubisoft\Launcher"; var root = Registry.LocalMachine.OpenSubKey(regPath); if (root != null) paths.AddRange( diff --git a/SteamCleaner/MainWindowViewModel.cs b/SteamCleaner/MainWindowViewModel.cs index 0d6d1ed..d168b67 100644 --- a/SteamCleaner/MainWindowViewModel.cs +++ b/SteamCleaner/MainWindowViewModel.cs @@ -73,10 +73,18 @@ private void RunRefresh() { _pathsInternal.Add("Uplay Games Detected"); } - if (Battlenet.Exisit()) + if (Battlenet.Exist()) { _pathsInternal.Add("Battle.net Games Detected"); } + if (Desura.Exist()) + { + _pathsInternal.Add("Desura Games Detected"); + } + if (Custom.Exist()) + { + _pathsInternal.Add("Custom Game Paths Detected"); + } _filesInternal.Clear(); foreach ( var fileViewModel in @@ -95,10 +103,6 @@ private async void RunClean() RunRefresh(); } - private async void CheckForUpdate() - { - Tools.CheckForUpdates(); - } protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { diff --git a/SteamCleaner/SteamCleaner.csproj b/SteamCleaner/SteamCleaner.csproj index 67cfa60..bf273ee 100644 --- a/SteamCleaner/SteamCleaner.csproj +++ b/SteamCleaner/SteamCleaner.csproj @@ -103,6 +103,8 @@ App.xaml + + diff --git a/SteamCleaner/Utilities/CleanerUtilities.cs b/SteamCleaner/Utilities/CleanerUtilities.cs index e9b4430..b982a9e 100644 --- a/SteamCleaner/Utilities/CleanerUtilities.cs +++ b/SteamCleaner/Utilities/CleanerUtilities.cs @@ -56,16 +56,9 @@ private static List DetectRenPyRedistributables(string sDir) return files; } - public static List FindRedistributables() + private static List GetAddtionalGames() { - if (cachedRedistributables != null && !updateRedistributables) - { - return cachedRedistributables; - } - var steamPaths = Steam.SteamPaths(); - var crawlableDirs = steamPaths.Select(steamPath => Steam.FixPath(steamPath)).Where(path => Directory.Exists(path)).ToList(); - var gameDirs = - crawlableDirs.Select(Directory.GetDirectories).SelectMany(directories => directories).ToList(); + var gameDirs = new List(); if (Gog.Exisit()) { gameDirs.AddRange(Gog.GetGames()); @@ -78,10 +71,32 @@ public static List FindRedistributables() { gameDirs.AddRange(Uplay.GetGames()); } - if (Battlenet.Exisit()) + if (Battlenet.Exist()) { gameDirs.AddRange(Battlenet.GetGames()); } + if (Desura.Exist()) + { + gameDirs.AddRange(Desura.GetGames()); + } + if (Custom.Exist()) + { + gameDirs.AddRange(Custom.GetGames()); + } + return gameDirs; + } + + public static List FindRedistributables() + { + if (cachedRedistributables != null && !updateRedistributables) + { + return cachedRedistributables; + } + var steamPaths = Steam.SteamPaths(); + var crawlableDirs = steamPaths.Select(Steam.FixPath).Where(Directory.Exists).ToList(); + var gameDirs = + crawlableDirs.Select(Directory.GetDirectories).SelectMany(directories => directories).ToList(); + gameDirs.AddRange(GetAddtionalGames()); //Probably a better way to detect if some retarded publisher nested their package in a folder, but atm capcom is the only one i've seen do it. foreach ( var nestedGameFolder in diff --git a/version.xml b/version.xml index 297c0d8..c19d526 100644 --- a/version.xml +++ b/version.xml @@ -1,5 +1,5 @@ - 1.9 + 2.0 https://github.com/Codeusa/SteamCleaner/releases/latest