using System.Windows; using Bloxstrap.UI.Elements.Bootstrapper; using Bloxstrap.UI.Elements.Dialogs; using Bloxstrap.UI.Elements.Settings; using Bloxstrap.UI.Elements.Installer; using System.Drawing; namespace Bloxstrap.UI { static class Frontend { public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxResult defaultResult = MessageBoxResult.None) { App.Logger.WriteLine("Frontend::ShowMessageBox", message); if (App.LaunchSettings.QuietFlag.Active) return defaultResult; if (App.LaunchSettings.RobloxLaunchMode != LaunchMode.None) return ShowFluentMessageBox(message, icon, buttons); switch (App.Settings.Prop.BootstrapperStyle) { case BootstrapperStyle.FluentDialog: case BootstrapperStyle.ClassicFluentDialog: case BootstrapperStyle.FluentAeroDialog: case BootstrapperStyle.ByfronDialog: return ShowFluentMessageBox(message, icon, buttons); default: return MessageBox.Show(message, App.ProjectName, buttons, icon); } } public static void ShowPlayerErrorDialog(bool crash = false) { if (App.LaunchSettings.QuietFlag.Active) return; string topLine = Strings.Dialog_PlayerError_FailedLaunch; if (crash) topLine = Strings.Dialog_PlayerError_Crash; ShowMessageBox($"{topLine}\n\n{Strings.Dialog_PlayerError_HelpInformation}", MessageBoxImage.Error); Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/wiki/Roblox-crashes-or-does-not-launch"); } public static void ShowExceptionDialog(Exception exception) { if (App.LaunchSettings.QuietFlag.Active) return; Application.Current.Dispatcher.Invoke(() => { new ExceptionDialog(exception).ShowDialog(); }); } public static void ShowConnectivityDialog(string title, string description, MessageBoxImage image, Exception exception) { if (App.LaunchSettings.QuietFlag.Active) return; Application.Current.Dispatcher.Invoke(() => { new ConnectivityDialog(title, description, image, exception).ShowDialog(); }); } public static IBootstrapperDialog GetBootstrapperDialog(BootstrapperStyle style) { return style switch { BootstrapperStyle.VistaDialog => new VistaDialog(), BootstrapperStyle.LegacyDialog2008 => new LegacyDialog2008(), BootstrapperStyle.LegacyDialog2011 => new LegacyDialog2011(), BootstrapperStyle.ProgressDialog => new ProgressDialog(), BootstrapperStyle.ClassicFluentDialog => new ClassicFluentDialog(), BootstrapperStyle.ByfronDialog => new ByfronDialog(), BootstrapperStyle.FluentDialog => new FluentDialog(false), BootstrapperStyle.FluentAeroDialog => new FluentDialog(true), _ => new FluentDialog(false) }; } private static MessageBoxResult ShowFluentMessageBox(string message, MessageBoxImage icon, MessageBoxButton buttons) { return Application.Current.Dispatcher.Invoke(new Func(() => { var messagebox = new FluentMessageBox(message, icon, buttons); messagebox.ShowDialog(); return messagebox.Result; })); } } }