diff --git a/UWPHook/AppManager.cs b/UWPHook/AppManager.cs index 5eb4771..0b3ae97 100644 --- a/UWPHook/AppManager.cs +++ b/UWPHook/AppManager.cs @@ -56,7 +56,7 @@ namespace UWPHook process.Start(); //mgr.ActivateApplication(aumid, extra_args, ActivateOptions.None, out processId); //Bring the launched app to the foreground, this fixes in-home streaming - //BringProcess(); + BringProcess(); } catch (Exception e) { diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs index bf7040d..840e380 100644 --- a/UWPHook/GamesWindow.xaml.cs +++ b/UWPHook/GamesWindow.xaml.cs @@ -549,7 +549,9 @@ namespace UWPHook string dest_file = String.Join(String.Empty, icons_path, app.Aumid + Path.GetFileName(icon_to_copy)); try { - File.Copy(icon_to_copy, dest_file, true); + System.Drawing.Image image = System.Drawing.Image.FromFile(dest_file); + image.Save(dest_file); + //File.Copy(icon_to_copy, dest_file, true); } catch (System.IO.IOException) { @@ -557,7 +559,35 @@ namespace UWPHook // but this app is now prone to #90 unfortunately, if we return String.empty, Steam will default // to UWPHook's icon Log.Warning("File could not be copied: " + icon_to_copy); - dest_file = app.IconPath; + try + { + if (File.GetAttributes(icon_to_copy).HasFlag(FileAttributes.Directory)) + { + System.Drawing.Size size = new System.Drawing.Size(0, 0); + System.Drawing.Image currentImage = null; + + foreach (var image in (Directory.GetFiles(icon_to_copy, "*.png"))) + { + currentImage = System.Drawing.Image.FromFile(image); + if (currentImage != null) + { + //UWP apps usually store live tile images inside the same directory + //Let's check if the image is square for use as icon on Steam and pick the largest one + if (currentImage.Width == currentImage.Height && (size.Height == 0 || (currentImage.Size.Height < size.Height))) + { + size = currentImage.Size; + dest_file = image; + } + } + } + } + } + catch (Exception e) + { + Log.Error("Path is not a directory and could not be read: " + icon_to_copy); + Log.Verbose(e.Message); + dest_file = ""; + } } return dest_file;