diff --git a/README.md b/README.md
index 968e892..6c935aa 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Select every app you want to add to Steam, you can change the name by double cli
![](https://i.imgur.com/on46CMQ.png)
-Close UWPHook, restart Steam, click play on your UWP game, and Steam will show your current game on your status as long as you are playing it!
+Close UWPHook, restart Steam if prompted, click play on your UWP game, and Steam will show your current game on your status as long as you are playing it!
----------
diff --git a/UWPHook/AppEntry.cs b/UWPHook/AppEntry.cs
index c8dce92..8df6091 100644
--- a/UWPHook/AppEntry.cs
+++ b/UWPHook/AppEntry.cs
@@ -118,14 +118,11 @@ namespace UWPHook
public string isKnownApp()
{
- if (_aumid.Contains("Microsoft.SeaofThieves"))
+ if(AppManager.IsKnownApp(_aumid, out string name))
{
- return "Sea of Thieves";
- }
- else if (_aumid.Contains("Microsoft.DeltaPC"))
- {
- return "Gears of War: Ultimate Edition";
+ return name;
}
+
return "Name not found, double click here to edit";
}
@@ -135,5 +132,10 @@ namespace UWPHook
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
+
+ public override string ToString()
+ {
+ return $"{Name} ({Aumid})";
+ }
}
}
diff --git a/UWPHook/AppManager.cs b/UWPHook/AppManager.cs
index 7b22e5d..ffd5856 100644
--- a/UWPHook/AppManager.cs
+++ b/UWPHook/AppManager.cs
@@ -101,6 +101,30 @@ namespace UWPHook
return result;
}
+ ///
+ /// Try to convert an aumid into a human-readable app name
+ ///
+ /// Application user model ID (aumid)
+ /// User-friendly app name
+ /// Whether this is a known app
+ public static bool IsKnownApp(string appName, out string readableName)
+ {
+ string appsJson = File.ReadAllText(@"Resources\KnownApps.json");
+ var apps = Newtonsoft.Json.JsonConvert.DeserializeObject>(appsJson);
+
+ foreach (var kvp in apps)
+ {
+ if (appName.StartsWith(kvp.Key + "_"))
+ {
+ readableName = kvp.Value;
+ return true;
+ }
+ }
+
+ readableName = null;
+ return false;
+ }
+
[DllImport("user32.dll")]
private static extern
bool SetForegroundWindow(IntPtr hWnd);
diff --git a/UWPHook/GamesWindow.xaml b/UWPHook/GamesWindow.xaml
index 3850702..09d0464 100644
--- a/UWPHook/GamesWindow.xaml
+++ b/UWPHook/GamesWindow.xaml
@@ -39,7 +39,7 @@
-
-
+
+
diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs
index 986cc82..3895dea 100644
--- a/UWPHook/GamesWindow.xaml.cs
+++ b/UWPHook/GamesWindow.xaml.cs
@@ -1,4 +1,4 @@
-using Force.Crc32;
+using Force.Crc32;
using SharpSteam;
using System;
using System.Collections.Generic;
@@ -18,7 +18,6 @@ using UWPHook.Properties;
using UWPHook.SteamGridDb;
using VDFParser;
using VDFParser.Models;
-using System.Diagnostics;
namespace UWPHook
{
@@ -38,13 +37,15 @@ namespace UWPHook
var args = Environment.GetCommandLineArgs();
//If null or 1, the app was launched normally
- if (args != null)
+ if (args?.Length > 1)
{
//When length is 1, the only argument is the path where the app is installed
- if (Environment.GetCommandLineArgs().Length > 1)
- {
- _ = LauncherAsync(args);
- }
+ _ = LauncherAsync(args);
+ }
+ else
+ {
+ //auto refresh on load
+ LoadButton_Click(null, null);
}
}
@@ -129,11 +130,23 @@ namespace UWPHook
grid.IsEnabled = false;
progressBar.Visibility = Visibility.Visible;
- await ExportGames();
+ bool restartSteam = true;
+ var result = await ExportGames(restartSteam);
grid.IsEnabled = true;
progressBar.Visibility = Visibility.Collapsed;
- MessageBox.Show("Your apps were successfuly exported, please restart Steam in order to see your apps.", "UWPHook", MessageBoxButton.OK, MessageBoxImage.Information);
+
+ string msg = "Your apps were successfuly exported!";
+ if(!restartSteam)
+ {
+ msg += " Please restart Steam in order to see them.";
+ }
+ else if(result)
+ {
+ msg += " Steam has been restarted.";
+ }
+
+ MessageBox.Show(msg, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Information);
}
private async Task SaveImage(string imageUrl, string destinationFilename, ImageFormat format)
@@ -264,7 +277,7 @@ namespace UWPHook
}
}
- private async Task ExportGames()
+ private async Task ExportGames(bool restartSteam)
{
string[] tags = Settings.Default.Tags.Split(',');
string steam_folder = SteamManager.GetSteamFolder();
@@ -391,6 +404,52 @@ namespace UWPHook
});
}
}
+
+ if(restartSteam)
+ {
+ Func getSteam = () => Process.GetProcessesByName("steam").SingleOrDefault();
+
+ Process steam = getSteam();
+ if (steam != null)
+ {
+ string steamExe = steam.MainModule.FileName;
+
+ //we always ask politely
+ Debug.WriteLine("Requesting Steam shutdown");
+ Process.Start(steamExe, "-exitsteam");
+
+ bool restarted = false;
+ Stopwatch watch = new Stopwatch();
+ watch.Start();
+
+ //give it N seconds to sort itself out
+ int waitSeconds = 8;
+ while (watch.Elapsed.TotalSeconds < waitSeconds)
+ {
+ Thread.Sleep(TimeSpan.FromSeconds(0.5f));
+ if (getSteam() == null)
+ {
+ Debug.WriteLine("Restarting Steam");
+ Process.Start(steamExe);
+ restarted = true;
+ break;
+ }
+ }
+
+ if (!restarted)
+ {
+ Debug.WriteLine("Steam instance not restarted");
+ MessageBox.Show("Failed to restart Steam, please launch it manually", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return false;
+ }
+ }
+ else
+ {
+ Debug.WriteLine("Steam instance not found to be restarted");
+ }
+ }
+
+ return true;
}
public static void ClearAllShortcuts()
@@ -427,7 +486,7 @@ namespace UWPHook
}
catch (Exception ex)
{
- MessageBox.Show("Error: Program failed while trying to clear your Steam shurtcuts:" + Environment.NewLine + ex.Message + ex.StackTrace);
+ MessageBox.Show("Error: Program failed while trying to clear your Steam shortcuts:" + Environment.NewLine + ex.Message + ex.StackTrace);
}
}
MessageBox.Show("All non-Steam shortcuts has been cleared.");
@@ -483,6 +542,12 @@ namespace UWPHook
//Remove end lines from the String and split both values, I split the appname and the AUMID using |
//I hope no apps have that in their name. Ever.
var values = app.Replace("\r\n", "").Split('|');
+
+ if (values.Length >= 3 && AppManager.IsKnownApp(values[2], out string readableName))
+ {
+ values[0] = readableName;
+ }
+
if (!String.IsNullOrWhiteSpace(values[0]))
{
//We get the default square tile to find where the app stores it's icons, then we resolve which one is the widest
@@ -492,17 +557,6 @@ namespace UWPHook
Apps.Entries.Add(new AppEntry() { Name = values[0], IconPath = logosPath, Aumid = values[2], Selected = false });
});
}
- if (values.Length > 2)
- {
- if (values[2].Contains("Microsoft.SeaofThieves"))
- {
- values[0] = "Sea of Thieves";
- }
- else if (values[2].Contains("Microsoft.DeltaPC"))
- {
- values[0] = "Gears of War: Ultimate Edition";
- }
- }
}
}
catch (Exception ex)
@@ -529,7 +583,7 @@ namespace UWPHook
public bool Contains(object o)
{
AppEntry appEntry = o as AppEntry;
- return (appEntry.Aumid.ToLower().Contains(textBox.Text.ToLower()));
+ return (appEntry.Aumid.ToLower().Contains(textBox.Text.ToLower()) || appEntry.Name.ToLower().Contains(textBox.Text.ToLower()));
}
private void SettingsButton_Click(object sender, RoutedEventArgs e)
diff --git a/UWPHook/Resources/KnownApps.json b/UWPHook/Resources/KnownApps.json
new file mode 100644
index 0000000..d7d263e
--- /dev/null
+++ b/UWPHook/Resources/KnownApps.json
@@ -0,0 +1,4 @@
+{
+ "Microsoft.SeaofThieves": "Sea of Thieves",
+ "Microsoft.DeltaPC": "Gears of War: Ultimate Edition"
+}
\ No newline at end of file
diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj
index 8d641f2..a380e08 100644
--- a/UWPHook/UWPHook.csproj
+++ b/UWPHook/UWPHook.csproj
@@ -1,4 +1,4 @@
-
+
@@ -162,6 +162,9 @@
Settings.Designer.cs
+
+ Always
+