Add icon for launching from desktop

This commit is contained in:
pizzaboxer 2023-01-21 22:32:06 +00:00
parent e10e2a830b
commit 0f8cd4a922
8 changed files with 60 additions and 46 deletions

View File

@ -373,15 +373,21 @@ namespace Bloxstrap
// this SHOULD go under Register(), // this SHOULD go under Register(),
// but then people who have Bloxstrap v1.0.0 installed won't have this without a reinstall // but then people who have Bloxstrap v1.0.0 installed won't have this without a reinstall
// maybe in a later version? // maybe in a later version?
if (!Directory.Exists(Program.StartMenu)) if (!Directory.Exists(Directories.StartMenu))
{ {
Directory.CreateDirectory(Program.StartMenu); Directory.CreateDirectory(Directories.StartMenu);
ShellLink.Shortcut.CreateShortcut(Directories.App, "", Directories.App, 0) ShellLink.Shortcut.CreateShortcut(Directories.App, "", Directories.App, 0)
.WriteToFile(Path.Combine(Program.StartMenu, "Play Roblox.lnk")); .WriteToFile(Path.Combine(Directories.StartMenu, "Play Roblox.lnk"));
ShellLink.Shortcut.CreateShortcut(Directories.App, "-preferences", Directories.App, 0) ShellLink.Shortcut.CreateShortcut(Directories.App, "-preferences", Directories.App, 0)
.WriteToFile(Path.Combine(Program.StartMenu, $"Configure {Program.ProjectName}.lnk")); .WriteToFile(Path.Combine(Directories.StartMenu, $"Configure {Program.ProjectName}.lnk"));
}
if (Program.Settings.CreateDesktopIcon && !File.Exists(Path.Combine(Directories.Desktop, "Play Roblox.lnk")))
{
ShellLink.Shortcut.CreateShortcut(Directories.App, "", Directories.App, 0)
.WriteToFile(Path.Combine(Directories.Desktop, "Play Roblox.lnk"));
} }
} }
@ -416,7 +422,10 @@ namespace Bloxstrap
Registry.CurrentUser.DeleteSubKey($@"Software\{Program.ProjectName}"); Registry.CurrentUser.DeleteSubKey($@"Software\{Program.ProjectName}");
// delete start menu folder // delete start menu folder
Directory.Delete(Program.StartMenu, true); Directory.Delete(Directories.StartMenu, true);
// delete desktop shortcut
File.Delete(Path.Combine(Directories.Desktop, "Play Roblox.lnk"));
// delete uninstall key // delete uninstall key
Registry.CurrentUser.DeleteSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Program.ProjectName}"); Registry.CurrentUser.DeleteSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Program.ProjectName}");
@ -425,7 +434,10 @@ namespace Bloxstrap
// (should delete everything except bloxstrap itself) // (should delete everything except bloxstrap itself)
Directory.Delete(Directories.Base, true); Directory.Delete(Directories.Base, true);
} }
catch (Exception) { } catch (Exception e)
{
Debug.WriteLine($"Could not fully uninstall! ({e})");
}
Dialog.ShowSuccess($"{Program.ProjectName} has succesfully uninstalled"); Dialog.ShowSuccess($"{Program.ProjectName} has succesfully uninstalled");
@ -604,8 +616,7 @@ namespace Bloxstrap
// package doesn't exist, likely mistakenly placed file // package doesn't exist, likely mistakenly placed file
string versionFileLocation = Path.Combine(VersionFolder, fileLocation); string versionFileLocation = Path.Combine(VersionFolder, fileLocation);
if (File.Exists(versionFileLocation)) File.Delete(versionFileLocation);
File.Delete(versionFileLocation);
continue; continue;
} }
@ -647,7 +658,7 @@ namespace Bloxstrap
{ {
string packageUrl = $"{DeployManager.BaseUrl}/{VersionGuid}-{package.Name}"; string packageUrl = $"{DeployManager.BaseUrl}/{VersionGuid}-{package.Name}";
string packageLocation = Path.Combine(Directories.Downloads, package.Signature); string packageLocation = Path.Combine(Directories.Downloads, package.Signature);
string robloxPackageLocation = Path.Combine(Program.LocalAppData, "Roblox", "Downloads", package.Signature); string robloxPackageLocation = Path.Combine(Directories.LocalAppData, "Roblox", "Downloads", package.Signature);
if (File.Exists(packageLocation)) if (File.Exists(packageLocation))
{ {
@ -657,7 +668,7 @@ namespace Bloxstrap
if (calculatedMD5 != package.Signature) if (calculatedMD5 != package.Signature)
{ {
Debug.WriteLine($"{package.Name} is corrupted ({calculatedMD5} != {package.Signature})! Deleting and re-downloading..."); Debug.WriteLine($"{package.Name} is corrupted ({calculatedMD5} != {package.Signature})! Deleting and re-downloading...");
file.Delete(); file.Delete();
} }
else else
{ {
@ -743,10 +754,7 @@ namespace Bloxstrap
Directory.CreateDirectory(directory); Directory.CreateDirectory(directory);
if (File.Exists(extractPath)) await Task.Run(() => entry.ExtractToFile(extractPath, true));
File.Delete(extractPath);
await Task.Run(() => entry.ExtractToFile(extractPath));
} }
} }
@ -776,8 +784,7 @@ namespace Bloxstrap
string fileLocation = Path.Combine(packageFolder, entry.FullName); string fileLocation = Path.Combine(packageFolder, entry.FullName);
if (File.Exists(fileLocation)) File.Delete(fileLocation);
File.Delete(fileLocation);
entry.ExtractToFile(fileLocation); entry.ExtractToFile(fileLocation);
} }

View File

@ -159,6 +159,7 @@
<Button x:Name="ButtonPreview" Content="Preview" Margin="0,5,0,0" VerticalAlignment="Bottom" Height="23" Click="ButtonPreview_Click" /> <Button x:Name="ButtonPreview" Content="Preview" Margin="0,5,0,0" VerticalAlignment="Bottom" Height="23" Click="ButtonPreview_Click" />
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
<CheckBox Content=" Create desktop icon" IsChecked="{Binding CreateDesktopIcon, Mode=TwoWay}" Margin="10,10,10,0" />
<CheckBox Content=" Check for Bloxstrap updates on startup" IsChecked="{Binding CheckForUpdates, Mode=TwoWay}" Margin="10,10,10,0" /> <CheckBox Content=" Check for Bloxstrap updates on startup" IsChecked="{Binding CheckForUpdates, Mode=TwoWay}" Margin="10,10,10,0" />
</StackPanel> </StackPanel>
</TabItem> </TabItem>

View File

@ -262,7 +262,7 @@ namespace Bloxstrap.Dialogs.Menu
#endregion #endregion
#region Installation #region Installation
private string installLocation = Program.IsFirstRun ? Path.Combine(Program.LocalAppData, Program.ProjectName) : Program.BaseDirectory; private string installLocation = Program.IsFirstRun ? Path.Combine(Directories.LocalAppData, Program.ProjectName) : Program.BaseDirectory;
public string InstallLocation public string InstallLocation
{ {
get => installLocation; get => installLocation;
@ -383,6 +383,12 @@ namespace Bloxstrap.Dialogs.Menu
set => Program.Settings.BootstrapperIcon = Icons[value]; set => Program.Settings.BootstrapperIcon = Icons[value];
} }
public bool CreateDesktopIcon
{
get => Program.Settings.CreateDesktopIcon;
set => Program.Settings.CreateDesktopIcon = value;
}
public bool CheckForUpdates public bool CheckForUpdates
{ {
get => Program.Settings.CheckForUpdates; get => Program.Settings.CheckForUpdates;

View File

@ -4,6 +4,12 @@ namespace Bloxstrap.Helpers
{ {
class Directories class Directories
{ {
// note that these are directories that aren't tethered to the basedirectory
// so these can safely be called before initialization
public static string LocalAppData { get => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); }
public static string Desktop { get => Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); }
public static string StartMenu { get => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", Program.ProjectName); }
public static string Base { get; private set; } = ""; public static string Base { get; private set; } = "";
public static string Downloads { get; private set; } = ""; public static string Downloads { get; private set; } = "";
public static string Integrations { get; private set; } = ""; public static string Integrations { get; private set; } = "";

View File

@ -85,7 +85,7 @@ namespace Bloxstrap.Helpers.Integrations
// //
// we'll tail the log file continuously, monitoring for any log entries that we need to determine the current game activity // we'll tail the log file continuously, monitoring for any log entries that we need to determine the current game activity
string logDirectory = Path.Combine(Program.LocalAppData, "Roblox\\logs"); string logDirectory = Path.Combine(Directories.LocalAppData, "Roblox\\logs");
if (!Directory.Exists(logDirectory)) if (!Directory.Exists(logDirectory))
return; return;

View File

@ -331,12 +331,8 @@ namespace Bloxstrap.Helpers.Integrations
Debug.WriteLine("[ReShade] Uninstalling ReShade..."); Debug.WriteLine("[ReShade] Uninstalling ReShade...");
// delete any stock config files // delete any stock config files
File.Delete(injectorLocation);
if (File.Exists(injectorLocation)) File.Delete(ConfigLocation);
File.Delete(injectorLocation);
if (File.Exists(ConfigLocation))
File.Delete(ConfigLocation);
Program.Settings.ReShadeConfigVersion = ""; Program.Settings.ReShadeConfigVersion = "";

View File

@ -5,32 +5,35 @@ namespace Bloxstrap.Models
{ {
public class SettingsFormat public class SettingsFormat
{ {
public string Channel { get; set; } = DeployManager.DefaultChannel;
public string VersionGuid { get; set; } = "";
public bool CheckForUpdates { get; set; } = true;
public bool PromptChannelChange { get; set; } = false;
public BootstrapperStyle BootstrapperStyle { get; set; } = BootstrapperStyle.ProgressDialog;
public BootstrapperIcon BootstrapperIcon { get; set; } = BootstrapperIcon.IconBloxstrap;
public Theme Theme { get; set; } = Theme.Default;
public bool UseDiscordRichPresence { get; set; } = true;
public bool HideRPCButtons { get; set; } = false;
public bool RFUEnabled { get; set; } = false;
public bool RFUAutoclose { get; set; } = false;
// could these be moved to a separate file (something like State.json)? // could these be moved to a separate file (something like State.json)?
// the only problem is i havent yet figured out a way to boil down the settings handler to reduce boilerplate // the only problem is i havent yet figured out a way to boil down the settings handler to reduce boilerplate
// as the Program class needs a Settings and a SettingsManager property // as the Program class needs a Settings and a SettingsManager property
// once i figure that out, then ig i could move these // once i figure that out, then ig i could move these
public string VersionGuid { get; set; } = "";
public string RFUVersion { get; set; } = ""; public string RFUVersion { get; set; } = "";
public string ReShadeConfigVersion { get; set; } = ""; public string ReShadeConfigVersion { get; set; } = "";
public string ExtraviPresetsVersion { get; set; } = ""; public string ExtraviPresetsVersion { get; set; } = "";
// bloxstrap configuration
public BootstrapperStyle BootstrapperStyle { get; set; } = BootstrapperStyle.ProgressDialog;
public BootstrapperIcon BootstrapperIcon { get; set; } = BootstrapperIcon.IconBloxstrap;
public Theme Theme { get; set; } = Theme.Default;
public bool CheckForUpdates { get; set; } = true;
public bool CreateDesktopIcon { get; set; } = true;
// channel configuration
public string Channel { get; set; } = DeployManager.DefaultChannel;
public bool PromptChannelChange { get; set; } = false;
// integration configuration
public bool UseDiscordRichPresence { get; set; } = true;
public bool HideRPCButtons { get; set; } = false;
public bool RFUEnabled { get; set; } = false;
public bool RFUAutoclose { get; set; } = false;
public bool UseReShade { get; set; } = false; public bool UseReShade { get; set; } = false;
public bool UseReShadeExtraviPresets { get; set; } = false; public bool UseReShadeExtraviPresets { get; set; } = false;
// mod preset configuration
public bool UseOldDeathSound { get; set; } = true; public bool UseOldDeathSound { get; set; } = true;
public bool UseOldMouseCursor { get; set; } = false; public bool UseOldMouseCursor { get; set; } = false;
public bool UseDisableAppPatch { get; set; } = false; public bool UseDisableAppPatch { get; set; } = false;

View File

@ -31,8 +31,6 @@ namespace Bloxstrap
public static bool IsUpgrade { get; private set; } = false; public static bool IsUpgrade { get; private set; } = false;
public static string[] LaunchArgs { get; private set; } = null!; public static string[] LaunchArgs { get; private set; } = null!;
public static string LocalAppData { get; private set; } = null!;
public static string StartMenu { get; private set; } = null!;
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2]; public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
@ -70,9 +68,6 @@ namespace Bloxstrap
HttpClient.Timeout = TimeSpan.FromMinutes(5); HttpClient.Timeout = TimeSpan.FromMinutes(5);
HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository); HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository);
LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
StartMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", ProjectName);
if (args.Length > 0) if (args.Length > 0)
{ {
if (Array.IndexOf(args, "-quiet") != -1) if (Array.IndexOf(args, "-quiet") != -1)
@ -97,7 +92,7 @@ namespace Bloxstrap
Settings = SettingsManager.Settings; Settings = SettingsManager.Settings;
if (IsQuiet) if (IsQuiet)
BaseDirectory = Path.Combine(LocalAppData, ProjectName); BaseDirectory = Path.Combine(Directories.LocalAppData, ProjectName);
else else
new Preferences().ShowDialog(); new Preferences().ShowDialog();
} }