context menu stabilization
This commit is contained in:
parent
faee45d0d7
commit
df64448f55
3 changed files with 278 additions and 193 deletions
|
@ -5,7 +5,7 @@
|
||||||
<UseWindowsForms>True</UseWindowsForms>
|
<UseWindowsForms>True</UseWindowsForms>
|
||||||
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
||||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||||
<Version>3.2.0.6</Version>
|
<Version>3.2.1.0</Version>
|
||||||
<PackageIcon>Resources\ini.ico</PackageIcon>
|
<PackageIcon>Resources\ini.ico</PackageIcon>
|
||||||
<PackageIconUrl />
|
<PackageIconUrl />
|
||||||
<Description />
|
<Description />
|
||||||
|
|
|
@ -77,7 +77,13 @@ internal partial class MainForm : CustomForm
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
if (latestVersion is not null)
|
if (latestVersion is null)
|
||||||
|
{
|
||||||
|
updateManager.Dispose();
|
||||||
|
updateManager = null;
|
||||||
|
StartProgram();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Size = new(420, 300);
|
Size = new(420, 300);
|
||||||
label1.Text = $"An update is available: v{latestVersion}";
|
label1.Text = $"An update is available: v{latestVersion}";
|
||||||
|
@ -112,10 +118,6 @@ internal partial class MainForm : CustomForm
|
||||||
}
|
}
|
||||||
versions = null;
|
versions = null;
|
||||||
}
|
}
|
||||||
updateManager.Dispose();
|
|
||||||
updateManager = null;
|
|
||||||
|
|
||||||
StartProgram();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoad(object sender, EventArgs _)
|
private void OnLoad(object sender, EventArgs _)
|
||||||
|
|
|
@ -536,223 +536,306 @@ internal partial class SelectForm : CustomForm
|
||||||
+ progressBar.Size.Height);
|
+ progressBar.Size.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class ContextMenuItem : ToolStripMenuItem
|
||||||
|
{
|
||||||
|
private static readonly ConcurrentDictionary<string, Image> images = new();
|
||||||
|
|
||||||
|
private static async Task TryImageIdentifier(ContextMenuItem item, string imageIdentifier) => await Task.Run(async () =>
|
||||||
|
{
|
||||||
|
if (images.TryGetValue(imageIdentifier, out Image image) && image is not null) item.Image = image;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (imageIdentifier)
|
||||||
|
{
|
||||||
|
case "Paradox Launcher":
|
||||||
|
if (Directory.Exists(ParadoxLauncher.InstallPath))
|
||||||
|
foreach (string file in Directory.GetFiles(ParadoxLauncher.InstallPath, "*.exe"))
|
||||||
|
{
|
||||||
|
image = IconGrabber.GetFileIconImage(file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Notepad":
|
||||||
|
image = IconGrabber.GetNotepadImage();
|
||||||
|
break;
|
||||||
|
case "Command Prompt":
|
||||||
|
image = IconGrabber.GetCommandPromptImage();
|
||||||
|
break;
|
||||||
|
case "File Explorer":
|
||||||
|
image = IconGrabber.GetFileExplorerImage();
|
||||||
|
break;
|
||||||
|
case "SteamDB":
|
||||||
|
image = await HttpClientManager.GetImageFromUrl("https://steamdb.info/favicon.ico");
|
||||||
|
break;
|
||||||
|
case "Steam Store":
|
||||||
|
image = await HttpClientManager.GetImageFromUrl("https://store.steampowered.com/favicon.ico");
|
||||||
|
break;
|
||||||
|
case "Steam Community":
|
||||||
|
image = await HttpClientManager.GetImageFromUrl("https://steamcommunity.com/favicon.ico");
|
||||||
|
break;
|
||||||
|
case "ScreamDB":
|
||||||
|
image = await HttpClientManager.GetImageFromUrl("https://scream-db.web.app/favicon.ico");
|
||||||
|
break;
|
||||||
|
case "Epic Games":
|
||||||
|
image = await HttpClientManager.GetImageFromUrl("https://www.epicgames.com/favicon.ico");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (image is not null)
|
||||||
|
{
|
||||||
|
images[imageIdentifier] = image;
|
||||||
|
item.Image = image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
private static async Task TryImageIdentifierInfo(ContextMenuItem item, (string id, string iconUrl, bool sub) imageIdentifierInfo, Action onFail = null) => await Task.Run(async () =>
|
||||||
|
{
|
||||||
|
(string id, string iconUrl, bool sub) = imageIdentifierInfo;
|
||||||
|
string imageIdentifier = sub ? "SubIcon_" + id : "Icon_" + id;
|
||||||
|
if (images.TryGetValue(imageIdentifier, out Image image) && image is not null) item.Image = image;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image = await HttpClientManager.GetImageFromUrl(iconUrl);
|
||||||
|
if (image is not null)
|
||||||
|
{
|
||||||
|
images[imageIdentifier] = image;
|
||||||
|
item.Image = image;
|
||||||
|
}
|
||||||
|
else if (onFail is not null)
|
||||||
|
onFail();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
private readonly EventHandler OnClickEvent;
|
||||||
|
protected override void OnClick(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnClick(e);
|
||||||
|
if (OnClickEvent is null) return;
|
||||||
|
OnClickEvent.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ContextMenuItem(string text, EventHandler onClick = null)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
OnClickEvent = onClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
: this(text, onClick) => _ = TryImageIdentifierInfo(this, imageIdentifierInfo);
|
||||||
|
|
||||||
|
internal ContextMenuItem(string text, (string id, string iconUrl, bool sub) 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)
|
||||||
|
: this(text, onClick) => _ = TryImageIdentifierInfo(this, imageIdentifierInfo, async () => await TryImageIdentifierInfo(this, imageIdentifierInfoFallback));
|
||||||
|
}
|
||||||
|
|
||||||
private void OnLoad(object sender, EventArgs _)
|
private void OnLoad(object sender, EventArgs _)
|
||||||
{
|
{
|
||||||
HideProgressBar();
|
HideProgressBar();
|
||||||
selectionTreeView.TreeViewNodeSorter = new TreeNodeSorter();
|
selectionTreeView.TreeViewNodeSorter = new TreeNodeSorter();
|
||||||
selectionTreeView.AfterCheck += OnTreeViewNodeCheckedChanged;
|
selectionTreeView.AfterCheck += OnTreeViewNodeCheckedChanged;
|
||||||
Dictionary<string, Image> images = new();
|
int contextMenuIndex = 0;
|
||||||
Task.Run(async () =>
|
void ClearContextMenu(int cmi)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(ParadoxLauncher.InstallPath))
|
if (cmi != contextMenuIndex || Program.Canceled) return;
|
||||||
{
|
nodeContextMenu.Items.Clear();
|
||||||
foreach (string file in Directory.GetFiles(ParadoxLauncher.InstallPath, "*.exe"))
|
}
|
||||||
{
|
void AddToContextMenu(int cmi, ToolStripItem item)
|
||||||
images["Icon_ParadoxLauncher"] = IconGrabber.GetFileIconImage(file);
|
{
|
||||||
break;
|
if (cmi != contextMenuIndex || Program.Canceled) return;
|
||||||
}
|
nodeContextMenu.Items.Add(item);
|
||||||
}
|
}
|
||||||
images["Notepad"] = IconGrabber.GetNotepadImage();
|
|
||||||
images["Command Prompt"] = IconGrabber.GetCommandPromptImage();
|
|
||||||
images["File Explorer"] = IconGrabber.GetFileExplorerImage();
|
|
||||||
images["SteamDB"] = await HttpClientManager.GetImageFromUrl("https://steamdb.info/favicon.ico");
|
|
||||||
images["Steam Store"] = await HttpClientManager.GetImageFromUrl("https://store.steampowered.com/favicon.ico");
|
|
||||||
images["Steam Community"] = await HttpClientManager.GetImageFromUrl("https://steamcommunity.com/favicon.ico");
|
|
||||||
images["ScreamDB"] = await HttpClientManager.GetImageFromUrl("https://scream-db.web.app/favicon.ico");
|
|
||||||
images["Epic Games"] = await HttpClientManager.GetImageFromUrl("https://www.epicgames.com/favicon.ico");
|
|
||||||
});
|
|
||||||
Image Image(string identifier) => images.GetValueOrDefault(identifier, null);
|
|
||||||
void TrySetImageAsync(ToolStripMenuItem menuItem, string appId, string iconUrl, bool client = false) =>
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
menuItem.Image = await HttpClientManager.GetImageFromUrl(iconUrl);
|
|
||||||
images[client ? "ClientIcon_" + appId : "Icon_" + appId] = menuItem.Image;
|
|
||||||
});
|
|
||||||
selectionTreeView.NodeMouseClick += (sender, e) =>
|
selectionTreeView.NodeMouseClick += (sender, e) =>
|
||||||
{
|
{
|
||||||
TreeNode node = e.Node;
|
int cmi = ++contextMenuIndex;
|
||||||
if (!node.Bounds.Contains(e.Location) || e.Button != MouseButtons.Right) return;
|
do { Thread.Sleep(0); } while (!Program.Canceled && nodeContextMenu.Visible);
|
||||||
selectionTreeView.SelectedNode = node;
|
if (cmi != contextMenuIndex || Program.Canceled) return;
|
||||||
|
TreeNode node = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
node = e.Node;
|
||||||
|
if (node is null || !node.Bounds.Contains(e.Location) || e.Button != MouseButtons.Right)
|
||||||
|
return;
|
||||||
|
selectionTreeView.SelectedNode = node;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
string id = node.Name;
|
string id = node.Name;
|
||||||
ProgramSelection selection = ProgramSelection.FromId(id);
|
ProgramSelection selection = ProgramSelection.FromId(id);
|
||||||
(string gameAppId, (DlcType type, string name, string icon) app)? dlc = null;
|
(string gameAppId, (DlcType type, string name, string icon) app)? dlc = null;
|
||||||
if (selection is null) dlc = ProgramSelection.GetDlcFromId(id);
|
if (selection is null) dlc = ProgramSelection.GetDlcFromId(id);
|
||||||
if (selection is not null || dlc is not null)
|
ProgramSelection dlcParentSelection = null;
|
||||||
|
if (dlc is not null) dlcParentSelection = ProgramSelection.FromId(dlc.Value.gameAppId);
|
||||||
|
if (selection is null && dlcParentSelection is null)
|
||||||
|
return;
|
||||||
|
ClearContextMenu(cmi);
|
||||||
|
ContextMenuItem header = null;
|
||||||
|
if (id == "ParadoxLauncher")
|
||||||
|
header = new(node.Text, "Paradox Launcher");
|
||||||
|
else if (selection is not null)
|
||||||
|
header = new(node.Text, (id, selection.IconUrl, false));
|
||||||
|
else if (dlc is not null)
|
||||||
{
|
{
|
||||||
nodeContextMenu.Items.Clear();
|
header = new(node.Text, (id, dlc.Value.app.icon, false), (id, dlcParentSelection.IconUrl, false));
|
||||||
ToolStripMenuItem header = new(selection?.Name ?? node.Text, Image("Icon_" + id));
|
}
|
||||||
if (header.Image is null)
|
AddToContextMenu(cmi, header ?? new ContextMenuItem(node.Text));
|
||||||
{
|
string appInfoVDF = $@"{SteamCMD.AppInfoPath}\{id}.vdf";
|
||||||
string icon = dlc?.app.icon ?? selection?.IconUrl;
|
string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json";
|
||||||
if (icon is not null)
|
if (Directory.Exists(Directory.GetDirectoryRoot(appInfoVDF)) && (File.Exists(appInfoVDF) || File.Exists(appInfoJSON)))
|
||||||
TrySetImageAsync(header, id, icon);
|
{
|
||||||
else if (dlc is not null)
|
AddToContextMenu(cmi, new ToolStripSeparator());
|
||||||
|
AddToContextMenu(cmi, new ContextMenuItem("Open AppInfo", "Notepad",
|
||||||
|
new EventHandler((sender, e) =>
|
||||||
{
|
{
|
||||||
string gameAppId = dlc.Value.gameAppId;
|
if (File.Exists(appInfoVDF))
|
||||||
header.Image = Image("Icon_" + gameAppId);
|
Diagnostics.OpenFileInNotepad(appInfoVDF);
|
||||||
ProgramSelection gameSelection = ProgramSelection.FromId(gameAppId);
|
else if (File.Exists(appInfoJSON))
|
||||||
icon = gameSelection?.IconUrl;
|
Diagnostics.OpenFileInNotepad(appInfoJSON);
|
||||||
if (header.Image is null && icon is not null)
|
})));
|
||||||
TrySetImageAsync(header, gameAppId, icon);
|
AddToContextMenu(cmi, new ContextMenuItem("Refresh AppInfo", "Command Prompt",
|
||||||
}
|
new EventHandler((sender, e) =>
|
||||||
}
|
|
||||||
nodeContextMenu.Items.Add(header);
|
|
||||||
string appInfoVDF = $@"{SteamCMD.AppInfoPath}\{id}.vdf";
|
|
||||||
string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json";
|
|
||||||
if (Directory.Exists(Directory.GetDirectoryRoot(appInfoVDF)) && (File.Exists(appInfoVDF) || File.Exists(appInfoJSON)))
|
|
||||||
{
|
|
||||||
nodeContextMenu.Items.Add(new ToolStripSeparator());
|
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Open AppInfo", Image("Notepad"),
|
|
||||||
new EventHandler((sender, e) =>
|
|
||||||
{
|
|
||||||
if (File.Exists(appInfoVDF))
|
|
||||||
Diagnostics.OpenFileInNotepad(appInfoVDF);
|
|
||||||
else if (File.Exists(appInfoJSON))
|
|
||||||
Diagnostics.OpenFileInNotepad(appInfoJSON);
|
|
||||||
})));
|
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Refresh AppInfo", Image("Command Prompt"),
|
|
||||||
new EventHandler((sender, e) =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Delete(appInfoVDF);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Delete(appInfoJSON);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
OnLoad();
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
if (selection is not null)
|
|
||||||
{
|
|
||||||
if (id == "ParadoxLauncher")
|
|
||||||
{
|
{
|
||||||
nodeContextMenu.Items.Add(new ToolStripSeparator());
|
try
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Repair", Image("Command Prompt"),
|
{
|
||||||
new EventHandler(async (sender, e) =>
|
File.Delete(appInfoVDF);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(appInfoJSON);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
OnLoad();
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
if (selection is not null)
|
||||||
|
{
|
||||||
|
if (id == "ParadoxLauncher")
|
||||||
|
{
|
||||||
|
AddToContextMenu(cmi, new ToolStripSeparator());
|
||||||
|
AddToContextMenu(cmi, new ContextMenuItem("Repair", "Command Prompt",
|
||||||
|
new EventHandler(async (sender, e) =>
|
||||||
|
{
|
||||||
|
if (!Program.IsProgramRunningDialog(this, selection)) return;
|
||||||
|
byte[] creamConfig = null;
|
||||||
|
byte[] steamOriginalSdk32 = null;
|
||||||
|
byte[] steamOriginalSdk64 = null;
|
||||||
|
byte[] screamConfig = null;
|
||||||
|
byte[] epicOriginalSdk32 = null;
|
||||||
|
byte[] epicOriginalSdk64 = null;
|
||||||
|
foreach (string directory in selection.DllDirectories)
|
||||||
{
|
{
|
||||||
if (!Program.IsProgramRunningDialog(this, selection)) return;
|
directory.GetCreamApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config);
|
||||||
byte[] creamConfig = null;
|
if (creamConfig is null && File.Exists(config))
|
||||||
byte[] steamOriginalSdk32 = null;
|
creamConfig = File.ReadAllBytes(config);
|
||||||
byte[] steamOriginalSdk64 = null;
|
await InstallForm.UninstallCreamAPI(directory);
|
||||||
byte[] screamConfig = null;
|
if (steamOriginalSdk32 is null && File.Exists(sdk32) && !Properties.Resources.Steamworks32.EqualsFile(sdk32))
|
||||||
byte[] epicOriginalSdk32 = null;
|
steamOriginalSdk32 = File.ReadAllBytes(sdk32);
|
||||||
byte[] epicOriginalSdk64 = null;
|
if (steamOriginalSdk64 is null && File.Exists(sdk64) && !Properties.Resources.Steamworks64.EqualsFile(sdk64))
|
||||||
|
steamOriginalSdk64 = File.ReadAllBytes(sdk64);
|
||||||
|
directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config);
|
||||||
|
if (screamConfig is null && File.Exists(config))
|
||||||
|
screamConfig = File.ReadAllBytes(config);
|
||||||
|
await InstallForm.UninstallScreamAPI(directory);
|
||||||
|
if (epicOriginalSdk32 is null && File.Exists(sdk32) && !Properties.Resources.EpicOnlineServices32.EqualsFile(sdk32))
|
||||||
|
epicOriginalSdk32 = File.ReadAllBytes(sdk32);
|
||||||
|
if (epicOriginalSdk64 is null && File.Exists(sdk64) && !Properties.Resources.EpicOnlineServices64.EqualsFile(sdk64))
|
||||||
|
epicOriginalSdk64 = File.ReadAllBytes(sdk64);
|
||||||
|
}
|
||||||
|
if (steamOriginalSdk32 is not null || steamOriginalSdk64 is not null || epicOriginalSdk32 is not null || epicOriginalSdk64 is not null)
|
||||||
|
{
|
||||||
|
bool neededRepair = false;
|
||||||
foreach (string directory in selection.DllDirectories)
|
foreach (string directory in selection.DllDirectories)
|
||||||
{
|
{
|
||||||
directory.GetCreamApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config);
|
directory.GetCreamApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config);
|
||||||
if (creamConfig is null && File.Exists(config))
|
if (steamOriginalSdk32 is not null && Properties.Resources.Steamworks32.EqualsFile(sdk32))
|
||||||
creamConfig = File.ReadAllBytes(config);
|
|
||||||
await InstallForm.UninstallCreamAPI(directory);
|
|
||||||
if (steamOriginalSdk32 is null && File.Exists(sdk32) && !Properties.Resources.Steamworks32.EqualsFile(sdk32))
|
|
||||||
steamOriginalSdk32 = File.ReadAllBytes(sdk32);
|
|
||||||
if (steamOriginalSdk64 is null && File.Exists(sdk64) && !Properties.Resources.Steamworks64.EqualsFile(sdk64))
|
|
||||||
steamOriginalSdk64 = File.ReadAllBytes(sdk64);
|
|
||||||
directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config);
|
|
||||||
if (screamConfig is null && File.Exists(config))
|
|
||||||
screamConfig = File.ReadAllBytes(config);
|
|
||||||
await InstallForm.UninstallScreamAPI(directory);
|
|
||||||
if (epicOriginalSdk32 is null && File.Exists(sdk32) && !Properties.Resources.EpicOnlineServices32.EqualsFile(sdk32))
|
|
||||||
epicOriginalSdk32 = File.ReadAllBytes(sdk32);
|
|
||||||
if (epicOriginalSdk64 is null && File.Exists(sdk64) && !Properties.Resources.EpicOnlineServices64.EqualsFile(sdk64))
|
|
||||||
epicOriginalSdk64 = File.ReadAllBytes(sdk64);
|
|
||||||
}
|
|
||||||
if (steamOriginalSdk32 is not null || steamOriginalSdk64 is not null || epicOriginalSdk32 is not null || epicOriginalSdk64 is not null)
|
|
||||||
{
|
|
||||||
bool neededRepair = false;
|
|
||||||
foreach (string directory in selection.DllDirectories)
|
|
||||||
{
|
{
|
||||||
directory.GetCreamApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config);
|
steamOriginalSdk32.Write(sdk32);
|
||||||
if (steamOriginalSdk32 is not null && Properties.Resources.Steamworks32.EqualsFile(sdk32))
|
neededRepair = true;
|
||||||
{
|
}
|
||||||
steamOriginalSdk32.Write(sdk32);
|
if (steamOriginalSdk64 is not null && Properties.Resources.Steamworks64.EqualsFile(sdk64))
|
||||||
neededRepair = true;
|
{
|
||||||
}
|
steamOriginalSdk64.Write(sdk64);
|
||||||
if (steamOriginalSdk64 is not null && Properties.Resources.Steamworks64.EqualsFile(sdk64))
|
neededRepair = true;
|
||||||
{
|
}
|
||||||
steamOriginalSdk64.Write(sdk64);
|
if (creamConfig is not null)
|
||||||
neededRepair = true;
|
{
|
||||||
}
|
await InstallForm.InstallCreamAPI(directory, selection);
|
||||||
if (creamConfig is not null)
|
creamConfig.Write(config);
|
||||||
{
|
}
|
||||||
await InstallForm.InstallCreamAPI(directory, selection);
|
|
||||||
creamConfig.Write(config);
|
directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config);
|
||||||
}
|
if (epicOriginalSdk32 is not null && Properties.Resources.EpicOnlineServices32.EqualsFile(sdk32))
|
||||||
|
{
|
||||||
directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config);
|
epicOriginalSdk32.Write(sdk32);
|
||||||
if (epicOriginalSdk32 is not null && Properties.Resources.EpicOnlineServices32.EqualsFile(sdk32))
|
neededRepair = true;
|
||||||
{
|
}
|
||||||
epicOriginalSdk32.Write(sdk32);
|
if (epicOriginalSdk64 is not null && Properties.Resources.EpicOnlineServices64.EqualsFile(sdk64))
|
||||||
neededRepair = true;
|
{
|
||||||
}
|
epicOriginalSdk64.Write(sdk64);
|
||||||
if (epicOriginalSdk64 is not null && Properties.Resources.EpicOnlineServices64.EqualsFile(sdk64))
|
neededRepair = true;
|
||||||
{
|
}
|
||||||
epicOriginalSdk64.Write(sdk64);
|
if (screamConfig is not null)
|
||||||
neededRepair = true;
|
{
|
||||||
}
|
await InstallForm.InstallScreamAPI(directory, selection);
|
||||||
if (screamConfig is not null)
|
screamConfig.Write(config);
|
||||||
{
|
|
||||||
await InstallForm.InstallScreamAPI(directory, selection);
|
|
||||||
screamConfig.Write(config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (neededRepair)
|
|
||||||
new DialogForm(this).Show(Icon, "Paradox Launcher successfully repaired!", "OK");
|
|
||||||
else
|
|
||||||
new DialogForm(this).Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK");
|
|
||||||
}
|
}
|
||||||
|
if (neededRepair)
|
||||||
|
new DialogForm(this).Show(Icon, "Paradox Launcher successfully repaired!", "OK");
|
||||||
else
|
else
|
||||||
new DialogForm(this).Show(SystemIcons.Error, "Paradox Launcher repair failed!"
|
new DialogForm(this).Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK");
|
||||||
+ "\n\nAn original Steamworks/Epic Online Services SDK file could not be found."
|
}
|
||||||
+ "\nYou must reinstall Paradox Launcher to fix this issue.", "OK");
|
else
|
||||||
})));
|
new DialogForm(this).Show(SystemIcons.Error, "Paradox Launcher repair failed!"
|
||||||
}
|
+ "\n\nAn original Steamworks/Epic Online Services SDK file could not be found."
|
||||||
nodeContextMenu.Items.Add(new ToolStripSeparator());
|
+ "\nYou must reinstall Paradox Launcher to fix this issue.", "OK");
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Open Root Directory", Image("File Explorer"),
|
})));
|
||||||
new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(selection.RootDirectory))));
|
|
||||||
for (int i = 0; i < selection.DllDirectories.Count; i++)
|
|
||||||
{
|
|
||||||
string directory = selection.DllDirectories[i];
|
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem($"Open {(selection.IsSteam ? "Steamworks" : "Epic Online Services")} SDK Directory ({i + 1})", Image("File Explorer"),
|
|
||||||
new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ProgramSelection dlcParentSelection = dlc.HasValue ? ProgramSelection.FromId(dlc.Value.gameAppId) : null;
|
AddToContextMenu(cmi, new ToolStripSeparator());
|
||||||
if (id != "ParadoxLauncher" && (selection is not null && selection.IsSteam || dlcParentSelection is not null && dlcParentSelection.IsSteam))
|
AddToContextMenu(cmi, new ContextMenuItem("Open Root Directory", "File Explorer",
|
||||||
|
new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(selection.RootDirectory))));
|
||||||
|
for (int i = 0; i < selection.DllDirectories.Count; i++)
|
||||||
{
|
{
|
||||||
nodeContextMenu.Items.Add(new ToolStripSeparator());
|
string directory = selection.DllDirectories[i];
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Open SteamDB", Image("SteamDB"),
|
AddToContextMenu(cmi, new ContextMenuItem($"Open {(selection.IsSteam ? "Steamworks" : "Epic Online Services")} SDK Directory ({i + 1})", "File Explorer",
|
||||||
|
new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (id != "ParadoxLauncher")
|
||||||
|
{
|
||||||
|
if (selection is not null && selection.IsSteam || dlcParentSelection is not null && dlcParentSelection.IsSteam)
|
||||||
|
{
|
||||||
|
AddToContextMenu(cmi, new ToolStripSeparator());
|
||||||
|
AddToContextMenu(cmi, new ContextMenuItem("Open SteamDB", "SteamDB",
|
||||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://steamdb.info/app/" + id))));
|
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://steamdb.info/app/" + id))));
|
||||||
}
|
}
|
||||||
if (id != "ParadoxLauncher" && selection is not null)
|
if (selection is not null && selection.IsSteam)
|
||||||
{
|
{
|
||||||
if (selection.IsSteam)
|
AddToContextMenu(cmi, new ContextMenuItem("Open Steam Store", "Steam Store",
|
||||||
{
|
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl))));
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Open Steam Store", Image("Steam Store"),
|
AddToContextMenu(cmi, new ContextMenuItem("Open Steam Community", (id, selection.SubIconUrl, true), "Steam Community",
|
||||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl))));
|
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://steamcommunity.com/app/" + id))));
|
||||||
ToolStripMenuItem steamCommunity = new("Open Steam Community", Image("ClientIcon_" + id),
|
}
|
||||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://steamcommunity.com/app/" + id)));
|
else
|
||||||
nodeContextMenu.Items.Add(steamCommunity);
|
{
|
||||||
if (steamCommunity.Image is null)
|
AddToContextMenu(cmi, new ToolStripSeparator());
|
||||||
{
|
AddToContextMenu(cmi, new ContextMenuItem("Open ScreamDB", "ScreamDB",
|
||||||
steamCommunity.Image = Image("Steam Community");
|
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://scream-db.web.app/offers/" + id))));
|
||||||
TrySetImageAsync(steamCommunity, id, selection.SubIconUrl, true);
|
AddToContextMenu(cmi, new ContextMenuItem("Open Epic Games Store", "Epic Games",
|
||||||
}
|
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl))));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nodeContextMenu.Items.Add(new ToolStripSeparator());
|
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Open ScreamDB", Image("ScreamDB"),
|
|
||||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://scream-db.web.app/offers/" + id))));
|
|
||||||
nodeContextMenu.Items.Add(new ToolStripMenuItem("Open Epic Games Store", Image("Epic Games"),
|
|
||||||
new EventHandler((sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nodeContextMenu.Show(selectionTreeView, e.Location);
|
|
||||||
}
|
}
|
||||||
|
if (cmi != contextMenuIndex) return;
|
||||||
|
nodeContextMenu.Show(selectionTreeView, e.Location);
|
||||||
};
|
};
|
||||||
OnLoad();
|
OnLoad();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue