mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Fixing library with no installed games error
Both Steam and Uplay library logic would error when the library was installed, but didn't have any installed games. Thanks to @joeymanson23 for the report. Fixes #4. Adds a LOT more logging to the Steam and Uplay libraries to allow for remote troubleshooting via the log file, especially if the logging settings are set to TRACE. Also fixed the long standing issue for being able to install two copies of DisplayMagician of the same version. Now the installer will prevent that from happening!
This commit is contained in:
parent
3fcd90a542
commit
a377f3477f
@ -20,8 +20,8 @@ namespace DisplayMagician.GameLibraries
|
||||
private static string _steamExe;
|
||||
private static string _steamPath;
|
||||
private static string _steamConfigVdfFile;
|
||||
private static string _registrySteamKey = @"SOFTWARE\\Valve\\Steam";
|
||||
private static string _registryAppsKey = $@"{_registrySteamKey}\\Apps";
|
||||
private static string _registrySteamKey = @"SOFTWARE\WOW6432Node\Valve\Steam"; // under LocalMachine
|
||||
private static string _registryAppsKey = $@"SOFTWARE\Valve\Steam\Apps"; // under CurrentUser
|
||||
private static bool _isSteamInstalled = false;
|
||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
// Other constants that are useful
|
||||
@ -41,32 +41,40 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Trace($"SteamLibrary/SteamLibrary: Steam launcher registry key = HKLM\\{_registrySteamKey}");
|
||||
// Find the SteamExe location, and the SteamPath for later
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(SteamLibrary.SteamRegistryKey, RegistryKeyPermissionCheck.ReadSubTree))
|
||||
using (var steamInstallKey = Registry.LocalMachine.OpenSubKey(_registrySteamKey, RegistryKeyPermissionCheck.ReadSubTree))
|
||||
{
|
||||
_steamExe = (string)key?.GetValue(@"SteamExe", string.Empty) ?? string.Empty;
|
||||
_steamExe = _steamExe.Replace('/', '\\');
|
||||
_steamPath = (string)key?.GetValue(@"SteamPath", string.Empty) ?? string.Empty;
|
||||
_steamPath = _steamPath.Replace('/', '\\');
|
||||
}
|
||||
if (steamInstallKey == null)
|
||||
return;
|
||||
_steamPath = steamInstallKey.GetValue("InstallPath", "C:\\Program Files (x86)\\Steam").ToString();
|
||||
_steamExe = $"{_steamPath}\\steam.exe";
|
||||
}
|
||||
if (File.Exists(_steamExe))
|
||||
_isSteamInstalled = true;
|
||||
{
|
||||
logger.Info($"SteamLibrary/SteamLibrary: Steam library is installed in {_steamPath}. Found {_steamExe}");
|
||||
_isSteamInstalled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info($"SteamLibrary/SteamLibrary: Steam library is not installed!");
|
||||
}
|
||||
}
|
||||
catch (SecurityException ex)
|
||||
{
|
||||
logger.Warn(ex,"The user does not have the permissions required to read the Steam registry key.");
|
||||
logger.Warn(ex, "SteamLibrary/SteamLibrary: The user does not have the permissions required to read the Steam registry key.");
|
||||
}
|
||||
catch (ObjectDisposedException ex)
|
||||
{
|
||||
logger.Warn(ex, "The Microsoft.Win32.RegistryKey is closed when trying to access theSteam registry key (closed keys cannot be accessed).");
|
||||
logger.Warn(ex, "SteamLibrary/SteamLibrary: The Microsoft.Win32.RegistryKey is closed when trying to access the Steam registry key (closed keys cannot be accessed).");
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.Warn(ex, "The Steam registry key has been marked for deletion so we cannot access the value during the SteamLibrary check.");
|
||||
logger.Warn(ex, "SteamLibrary/SteamLibrary: The Steam registry key has been marked for deletion so we cannot access the value during the SteamLibrary check.");
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
logger.Warn(ex, "The user does not have the necessary registry rights to check whether Steam is installed.");
|
||||
logger.Warn(ex, "SteamLibrary/SteamLibrary: The user does not have the necessary registry rights to check whether Steam is installed.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -146,12 +154,14 @@ namespace DisplayMagician.GameLibraries
|
||||
// Because then we just update the one that already exists
|
||||
if (ContainsSteamGame(steamGame))
|
||||
{
|
||||
logger.Debug($"SteamLibrary/AddSteamGame: Updating Steam game {steamGame.Name} in our Steam library");
|
||||
// We update the existing Shortcut with the data over
|
||||
SteamGame steamGameToUpdate = GetSteamGame(steamGame.Id.ToString());
|
||||
steamGame.CopyInto(steamGameToUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Debug($"SteamLibrary/AddSteamGame: Adding Steam game {steamGame.Name} to our Steam library");
|
||||
// Add the steamGame to the list of steamGames
|
||||
_allSteamGames.Add(steamGame);
|
||||
}
|
||||
@ -171,15 +181,21 @@ namespace DisplayMagician.GameLibraries
|
||||
if (!(steamGame is SteamGame))
|
||||
return false;
|
||||
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame: Removing Steam game {steamGame.Name} from our Steam library");
|
||||
|
||||
// Remove the steamGame from the list.
|
||||
int numRemoved = _allSteamGames.RemoveAll(item => item.Id.Equals(steamGame.Id));
|
||||
|
||||
if (numRemoved == 1)
|
||||
{
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame: Removed Steam game with name {steamGame.Name}");
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
{
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame: Didn't remove Steam game with ID {steamGame.Name} from the Steam Library");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw new SteamLibraryException();
|
||||
}
|
||||
@ -189,15 +205,21 @@ namespace DisplayMagician.GameLibraries
|
||||
if (steamGameId<=0)
|
||||
return false;
|
||||
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame2: Removing Steam game with ID {steamGameId} from the Steam library");
|
||||
|
||||
// Remove the steamGame from the list.
|
||||
int numRemoved = _allSteamGames.RemoveAll(item => item.Id.Equals(steamGameId));
|
||||
|
||||
if (numRemoved == 1)
|
||||
{
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame2: Removed Steam game with ID {steamGameId}");
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
{
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame2: Didn't remove Steam game with ID {steamGameId} from the Steam Library");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw new SteamLibraryException();
|
||||
}
|
||||
@ -208,6 +230,8 @@ namespace DisplayMagician.GameLibraries
|
||||
if (String.IsNullOrWhiteSpace(steamGameNameOrUuid))
|
||||
return false;
|
||||
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame3: Removing Steam game with Name or UUID {steamGameNameOrUuid} from the Steam library");
|
||||
|
||||
int numRemoved;
|
||||
Match match = Regex.Match(steamGameNameOrUuid, steamAppIdRegex, RegexOptions.IgnoreCase);
|
||||
if (match.Success)
|
||||
@ -216,9 +240,15 @@ namespace DisplayMagician.GameLibraries
|
||||
numRemoved = _allSteamGames.RemoveAll(item => steamGameNameOrUuid.Equals(item.Name));
|
||||
|
||||
if (numRemoved == 1)
|
||||
{
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame3: Removed Steam game with Name or UUID {steamGameNameOrUuid} ");
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
{
|
||||
logger.Debug($"SteamLibrary/RemoveSteamGame3: Didn't remove Steam game with Name or UUID {steamGameNameOrUuid} from the Steam Library");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw new SteamLibraryException();
|
||||
|
||||
@ -328,26 +358,15 @@ namespace DisplayMagician.GameLibraries
|
||||
try
|
||||
{
|
||||
|
||||
// Find the SteamExe location, and the SteamPath for later
|
||||
/*using (var key = Registry.CurrentUser.OpenSubKey(_registrySteamKey, RegistryKeyPermissionCheck.ReadSubTree))
|
||||
{
|
||||
_steamExe = (string)key?.GetValue(@"SteamExe", string.Empty) ?? string.Empty;
|
||||
_steamExe = _steamExe.Replace('/', '\\');
|
||||
_steamPath = (string)key?.GetValue(@"SteamPath", string.Empty) ?? string.Empty;
|
||||
_steamPath = _steamPath.Replace('/', '\\');
|
||||
}*/
|
||||
|
||||
if (!_isSteamInstalled)
|
||||
{
|
||||
// Steam isn't installed, so we return an empty list.
|
||||
logger.Info($"SteamLibrary/LoadInstalledGames: Steam library is not installed");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Icon _steamIcon = Icon.ExtractAssociatedIcon(_steamExe);
|
||||
//IconExtractor steamIconExtractor = new IconExtractor(_steamExe);
|
||||
//Icon _steamIcon = steamIconExtractor.GetIcon(0);
|
||||
//MultiIcon _steamIcon = new MultiIcon();
|
||||
//_steamIcon.Load(_steamExe);
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Steam Base Registry Key = HKLM\\{_registrySteamKey}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Steam Apps Registry Key = HKCU\\{_registryAppsKey}");
|
||||
|
||||
List<int> steamAppIdsInstalled = new List<int>();
|
||||
// Now look for what games app id's are actually installed on this computer
|
||||
@ -355,11 +374,14 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
if (steamAppsKey != null)
|
||||
{
|
||||
//
|
||||
// Loop through the subKeys as they are the Steam Game IDs
|
||||
foreach (string steamGameKeyName in steamAppsKey.GetSubKeyNames())
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found SteamGameKeyName = {steamGameKeyName}");
|
||||
if (int.TryParse(steamGameKeyName, out int steamAppId))
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: SteamGameKeyName is an int, so trying to see if it is a game");
|
||||
string steamGameKeyFullName = $"{_registryAppsKey}\\{steamGameKeyName}";
|
||||
using (RegistryKey steamGameKey = Registry.CurrentUser.OpenSubKey(steamGameKeyFullName, RegistryKeyPermissionCheck.ReadSubTree))
|
||||
{
|
||||
@ -367,14 +389,36 @@ namespace DisplayMagician.GameLibraries
|
||||
// We want to keep track of that for later
|
||||
if ((int)steamGameKey.GetValue(@"Installed", 0) == 1)
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: {steamGameKeyFullName} contains an 'Installed' value so is an installed Steam Game.");
|
||||
// Add this Steam App ID to the list we're keeping for later
|
||||
steamAppIdsInstalled.Add(steamAppId);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: {steamGameKeyFullName} does not contain an 'Installed' value so can't be a Steam Game.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (steamAppIdsInstalled.Count == 0)
|
||||
{
|
||||
// There aren't any game ids so return false
|
||||
logger.Warn($"SteamLibrary/LoadInstalledGames: No Steam games installed in the Steam library");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info($"SteamLibrary/LoadInstalledGames: Found {steamAppIdsInstalled.Count} installed games in the Steam library");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// There isnt any steam registry key
|
||||
logger.Warn($"SteamLibrary/LoadInstalledGames: Couldn't access the Steam Registry Key {_registrySteamKey}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,7 +433,7 @@ namespace DisplayMagician.GameLibraries
|
||||
var newAppInfo = new AppInfo();
|
||||
newAppInfo.Read(appInfoVdfFile);
|
||||
|
||||
Debug.WriteLine($"{newAppInfo.Apps.Count} apps");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found {newAppInfo.Apps.Count} apps in the {appInfoVdfFile} VDF file");
|
||||
|
||||
// Chec through all the apps we've extracted
|
||||
foreach (var app in newAppInfo.Apps)
|
||||
@ -411,28 +455,30 @@ namespace DisplayMagician.GameLibraries
|
||||
|
||||
foreach (KVObject data in app.Data)
|
||||
{
|
||||
//Debug.WriteLine($"App: {app.AppID} - Data.Name: {data.Name}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found App: {app.AppID} - Data.Name: {data.Name}");
|
||||
|
||||
if (data.Name == "common")
|
||||
{
|
||||
foreach (KVObject common in data.Children)
|
||||
{
|
||||
|
||||
//Debug.WriteLine($"App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
|
||||
if (common.Name == "name")
|
||||
{
|
||||
Debug.WriteLine($"App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: name: App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
steamGameAppInfo.GameName = common.Value.ToString();
|
||||
}
|
||||
else if (common.Name == "clienticon")
|
||||
{
|
||||
Debug.WriteLine($"App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: clienticon: App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
steamGameAppInfo.GameSteamIconPath = Path.Combine(_steamPath, @"steam", @"games", String.Concat(common.Value, @".ico"));
|
||||
}
|
||||
else if (common.Name == "type")
|
||||
{
|
||||
Debug.WriteLine($"App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: type: App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found unrecognised line App: {app.AppID} - Common {common.Name}: {common.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -444,7 +490,7 @@ namespace DisplayMagician.GameLibraries
|
||||
|
||||
if (config.Name == "installdir")
|
||||
{
|
||||
Debug.WriteLine($"App: {detectedAppID} - Config {config.Name}: {config.Value}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found installdir App: {detectedAppID} - Config {config.Name}: {config.Value}");
|
||||
steamGameAppInfo.GameInstallDir = config.Value.ToString();
|
||||
}
|
||||
else if (config.Name == "launch")
|
||||
@ -455,7 +501,7 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
if (launch_num.Name == "executable")
|
||||
{
|
||||
Debug.WriteLine($"App: {detectedAppID} - Config - Launch {launch.Name} - {launch_num.Name}: {launch_num.Value}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found launch executable App: {detectedAppID} - Config - Launch {launch.Name} - {launch_num.Name}: {launch_num.Value}");
|
||||
steamGameAppInfo.GameExes.Add(launch_num.Value.ToString());
|
||||
}
|
||||
|
||||
@ -470,11 +516,11 @@ namespace DisplayMagician.GameLibraries
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Console.WriteLine($"SteamGame/GetAllInstalledGames exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
|
||||
logger.Warn(ex, $"SteamLibrary/LoadInstalledGames: ArgumentException while processing the {appInfoVdfFile} VDF file");
|
||||
//we just want to ignore it if we try to add it twice....
|
||||
}
|
||||
|
||||
Debug.WriteLine($"App: {detectedAppID} - Token: {app.Token}");
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found end of loop App: {detectedAppID} - Token: {app.Token}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,6 +531,8 @@ namespace DisplayMagician.GameLibraries
|
||||
_steamConfigVdfFile = Path.Combine(_steamPath, "config", "config.vdf");
|
||||
string steamConfigVdfText = File.ReadAllText(_steamConfigVdfFile, Encoding.UTF8);
|
||||
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Processing the {_steamConfigVdfFile} VDF file");
|
||||
|
||||
List<string> steamLibrariesPaths = new List<string>();
|
||||
// Now we have to parse the config.vdf looking for the location of the SteamLibraries
|
||||
// We look for lines similar to this: "BaseInstallFolder_1" "E:\\SteamLibrary"
|
||||
@ -498,7 +546,7 @@ namespace DisplayMagician.GameLibraries
|
||||
if (steamLibraryMatch.Success)
|
||||
{
|
||||
string steamLibraryPath = Regex.Unescape(steamLibraryMatch.Groups[1].Value);
|
||||
Debug.WriteLine($"Found steam library: {steamLibraryPath}");
|
||||
logger.Info($"SteamLibrary/LoadInstalledGames: Found steam library {steamLibraryPath}");
|
||||
steamLibrariesPaths.Add(steamLibraryPath);
|
||||
}
|
||||
}
|
||||
@ -512,6 +560,7 @@ namespace DisplayMagician.GameLibraries
|
||||
// Go through each app and extract it's details
|
||||
foreach (string steamLibraryAppManifestFilename in steamLibraryAppManifestFilenames)
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found {steamLibraryAppManifestFilename} app manifest within steam library {steamLibraryPath}");
|
||||
// Read in the contents of the file
|
||||
string steamLibraryAppManifestText = File.ReadAllText(steamLibraryAppManifestFilename);
|
||||
// Grab the appid from the file
|
||||
@ -519,12 +568,13 @@ namespace DisplayMagician.GameLibraries
|
||||
Match appidMatches = appidRegex.Match(steamLibraryAppManifestText);
|
||||
if (appidMatches.Success)
|
||||
{
|
||||
|
||||
if (int.TryParse(appidMatches.Groups[1].Value, out int steamGameId))
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Found Steam Game ID {steamGameId} within {steamLibraryAppManifestFilename} steam app manifest within steam library {steamLibraryPath}");
|
||||
// Check if this game is one that was installed
|
||||
if (steamAppInfo.ContainsKey(steamGameId))
|
||||
{
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Steam Game ID {steamGameId} is installed within steam library {steamLibraryPath}!");
|
||||
// This game is an installed game! so we start to populate it with data!
|
||||
string steamGameExe = "";
|
||||
|
||||
@ -533,6 +583,8 @@ namespace DisplayMagician.GameLibraries
|
||||
// Construct the full path to the game dir from the appInfo and libraryAppManifest data
|
||||
string steamGameInstallDir = Path.Combine(steamLibraryPath, @"steamapps", @"common", steamAppInfo[steamGameId].GameInstallDir);
|
||||
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Looking for Steam Game ID {steamGameId} at {steamGameInstallDir }");
|
||||
|
||||
// And finally we try to populate the 'where', to see what gets run
|
||||
// And so we can extract the process name
|
||||
if (steamAppInfo[steamGameId].GameExes.Count > 0)
|
||||
@ -540,9 +592,11 @@ namespace DisplayMagician.GameLibraries
|
||||
foreach (string gameExe in steamAppInfo[steamGameId].GameExes)
|
||||
{
|
||||
steamGameExe = Path.Combine(steamGameInstallDir, gameExe);
|
||||
logger.Trace($"SteamLibrary/LoadInstalledGames: Looking for Steam Game Exe {steamGameExe} for Steam Game ID {steamGameId} at {steamGameInstallDir }");
|
||||
// If the game executable exists, then we can proceed
|
||||
if (File.Exists(steamGameExe))
|
||||
{
|
||||
logger.Debug($"SteamLibrary/LoadInstalledGames: Found Steam Game Exe {steamGameExe} for Steam Game ID {steamGameId} at {steamGameInstallDir }");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -555,57 +609,59 @@ namespace DisplayMagician.GameLibraries
|
||||
if (File.Exists(steamAppInfo[steamGameId].GameSteamIconPath) && steamAppInfo[steamGameId].GameSteamIconPath.EndsWith(".ico"))
|
||||
{
|
||||
steamGameIconPath = steamAppInfo[steamGameId].GameSteamIconPath;
|
||||
logger.Debug($"SteamLibrary/LoadInstalledGames: Found Steam Game Icon Path {steamGameIconPath} for Steam Game ID {steamGameId} at {steamGameInstallDir }");
|
||||
|
||||
}
|
||||
// If there isn't an icon for us to use, then we need to extract one from the Game Executables
|
||||
else if (!String.IsNullOrEmpty(steamGameExe))
|
||||
{
|
||||
steamGameIconPath = steamGameExe;
|
||||
logger.Debug($"SteamLibrary/LoadInstalledGames: Found Steam Game Icon Path {steamGameIconPath} for Steam Game ID {steamGameId} at {steamGameInstallDir }");
|
||||
}
|
||||
// The absolute worst case means we don't have an icon to use. SO we use the Steam one.
|
||||
else
|
||||
{
|
||||
// And we have to make do with a Steam Icon
|
||||
logger.Debug($"SteamLibrary/LoadInstalledGames: Couldn't find Steam Game Icon Path {steamGameIconPath} for Steam Game ID {steamGameId} so using default Steam Icon");
|
||||
steamGameIconPath = _steamPath;
|
||||
}
|
||||
|
||||
// And we add the Game to the list of games we have!
|
||||
_allSteamGames.Add(new SteamGame(steamGameId, steamGameName, steamGameExe, steamGameIconPath));
|
||||
|
||||
logger.Debug($"SteamLibrary/LoadInstalledGames: Adding Steam Game with game id {steamGameId}, name {steamGameName}, game exe {steamGameExe} and icon path {steamGameIconPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
logger.Warn(ex, "SteamLibrary/GetAllInstalledGames: An argument supplied to the function is null.");
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
logger.Warn(ex, "SteamLibrary/GetAllInstalledGames: The invoked method is not supported or reading, seeking or writing tp a stream that isn't supported.");
|
||||
}
|
||||
catch (PathTooLongException ex)
|
||||
{
|
||||
logger.Warn(ex, "SteamLibrary/GetAllInstalledGames: The path is longer than the maximum allowed by the operating system.");
|
||||
}
|
||||
catch (SecurityException ex)
|
||||
{
|
||||
Console.WriteLine($"SteamGame/GetAllInstalledGames securityexception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
|
||||
if (ex.Source != null)
|
||||
Console.WriteLine("SecurityException source: {0} - Message: {1}", ex.Source, ex.Message);
|
||||
throw;
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
Console.WriteLine($"SteamGame/GetAllInstalledGames unauthorizedaccessexception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
|
||||
if (ex.Source != null)
|
||||
Console.WriteLine("UnauthorizedAccessException source: {0} - Message: {1}", ex.Source, ex.Message);
|
||||
throw;
|
||||
logger.Warn(ex, "SteamLibrary/GetAllInstalledGames: The user does not have the permissions required to read the Uplay InstallDir registry key.");
|
||||
}
|
||||
catch (ObjectDisposedException ex)
|
||||
{
|
||||
Console.WriteLine($"SteamGame/GetAllInstalledGames objectdisposedexceptions: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
|
||||
if (ex.Source != null)
|
||||
Console.WriteLine("ObjectDisposedException source: {0} - Message: {1}", ex.Source, ex.Message);
|
||||
throw;
|
||||
logger.Warn(ex, "SteamLibrary/GetAllInstalledGames: The Microsoft.Win32.RegistryKey is closed when trying to access the Uplay InstallDir registry key (closed keys cannot be accessed).");
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Console.WriteLine($"SteamGame/GetAllInstalledGames ioexception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
|
||||
// Extract some information from this exception, and then
|
||||
// throw it to the parent method.
|
||||
if (ex.Source != null)
|
||||
Console.WriteLine("IOException source: {0} - Message: {1}", ex.Source, ex.Message);
|
||||
throw;
|
||||
logger.Warn(ex, "SteamLibrary/GetAllInstalledGames: The Uplay InstallDir registry key has been marked for deletion so we cannot access the value dueing the UplayLibrary check.");
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
logger.Warn(ex, "SteamLibrary/GetAllInstalledGames: The user does not have the necessary registry rights to check whether Uplay is installed.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -41,6 +41,7 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Trace($"UplayLibrary/UplayLibrary: Uplay launcher registry key = HKLM\\{registryUplayLauncherKey}");
|
||||
// Find the UplayExe location, and the UplayPath for later
|
||||
RegistryKey uplayInstallKey = Registry.LocalMachine.OpenSubKey(registryUplayLauncherKey, RegistryKeyPermissionCheck.ReadSubTree);
|
||||
if (uplayInstallKey == null)
|
||||
@ -177,8 +178,7 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame: Didn't remove Uplay game with ID {uplayGame.Name} from the Uplay Library");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
throw new UplayLibraryException();
|
||||
}
|
||||
@ -343,11 +343,63 @@ namespace DisplayMagician.GameLibraries
|
||||
if (!_isUplayInstalled)
|
||||
{
|
||||
// Uplay isn't installed, so we return an empty list.
|
||||
logger.Debug($"UplayLibrary/LoadInstalledGames: Uplay library is not installed, so returning false");
|
||||
logger.Info($"UplayLibrary/LoadInstalledGames: Uplay library is not installed");
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Uplay Game Installs Registry Key = HKLM\\{registryUplayInstallsKey}");
|
||||
|
||||
using (RegistryKey uplayInstallKey = Registry.LocalMachine.OpenSubKey(registryUplayInstallsKey, RegistryKeyPermissionCheck.ReadSubTree))
|
||||
{
|
||||
if (uplayInstallKey != null)
|
||||
{
|
||||
int uplayGamesInstalledCount = 0;
|
||||
// Loop through the subKeys as they are the Steam Game IDs
|
||||
foreach (string uplayGameKeyName in uplayInstallKey.GetSubKeyNames())
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found uplayGameKeyName = {uplayGameKeyName}");
|
||||
if (int.TryParse(uplayGameKeyName, out int uplayGameId))
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: uplayGameKeyName is an int, so trying to see if it is a game");
|
||||
string uplayGameKeyFullName = $"{registryUplayInstallsKey}\\{uplayGameKeyName}";
|
||||
using (RegistryKey uplayGameKey = Registry.LocalMachine.OpenSubKey(uplayGameKeyFullName, RegistryKeyPermissionCheck.ReadSubTree))
|
||||
{
|
||||
// If the Installed Value is set to 1, then the game is installed
|
||||
// We want to keep track of that for later
|
||||
if (!uplayGameKey.GetValue(@"InstallDir", "").ToString().Equals(""))
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: {uplayGameKey} contains an 'InstallDir' value so is an installed Uplay Game.");
|
||||
// Add this Steam App ID to the list we're keeping for later
|
||||
uplayGamesInstalledCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: {uplayGameKey} does not contain an 'Installed' value so can't be a Uplay Game.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uplayGamesInstalledCount == 0)
|
||||
{
|
||||
// There aren't any game ids so return false
|
||||
logger.Warn($"UplayLibrary/LoadInstalledGames: No Uplay games installed in the Uplay library");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info($"UplayLibrary/LoadInstalledGames: Found {uplayGamesInstalledCount} installed games in the Uplay library");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// There isnt any Uplay registry key
|
||||
logger.Warn($"UplayLibrary/LoadInstalledGames: Couldn't access the Uplay Registry Key {registryUplayInstallsKey}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Look in HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Ubisoft\\Launcher and check the InstallDir key
|
||||
// That returns the location of the install dir : E:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\
|
||||
|
||||
@ -431,7 +483,11 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
// Stop this loop once we have both filname and gameid
|
||||
if (gotGameFileName && gotGameId && gotGameIconPath && gotGameName)
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: We got all the entries: gameFileName = {gameFileName } && gameId = {gameId } && gameIconPath = {uplayGameAppInfo.GameUplayIconPath} && gameName = {uplayGameAppInfo.GameName}");
|
||||
break;
|
||||
}
|
||||
|
||||
// This line contains the Game Name
|
||||
if (uplayEntryLines[i].StartsWith(" name:", StringComparison.OrdinalIgnoreCase) && !gotGameName)
|
||||
{
|
||||
@ -442,6 +498,7 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
uplayGameAppInfo.GameName = localizations[uplayGameAppInfo.GameName];
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found uplayGameAppInfo.GameName = {uplayGameAppInfo.GameName}");
|
||||
gotGameName = true;
|
||||
}
|
||||
else if (uplayEntryLines[i].StartsWith(" icon_image:", StringComparison.OrdinalIgnoreCase) && !gotGameIconPath)
|
||||
@ -452,12 +509,14 @@ namespace DisplayMagician.GameLibraries
|
||||
if (localizations.ContainsKey(iconImageFileName))
|
||||
{
|
||||
iconImageFileName = localizations[iconImageFileName];
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found iconImageFile = {iconImageFileName }");
|
||||
}
|
||||
//61fdd16f06ae08158d0a6d476f1c6bd5.ico
|
||||
string uplayGameIconPath = _uplayPath + @"data\games\" + iconImageFileName;
|
||||
if (File.Exists(uplayGameIconPath) && uplayGameIconPath.EndsWith(".ico"))
|
||||
{
|
||||
uplayGameAppInfo.GameUplayIconPath = uplayGameIconPath;
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found uplayGameAppInfo.GameUplayIconPath = {uplayGameAppInfo.GameUplayIconPath }");
|
||||
}
|
||||
gotGameIconPath = true;
|
||||
}
|
||||
@ -467,6 +526,7 @@ namespace DisplayMagician.GameLibraries
|
||||
mc = Regex.Matches(uplayEntryLines[i], @"relative: (.*)");
|
||||
gameFileName = mc[0].Groups[1].ToString();
|
||||
gotGameFileName = true;
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found gameFileName = {gameFileName}");
|
||||
}
|
||||
// This line contains the registryKey
|
||||
else if (uplayEntryLines[i].StartsWith(" register: HKEY_LOCAL_MACHINE") && !gotGameId)
|
||||
@ -475,6 +535,7 @@ namespace DisplayMagician.GameLibraries
|
||||
mc = Regex.Matches(uplayEntryLines[i], @"Installs\\(\d+)\\InstallDir");
|
||||
gameId = mc[0].Groups[1].ToString();
|
||||
gotGameId = true;
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found gameId = {gameId}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,6 +571,7 @@ namespace DisplayMagician.GameLibraries
|
||||
// Then we have the gameID, the thumbimage, the icon, the name, the exe path
|
||||
// And we add the Game to the list of games we have!
|
||||
_allUplayGames.Add(new UplayGame(uplayGameAppInfo.GameID, uplayGameAppInfo.GameName, uplayGameAppInfo.GameExe, uplayGameAppInfo.GameUplayIconPath));
|
||||
logger.Debug($"UplayLibrary/LoadInstalledGames: Adding Uplay Game with game id {uplayGameAppInfo.GameID}, name {uplayGameAppInfo.GameName}, game exe {uplayGameAppInfo.GameExe} and icon path {uplayGameAppInfo.GameUplayIconPath}");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -722,7 +722,6 @@ namespace DisplayMagician {
|
||||
if (!DisplayMagician.GameLibraries.SteamLibrary.LoadInstalledGames())
|
||||
{
|
||||
logger.Info($"Program/LoadGamesInBackground: Cannot load installed Steam Games!");
|
||||
throw new LoadingInstalledGamesException("Program/LoadGamesInBackground: Cannot load installed Steam Games!");
|
||||
}
|
||||
Console.WriteLine("Done.");
|
||||
logger.Info($"Program/LoadGamesInBackground: Loaded all Installed Steam Games (found {GameLibraries.SteamLibrary.InstalledSteamGameCount})");
|
||||
@ -746,7 +745,6 @@ namespace DisplayMagician {
|
||||
if (!DisplayMagician.GameLibraries.UplayLibrary.LoadInstalledGames())
|
||||
{
|
||||
logger.Info($"Program/LoadGamesInBackground: Cannot load installed Uplay Games!");
|
||||
throw new LoadingInstalledGamesException("Program/LoadGamesInBackground: Cannot load installed Uplay Games!");
|
||||
}
|
||||
Console.WriteLine("Done.");
|
||||
logger.Info($"Program/LoadGamesInBackground: Loaded all Installed Uplay Games (found {GameLibraries.UplayLibrary.InstalledUplayGameCount})");
|
||||
|
@ -37,8 +37,8 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
[assembly: AssemblyVersion("1.0.3.*")]
|
||||
[assembly: AssemblyFileVersion("1.0.3.0")]
|
||||
[assembly: AssemblyVersion("1.0.3.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.3.1")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
@ -10,6 +10,14 @@
|
||||
<!-- Revision is NOT used by WiX in the upgrade procedure -->
|
||||
<!-- Full version number to display -->
|
||||
<?define VersionNumber="$(var.MajorVersion).$(var.MinorVersion).$(var.BuildVersion)" ?>
|
||||
|
||||
<?define PreviousMajorVersion="1" ?>
|
||||
<?define PreviousMinorVersion="0" ?>
|
||||
<?define PreviousBuildVersion="2" ?>
|
||||
<!-- Revision is NOT used by WiX in the upgrade procedure -->
|
||||
<!-- Full version number to display -->
|
||||
<?define PreviousVersionNumber="$(var.PreviousMajorVersion).$(var.PreviousMinorVersion).$(var.PreviousBuildVersion)" ?>
|
||||
|
||||
<!--
|
||||
Upgrade code HAS to be the same for all updates.
|
||||
Once you've chosen it don't change it.
|
||||
|
@ -15,12 +15,20 @@
|
||||
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
|
||||
<!-- Upgrade settings. This will be explained in more detail in a future post -->
|
||||
<Upgrade Id="$(var.UpgradeCode)">
|
||||
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.VersionNumber)" IncludeMinimum="no" Property="NEWER_VERSION_FOUND" />
|
||||
<UpgradeVersion Minimum="0.0.0.0" IncludeMinimum="yes" Maximum="$(var.VersionNumber)" IncludeMaximum="no" Property="OLDER_VERSION_FOUND" IgnoreRemoveFailure="yes" />
|
||||
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.VersionNumber)" IncludeMinimum="no" Property="NEWERFOUND" />
|
||||
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.VersionNumber)" Maximum="$(var.VersionNumber)" IncludeMinimum="yes" IncludeMaximum="yes" Property="SELFFOUND" />
|
||||
<UpgradeVersion Minimum="0.0.0.0" IncludeMinimum="no" Maximum="$(var.VersionNumber)" IncludeMaximum="no" Property="OLDER_VERSION_FOUND" IgnoreRemoveFailure="yes" />
|
||||
</Upgrade>
|
||||
<Condition Message="A newer version of [ProductName] is already installed.">
|
||||
NOT NEWER_VERSION_FOUND
|
||||
|
||||
<CustomAction Id='AlreadyUpdated' Error='!(loc.ProductName) has already been updated to $(var.VersionNumber) or newer. If you want to reinstall this version then uninstall !(loc.ProductName) first.' />
|
||||
<CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' />
|
||||
|
||||
<!--<Condition Message="A newer version of [ProductName] is already installed.">
|
||||
NEWER_FOUND
|
||||
</Condition>
|
||||
<Condition Message="You are trying to upgrade to the same version of [ProductName].">
|
||||
SELF_FOUND
|
||||
</Condition>-->
|
||||
<!--<MajorUpgrade IgnoreRemoveFailure="yes" AllowDowngrades="no" AllowSameVersionUpgrades="no" DowngradeErrorMessage="!(loc.DowngradeErrorMessage)" />-->
|
||||
<!-- Reference the global WIXNETFX4RELEASEINSTALLED property so that will automatically pull in the .Net 4.8 variables (WiX 3.14 and higher only supported) -->
|
||||
<!--<PropertyRef Id="WIX_IS_NETFRAMEWORK_48_OR_LATER_INSTALLED"/>
|
||||
@ -143,6 +151,8 @@
|
||||
<RemoveExistingProducts After="InstallInitialize"/>
|
||||
<Custom Action="InstallShell" After="InstallFiles">NOT Installed</Custom>
|
||||
<Custom Action="UninstallShell" Before="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
|
||||
<Custom Action='AlreadyUpdated' After='FindRelatedProducts'>SELFFOUND</Custom>
|
||||
<Custom Action='NoDowngrade' After='FindRelatedProducts'>NEWERFOUND</Custom>
|
||||
</InstallExecuteSequence>
|
||||
|
||||
<!-- Set the components defined in our fragment files that will be used for our feature -->
|
||||
|
Loading…
Reference in New Issue
Block a user