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 @@