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 @@
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
@@ -67,26 +69,30 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
@@ -95,11 +101,11 @@
-
-
-
-
-
+
+
+
+
+
- contributors
+ contributors
diff --git a/UWPHook/SettingsWindow.xaml.cs b/UWPHook/SettingsWindow.xaml.cs
index f7277cb..df850fb 100644
--- a/UWPHook/SettingsWindow.xaml.cs
+++ b/UWPHook/SettingsWindow.xaml.cs
@@ -1,6 +1,9 @@
using System;
using System.Globalization;
using System.Windows;
+using System.Linq;
+using System.Runtime.InteropServices;
+//using System.Windows.Forms;
namespace UWPHook
{
@@ -20,7 +23,9 @@ namespace UWPHook
cultures_comboBox.Items.Add(culture.TextInfo.CultureName);
}
- for (int i = 1; i < 10; i++)
+
+
+ for (int i = 0; i < 10; i++)
{
seconds_comboBox.Items.Add(i + " seconds");
if (i == Properties.Settings.Default.Seconds)
@@ -92,5 +97,14 @@ namespace UWPHook
"Log-in, or create your account, go to your profile preferences and click 'Generate API Key', then paste the key back on UWPHook.", "Attention!", MessageBoxButton.OK, MessageBoxImage.Information );
System.Diagnostics.Process.Start("https://www.steamgriddb.com/profile/preferences/api");
}
+
+ private void test()
+ {
+ FixHeight = 1280;
+
+ FixWidth = 1024;
+
+ Resolution.CResolution ChangeRes1024 = new Resolution.CResolution(FixHeight, FixWidth);
+ }
}
}
\ No newline at end of file
diff --git a/UWPHook/SteamGridDb/SteamGridDbApi.cs b/UWPHook/SteamGridDb/SteamGridDbApi.cs
index b92eee3..b340a9f 100644
--- a/UWPHook/SteamGridDb/SteamGridDbApi.cs
+++ b/UWPHook/SteamGridDb/SteamGridDbApi.cs
@@ -45,16 +45,14 @@ namespace UWPHook.SteamGridDb
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
- System.Windows.MessageBox.Show("Warning: SteamGrid API Key Invalid. Please generate a new key and add it to settings.");
Debug.WriteLine("ERROR RESPONSE: " + response.ToString());
settings.SteamGridDbApiKey = String.Empty;
settings.Save();
- System.Windows.Application.Current.Shutdown();
+ throw new TaskCanceledException("Warning: SteamGrid API Key Invalid. Please generate a new key and add it to settings.");
}
-
return games;
}
diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj
index a380e08..0362c98 100644
--- a/UWPHook/UWPHook.csproj
+++ b/UWPHook/UWPHook.csproj
@@ -1,4 +1,4 @@
-
+
@@ -61,27 +61,35 @@
..\packages\Crc32.NET.1.2.0\lib\net20\Crc32.NET.dll
+ True
-
- ..\packages\MaterialDesignColors.2.0.1\lib\net452\MaterialDesignColors.dll
+
+ ..\packages\MaterialDesignColors.2.0.4\lib\net452\MaterialDesignColors.dll
+ True
-
- ..\packages\MaterialDesignThemes.4.1.0\lib\net452\MaterialDesignThemes.Wpf.dll
+
+ ..\packages\MaterialDesignThemes.4.3.0\lib\net452\MaterialDesignThemes.Wpf.dll
+ True
..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+ True
..\..\SharpSteam\SharpSteam\bin\Release\SharpSteam.dll
-
+
+ ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll
+
..\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.1.0\lib\net4\System.Management.Automation.dll
+ True
..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll
+ True
@@ -215,7 +223,9 @@
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+