-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential fixes for issues #22, #20, and #19 #23
base: main
Are you sure you want to change the base?
Changes from 13 commits
4e013a8
94b2448
e6499d7
ce2d7e8
ae0cb51
57d1dd2
84f0d2f
6ebf9ab
53c95d0
831bee5
baf9f5d
2dc6b71
0eacf14
419307d
ff676aa
bc14ae4
b8e98c9
514d71c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
using Gameloop.Vdf; | ||
using Gameloop.Vdf.Linq; | ||
using Microsoft.Win32; | ||
using Newtonsoft.Json; | ||
using SunshineGameFinder; | ||
using System.CommandLine; | ||
|
@@ -11,7 +12,20 @@ | |
const string steamLibraryFolders = @"Program Files (x86)\Steam\steamapps\libraryfolders.vdf"; | ||
|
||
// default values | ||
var gameDirs = new List<string>() { @"*:\Program Files (x86)\Steam\steamapps\common", @"*:\XboxGames", @"*:\Program Files\EA Games", @"*:\Program Files\Epic Games\", @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" }; | ||
var gameDirs = new List<string>() { | ||
//@"*:\Program Files (x86)\Steam\steamapps\common", | ||
//@"*:\XboxGames", @"*:\Program Files\EA Games", | ||
//@"*:\Program Files\Epic Games\", | ||
//@"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" | ||
}; | ||
|
||
var registryDir = new List<string>() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove these if they're not being used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is used - need to be declared for ScanFolder method to work, as well as the adding addlDirectories on line 60 |
||
{ | ||
//@"SOFTWARE\Wow6432Node\Valve\Steam", | ||
//@"SOFTWARE\Valve\Steam" | ||
//Other installer registry paths... | ||
}; | ||
|
||
var exclusionWords = new List<string>() { "Steam" }; | ||
var exeExclusionWords = new List<string>() { "Steam", "Cleanup", "DX", "Uninstall", "Touchup", "redist", "Crash", "Editor" }; | ||
|
||
|
@@ -117,7 +131,10 @@ void ScanFolder(string folder) | |
Logger.Log($"Skipping {gameName} as it was an excluded word match..."); | ||
continue; | ||
} | ||
var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories).FirstOrDefault(exefile => { | ||
var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories) | ||
.OrderBy(f => new FileInfo(f).Length) | ||
.FirstOrDefault(exefile => | ||
{ | ||
var exeName = new FileInfo(exefile).Name.ToLower(); | ||
return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); | ||
}); | ||
|
@@ -174,23 +191,75 @@ void ScanFolder(string folder) | |
Console.WriteLine(""); //blank line to separate platforms | ||
} | ||
|
||
string MakePathGooder(string path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename with a more descriptive function name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
{ | ||
string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; | ||
string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); | ||
|
||
return gooderPath; | ||
} | ||
|
||
void RegistrySearch() | ||
{ | ||
foreach (var path in registryDir) | ||
{ | ||
if (path.ToLower().Contains("steam")) | ||
{ | ||
RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); | ||
if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) | ||
{ | ||
string temp = steamRegistry.GetValue("SteamPath").ToString(); | ||
temp = MakePathGooder(temp); | ||
gameDirs.Add(temp); | ||
} | ||
else | ||
{ | ||
steamRegistry = Registry.CurrentUser.OpenSubKey(path); | ||
if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can probably dedupe these 2 conditional blocks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
{ | ||
string temp = steamRegistry.GetValue("SteamPath").ToString(); | ||
temp = MakePathGooder(temp); | ||
gameDirs.Add(temp); | ||
} | ||
} | ||
} | ||
/*else if (path contains other installer keywords) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused comment blocks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
{ | ||
|
||
}*/ | ||
} | ||
} | ||
|
||
var logicalDrives = DriveInfo.GetDrives(); | ||
var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); | ||
|
||
foreach (var drive in logicalDrives) | ||
if (OperatingSystem.IsWindows()) | ||
{ | ||
var libraryFoldersPath = drive.Name + steamLibraryFolders; | ||
var file = new FileInfo(libraryFoldersPath); | ||
if (!file.Exists) | ||
gameDirs = new List<string> | ||
{ | ||
Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); | ||
continue; | ||
} | ||
var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); | ||
foreach(var library in libraries.Value) | ||
@"*:\Program Files (x86)\Steam\steamapps\common", | ||
@"*:\XboxGames", | ||
@"*:\Program Files\EA Games", | ||
@"*:\Program Files\Epic Games\", | ||
@"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" | ||
//Other common directories | ||
}; | ||
|
||
bool isSteamLibraryFound = false; | ||
foreach (var drive in logicalDrives) | ||
{ | ||
if (library is not VProperty libProp) | ||
var libraryFoldersPath = drive.Name + steamLibraryFolders; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add some comments explaining how the Vdf stuff works? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comments to code - not sure if you meant here or there. |
||
var file = new FileInfo(libraryFoldersPath); | ||
if (!file.Exists) | ||
{ | ||
Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); | ||
continue; | ||
} | ||
var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); | ||
foreach (var library in libraries.Value) | ||
{ | ||
if (library is not VProperty libProp) | ||
continue; | ||
|
||
gameDirs.Add($@"{libProp.Value.Value<string>("path")}\steamapps\common"); | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move all the files back to where they were originally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done (i think) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to keep this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PublishProfiles and .pubxml were in the .gitignore - added back |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remov these if they're not being used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used - need to be declared for RegistrySearch method to work