From e09dedc6133b21ea7c0f140a81db926370e4e5fb Mon Sep 17 00:00:00 2001 From: Faiz-ur Rahman Date: Wed, 3 Nov 2021 13:33:32 -0700 Subject: [PATCH 1/2] Update README.md Updated the Troubleshooting section to enhance readability. --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 968e892..3fc2ce6 100644 --- a/README.md +++ b/README.md @@ -41,16 +41,13 @@ Special thanks to @FusRoDah061 for implementing the base feature! # Troubleshooting # - **Steam's Overlay isn't working!** -- Unfortunately, it's a Steam limitation, Valve has to update it in order to work properly with UWP, DXTory is a recommended overlay for UWP games. - + - Unfortunately, it's a Steam limitation, Valve has to update it in order to work properly with UWP, DXTory is a recommended overlay for UWP games. - **Steam Link launches the game but input doesn't work!** -- Unfortunately, another limitation by Steam, i have some ideas as to why it isn't working, but i can't give an ETA for when i can fix this, or even if it's fixable on my end, since Valve didn't released the Link in Brazil and i can't get one to test. - + - Unfortunately, another limitation by Steam, i have some ideas as to why it isn't working, but i can't give an ETA for when i can fix this, or even if it's fixable on my end, since Valve didn't released the Link in Brazil and i can't get one to test. - **Steam Controller isn't working** -- Another limitation by Steam, some people reported it works with "Desktop Mode" configuration, but i can't verify this. - + - Another limitation by Steam, some people reported it works with "Desktop Mode" configuration, but i can't verify this. - **My question isn't listed here!** -- Drop by our subreddit and ask a question over there, maybe someone will help you, i surely will as soon as i can + - Drop by our subreddit and ask a question over there, maybe someone will help you, i surely will as soon as i can **[https://www.reddit.com/r/uwphook](https://www.reddit.com/r/uwphook)** ---------- From b050329ea2eee5de4f5831c6f55f7d6935bff0ff Mon Sep 17 00:00:00 2001 From: Brian Lima Date: Mon, 29 Nov 2021 00:08:04 -0300 Subject: [PATCH 2/2] Improve error handler, prepare new settings --- UWPHook/GamesWindow.xaml.cs | 117 +++++++++++++++++++++++--- UWPHook/SettingsWindow.xaml | 66 ++++++++------- UWPHook/SettingsWindow.xaml.cs | 16 +++- UWPHook/SteamGridDb/SteamGridDbApi.cs | 4 +- UWPHook/UWPHook.csproj | 22 +++-- UWPHook/packages.config | 12 +-- 6 files changed, 177 insertions(+), 60 deletions(-) diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs index 3895dea..dd054a6 100644 --- a/UWPHook/GamesWindow.xaml.cs +++ b/UWPHook/GamesWindow.xaml.cs @@ -36,11 +36,12 @@ namespace UWPHook Apps = new AppEntryModel(); var args = Environment.GetCommandLineArgs(); - //If null or 1, the app was launched normally + // If null or 1, the app was launched normally if (args?.Length > 1) { - //When length is 1, the only argument is the path where the app is installed - _ = LauncherAsync(args); + // When length is 1, the only argument is the path where the app is installed + _ = LauncherAsync(args); // Launches the requested game + } else { @@ -58,6 +59,12 @@ namespace UWPHook await Task.Delay(10000); } + /// + /// Main task that launches a game + /// Usually invoked by steam + /// + /// launch args received from the program execution + /// private async Task LauncherAsync(string[] args) { FullScreenLauncher launcher = null; @@ -116,6 +123,13 @@ namespace UWPHook } } + /// + /// Generates a CRC32 hash expected by Steam to link an image with a game in the library + /// See https://blog.yo1.dog/calculate-id-for-non-steam-games-js/ for an example + /// + /// The name of the executable to be displayed + /// The executable target path + /// private UInt64 GenerateSteamGridAppId(string appName, string appTarget) { byte[] nameTargetBytes = Encoding.UTF8.GetBytes(appTarget + appName + ""); @@ -125,30 +139,53 @@ namespace UWPHook return gameId; } + /// + /// Task responsible for triggering the export, blocks the UI, and shows a message + /// once the task is finished, unlocking the UI + /// + /// + /// private async void ExportButton_Click(object sender, RoutedEventArgs e) { grid.IsEnabled = false; progressBar.Visibility = Visibility.Visible; - bool restartSteam = true; - var result = await ExportGames(restartSteam); - - grid.IsEnabled = true; - progressBar.Visibility = Visibility.Collapsed; + bool result = false, restartSteam = true; + string msg = String.Empty; - string msg = "Your apps were successfuly exported!"; - if(!restartSteam) + try { - msg += " Please restart Steam in order to see them."; + await ExportGames(restartSteam); + + 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."; + } + } - else if(result) + catch (TaskCanceledException exception) { - msg += " Steam has been restarted."; + msg = exception.Message; } + grid.IsEnabled = true; + progressBar.Visibility = Visibility.Collapsed; + MessageBox.Show(msg, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Information); } + /// + /// Downloads the given image in the url to a given path in a given format + /// + /// The url for the image + /// Path to store the image + /// + /// private async Task SaveImage(string imageUrl, string destinationFilename, ImageFormat format) { await Task.Run(() => @@ -176,6 +213,10 @@ namespace UWPHook }); } + /// + /// Copies all temporary images to the given user + /// + /// The user path to copy images to private void CopyTempGridImagesToSteamUser(string user) { string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\"; @@ -210,12 +251,28 @@ namespace UWPHook } } + /// + /// Task responsible for downloading grid images to a temporary location, + /// generates the steam ID for the game based in the receiving parameters, + /// Throws TaskCanceledException if cannot communicate with SteamGridDB properly + /// + /// The name of the app + /// The target path of the executable + /// private async Task DownloadTempGridImages(string appName, string appTarget) { SteamGridDbApi api = new SteamGridDbApi(Properties.Settings.Default.SteamGridDbApiKey); string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\"; + GameResponse[] games; - var games = await api.SearchGame(appName); + try + { + games = await api.SearchGame(appName); + } + catch (TaskCanceledException exception) + { + throw; + } if (games != null) { @@ -277,6 +334,11 @@ namespace UWPHook } } + /// + /// Main Task to export the selected games to steam + /// + /// + /// private async Task ExportGames(bool restartSteam) { string[] tags = Settings.Default.Tags.Split(','); @@ -301,10 +363,13 @@ namespace UWPHook if (downloadGridImages) { Debug.WriteLine("Downloading grid images for app " + app.Name); + gridImagesDownloadTasks.Add(DownloadTempGridImages(app.Name, exePath)); } } + // Export the selected apps and the downloaded images to each user + // in the steam folder by modifying it's VDF file foreach (var user in users) { try @@ -493,6 +558,11 @@ namespace UWPHook } } + /// + /// Fires the Bwr_DoWork, to load the apps installed at the machine + /// + /// + /// private void LoadButton_Click(object sender, RoutedEventArgs e) { bwrLoad = new BackgroundWorker(); @@ -500,12 +570,19 @@ namespace UWPHook bwrLoad.RunWorkerCompleted += Bwr_RunWorkerCompleted; grid.IsEnabled = false; + label.Content = "Loading your installed apps"; + progressBar.Visibility = Visibility.Visible; Apps.Entries = new System.Collections.ObjectModel.ObservableCollection(); bwrLoad.RunWorkerAsync(); } + /// + /// Callback for restoring the grid list interactivity + /// + /// + /// private void Bwr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { listGames.ItemsSource = Apps.Entries; @@ -518,6 +595,11 @@ namespace UWPHook label.Content = "Installed Apps"; } + /// + /// Worker responsible for loading the apps installed in the machine + /// + /// + /// private void Bwr_DoWork(object sender, DoWorkEventArgs e) { try @@ -592,6 +674,13 @@ namespace UWPHook window.ShowDialog(); } + /// + /// Function that executes when the Games Window is loaded + /// Will inform the user of the possibility of using the SteamGridDB API + /// redirecting him to the settings page if he wishes to use the functionality + /// + /// + /// private void Window_Loaded(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(Settings.Default.SteamGridDbApiKey) && !Settings.Default.OfferedSteamGridDB) diff --git a/UWPHook/SettingsWindow.xaml b/UWPHook/SettingsWindow.xaml index dd1aed0..d1fe0dc 100644 --- a/UWPHook/SettingsWindow.xaml +++ b/UWPHook/SettingsWindow.xaml @@ -11,7 +11,7 @@ TextElement.FontWeight="Medium" TextElement.FontSize="14" FontFamily="Segoe UI Light" - Title="Settings" Height="638" Width="800" Icon="Resources/hook2.ico"> + Title="Settings" Height="750" Width="800" Icon="Resources/hook2.ico"> @@ -28,10 +28,12 @@ - - - - + + + + + + @@ -45,21 +47,21 @@