From fa87e67f4c13e5badf722d56a975836539322609 Mon Sep 17 00:00:00 2001 From: Doriel Rivalet <100863878+DorielRivalet@users.noreply.github.com> Date: Fri, 9 Jun 2023 14:29:46 -0300 Subject: [PATCH] feat: implement snackbars --- MHFZ_Overlay/App.config | 4 +- MHFZ_Overlay/App.xaml.cs | 2 +- MHFZ_Overlay/ConfigWindow.xaml | 13 +- MHFZ_Overlay/ConfigWindow.xaml.cs | 69 ++++- .../Class/DataAccessLayer/DatabaseManager.cs | 4 +- MHFZ_Overlay/DataLoader.cs | 4 +- MHFZ_Overlay/MainWindow.xaml | 17 +- MHFZ_Overlay/MainWindow.xaml.cs | 14 + MHFZ_Overlay/Settings.Designer.cs | 4 +- MHFZ_Overlay/Settings.settings | 4 +- MHFZ_Overlay/UI/Class/Achievement.cs | 88 ++++++ MHFZ_Overlay/UI/Class/ZenithGauntlet.cs | 39 +++ MHFZ_Overlay/UI/Themes/CatppuccinMocha.xaml | 288 +++++++++++++++++- 13 files changed, 531 insertions(+), 19 deletions(-) create mode 100644 MHFZ_Overlay/UI/Class/Achievement.cs create mode 100644 MHFZ_Overlay/UI/Class/ZenithGauntlet.cs diff --git a/MHFZ_Overlay/App.config b/MHFZ_Overlay/App.config index 78e96c1a..78ff184f 100644 --- a/MHFZ_Overlay/App.config +++ b/MHFZ_Overlay/App.config @@ -494,10 +494,10 @@ False - 3840 + 1360 - 2160 + 768 True diff --git a/MHFZ_Overlay/App.xaml.cs b/MHFZ_Overlay/App.xaml.cs index 2a1cc447..29dfbc66 100644 --- a/MHFZ_Overlay/App.xaml.cs +++ b/MHFZ_Overlay/App.xaml.cs @@ -174,7 +174,7 @@ private static void OnAppRun(SemanticVersion version, IAppTools tools, bool firs The overlay might take some time to start due to databases. The next time you run the program, you may be asked to update the database. -It's also recommended to change the resolution of the overlay if you are using a resolution other than 4K. +It's also recommended to change the resolution of the overlay if you are using a resolution other than the default set. Happy Hunting!", "MHF-Z Overlay Installation", MessageBoxButton.OK, MessageBoxImage.Information); diff --git a/MHFZ_Overlay/ConfigWindow.xaml b/MHFZ_Overlay/ConfigWindow.xaml index d395f6da..36032f8a 100644 --- a/MHFZ_Overlay/ConfigWindow.xaml +++ b/MHFZ_Overlay/ConfigWindow.xaml @@ -559,8 +559,14 @@ - - + + + + + + + + @@ -736,6 +742,7 @@ #f38ba8 + @@ -3490,4 +3497,6 @@ Thunder Clad, Vigorous" Text="{Binding GetActiveSkillsForImage,Mode=OneTime}" Fo + + diff --git a/MHFZ_Overlay/ConfigWindow.xaml.cs b/MHFZ_Overlay/ConfigWindow.xaml.cs index 395c1973..f2e2ef10 100644 --- a/MHFZ_Overlay/ConfigWindow.xaml.cs +++ b/MHFZ_Overlay/ConfigWindow.xaml.cs @@ -45,6 +45,10 @@ using Wpf.Ui.Controls.Window; using DataGrid = Wpf.Ui.Controls.DataGrid; using MHFZ_Overlay.UI.CustomControls; +using Wpf.Ui.Controls.IconElements; +using Wpf.Ui.Common; +using Wpf.Ui.Contracts; +using Wpf.Ui.Services; namespace MHFZ_Overlay; @@ -550,6 +554,12 @@ public ConfigWindow(MainWindow mainWindow) replaceAllMonsterInfoFeriasLinks(); weaponUsageData = databaseManager.CalculateTotalWeaponUsage(this, MainWindow.DataLoader); + + // In your initialization or setup code + ISnackbarService snackbarService = new SnackbarService(); + // Replace 'snackbarControl' with your actual snackbar control instance + snackbarService.SetSnackbarControl(ConfigWindowSnackBar); + // Stop the stopwatch stopwatch.Stop(); // Get the elapsed time in milliseconds @@ -1196,7 +1206,7 @@ private void OpenSettingsFolder_Click(object sender, RoutedEventArgs e) catch (Exception ex) { logger.Error(ex); - MessageBox.Show("Could not open settings folder", Messages.ERROR_TITLE, MessageBoxButton.OK, MessageBoxImage.Error); + ConfigWindowSnackBar.ShowAsync(Messages.ERROR_TITLE, "Could not open settings folder", new SymbolIcon(SymbolRegular.ErrorCircle24), ControlAppearance.Danger); } } @@ -1440,15 +1450,68 @@ private void weaponUsageChart_Loaded(object sender, RoutedEventArgs e) private string personalBestSelectedType = string.Empty; private DataGrid? calendarDataGrid; + // TODO: it works. i need to put this somewhere else + private async void ShowSequentialSnackbars() + { + // Show the first snackbar + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 1", "Message 1", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Dark); + + // Handle completion of the first snackbar + await Task.Delay(TimeSpan.FromSeconds(2)); // Delay for a certain duration + MainWindow.MainWindowSnackBar.Hide(); // Hide the first snackbar + + // Show the second snackbar + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 2", "Message 2", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Light); + + // Handle completion of the second snackbar + await Task.Delay(TimeSpan.FromSeconds(2)); // Delay for a certain duration + MainWindow.MainWindowSnackBar.Hide(); // Hide the second snackbar + + // Show the third snackbar + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 3", "Message 3", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Primary); + + // Handle completion of the third snackbar + await Task.Delay(TimeSpan.FromSeconds(2)); // Delay for a certain duration + MainWindow.MainWindowSnackBar.Hide(); // Hide the third snackbar + + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 4", "Message 3", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Secondary); + await Task.Delay(TimeSpan.FromSeconds(2)); + MainWindow.MainWindowSnackBar.Hide(); + + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 5", "Message 3", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Success); + await Task.Delay(TimeSpan.FromSeconds(2)); + MainWindow.MainWindowSnackBar.Hide(); + + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 6", "Message 3", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Caution); + await Task.Delay(TimeSpan.FromSeconds(2)); + MainWindow.MainWindowSnackBar.Hide(); + + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 7", "Message 3", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Danger); + await Task.Delay(TimeSpan.FromSeconds(2)); + MainWindow.MainWindowSnackBar.Hide(); + + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 8", "Message 3", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Transparent); + await Task.Delay(TimeSpan.FromSeconds(2)); + MainWindow.MainWindowSnackBar.Hide(); + + await MainWindow.MainWindowSnackBar.ShowAsync("Important message 9", "Message 3", new SymbolIcon(SymbolRegular.Accessibility24), ControlAppearance.Info); + await Task.Delay(TimeSpan.FromSeconds(2)); + MainWindow.MainWindowSnackBar.Hide(); + } + private void UpdateYoutubeLink_ButtonClick(object sender, RoutedEventArgs e) { // Get the quest ID and new YouTube link from the textboxes long runID = long.Parse(RunIDTextBox.Text.Trim()); string youtubeLink = youtubeLinkTextBox.Text.Trim(); if (databaseManager.UpdateYoutubeLink(sender, e, runID, youtubeLink)) - MessageBox.Show(String.Format("Updated run {0} with link https://youtube.com/watch?v={1}", runID, youtubeLink), "Success", MessageBoxButton.OK, MessageBoxImage.Information); + { + ConfigWindowSnackBar.ShowAsync(Messages.INFO_TITLE, String.Format("Updated run {0} with link https://youtube.com/watch?v={1}", runID, youtubeLink), new SymbolIcon(SymbolRegular.Video32), ControlAppearance.Success); + } else - MessageBox.Show(String.Format("Could not update run {0} with link https://youtube.com/watch?v={1}. The link may have already been set to the same value, or the run ID and link input are invalid.", runID, youtubeLink), Messages.ERROR_TITLE, MessageBoxButton.OK, MessageBoxImage.Error); + { + ConfigWindowSnackBar.ShowAsync(Messages.ERROR_TITLE, String.Format("Could not update run {0} with link https://youtube.com/watch?v={1}. The link may have already been set to the same value, or the run ID and link input are invalid.", runID, youtubeLink), new SymbolIcon(SymbolRegular.Video32), ControlAppearance.Danger); + } } private void UpdateYoutubeLink_Loaded(object sender, RoutedEventArgs e) diff --git a/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs b/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs index 5058a60a..8a1f4efd 100644 --- a/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs +++ b/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs @@ -4803,7 +4803,9 @@ public bool UpdateYoutubeLink(object sender, RoutedEventArgs e, long runID, stri } catch (Exception ex) { - HandleError(transaction, ex); + //HandleError(transaction, ex); + logger.Error(ex, "Could not update youtube link"); + success = false; } } } diff --git a/MHFZ_Overlay/DataLoader.cs b/MHFZ_Overlay/DataLoader.cs index 19cb27c9..d1eaa954 100644 --- a/MHFZ_Overlay/DataLoader.cs +++ b/MHFZ_Overlay/DataLoader.cs @@ -93,6 +93,8 @@ public DataLoader() logger.Debug($"DataLoader ctor Elapsed Time: {elapsedTimeMs} ms"); } + public static bool loadedOutsideMezeporta = false; + private void CheckIfLoadedInMezeporta() { if (model.AreaID() != 200) @@ -101,7 +103,7 @@ private void CheckIfLoadedInMezeporta() Settings s = (Settings)System.Windows.Application.Current.TryFindResource("Settings"); if (s.EnableOutsideMezeportaLoadingWarning) - MessageBox.Show("It is not recommended to load the overlay outside of Mezeporta", Messages.WARNING_TITLE, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); + loadedOutsideMezeporta = true; } } diff --git a/MHFZ_Overlay/MainWindow.xaml b/MHFZ_Overlay/MainWindow.xaml index a178d4e8..11791156 100644 --- a/MHFZ_Overlay/MainWindow.xaml +++ b/MHFZ_Overlay/MainWindow.xaml @@ -19,15 +19,20 @@ x:Name="Window" Title="Monster Hunter Frontier Z Overlay" Height="{Binding Source={StaticResource Settings},Path=MaxResolutionHeight}" - Width="{Binding Source={StaticResource Settings},Path=MaxResolutionWidth}" Background="Transparent" AllowsTransparency="True" WindowStyle="None" + Width="{Binding Source={StaticResource Settings},Path=MaxResolutionWidth}" + Background="Transparent" + AllowsTransparency="True" + WindowStyle="None" + Loaded="Window_Loaded" Style="{StaticResource WinAll}" - FontFamily="{StaticResource MesloLGM NF}" + FontFamily="{StaticResource Segoe UI Variable}" > + @@ -724,8 +729,14 @@ -