Skip to content

Commit

Permalink
Push release for Custom paths, Battle Net and Desura
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew committed Jan 24, 2016
1 parent ccd0c4f commit b6c08c5
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 99 deletions.
2 changes: 1 addition & 1 deletion SteamCleaner/Clients/Battlenet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
34 changes: 34 additions & 0 deletions SteamCleaner/Clients/CustomPaths.cs
Original file line number Diff line number Diff line change
@@ -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<string> GetGames()
{
var lines = File.ReadAllLines("custom.txt");
List<string> games = new List<string>(lines);
return games;
}
}
}
38 changes: 38 additions & 0 deletions SteamCleaner/Clients/Desura.cs
Original file line number Diff line number Diff line change
@@ -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<string> GetGames()
{
var paths = new List<string>();
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;
}
}
}
27 changes: 3 additions & 24 deletions SteamCleaner/Clients/Gog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,18 @@ 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;
}

public static List<string> GetGames()
{
var paths = new List<string>();
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(
Expand Down
24 changes: 2 additions & 22 deletions SteamCleaner/Clients/Origin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,8 @@ public static List<string> GetGames()
{
if (!Exist()) return null;
var paths = new List<string>();
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(
Expand All @@ -57,16 +46,7 @@ public static List<string> 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(
Expand Down
13 changes: 1 addition & 12 deletions SteamCleaner/Clients/Steam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
26 changes: 2 additions & 24 deletions SteamCleaner/Clients/Uplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,17 @@ 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;
}

public static List<string> GetGames()
{
var paths = new List<string>();
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(
Expand Down
14 changes: 9 additions & 5 deletions SteamCleaner/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -95,10 +103,6 @@ private async void RunClean()
RunRefresh();
}

private async void CheckForUpdate()
{
Tools.CheckForUpdates();
}

protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
Expand Down
2 changes: 2 additions & 0 deletions SteamCleaner/SteamCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Clients\Battlenet.cs" />
<Compile Include="Clients\CustomPaths.cs" />
<Compile Include="Clients\Desura.cs" />
<Compile Include="Clients\Origin.cs" />
<Compile Include="Clients\Uplay.cs" />
<Compile Include="ConfirmationDialog.xaml.cs">
Expand Down
35 changes: 25 additions & 10 deletions SteamCleaner/Utilities/CleanerUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,9 @@ private static List<string> DetectRenPyRedistributables(string sDir)
return files;
}

public static List<Redistributables> FindRedistributables()
private static List<string> 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<string>();
if (Gog.Exisit())
{
gameDirs.AddRange(Gog.GetGames());
Expand All @@ -78,10 +71,32 @@ public static List<Redistributables> 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<Redistributables> 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
Expand Down
2 changes: 1 addition & 1 deletion version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<steamcleaner>
<version>1.9</version>
<version>2.0</version>
<url>https://github.com/Codeusa/SteamCleaner/releases/latest</url>
</steamcleaner>

0 comments on commit b6c08c5

Please sign in to comment.