mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 01:51:29 -07:00
Show notice if ShellLink can't be loaded
This commit is contained in:
parent
0df4840873
commit
30ae314537
@ -277,7 +277,7 @@ namespace Bloxstrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Task bootstrapperTask = Task.Run(() => bootstrapper.Run()).ContinueWith(t =>
|
Task bootstrapperTask = Task.Run(async () => await bootstrapper.Run()).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
Logger.WriteLine(LOG_IDENT, "Bootstrapper task has finished");
|
Logger.WriteLine(LOG_IDENT, "Bootstrapper task has finished");
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ namespace Bloxstrap
|
|||||||
private readonly CancellationTokenSource _cancelTokenSource = new();
|
private readonly CancellationTokenSource _cancelTokenSource = new();
|
||||||
|
|
||||||
private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid);
|
private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid);
|
||||||
private static string DesktopShortcutLocation => Path.Combine(Paths.Desktop, "Play Roblox.lnk");
|
|
||||||
|
|
||||||
private string _playerLocation => Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
|
private string _playerLocation => Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
|
||||||
|
|
||||||
@ -508,45 +507,32 @@ namespace Bloxstrap
|
|||||||
if (!Directory.Exists(Paths.StartMenu))
|
if (!Directory.Exists(Paths.StartMenu))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Paths.StartMenu);
|
Directory.CreateDirectory(Paths.StartMenu);
|
||||||
|
|
||||||
ShellLink.Shortcut.CreateShortcut(Paths.Application, "", Paths.Application, 0)
|
|
||||||
.WriteToFile(Path.Combine(Paths.StartMenu, "Play Roblox.lnk"));
|
|
||||||
|
|
||||||
ShellLink.Shortcut.CreateShortcut(Paths.Application, "-menu", Paths.Application, 0)
|
|
||||||
.WriteToFile(Path.Combine(Paths.StartMenu, $"{App.ProjectName} Menu.lnk"));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// v2.0.0 - rebadge configuration menu as just "Bloxstrap Menu"
|
// v2.0.0 - rebadge configuration menu as just "Bloxstrap Menu"
|
||||||
string oldMenuShortcut = Path.Combine(Paths.StartMenu, $"Configure {App.ProjectName}.lnk");
|
string oldMenuShortcut = Path.Combine(Paths.StartMenu, $"Configure {App.ProjectName}.lnk");
|
||||||
string newMenuShortcut = Path.Combine(Paths.StartMenu, $"{App.ProjectName} Menu.lnk");
|
|
||||||
|
|
||||||
if (File.Exists(oldMenuShortcut))
|
if (File.Exists(oldMenuShortcut))
|
||||||
File.Delete(oldMenuShortcut);
|
File.Delete(oldMenuShortcut);
|
||||||
|
|
||||||
if (!File.Exists(newMenuShortcut))
|
|
||||||
ShellLink.Shortcut.CreateShortcut(Paths.Application, "-menu", Paths.Application, 0)
|
|
||||||
.WriteToFile(newMenuShortcut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utility.Shortcut.Create(Paths.Application, "", Path.Combine(Paths.StartMenu, "Play Roblox.lnk"));
|
||||||
|
Utility.Shortcut.Create(Paths.Application, "-menu", Path.Combine(Paths.StartMenu, $"{App.ProjectName} Menu.lnk"));
|
||||||
|
|
||||||
if (App.Settings.Prop.CreateDesktopIcon)
|
if (App.Settings.Prop.CreateDesktopIcon)
|
||||||
{
|
{
|
||||||
if (!File.Exists(DesktopShortcutLocation))
|
try
|
||||||
{
|
{
|
||||||
try
|
Utility.Shortcut.Create(Paths.Application, "", Path.Combine(Paths.Desktop, "Play Roblox.lnk"));
|
||||||
{
|
|
||||||
ShellLink.Shortcut.CreateShortcut(Paths.Application, "", Paths.Application, 0)
|
|
||||||
.WriteToFile(DesktopShortcutLocation);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, "Could not create desktop shortcut, aborting");
|
|
||||||
App.Logger.WriteException(LOG_IDENT, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// one-time toggle, set it back to false
|
// one-time toggle, set it back to false
|
||||||
App.Settings.Prop.CreateDesktopIcon = false;
|
App.Settings.Prop.CreateDesktopIcon = false;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// suppress, we likely just don't have write perms for the desktop folder
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
Bloxstrap/Enums/AssemblyLoadStatus.cs
Normal file
9
Bloxstrap/Enums/AssemblyLoadStatus.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Bloxstrap.Enums
|
||||||
|
{
|
||||||
|
enum AssemblyLoadStatus
|
||||||
|
{
|
||||||
|
NotAttempted,
|
||||||
|
Failed,
|
||||||
|
Successful
|
||||||
|
}
|
||||||
|
}
|
43
Bloxstrap/Utility/Shortcut.cs
Normal file
43
Bloxstrap/Utility/Shortcut.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace Bloxstrap.Utility
|
||||||
|
{
|
||||||
|
internal static class Shortcut
|
||||||
|
{
|
||||||
|
private static AssemblyLoadStatus _loadStatus = AssemblyLoadStatus.NotAttempted;
|
||||||
|
|
||||||
|
public static void Create(string exePath, string exeArgs, string lnkPath)
|
||||||
|
{
|
||||||
|
const string LOG_IDENT = "Shortcut::Create";
|
||||||
|
|
||||||
|
if (File.Exists(lnkPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ShellLink.Shortcut.CreateShortcut(exePath, exeArgs, exePath, 0).WriteToFile(lnkPath);
|
||||||
|
|
||||||
|
if (_loadStatus != AssemblyLoadStatus.Successful)
|
||||||
|
_loadStatus = AssemblyLoadStatus.Successful;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine(LOG_IDENT, $"Failed to create a shortcut for {lnkPath}!");
|
||||||
|
App.Logger.WriteException(LOG_IDENT, ex);
|
||||||
|
|
||||||
|
if (ex.GetType() != typeof(FileNotFoundException))
|
||||||
|
throw;
|
||||||
|
|
||||||
|
if (_loadStatus == AssemblyLoadStatus.Failed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_loadStatus = AssemblyLoadStatus.Failed;
|
||||||
|
|
||||||
|
Controls.ShowMessageBox(
|
||||||
|
$"{App.ProjectName} was unable to create shortcuts for the Desktop and Start menu. They will be created the next time Roblox is launched.",
|
||||||
|
MessageBoxImage.Information
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user