Skip to content

Commit

Permalink
Add Fluent MessageBoxes
Browse files Browse the repository at this point in the history
thats a lot of updated files huh
  • Loading branch information
pizzaboxer committed Jun 29, 2023
1 parent d27ca05 commit 5ef20a7
Show file tree
Hide file tree
Showing 22 changed files with 371 additions and 130 deletions.
28 changes: 13 additions & 15 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
using Bloxstrap.Models;
using Bloxstrap.Models.Attributes;
using Bloxstrap.UI.BootstrapperDialogs;
using Bloxstrap.UI.Menu.Views;
using Bloxstrap.UI.MessageBox;
using Bloxstrap.Utility;
using Bloxstrap.UI;

namespace Bloxstrap
{
Expand Down Expand Up @@ -57,15 +58,6 @@ public partial class App : Application

public static System.Windows.Forms.NotifyIcon Notification { get; private set; } = null!;

// shorthand
public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK)
{
if (IsQuiet)
return MessageBoxResult.None;

return MessageBox.Show(message, ProjectName, buttons, icon);
}

public static void Terminate(int code = Bootstrapper.ERROR_SUCCESS)
{
Logger.WriteLine($"[App::Terminate] Terminating with exit code {code}");
Expand Down Expand Up @@ -198,7 +190,7 @@ protected override void OnStartup(StartupEventArgs e)
{
IsSetupComplete = false;
FastFlags.Load();
new MainWindow().ShowDialog();
Controls.ShowMenu();
}
}
else
Expand Down Expand Up @@ -246,10 +238,13 @@ protected override void OnStartup(StartupEventArgs e)
}
else
{
if (Process.GetProcessesByName(ProjectName).Length > 1)
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);
if (Process.GetProcessesByName(ProjectName).Length > 1 && !IsQuiet)
FluentMessageBox.Show(
$"{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();
Controls.ShowMenu();
}
}
else if (LaunchArgs.Length > 0)
Expand All @@ -261,7 +256,10 @@ protected override void OnStartup(StartupEventArgs e)
else if (LaunchArgs[0].StartsWith("roblox:"))
{
if (Settings.Prop.UseDisableAppPatch)
ShowMessageBox("Roblox was launched via a deeplink, however the desktop app is required for deeplink launching to work. Because you've opted to disable the desktop app, it will temporarily be re-enabled for this launch only.", MessageBoxImage.Information);
Controls.ShowMessageBox(
"Roblox was launched via a deeplink, however the desktop app is required for deeplink launching to work. Because you've opted to disable the desktop app, it will temporarily be re-enabled for this launch only.",
MessageBoxImage.Information
);

commandLine = $"--app --deeplink {LaunchArgs[0]}";
}
Expand Down
4 changes: 4 additions & 0 deletions Bloxstrap/Bloxstrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<Resource Include="Resources\Fonts\Rubik-VariableFont_wght.ttf" />
<Resource Include="Resources\BootstrapperStyles\ByfronDialog\ByfronLogoDark.jpg" />
<Resource Include="Resources\BootstrapperStyles\ByfronDialog\ByfronLogoLight.jpg" />
<Resource Include="Resources\MessageBox\Error.png" />
<Resource Include="Resources\MessageBox\Information.png" />
<Resource Include="Resources\MessageBox\Question.png" />
<Resource Include="Resources\MessageBox\Warning.png" />
</ItemGroup>

<ItemGroup>
Expand Down
29 changes: 24 additions & 5 deletions Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Bloxstrap.Integrations;
using Bloxstrap.Models;
using Bloxstrap.Tools;
using Bloxstrap.UI;
using Bloxstrap.UI.BootstrapperDialogs;

namespace Bloxstrap
Expand Down Expand Up @@ -126,6 +127,8 @@ public async Task Run()
{
App.Logger.WriteLine("[Bootstrapper::Run] Running bootstrapper");

Controls.ShowMessageBox("hi :D", MessageBoxImage.Error, MessageBoxButton.YesNoCancel);

if (App.IsUninstall)
{
Uninstall();
Expand Down Expand Up @@ -230,7 +233,9 @@ private async Task CheckLatestVersion()

if (!String.IsNullOrEmpty(switchDefaultPrompt))
{
MessageBoxResult result = App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Automatic ? MessageBoxResult.Yes : App.ShowMessageBox(switchDefaultPrompt, MessageBoxImage.Question, MessageBoxButton.YesNo);
MessageBoxResult result = App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Prompt
? Controls.ShowMessageBox(switchDefaultPrompt, MessageBoxImage.Question, MessageBoxButton.YesNo)
: MessageBoxResult.Yes;

if (result == MessageBoxResult.Yes)
{
Expand Down Expand Up @@ -263,7 +268,10 @@ private async Task StartRoblox()

if (!File.Exists("C:\\Windows\\System32\\mfplat.dll"))
{
App.ShowMessageBox("Roblox requires the use of Windows Media Foundation components. You appear to be missing them, likely because you are using an N edition of Windows. Please install them first, and then launch Roblox.", MessageBoxImage.Error);
Controls.ShowMessageBox(
"Roblox requires the use of Windows Media Foundation components. You appear to be missing them, likely because you are using an N edition of Windows. Please install them first, and then launch Roblox.",
MessageBoxImage.Error
);
Utilities.ShellExecute("https://support.microsoft.com/en-us/topic/media-feature-pack-list-for-windows-n-editions-c1c6fffa-d052-8338-7a79-a4bb980a700a");
Dialog?.CloseBootstrapper();
return;
Expand Down Expand Up @@ -637,7 +645,14 @@ private void Uninstall()
{
App.Logger.WriteLine($"[Bootstrapper::Uninstall] Prompting to shut down all open Roblox instances");

Dialog?.PromptShutdown();
MessageBoxResult result = Controls.ShowMessageBox(
"Roblox is currently running, but must be closed before uninstalling Bloxstrap. Would you like close Roblox now?",
MessageBoxImage.Information,
MessageBoxButton.OKCancel
);

if (result != MessageBoxResult.OK)
Environment.Exit(ERROR_INSTALL_USEREXIT);

try
{
Expand Down Expand Up @@ -742,7 +757,11 @@ private async Task InstallLatestVersion()

if (Utilities.GetFreeDiskSpace(Directories.Base) < totalSizeRequired)
{
App.ShowMessageBox($"{App.ProjectName} does not have enough disk space to download and install Roblox. Please free up some disk space and try again.", MessageBoxImage.Error);
Controls.ShowMessageBox(
$"{App.ProjectName} does not have enough disk space to download and install Roblox. Please free up some disk space and try again.",
MessageBoxImage.Error
);

App.Terminate(ERROR_INSTALL_FAILURE);
return;
}
Expand Down Expand Up @@ -910,7 +929,7 @@ public static void MigrateIntegrations()

if (File.Exists(injectorLocation))
{
App.ShowMessageBox(
Controls.ShowMessageBox(
"Roblox has now finished rolling out the new game client update, featuring 64-bit support and the Hyperion anticheat. ReShade does not work with this update, and so it has now been disabled and removed from Bloxstrap.\n\n"+
"Your ReShade configuration files will still be saved, and you can locate them by opening the folder where Bloxstrap is installed to, and navigating to the Integrations folder. You can choose to delete these if you want.",
MessageBoxImage.Warning
Expand Down
15 changes: 9 additions & 6 deletions Bloxstrap/ProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Win32;

using Bloxstrap.Enums;
using Bloxstrap.UI;

namespace Bloxstrap
{
Expand Down Expand Up @@ -59,12 +60,14 @@ public static string ParseUri(string protocol)
{
if (val.ToLowerInvariant() != App.Settings.Prop.Channel.ToLowerInvariant() && App.Settings.Prop.ChannelChangeMode != ChannelChangeMode.Ignore)
{
MessageBoxResult result = App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Automatic ? MessageBoxResult.Yes : App.ShowMessageBox(
$"{App.ProjectName} was launched with the Roblox build channel set to {val}, however your current preferred channel is {App.Settings.Prop.Channel}.\n\n" +
$"Would you like to switch channels from {App.Settings.Prop.Channel} to {val}?",
MessageBoxImage.Question,
MessageBoxButton.YesNo
);
MessageBoxResult result = App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Automatic
? MessageBoxResult.Yes
: Controls.ShowMessageBox(
$"{App.ProjectName} was launched with the Roblox build channel set to {val}, however your current preferred channel is {App.Settings.Prop.Channel}.\n\n" +
$"Would you like to switch channels from {App.Settings.Prop.Channel} to {val}?",
MessageBoxImage.Question,
MessageBoxButton.YesNo
);

if (result == MessageBoxResult.Yes)
{
Expand Down
Binary file added Bloxstrap/Resources/MessageBox/Error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bloxstrap/Resources/MessageBox/Information.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bloxstrap/Resources/MessageBox/Question.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bloxstrap/Resources/MessageBox/Warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions Bloxstrap/UI/BootstrapperDialogs/BaseFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Windows;

namespace Bloxstrap.UI.BootstrapperDialogs
{
static class BaseFunctions
{
public static void ShowSuccess(string message, Action? callback)
{
Controls.ShowMessageBox(message, MessageBoxImage.Information);

if (callback is not null)
callback();

App.Terminate();
}

public static void ShowError(string message)
{
Controls.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxImage.Error);
App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE);
}
}
}
1 change: 0 additions & 1 deletion Bloxstrap/UI/BootstrapperDialogs/IBootstrapperDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ public interface IBootstrapperDialog
void CloseBootstrapper();
void ShowSuccess(string message, Action? callback = null);
void ShowError(string message);
void PromptShutdown();
}
}
28 changes: 2 additions & 26 deletions Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,9 @@ public ByfronDialog()

public void CloseBootstrapper() => Dispatcher.BeginInvoke(this.Close);

public void ShowSuccess(string message, Action? callback)
{
App.ShowMessageBox(message, MessageBoxImage.Information);

if (callback is not null)
callback();

App.Terminate();
}

public void ShowError(string message)
{
App.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxImage.Error);
App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE);
}
public void ShowSuccess(string message, Action? callback) => BaseFunctions.ShowSuccess(message, callback);

public void PromptShutdown()
{
MessageBoxResult result = App.ShowMessageBox(
"Roblox is currently running, but needs to close. Would you like close Roblox now?",
MessageBoxImage.Information,
MessageBoxButton.OKCancel
);

if (result != MessageBoxResult.OK)
Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT);
}
public void ShowError(string message) => BaseFunctions.ShowError(message);
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Margin="0,12,0,0" Width="48" Height="48" VerticalAlignment="Top">
<Border.Background>
<ImageBrush ImageSource="{Binding Icon, Mode=OneWay}" />
<ImageBrush ImageSource="{Binding Icon, Mode=OneWay}" RenderOptions.BitmapScalingMode="HighQuality" />
</Border.Background>
</Border>
<StackPanel Grid.Column="1">
Expand Down
29 changes: 2 additions & 27 deletions Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,9 @@ public FluentDialog()
public void CloseBootstrapper() => Dispatcher.BeginInvoke(this.Close);

// TODO: make prompts use dialog view natively rather than using message dialog boxes
public void ShowSuccess(string message, Action? callback) => BaseFunctions.ShowSuccess(message, callback);

public void ShowSuccess(string message, Action? callback)
{
App.ShowMessageBox(message, MessageBoxImage.Information);

if (callback is not null)
callback();

App.Terminate();
}

public void ShowError(string message)
{
App.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxImage.Error);
App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE);
}

public void PromptShutdown()
{
MessageBoxResult result = App.ShowMessageBox(
"Roblox is currently running, but needs to close. Would you like close Roblox now?",
MessageBoxImage.Information,
MessageBoxButton.OKCancel
);

if (result != MessageBoxResult.OK)
Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT);
}
public void ShowError(string message) => BaseFunctions.ShowError(message);
#endregion
}
}
29 changes: 2 additions & 27 deletions Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Windows;
using System.Windows.Forms;

using Bloxstrap.Extensions;
Expand Down Expand Up @@ -101,33 +100,9 @@ public virtual void CloseBootstrapper()
Close();
}

public virtual void ShowSuccess(string message, Action? callback)
{
App.ShowMessageBox(message, MessageBoxImage.Information);

if (callback is not null)
callback();

App.Terminate();
}

public virtual void ShowError(string message)
{
App.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxImage.Error);
App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE);
}
public virtual void ShowSuccess(string message, Action? callback) => BaseFunctions.ShowSuccess(message, callback);

public void PromptShutdown()
{
MessageBoxResult result = App.ShowMessageBox(
"Roblox is currently running, but needs to close. Would you like close Roblox now?",
MessageBoxImage.Information,
MessageBoxButton.OKCancel
);

if (result != MessageBoxResult.OK)
Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT);
}
public virtual void ShowError(string message) => BaseFunctions.ShowError(message);
#endregion
}
}
26 changes: 26 additions & 0 deletions Bloxstrap/UI/Controls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Windows;

using Bloxstrap.Enums;
using Bloxstrap.UI.Menu.Views;
using Bloxstrap.UI.MessageBox;

namespace Bloxstrap.UI
{
static class Controls
{
public static void ShowMenu() => new MainWindow().ShowDialog();

public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxResult defaultResult = MessageBoxResult.None)
{
switch (App.Settings.Prop.BootstrapperStyle)
{
case BootstrapperStyle.FluentDialog:
case BootstrapperStyle.ByfronDialog:
return FluentMessageBox.Show(message, icon, buttons, defaultResult);

default:
return NativeMessageBox.Show(message, icon, buttons, defaultResult);
}
}
}
}
Loading

0 comments on commit 5ef20a7

Please sign in to comment.