Skip to content

Commit

Permalink
Don't launch Roblox after install/update
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Oct 5, 2022
1 parent 350b655 commit 4c5bdb3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 21 deletions.
7 changes: 6 additions & 1 deletion Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ public async Task Run()

await RbxFpsUnlocker.CheckInstall();

await StartRoblox();
if (Program.IsFirstRun)
Dialog.ShowSuccess($"{Program.ProjectName} has been installed");
else
await StartRoblox();

Program.Exit();
}
Expand Down Expand Up @@ -293,6 +296,8 @@ public static void Register()
uninstallKey.SetValue("Publisher", Program.ProjectName);
uninstallKey.SetValue("ModifyPath", $"\"{Directories.App}\" -preferences");
uninstallKey.SetValue("UninstallString", $"\"{Directories.App}\" -uninstall");
uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{Program.ProjectRepository}");
uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{Program.ProjectRepository}/releases/latest");
uninstallKey.Close();
}

Expand Down
5 changes: 3 additions & 2 deletions Bloxstrap/Dialogs/Preferences.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<StackPanel VerticalAlignment="Center">
<CheckBox x:Name="CheckBoxModDeathSound" Content=" Use old death sound" Margin="5" IsChecked="{Binding ModOldDeathSound, Mode=TwoWay}" />
<CheckBox x:Name="CheckBoxModMouseCursor" Content=" Use old mouse cursor" Margin="5" IsChecked="{Binding ModOldMouseCursor, Mode=TwoWay}" />
<Button x:Name="ButtonOpenModFolder" Content="Open folder" VerticalAlignment="Bottom" Height="23" Margin="5,5,5,5" Click="ButtonOpenModFolder_Click" />
<Button x:Name="ButtonOpenModFolder" Content="{Binding ModFolderButtonText, Mode=OneTime}" IsEnabled="{Binding ModFolderButtonEnabled, Mode=OneTime}" VerticalAlignment="Bottom" Height="23" Margin="5,5,5,5" Click="ButtonOpenModFolder_Click" />
</StackPanel>
</GroupBox>
</StackPanel>
Expand All @@ -68,7 +68,7 @@
<Button Grid.Column="1" x:Name="ButtonInstallLocationBrowse" Content="Browse..." Margin="5,0,0,0" Click="ButtonLocationBrowse_Click" />
</Grid>
</GroupBox>
<GroupBox Header="Channel" VerticalAlignment="Top" Margin="10, 5, 10, 0">
<GroupBox Header="Channel" VerticalAlignment="Top" Margin="10, 5, 10, 5">
<StackPanel VerticalAlignment="Center">
<Grid>
<Grid.ColumnDefinitions>
Expand All @@ -81,6 +81,7 @@
<TextBlock x:Name="TextBlockChannelInfo" Text="{Binding ChannelInfo, Mode=OneWay}" TextWrapping="Wrap" Margin="5" />
</StackPanel>
</GroupBox>
<CheckBox Content=" Check for Bloxstrap updates on startup" IsChecked="{Binding CheckForUpdates, Mode=TwoWay}" Margin="10,5,10,5" />
</StackPanel>
</TabItem>
<TabItem Padding="5">
Expand Down
8 changes: 7 additions & 1 deletion Bloxstrap/Dialogs/Preferences.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public bool ModOldMouseCursor
}

public bool ModFolderButtonEnabled { get; } = !Program.IsFirstRun;
public string ModFolderButtonText { get; } = Program.IsFirstRun ? "Install Bloxstrap first to add custom mods" : "Open mod folder";
public string ModFolderButtonText { get; } = Program.IsFirstRun ? "Custom mods can be added after installing Bloxstrap" : "Open mod folder";
#endregion

#region Installation
Expand Down Expand Up @@ -267,6 +267,12 @@ public string ChannelInfo
OnPropertyChanged();
}
}

public bool CheckForUpdates
{
get => Program.Settings.CheckForUpdates;
set => Program.Settings.CheckForUpdates = value;
}
#endregion

#region Style
Expand Down
6 changes: 3 additions & 3 deletions Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static async Task CheckInstall()
if (Program.BaseDirectory is null)
return;

string folderLocation = Path.Combine(Program.BaseDirectory, "Integrations", "rbxfpsunlocker");
string folderLocation = Path.Combine(Program.BaseDirectory, "Integrations\\rbxfpsunlocker");
string fileLocation = Path.Combine(folderLocation, "rbxfpsunlocker.exe");
string settingsLocation = Path.Combine(folderLocation, "settings");

Expand All @@ -47,11 +47,11 @@ public static async Task CheckInstall()

var releaseInfo = await Utilities.GetJson<GithubRelease>($"https://api.github.com/repos/{ProjectRepository}/releases/latest");

if (releaseInfo is null || releaseInfo.CreatedAt is null || releaseInfo.Assets is null)
if (releaseInfo is null || releaseInfo.Assets is null)
return;

lastReleasePublish = DateTime.Parse(releaseInfo.CreatedAt);
downloadUrl = releaseInfo.Assets![0].BrowserDownloadUrl!;
downloadUrl = releaseInfo.Assets[0].BrowserDownloadUrl;

Directory.CreateDirectory(folderLocation);

Expand Down
21 changes: 14 additions & 7 deletions Bloxstrap/Helpers/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace Bloxstrap.Helpers
{
public class Updater
{
public static bool CheckInstalledVersion()
public static void CheckInstalledVersion()
{
if (Environment.ProcessPath is null || !File.Exists(Directories.App) || Environment.ProcessPath == Directories.App)
return false;
return;

// if downloaded version doesn't match, replace installed version with downloaded version
FileVersionInfo currentVersionInfo = FileVersionInfo.GetVersionInfo(Environment.ProcessPath);
Expand All @@ -23,7 +23,7 @@ public static bool CheckInstalledVersion()
if (installedVersionInfo.ProductVersion != currentVersionInfo.ProductVersion)
{
DialogResult result = Program.ShowMessageBox(
$"The version of {Program.ProjectName} you've launched is newer than the version you currently have installed.\nWould you like to update your currently installed version?",
$"The version of {Program.ProjectName} you've launched is different to the version you currently have installed.\nWould you like to update your currently installed version?",
MessageBoxIcon.Question,
MessageBoxButtons.YesNo
);
Expand All @@ -32,20 +32,27 @@ public static bool CheckInstalledVersion()
{
File.Delete(Directories.App);
File.Copy(Environment.ProcessPath, Directories.App);
return true;

Program.ShowMessageBox(
$"{Program.ProjectName} has been updated to v{currentVersionInfo.ProductVersion}",
MessageBoxIcon.Information,
MessageBoxButtons.OK
);

Environment.Exit(0);
}
}

return false;
return;
}

public static async Task Check()
{
if (Environment.ProcessPath is null)
return;

if (!Program.IsFirstRun && CheckInstalledVersion())
return;
if (!Program.IsFirstRun)
CheckInstalledVersion();

if (!Program.Settings.CheckForUpdates)
return;
Expand Down
15 changes: 9 additions & 6 deletions Bloxstrap/Models/GithubRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ namespace Bloxstrap.Models
public class GithubRelease
{
[JsonPropertyName("name")]
public string? Name { get; set; }
public string Name { get; set; } = null!;

[JsonPropertyName("body")]
public string? Body { get; set; }
public string Body { get; set; } = null!;

[JsonPropertyName("created_at")]
public string? CreatedAt { get; set; }
public string CreatedAt { get; set; } = null!;

[JsonPropertyName("assets")]
public List<GithubReleaseAsset>? Assets { get; set; }
}

public class GithubReleaseAsset
{
[JsonPropertyName("browser_download_url")]
public string? BrowserDownloadUrl { get; set; }
public string BrowserDownloadUrl { get; set; } = null!;

[JsonPropertyName("name")]
public string Name { get; set; } = null!;
}
}
2 changes: 1 addition & 1 deletion Bloxstrap/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static void Main(string[] args)
return;
}

new PreferencesWPF().ShowDialog();
new Preferences().ShowDialog();
}
else if (args[0].StartsWith("roblox-player:"))
{
Expand Down

0 comments on commit 4c5bdb3

Please sign in to comment.