Add two methods to get target executable + get icon from image api

pull/99/head
stevealexandre 2 years ago
parent 80419cab7f
commit 108a3a580b

@ -398,7 +398,29 @@ namespace UWPHook
{
foreach (var app in selected_apps)
{
string icon = PersistAppIcon(app);
string icon = "";
if (gridImagesDownloadTasks.Count > 0)
{
await Task.WhenAll(gridImagesDownloadTasks);
await Task.Run(() =>
{
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
string[] images = Directory.GetFiles(tmpGridDirectory);
foreach (string image in images)
{
if (image.EndsWith("_logo.png"))
{
icon = PersistAppIcon(app, image);
break;
}
}
});
}
else {
icon = PersistAppIcon(app);
}
VDFEntry newApp = new VDFEntry()
{
@ -489,19 +511,35 @@ namespace UWPHook
private string PersistAppIcon(AppEntry app)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string icons_path = path + @"\\Briano\\UWPHook\\icons\\";
string icons_path = path + @"\Briano\UWPHook\icons\";
if (!Directory.Exists(icons_path))
{
Directory.CreateDirectory(icons_path);
}
string destFile = String.Join(String.Empty, icons_path+ @"\\", app.Aumid + Path.GetFileName(app.Icon));
string destFile = String.Join(String.Empty, icons_path, app.Aumid + Path.GetFileName(app.Icon));
File.Copy(app.Icon, destFile, true);
return destFile;
}
private string PersistAppIcon(AppEntry app, string iconDownloadedPath)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string icons_path = path + @"\Briano\UWPHook\icons\";
if (!Directory.Exists(icons_path))
{
Directory.CreateDirectory(icons_path);
}
string destFile = String.Join(String.Empty, icons_path, app.Aumid + Path.GetFileName(iconDownloadedPath));
File.Copy(iconDownloadedPath, destFile, true);
return destFile;
}
/// <summary>
/// Restarts the Steam.exe process
/// </summary>

@ -10,24 +10,46 @@ foreach ($app in $installedapps)
{
$appx = Get-AppxPackageManifest $app;
$name = $appx.Package.Properties.DisplayName;
$executable = (Select-Xml -Path ($app.InstallLocation + "\MicrosoftGame.Config") -XPath "/Game/ExecutableList/Executable/@Name").Node.Value
$executable = $appx.Package.Applications.Application.Executable;
# Handle app running with microsoft launcher or which doesn't have an executable in the manifest
if([string]::IsNullOrWhitespace($executable) -or $executable -eq "GameLaunchHelper.exe") {
if(Test-Path -Path ($app.InstallLocation + "\MicrosoftGame.Config")) {
[xml]$msconfig = Get-Content ($app.InstallLocation + "\MicrosoftGame.Config");
$executable = $msconfig.Game.ExecutableList.Executable.Name;
}
else {
# Cannot handle app which doesn't have any configuration to read
continue;
}
}
# Convert object to ensure is the String of execuble (cf Halo Master Chief Collection example below)
# mcclauncher.exe
# MCC\Binaries\Win64\MCCWinStore-Win64-Shipping.exe
if($executable -is [Object[]]) { $executable = $executable[1].ToString() }
# Exclude apps without a name acceptable
if($name -like '*DisplayName*' -or $name -like '*ms-resource*')
{
$name = $appx.Package.Applications.Application.VisualElements.DisplayName;
}
if($name -like '*DisplayName*' -or $name -like '*ms-resource*')
{
$name = "App name not found, double click here to edit it";
continue;
}
$logo = $app.InstallLocation + "\" + $appx.Package.Applications.Application.VisualElements.Square150x150Logo;
# Check for possible duplicate game like Halo MCC which have two version (one with AC and one witohut AC)
$duplicate = $false;
foreach($item in $aumidList) {
#Write-host $item - $name
if($item.StartsWith($name)) {
$duplicate = $true;
break;
}
}
$aumidList += $name + "|" + $logo + "|" + $app.packagefamilyname + "!" + $id + "|" + $executable + ";"
# Insert if not duplicated
if(!$duplicate) {
$aumidList += $name + "|" + $logo + "|" + $app.packagefamilyname + "!" + $id + "|" + $executable + ";"
}
}
}
}

Loading…
Cancel
Save