mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #271 from erri120/steam-fixes
SteamHandler and ExceptionManager fixes
This commit is contained in:
commit
38c2ad0aa9
@ -33,25 +33,26 @@ namespace Wabbajack.Common
|
||||
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);
|
||||
var tempKey = progIDKey?.OpenSubKey("shell\\open\\command");
|
||||
if (progIDKey == null || tempKey == null) return true;
|
||||
return tempKey.GetValue("").ToString().Equals($"\"{appPath}\" -i \"%1\"");
|
||||
var value = tempKey.GetValue("");
|
||||
return value == null || value.ToString().Equals($"\"{appPath}\" -i \"%1\"");
|
||||
}
|
||||
|
||||
public static bool IsAssociated()
|
||||
{
|
||||
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);
|
||||
var extKey = Registry.CurrentUser.OpenSubKey(ExtPath);
|
||||
return (progIDKey != null && extKey != null);
|
||||
return progIDKey != null && extKey != null;
|
||||
}
|
||||
|
||||
public static void Associate(string appPath)
|
||||
{
|
||||
var progIDKey = Registry.CurrentUser.CreateSubKey(ProgIDPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
foreach (KeyValuePair<string, string> entry in ProgIDList)
|
||||
foreach (var entry in ProgIDList)
|
||||
{
|
||||
if (entry.Key.Contains("\\"))
|
||||
{
|
||||
var tempKey = progIDKey.CreateSubKey(entry.Key);
|
||||
tempKey.SetValue("", entry.Value.Replace("{appPath}", appPath));
|
||||
var tempKey = progIDKey?.CreateSubKey(entry.Key);
|
||||
tempKey?.SetValue("", entry.Value.Replace("{appPath}", appPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -60,7 +61,7 @@ namespace Wabbajack.Common
|
||||
}
|
||||
|
||||
var extKey = Registry.CurrentUser.CreateSubKey(ExtPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
foreach (KeyValuePair<string, string> entry in ExtList)
|
||||
foreach (var entry in ExtList)
|
||||
{
|
||||
extKey?.SetValue(entry.Key, entry.Value);
|
||||
}
|
||||
|
@ -92,11 +92,13 @@ namespace Wabbajack.Common
|
||||
if (!l.Contains("BaseInstallFolder_")) return;
|
||||
var s = GetVdfValue(l);
|
||||
s = Path.Combine(s, "steamapps");
|
||||
paths.Add(s);
|
||||
if(Directory.Exists(s))
|
||||
paths.Add(s);
|
||||
});
|
||||
|
||||
// Default path in the Steam folder isn't in the configs
|
||||
paths.Add(Path.Combine(SteamPath, "steamapps"));
|
||||
if(Directory.Exists(Path.Combine(SteamPath, "steamapps")))
|
||||
paths.Add(Path.Combine(SteamPath, "steamapps"));
|
||||
|
||||
InstallFolders = paths;
|
||||
}
|
||||
@ -111,7 +113,7 @@ namespace Wabbajack.Common
|
||||
|
||||
InstallFolders.Do(p =>
|
||||
{
|
||||
Directory.EnumerateFiles(p, "*.acf", SearchOption.TopDirectoryOnly).Do(f =>
|
||||
Directory.EnumerateFiles(p, "*.acf", SearchOption.TopDirectoryOnly).Where(File.Exists).Do(f =>
|
||||
{
|
||||
var steamGame = new SteamGame();
|
||||
var valid = false;
|
||||
@ -122,8 +124,11 @@ namespace Wabbajack.Common
|
||||
return;
|
||||
if(l.Contains("\"name\""))
|
||||
steamGame.Name = GetVdfValue(l);
|
||||
if(l.Contains("\"installdir\""))
|
||||
steamGame.InstallDir = Path.Combine(p, "common", GetVdfValue(l));
|
||||
if (l.Contains("\"installdir\""))
|
||||
{
|
||||
var path = Path.Combine(p, "common", GetVdfValue(l));
|
||||
steamGame.InstallDir = Directory.Exists(path) ? path : null;
|
||||
}
|
||||
|
||||
if (steamGame.AppId != 0 && !string.IsNullOrWhiteSpace(steamGame.Name) &&
|
||||
!string.IsNullOrWhiteSpace(steamGame.InstallDir))
|
||||
@ -157,7 +162,7 @@ namespace Wabbajack.Common
|
||||
if(!Directory.Exists(workshop))
|
||||
return;
|
||||
|
||||
Directory.EnumerateFiles(workshop, "*.acf", SearchOption.TopDirectoryOnly).Do(f =>
|
||||
Directory.EnumerateFiles(workshop, "*.acf", SearchOption.TopDirectoryOnly).Where(File.Exists).Do(f =>
|
||||
{
|
||||
if (Path.GetFileName(f) != $"appworkshop_{game.AppId}.acf")
|
||||
return;
|
||||
|
@ -4,6 +4,7 @@ using System.Windows;
|
||||
using MahApps.Metro.Controls;
|
||||
using Wabbajack.Common;
|
||||
using Application = System.Windows.Application;
|
||||
using Utils = Wabbajack.Common.Utils;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -25,10 +26,18 @@ namespace Wabbajack
|
||||
};
|
||||
|
||||
var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
if (!ExtensionManager.IsAssociated() || ExtensionManager.NeedsUpdating(appPath))
|
||||
try
|
||||
{
|
||||
ExtensionManager.Associate(appPath);
|
||||
if (!ExtensionManager.IsAssociated() || ExtensionManager.NeedsUpdating(appPath))
|
||||
{
|
||||
ExtensionManager.Associate(appPath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.Log($"ExtensionManager had an exception:\n{e}");
|
||||
}
|
||||
|
||||
|
||||
Wabbajack.Common.Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user