mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Improve auto updating (notification/bugfix)
This commit is contained in:
parent
fdc9f9b1bc
commit
558fc4e983
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@ -138,6 +137,8 @@ namespace Bloxstrap
|
|||||||
if (!IsQuiet)
|
if (!IsQuiet)
|
||||||
{
|
{
|
||||||
IsSetupComplete = false;
|
IsSetupComplete = false;
|
||||||
|
// we have reshade enabled by default so we need this
|
||||||
|
FastFlags.SetRenderingMode("Direct3D 11");
|
||||||
new MainWindow().ShowDialog();
|
new MainWindow().ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,8 +195,8 @@ namespace Bloxstrap
|
|||||||
ShowMessageBox($"{ProjectName} is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances.", MessageBoxImage.Information);
|
ShowMessageBox($"{ProjectName} is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances.", MessageBoxImage.Information);
|
||||||
|
|
||||||
new MainWindow().ShowDialog();
|
new MainWindow().ShowDialog();
|
||||||
App.FastFlags.Save();
|
App.FastFlags.Save();
|
||||||
}
|
}
|
||||||
else if (LaunchArgs.Length > 0)
|
else if (LaunchArgs.Length > 0)
|
||||||
{
|
{
|
||||||
if (LaunchArgs[0].StartsWith("roblox-player:"))
|
if (LaunchArgs[0].StartsWith("roblox-player:"))
|
||||||
@ -224,11 +225,13 @@ namespace Bloxstrap
|
|||||||
DeployManager.SetChannel(Settings.Prop.Channel);
|
DeployManager.SetChannel(Settings.Prop.Channel);
|
||||||
|
|
||||||
// start bootstrapper and show the bootstrapper modal if we're not running silently
|
// start bootstrapper and show the bootstrapper modal if we're not running silently
|
||||||
Bootstrapper bootstrapper = new Bootstrapper(commandLine);
|
Logger.WriteLine($"[App::OnStartup] Initializing bootstrapper");
|
||||||
|
Bootstrapper bootstrapper = new(commandLine);
|
||||||
IBootstrapperDialog? dialog = null;
|
IBootstrapperDialog? dialog = null;
|
||||||
|
|
||||||
if (!IsQuiet)
|
if (!IsQuiet)
|
||||||
{
|
{
|
||||||
|
Logger.WriteLine($"[App::OnStartup] Initializing bootstrapper dialog");
|
||||||
dialog = Settings.Prop.BootstrapperStyle.GetNew();
|
dialog = Settings.Prop.BootstrapperStyle.GetNew();
|
||||||
bootstrapper.Dialog = dialog;
|
bootstrapper.Dialog = dialog;
|
||||||
dialog.Bootstrapper = bootstrapper;
|
dialog.Bootstrapper = bootstrapper;
|
||||||
@ -251,11 +254,17 @@ namespace Bloxstrap
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// this might be a bit problematic since this mutex will be released when the first launched instance is closed...
|
// create the singleton mutex before the game client does
|
||||||
singletonMutex = new Mutex(true, "ROBLOX_singletonMutex");
|
singletonMutex = new Mutex(true, "ROBLOX_singletonMutex");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// there's a bug here that i have yet to fix!
|
||||||
|
// sometimes the task just terminates when the bootstrapper hasn't
|
||||||
|
// actually finished, causing the bootstrapper to hang indefinitely
|
||||||
|
// i have no idea how the fuck this happens, but it happens like VERY
|
||||||
|
// rarely so i'm not too concerned by it
|
||||||
|
// maybe one day ill find out why it happens
|
||||||
Task bootstrapperTask = Task.Run(() => bootstrapper.Run()).ContinueWith(t =>
|
Task bootstrapperTask = Task.Run(() => bootstrapper.Run()).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
Logger.WriteLine("[App::OnStartup] Bootstrapper task has finished");
|
Logger.WriteLine("[App::OnStartup] Bootstrapper task has finished");
|
||||||
@ -279,23 +288,13 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
if (singletonMutex is not null)
|
if (singletonMutex is not null)
|
||||||
{
|
{
|
||||||
|
Logger.WriteLine($"[App::OnStartup] We have singleton mutex ownership! Running in background until all Roblox processes are closed");
|
||||||
|
|
||||||
// we've got ownership of the roblox singleton mutex!
|
// we've got ownership of the roblox singleton mutex!
|
||||||
// if we stop running, everything will screw up once any more roblox instances launched
|
// if we stop running, everything will screw up once any more roblox instances launched
|
||||||
// also this code is blehhhh im sure theres a better way of checking if the process count changed like this
|
while (Utilities.GetProcessCount("RobloxPlayerBeta", false) != 0)
|
||||||
|
|
||||||
int runningProcesses = -1;
|
|
||||||
while (runningProcesses != 0)
|
|
||||||
{
|
{
|
||||||
int runningProcessesNow = Utilities.GetProcessCount("RobloxPlayerBeta", false);
|
Thread.Sleep(5000);
|
||||||
|
|
||||||
if (runningProcessesNow != runningProcesses)
|
|
||||||
{
|
|
||||||
Logger.WriteLine($"[App::OnStartup] We have singleton mutex ownership! Running in background until all Roblox processes are closed ({runningProcessesNow} remaining)...");
|
|
||||||
runningProcesses = runningProcessesNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
// hmm... good idea to do this on main thread?
|
|
||||||
Task.Delay(5000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,13 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
private async Task CheckForUpdates()
|
private async Task CheckForUpdates()
|
||||||
{
|
{
|
||||||
|
// don't update if there's another instance running (likely running in the background)
|
||||||
|
if (Utilities.GetProcessCount(App.ProjectName) > 1)
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] More than one Bloxstrap instance running, aborting update check");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string currentVersion = $"{App.ProjectName} v{App.Version}";
|
string currentVersion = $"{App.ProjectName} v{App.Version}";
|
||||||
|
|
||||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Checking for {App.ProjectName} updates...");
|
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Checking for {App.ProjectName} updates...");
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Bloxstrap.Enums;
|
using System.Windows.Forms;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Bloxstrap.Properties;
|
||||||
using Bloxstrap.Views;
|
using Bloxstrap.Views;
|
||||||
|
|
||||||
namespace Bloxstrap.Helpers
|
namespace Bloxstrap.Helpers
|
||||||
@ -24,7 +28,6 @@ namespace Bloxstrap.Helpers
|
|||||||
if (installedVersionInfo.ProductVersion == currentVersionInfo.ProductVersion)
|
if (installedVersionInfo.ProductVersion == currentVersionInfo.ProductVersion)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
MessageBoxResult result;
|
MessageBoxResult result;
|
||||||
|
|
||||||
// silently upgrade version if the command line flag is set or if we're launching from an auto update
|
// silently upgrade version if the command line flag is set or if we're launching from an auto update
|
||||||
@ -41,31 +44,71 @@ namespace Bloxstrap.Helpers
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (result != MessageBoxResult.Yes)
|
if (result != MessageBoxResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
File.Delete(Directories.Application);
|
// yes, this is EXTREMELY hacky, but the updater process that launched the
|
||||||
|
// new version may still be open and so we have to wait for it to close
|
||||||
|
int attempts = 0;
|
||||||
|
while (attempts < 10)
|
||||||
|
{
|
||||||
|
attempts++;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(Directories.Application);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (attempts == 1)
|
||||||
|
App.Logger.WriteLine("[Updater::CheckInstalledVersion] Waiting for write permissions to update version");
|
||||||
|
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attempts == 10)
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine("[Updater::CheckInstalledVersion] Failed to update! (Could not get write permissions after 5 seconds)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
File.Copy(Environment.ProcessPath, Directories.Application);
|
File.Copy(Environment.ProcessPath, Directories.Application);
|
||||||
|
|
||||||
Bootstrapper.Register();
|
Bootstrapper.Register();
|
||||||
|
|
||||||
// make people using progress dialog auto switch over to fluent on upgrade
|
if (isAutoUpgrade)
|
||||||
if (App.Version == "2.0.0" && App.Settings.Prop.BootstrapperStyle == BootstrapperStyle.ProgressDialog)
|
{
|
||||||
App.Settings.Prop.BootstrapperStyle = BootstrapperStyle.FluentDialog;
|
NotifyIcon notification = new()
|
||||||
|
{
|
||||||
|
Icon = Resources.IconBloxstrap,
|
||||||
|
Text = "Bloxstrap",
|
||||||
|
Visible = true,
|
||||||
|
BalloonTipTitle = $"Bloxstrap has been upgraded to v{currentVersionInfo.ProductVersion}",
|
||||||
|
BalloonTipText = "Click here to see what's new in this version"
|
||||||
|
};
|
||||||
|
|
||||||
if (App.IsQuiet || isAutoUpgrade)
|
notification.BalloonTipClicked += (_, _) => Utilities.OpenWebsite($"https://github.com/{App.ProjectRepository}/releases/tag/v{currentVersionInfo.ProductVersion}");
|
||||||
return;
|
notification.ShowBalloonTip(30);
|
||||||
|
|
||||||
App.ShowMessageBox(
|
Task.Run(() =>
|
||||||
$"{App.ProjectName} has been updated to v{currentVersionInfo.ProductVersion}",
|
{
|
||||||
MessageBoxImage.Information,
|
Task.Delay(30000).Wait();
|
||||||
MessageBoxButton.OK
|
notification.Dispose();
|
||||||
);
|
});
|
||||||
|
}
|
||||||
|
else if (!App.IsQuiet)
|
||||||
|
{
|
||||||
|
App.ShowMessageBox(
|
||||||
|
$"{App.ProjectName} has been updated to v{currentVersionInfo.ProductVersion}",
|
||||||
|
MessageBoxImage.Information,
|
||||||
|
MessageBoxButton.OK
|
||||||
|
);
|
||||||
|
|
||||||
//new Preferences().ShowDialog();
|
new MainWindow().ShowDialog();
|
||||||
new MainWindow().ShowDialog();
|
App.Terminate();
|
||||||
App.Terminate();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user