|
5 | 5 | using CollapseLauncher.Statics; |
6 | 6 | using CommunityToolkit.WinUI; |
7 | 7 | using Hi3Helper; |
| 8 | +using Hi3Helper.SentryHelper; |
8 | 9 | using Hi3Helper.Shared.Region; |
9 | 10 | using Microsoft.UI.Input; |
10 | 11 | using Microsoft.UI.Text; |
@@ -92,15 +93,25 @@ protected override void OnApplyTemplate() |
92 | 93 | _layoutCloseButton?.EnableImplicitAnimation(); |
93 | 94 |
|
94 | 95 | // Assign dialog title image background |
95 | | - GamePresetProperty currentGameProperty = GamePropertyVault.GetCurrentGameProperty(); |
96 | | - GameNameType gameNameType = currentGameProperty.GamePreset.GameType; |
97 | | - string relFilePath = gameNameType switch |
| 96 | + var relFilePath = @"Assets\\Images\\GamePoster\\headerposter_genshin.png"; |
| 97 | + try |
98 | 98 | { |
99 | | - GameNameType.Zenless => @"Assets\\Images\\GamePoster\\headerposter_zzz.png", |
100 | | - GameNameType.Honkai => @"Assets\\Images\\GamePoster\\headerposter_honkai.png", |
101 | | - GameNameType.StarRail => @"Assets\\Images\\GamePoster\\headerposter_starrail.png", |
102 | | - _ => @"Assets\\Images\\GamePoster\\headerposter_genshin.png" |
103 | | - }; |
| 99 | + var currentGameProperty = GamePropertyVault.GetCurrentGameProperty(); |
| 100 | + var gameNameType = currentGameProperty.GamePreset.GameType; |
| 101 | + relFilePath = gameNameType switch |
| 102 | + { |
| 103 | + GameNameType.Zenless => @"Assets\\Images\\GamePoster\\headerposter_zzz.png", |
| 104 | + GameNameType.Honkai => @"Assets\\Images\\GamePoster\\headerposter_honkai.png", |
| 105 | + GameNameType.StarRail => @"Assets\\Images\\GamePoster\\headerposter_starrail.png", |
| 106 | + _ => @"Assets\\Images\\GamePoster\\headerposter_genshin.png" |
| 107 | + }; |
| 108 | + } |
| 109 | + catch (Exception ex) |
| 110 | + { |
| 111 | + SentryHelper.ExceptionHandler(ex); |
| 112 | + Logger.LogWriteLine($"[UserFeedbackDialog::OnApplyTemplate] Failed to grab game type! Returning default game header..." + |
| 113 | + $"\r\n{ex}", LogType.Error, true); |
| 114 | + } |
104 | 115 | // Get the title image background and load it. |
105 | 116 | FileInfo filePathInfo = new(Path.Combine(LauncherConfig.AppExecutableDir, relFilePath)); |
106 | 117 | if (filePathInfo.Exists) |
@@ -155,8 +166,8 @@ protected override void OnApplyTemplate() |
155 | 166 | // Find an overlay grid where the UI element will be spawn to |
156 | 167 | _parentOverlayGrid = XamlRoot.FindOverlayGrid(_isAlwaysOnTop); |
157 | 168 | // Get the count of the Rows and Column so it can be spanned across the grid. |
158 | | - int parentGridRowCount = _parentOverlayGrid?.RowDefinitions.Count ?? 1; |
159 | | - int parentGridColumnCount = _parentOverlayGrid?.ColumnDefinitions.Count ?? 1; |
| 169 | + var parentGridRowCount = _parentOverlayGrid?.RowDefinitions.Count ?? 1; |
| 170 | + var parentGridColumnCount = _parentOverlayGrid?.ColumnDefinitions.Count ?? 1; |
160 | 171 | // Add the UI element to the grid |
161 | 172 | _parentOverlayGrid?.AddElementToGridRowColumn(this, |
162 | 173 | 0, |
@@ -200,14 +211,14 @@ protected override void OnApplyTemplate() |
200 | 211 | private void AssignLocalization() |
201 | 212 | { |
202 | 213 | // Assign locale for Text header, button, placeholders and stuffs... |
203 | | - _layoutTitleGridText?.BindProperty(TextBlock.TextProperty, Locale.Lang._Dialogs, nameof(Locale.Lang._Dialogs.UserFeedback_DialogTitle)); |
204 | | - _layoutFeedbackTitleInput?.BindProperty(TextBox.PlaceholderTextProperty, Locale.Lang._Dialogs, nameof(Locale.Lang._Dialogs.UserFeedback_TextFieldTitlePlaceholder)); |
205 | | - _layoutFeedbackMessageInput?.BindProperty(TextBox.PlaceholderTextProperty, Locale.Lang._Dialogs, nameof(Locale.Lang._Dialogs.UserFeedback_TextFieldMessagePlaceholder)); |
206 | | - SetTextBoxPropertyHeaderLocale(_layoutFeedbackTitleInput, Locale.Lang._Dialogs.UserFeedback_TextFieldTitleHeader, Locale.Lang._Dialogs.UserFeedback_TextFieldRequired); |
207 | | - SetTextBoxPropertyHeaderLocale(_layoutFeedbackMessageInput, Locale.Lang._Dialogs.UserFeedback_TextFieldMessageHeader, Locale.Lang._Dialogs.UserFeedback_TextFieldRequired); |
208 | | - _layoutFeedbackRatingText?.BindProperty(TextBlock.TextProperty, Locale.Lang._Dialogs, nameof(Locale.Lang._Dialogs.UserFeedback_RatingText)); |
209 | | - SetButtonPropertyTextLocale(_layoutPrimaryButton, Locale.Lang._Dialogs, nameof(Locale.Lang._Dialogs.UserFeedback_SubmitBtn)); |
210 | | - SetButtonPropertyTextLocale(_layoutCloseButton, Locale.Lang._Dialogs, nameof(Locale.Lang._Dialogs.UserFeedback_CancelBtn)); |
| 214 | + _layoutTitleGridText?.BindProperty(TextBlock.TextProperty, Lang._Dialogs, nameof(Lang._Dialogs.UserFeedback_DialogTitle)); |
| 215 | + _layoutFeedbackTitleInput?.BindProperty(TextBox.PlaceholderTextProperty, Lang._Dialogs, nameof(Lang._Dialogs.UserFeedback_TextFieldTitlePlaceholder)); |
| 216 | + _layoutFeedbackMessageInput?.BindProperty(TextBox.PlaceholderTextProperty, Lang._Dialogs, nameof(Lang._Dialogs.UserFeedback_TextFieldMessagePlaceholder)); |
| 217 | + SetTextBoxPropertyHeaderLocale(_layoutFeedbackTitleInput, Lang._Dialogs.UserFeedback_TextFieldTitleHeader, Lang._Dialogs.UserFeedback_TextFieldRequired); |
| 218 | + SetTextBoxPropertyHeaderLocale(_layoutFeedbackMessageInput, Lang._Dialogs.UserFeedback_TextFieldMessageHeader, Lang._Dialogs.UserFeedback_TextFieldRequired); |
| 219 | + _layoutFeedbackRatingText?.BindProperty(TextBlock.TextProperty, Lang._Dialogs, nameof(Lang._Dialogs.UserFeedback_RatingText)); |
| 220 | + SetButtonPropertyTextLocale(_layoutPrimaryButton, Lang._Dialogs, nameof(Lang._Dialogs.UserFeedback_SubmitBtn)); |
| 221 | + SetButtonPropertyTextLocale(_layoutCloseButton, Lang._Dialogs, nameof(Lang._Dialogs.UserFeedback_CancelBtn)); |
211 | 222 | } |
212 | 223 |
|
213 | 224 | private static void SetButtonPropertyTextLocale(Button? button, object localeObject, string nameOfLocale) |
|
0 commit comments