v3.5.3.1
- Right-click context menu favicons are now grabbed via Google's favicons API - Official program/game websites are now openable via the right-click context menu should the Steam Store provide one
This commit is contained in:
parent
f9c8002a4c
commit
92a20f87f4
6 changed files with 27 additions and 33 deletions
|
@ -39,19 +39,19 @@ internal class ContextMenuItem : ToolStripMenuItem
|
|||
image = IconGrabber.GetFileExplorerImage();
|
||||
break;
|
||||
case "SteamDB":
|
||||
image = await HttpClientManager.GetImageFromUrl("https://steamdb.info/favicon.ico");
|
||||
image = await HttpClientManager.GetImageFromUrl(IconGrabber.GetDomainFaviconUrl("steamdb.info"));
|
||||
break;
|
||||
case "Steam Store":
|
||||
image = await HttpClientManager.GetImageFromUrl("https://store.steampowered.com/favicon.ico");
|
||||
image = await HttpClientManager.GetImageFromUrl(IconGrabber.GetDomainFaviconUrl("store.steampowered.com"));
|
||||
break;
|
||||
case "Steam Community":
|
||||
image = await HttpClientManager.GetImageFromUrl("https://steamcommunity.com/favicon.ico");
|
||||
image = await HttpClientManager.GetImageFromUrl(IconGrabber.GetDomainFaviconUrl("steamcommunity.com"));
|
||||
break;
|
||||
case "ScreamDB":
|
||||
image = await HttpClientManager.GetImageFromUrl("https://scream-db.web.app/favicon.ico");
|
||||
image = await HttpClientManager.GetImageFromUrl(IconGrabber.GetDomainFaviconUrl("scream-db.web.app"));
|
||||
break;
|
||||
case "Epic Games":
|
||||
image = await HttpClientManager.GetImageFromUrl("https://www.epicgames.com/favicon.ico");
|
||||
image = await HttpClientManager.GetImageFromUrl(IconGrabber.GetDomainFaviconUrl("epicgames.com"));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
@ -64,10 +64,10 @@ internal class ContextMenuItem : ToolStripMenuItem
|
|||
}
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
private static async Task TryImageIdentifierInfo(ContextMenuItem item, (string id, string iconUrl, bool sub) imageIdentifierInfo, Action onFail = null) => await Task.Run(async () =>
|
||||
private static async Task TryImageIdentifierInfo(ContextMenuItem item, (string id, string iconUrl) imageIdentifierInfo, Action onFail = null) => await Task.Run(async () =>
|
||||
{
|
||||
(string id, string iconUrl, bool sub) = imageIdentifierInfo;
|
||||
string imageIdentifier = sub ? "SubIcon_" + id : "Icon_" + id;
|
||||
(string id, string iconUrl) = imageIdentifierInfo;
|
||||
string imageIdentifier = "Icon_" + id;
|
||||
if (images.TryGetValue(imageIdentifier, out Image image) && image is not null) item.Image = image;
|
||||
else
|
||||
{
|
||||
|
@ -99,12 +99,12 @@ internal class ContextMenuItem : ToolStripMenuItem
|
|||
internal ContextMenuItem(string text, string imageIdentifier, EventHandler onClick = null)
|
||||
: this(text, onClick) => _ = TryImageIdentifier(this, imageIdentifier);
|
||||
|
||||
internal ContextMenuItem(string text, (string id, string iconUrl, bool sub) imageIdentifierInfo, EventHandler onClick = null)
|
||||
internal ContextMenuItem(string text, (string id, string iconUrl) imageIdentifierInfo, EventHandler onClick = null)
|
||||
: this(text, onClick) => _ = TryImageIdentifierInfo(this, imageIdentifierInfo);
|
||||
|
||||
internal ContextMenuItem(string text, (string id, string iconUrl, bool sub) imageIdentifierInfo, string imageIdentifierFallback, EventHandler onClick = null)
|
||||
internal ContextMenuItem(string text, (string id, string iconUrl) imageIdentifierInfo, string imageIdentifierFallback, EventHandler onClick = null)
|
||||
: this(text, onClick) => _ = TryImageIdentifierInfo(this, imageIdentifierInfo, async () => await TryImageIdentifier(this, imageIdentifierFallback));
|
||||
|
||||
internal ContextMenuItem(string text, (string id, string iconUrl, bool sub) imageIdentifierInfo, (string id, string iconUrl, bool sub) imageIdentifierInfoFallback, EventHandler onClick = null)
|
||||
internal ContextMenuItem(string text, (string id, string iconUrl) imageIdentifierInfo, (string id, string iconUrl) imageIdentifierInfoFallback, EventHandler onClick = null)
|
||||
: this(text, onClick) => _ = TryImageIdentifierInfo(this, imageIdentifierInfo, async () => await TryImageIdentifierInfo(this, imageIdentifierInfoFallback));
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<Version>3.5.3.0</Version>
|
||||
<Version>3.5.3.1</Version>
|
||||
<PackageIcon>Resources\ini.ico</PackageIcon>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
|
||||
|
|
|
@ -231,6 +231,7 @@ internal partial class SelectForm : CustomForm
|
|||
selection.IconUrl = IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("icon")}.jpg";
|
||||
selection.SubIconUrl = appData?.header_image ?? IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("clienticon")}.ico";
|
||||
selection.Publisher = appData?.publishers[0] ?? appInfo?.Value?.GetChild("extended")?.GetChild("publisher")?.ToString();
|
||||
selection.WebsiteUrl = appData?.website;
|
||||
|
||||
if (Program.Canceled) return;
|
||||
Program.Invoke(selectionTreeView, delegate
|
||||
|
@ -607,9 +608,9 @@ internal partial class SelectForm : CustomForm
|
|||
if (id == "ParadoxLauncher")
|
||||
header = new(node.Text, "Paradox Launcher");
|
||||
else if (selection is not null)
|
||||
header = new(node.Text, (id, selection.IconUrl, false));
|
||||
header = new(node.Text, (id, selection.IconUrl));
|
||||
else if (dlc is not null && dlcParentSelection is not null)
|
||||
header = new(node.Text, (id, dlc.Value.app.icon, false), (id, dlcParentSelection.IconUrl, false));
|
||||
header = new(node.Text, (id, dlc.Value.app.icon), (id, dlcParentSelection.IconUrl));
|
||||
contextMenuStrip.Items.Add(header ?? new ContextMenuItem(node.Text));
|
||||
string appInfoVDF = $@"{SteamCMD.AppInfoPath}\{id}.vdf";
|
||||
string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json";
|
||||
|
@ -702,7 +703,7 @@ internal partial class SelectForm : CustomForm
|
|||
{
|
||||
contextMenuStrip.Items.Add(new ContextMenuItem("Open Steam Store", "Steam Store",
|
||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl))));
|
||||
contextMenuStrip.Items.Add(new ContextMenuItem("Open Steam Community", (id, selection.SubIconUrl, true), "Steam Community",
|
||||
contextMenuStrip.Items.Add(new ContextMenuItem("Open Steam Community", ("Sub_" + id, selection.SubIconUrl), "Steam Community",
|
||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://steamcommunity.com/app/" + id))));
|
||||
}
|
||||
else if (selection.IsEpic)
|
||||
|
@ -715,6 +716,11 @@ internal partial class SelectForm : CustomForm
|
|||
}
|
||||
}
|
||||
}
|
||||
if (selection is not null && selection.WebsiteUrl is not null)
|
||||
{
|
||||
contextMenuStrip.Items.Add(new ContextMenuItem("Open Official Website", ("Web_" + id, IconGrabber.GetDomainFaviconUrl(selection.WebsiteUrl)),
|
||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.WebsiteUrl))));
|
||||
}
|
||||
contextMenuStrip.Show(selectionTreeView, e.Location);
|
||||
};
|
||||
OnLoad(forceProvideChoices: true);
|
||||
|
|
|
@ -27,6 +27,8 @@ internal class ProgramSelection
|
|||
|
||||
internal string Publisher;
|
||||
|
||||
internal string WebsiteUrl;
|
||||
|
||||
internal string RootDirectory;
|
||||
internal List<string> DllDirectories;
|
||||
|
||||
|
|
|
@ -7,20 +7,6 @@ using System.Collections.Generic;
|
|||
|
||||
namespace CreamInstaller.Steam;
|
||||
|
||||
public class Category
|
||||
{
|
||||
public int id { get; set; }
|
||||
|
||||
public string description { get; set; }
|
||||
}
|
||||
|
||||
public class Genre
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
public string description { get; set; }
|
||||
}
|
||||
|
||||
public class AppData
|
||||
{
|
||||
public string type { get; set; }
|
||||
|
@ -40,10 +26,6 @@ public class AppData
|
|||
public List<string> publishers { get; set; }
|
||||
|
||||
public List<int> packages { get; set; }
|
||||
|
||||
public List<Category> categories { get; set; }
|
||||
|
||||
public List<Genre> genres { get; set; }
|
||||
}
|
||||
|
||||
public class AppDetails
|
||||
|
|
|
@ -14,6 +14,10 @@ internal static class IconGrabber
|
|||
|
||||
internal const string SteamAppImagesPath = "https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/";
|
||||
|
||||
internal const string GoogleFaviconsApiUrl = "https://www.google.com/s2/favicons";
|
||||
|
||||
internal static string GetDomainFaviconUrl(string domain, int size = 16) => GoogleFaviconsApiUrl + $"?domain={domain}&sz={size}";
|
||||
|
||||
internal static Image GetFileIconImage(string path) => File.Exists(path) ? Icon.ExtractAssociatedIcon(path).ToBitmap() : null;
|
||||
|
||||
internal static Image GetNotepadImage() => GetFileIconImage(Diagnostics.GetNotepadPath());
|
||||
|
|
Loading…
Reference in a new issue