mirror of
https://github.com/BrianLima/UWPHook.git
synced 2024-10-31 21:20:09 +00:00
Fix icons being repeated between apps, default to app.Icon
This commit is contained in:
parent
2dd9d96a96
commit
faa6b36759
@ -284,7 +284,7 @@ private async Task DownloadTempGridImages(string appName, string appTarget)
|
|||||||
{
|
{
|
||||||
SteamGridDbApi api = new SteamGridDbApi(Properties.Settings.Default.SteamGridDbApiKey);
|
SteamGridDbApi api = new SteamGridDbApi(Properties.Settings.Default.SteamGridDbApiKey);
|
||||||
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
|
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
|
||||||
GameResponse[] games;
|
GameResponse[] games = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -293,7 +293,6 @@ private async Task DownloadTempGridImages(string appName, string appTarget)
|
|||||||
catch (TaskCanceledException exception)
|
catch (TaskCanceledException exception)
|
||||||
{
|
{
|
||||||
Log.Error(exception.Message);
|
Log.Error(exception.Message);
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (games != null)
|
if (games != null)
|
||||||
@ -390,6 +389,8 @@ private async Task<bool> ExportGames()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Task.WhenAll(gridImagesDownloadTasks);
|
||||||
|
|
||||||
// Export the selected apps and the downloaded images to each user
|
// Export the selected apps and the downloaded images to each user
|
||||||
// in the steam folder by modifying it's VDF file
|
// in the steam folder by modifying it's VDF file
|
||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
@ -415,30 +416,26 @@ private async Task<bool> ExportGames()
|
|||||||
{
|
{
|
||||||
foreach (var app in selected_apps)
|
foreach (var app in selected_apps)
|
||||||
{
|
{
|
||||||
string icon = "";
|
try
|
||||||
if (gridImagesDownloadTasks.Count > 0)
|
|
||||||
{
|
{
|
||||||
await Task.WhenAll(gridImagesDownloadTasks);
|
|
||||||
|
app.Icon = PersistAppIcon(app);
|
||||||
|
Log.Verbose("Defaulting to app.Icon for app " + app.Name);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (System.IO.IOException)
|
||||||
|
{
|
||||||
|
Log.Verbose("Using backup icon for app " + app.Name);
|
||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
|
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
|
||||||
string[] images = Directory.GetFiles(tmpGridDirectory);
|
string[] images = Directory.GetFiles(tmpGridDirectory);
|
||||||
|
|
||||||
foreach (string image in images)
|
UInt64 gameId = GenerateSteamGridAppId(app.Name, exePath);
|
||||||
{
|
app.Icon = PersistAppIcon(app, tmpGridDirectory + gameId + "_logo.png");
|
||||||
if (image.EndsWith("_logo.png"))
|
|
||||||
{
|
|
||||||
icon = PersistAppIcon(app, image);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
icon = PersistAppIcon(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
VDFEntry newApp = new VDFEntry()
|
VDFEntry newApp = new VDFEntry()
|
||||||
{
|
{
|
||||||
@ -448,7 +445,7 @@ await Task.Run(() =>
|
|||||||
LaunchOptions = app.Aumid + " " + app.Executable,
|
LaunchOptions = app.Aumid + " " + app.Executable,
|
||||||
AllowDesktopConfig = 1,
|
AllowDesktopConfig = 1,
|
||||||
AllowOverlay = 1,
|
AllowOverlay = 1,
|
||||||
Icon = icon,
|
Icon = app.Icon,
|
||||||
Index = shortcuts.Length,
|
Index = shortcuts.Length,
|
||||||
IsHidden = 0,
|
IsHidden = 0,
|
||||||
OpenVR = 0,
|
OpenVR = 0,
|
||||||
@ -537,7 +534,6 @@ private string PersistAppIcon(AppEntry app, string forcedIcon = "")
|
|||||||
// If we do not have an specific icon to copy, copy app.icon, if we do, copy the specified icon
|
// If we do not have an specific icon to copy, copy app.icon, if we do, copy the specified icon
|
||||||
string icon_to_copy = String.IsNullOrEmpty(forcedIcon) ? app.Icon : forcedIcon;
|
string icon_to_copy = String.IsNullOrEmpty(forcedIcon) ? app.Icon : forcedIcon;
|
||||||
|
|
||||||
|
|
||||||
if (!Directory.Exists(icons_path))
|
if (!Directory.Exists(icons_path))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(icons_path);
|
Directory.CreateDirectory(icons_path);
|
||||||
@ -548,13 +544,10 @@ private string PersistAppIcon(AppEntry app, string forcedIcon = "")
|
|||||||
{
|
{
|
||||||
File.Copy(icon_to_copy, dest_file, true);
|
File.Copy(icon_to_copy, dest_file, true);
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException)
|
catch (System.IO.IOException e)
|
||||||
{
|
{
|
||||||
// This file is most likely encrypted or does not exist, so we return the app.Icon itself
|
Log.Warning(e, "Could not copy icon " + app.Icon);
|
||||||
// but this app is now prone to #90 unfortunately, if we return String.empty, Steam will default
|
throw e;
|
||||||
// to UWPHook's icon
|
|
||||||
Log.Warning("File could not be copied: " + icon_to_copy);
|
|
||||||
dest_file = app.Icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest_file;
|
return dest_file;
|
||||||
|
Loading…
Reference in New Issue
Block a user