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 @@
-
+
+
+
+
+
+
+
diff --git a/MHFZ_Overlay/MainWindow.xaml.cs b/MHFZ_Overlay/MainWindow.xaml.cs
index 27213c55..e804c5fb 100644
--- a/MHFZ_Overlay/MainWindow.xaml.cs
+++ b/MHFZ_Overlay/MainWindow.xaml.cs
@@ -55,6 +55,10 @@
using System.Windows.Media.Imaging;
using MHFZ_Overlay.Core.Constant;
using Wpf.Ui.Controls.TitleBarControl;
+using Wpf.Ui.Contracts;
+using Wpf.Ui.Services;
+using System.Windows.Documents;
+using Wpf.Ui.Controls.IconElements;
namespace MHFZ_Overlay;
@@ -328,6 +332,11 @@ public MainWindow()
logger.Info("Loaded MHF-Z Overlay {0}", App.CurrentProgramVersion);
+ // In your initialization or setup code
+ ISnackbarService snackbarService = new SnackbarService();
+ // Replace 'snackbarControl' with your actual snackbar control instance
+ snackbarService.SetSnackbarControl(MainWindowSnackBar);
+
splashScreen.Close(TimeSpan.FromSeconds(0.1));
// Stop the stopwatch
stopwatch.Stop();
@@ -1926,6 +1935,11 @@ private void MapPlayerInputImages()
#endregion
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ if (DataLoader.loadedOutsideMezeporta)
+ MainWindowSnackBar.ShowAsync(Messages.WARNING_TITLE, "It is not recommended to load the overlay outside of Mezeporta", new SymbolIcon(SymbolRegular.Warning28), ControlAppearance.Caution);
+ }
}
///
/// [] Not Done
diff --git a/MHFZ_Overlay/Settings.Designer.cs b/MHFZ_Overlay/Settings.Designer.cs
index e14de954..81f56316 100644
--- a/MHFZ_Overlay/Settings.Designer.cs
+++ b/MHFZ_Overlay/Settings.Designer.cs
@@ -1969,7 +1969,7 @@ public bool EnableKeyLogging {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("3840")]
+ [global::System.Configuration.DefaultSettingValueAttribute("1360")]
public int MaxResolutionWidth {
get {
return ((int)(this["MaxResolutionWidth"]));
@@ -1981,7 +1981,7 @@ public int MaxResolutionWidth {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("2160")]
+ [global::System.Configuration.DefaultSettingValueAttribute("768")]
public string MaxResolutionHeight {
get {
return ((string)(this["MaxResolutionHeight"]));
diff --git a/MHFZ_Overlay/Settings.settings b/MHFZ_Overlay/Settings.settings
index 9707c5fd..12183cc4 100644
--- a/MHFZ_Overlay/Settings.settings
+++ b/MHFZ_Overlay/Settings.settings
@@ -489,10 +489,10 @@
False
- 3840
+ 1360
- 2160
+ 768
True
diff --git a/MHFZ_Overlay/UI/Class/Achievement.cs b/MHFZ_Overlay/UI/Class/Achievement.cs
new file mode 100644
index 00000000..b9305cba
--- /dev/null
+++ b/MHFZ_Overlay/UI/Class/Achievement.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Wpf.Ui.Common;
+using Wpf.Ui.Controls;
+using Wpf.Ui.Controls.IconElements;
+
+namespace MHFZ_Overlay.UI.Class;
+
+///
+/// TODO: add GHC carve sound when obtaining and displaying snackbar
+///
+public class Achievement
+{
+ ///
+ /// Gets or sets the title.
+ ///
+ ///
+ /// The title.
+ ///
+ public string Title { get; set; } = string.Empty;
+ ///
+ /// Gets or sets the description of the snackbar.
+ ///
+ ///
+ /// The description.
+ ///
+ public string Description { get; set; } = string.Empty;
+ ///
+ /// Gets or sets the snackbar icon.
+ ///
+ ///
+ /// The icon.
+ ///
+ public IconElement Icon { get; set; } = new SymbolIcon(SymbolRegular.Fluent24);
+ ///
+ /// Gets or sets the appearance.
+ ///
+ ///
+ /// The appearance.
+ ///
+ public ControlAppearance Appearance { get; set; } = ControlAppearance.Secondary;
+ ///
+ /// Gets or sets the completion date.
+ ///
+ ///
+ /// The completion date.
+ ///
+ public DateTime CompletionDate { get; set; } = DateTime.MinValue;
+ ///
+ /// Gets or sets the objective description to obtain this achievement.
+ ///
+ ///
+ /// The objective.
+ ///
+ public string Objective { get; set; } = string.Empty;
+ ///
+ /// Gets or sets the image of the achievement when displayed.
+ ///
+ ///
+ /// The image.
+ ///
+ public string Image { get; set; } = string.Empty;
+ ///
+ /// Gets or sets a value indicating whether this instance is secret. If it is secret, it shows everything as ?, otherwise it shows the Objective and everything else but grayed out.
+ ///
+ ///
+ /// true if this instance is secret; otherwise, false.
+ ///
+ public bool IsSecret { get; set; } = false;
+ ///
+ /// Gets or sets the hint, which replaces the Objective if the achievement is secret.
+ ///
+ ///
+ /// The hint.
+ ///
+ public string Hint { get; set; } = string.Empty;
+ ///
+ /// Gets or sets a value indicating whether this instance is unlocked.
+ ///
+ ///
+ /// true if this instance is unlocked; otherwise, false.
+ ///
+ public bool IsUnlocked { get; set; } = false;
+ // Additional properties or methods related to achievements can be added here
+}
diff --git a/MHFZ_Overlay/UI/Class/ZenithGauntlet.cs b/MHFZ_Overlay/UI/Class/ZenithGauntlet.cs
new file mode 100644
index 00000000..53482041
--- /dev/null
+++ b/MHFZ_Overlay/UI/Class/ZenithGauntlet.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MHFZ_Overlay.UI.Class;
+
+public class ZenithGauntlet
+{
+ public string WeaponType { get; set; } = "Any";
+ public string Category { get; set; } = "Standard";
+ public long TotalFramesElapsed { get; set; }
+ public string TotalTimeElapsed { get; set; } = DateTime.MaxValue.ToString();
+ public long RunID1 { get; set;}
+ public long RunID2 { get; set;}
+ public long RunID3 { get; set;}
+ public long RunID4 { get; set;}
+ public long RunID5 { get; set;}
+ public long RunID6 { get; set;}
+ public long RunID7 { get; set;}
+ public long RunID8 { get; set;}
+ public long RunID9 { get; set;}
+ public long RunID10 { get; set;}
+ public long RunID11 { get; set;}
+ public long RunID12 { get; set;}
+ public long RunID13 { get; set;}
+ public long RunID14 { get; set;}
+ public long RunID15 { get; set;}
+ public long RunID16 { get; set;}
+ public long RunID17 { get; set;}
+ public long RunID18 { get; set;}
+ public long RunID19 { get; set;}
+ public long RunID20 { get; set;}
+ public long RunID21 { get; set;}
+ public long RunID22 { get; set;}
+ public long RunID23 { get; set;}
+
+}
diff --git a/MHFZ_Overlay/UI/Themes/CatppuccinMocha.xaml b/MHFZ_Overlay/UI/Themes/CatppuccinMocha.xaml
index 8df103f3..e323b23e 100644
--- a/MHFZ_Overlay/UI/Themes/CatppuccinMocha.xaml
+++ b/MHFZ_Overlay/UI/Themes/CatppuccinMocha.xaml
@@ -4,7 +4,8 @@
// found in the LICENSE file.
-->
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
@@ -533,7 +534,290 @@
-->
-
+
+