Skip to content

Commit 9b88a9a

Browse files
committed
Changes for issue: #409 (pt. 1)
1 parent 5892933 commit 9b88a9a

25 files changed

+731
-346
lines changed

CollapseLauncher/Classes/Extension/UIElementExtensions.cs

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Microsoft.UI.Text;
1+
using CollapseLauncher.Helper.Animation;
2+
using CommunityToolkit.WinUI.Controls;
3+
using Microsoft.UI.Text;
24
using Microsoft.UI.Xaml;
35
using Microsoft.UI.Xaml.Controls;
46
using Microsoft.UI.Xaml.Controls.Primitives;
@@ -141,5 +143,46 @@ internal static CornerRadius AttachRoundedKindCornerRadius(Control element)
141143

142144
return initialRadius;
143145
}
146+
147+
internal static void FindAndSetTextBlockWrapping(this UIElement element, TextWrapping wrap = TextWrapping.Wrap, HorizontalAlignment posAlign = HorizontalAlignment.Center, TextAlignment textAlign = TextAlignment.Center, bool recursiveAssignment = false, bool isParentAButton = false)
148+
{
149+
if (element is not null && element is TextBlock textBlock)
150+
{
151+
textBlock.TextWrapping = wrap;
152+
if (isParentAButton)
153+
{
154+
textBlock.HorizontalAlignment = posAlign;
155+
textBlock.HorizontalTextAlignment = textAlign;
156+
}
157+
}
158+
159+
if (!recursiveAssignment) return;
160+
161+
if (element is ButtonBase button)
162+
{
163+
if (button.Content is UIElement buttonContent)
164+
buttonContent.FindAndSetTextBlockWrapping(wrap, posAlign, textAlign, recursiveAssignment, true);
165+
else if (button.Content is string buttonString)
166+
button.Content = new TextBlock { Text = buttonString, TextWrapping = wrap, HorizontalAlignment = HorizontalAlignment.Center };
167+
}
168+
169+
if (element is Panel panel)
170+
foreach (UIElement childrenElement in panel.Children!)
171+
childrenElement.FindAndSetTextBlockWrapping(wrap, posAlign, textAlign, recursiveAssignment, isParentAButton);
172+
173+
if (element is ScrollViewer scrollViewer && scrollViewer.Content is UIElement elementInner)
174+
elementInner.FindAndSetTextBlockWrapping(wrap, posAlign, textAlign, recursiveAssignment, isParentAButton);
175+
176+
if (element is ContentControl contentControl && (element is SettingsCard || element is Expander) && contentControl.Content is UIElement contentControlInner)
177+
{
178+
contentControlInner.FindAndSetTextBlockWrapping(wrap, posAlign, textAlign, recursiveAssignment, isParentAButton);
179+
180+
if (contentControl is Expander expander && expander.Header is UIElement expanderHeader)
181+
expanderHeader.FindAndSetTextBlockWrapping(wrap, posAlign, textAlign, recursiveAssignment, isParentAButton);
182+
}
183+
184+
if (element is InfoBar infoBar && infoBar.Content is UIElement infoBarInner)
185+
infoBarInner.FindAndSetTextBlockWrapping(wrap, posAlign, textAlign, recursiveAssignment, isParentAButton);
186+
}
144187
}
145188
}

CollapseLauncher/Classes/Helper/Animation/AnimationHelper.cs

-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ internal static void EnableImplicitAnimation(this UIElement element,
110110

111111
private static void EnableElementVisibilityAnimation(Compositor compositor, Visual elementVisual, UIElement element)
112112
{
113-
ElementCompositionPreview.SetIsTranslationEnabled(element, true);
114113
TimeSpan animDur = TimeSpan.FromSeconds(0.25d);
115114

116115
ScalarKeyFrameAnimation HideOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();
@@ -120,8 +119,6 @@ private static void EnableElementVisibilityAnimation(Compositor compositor, Visu
120119
HideOpacityAnimation.Duration = animDur;
121120
HideOpacityAnimation.Target = "Opacity";
122121

123-
elementVisual.Opacity = 0.0f;
124-
125122
ShowOpacityAnimation.InsertKeyFrame(1.0f, 1.0f);
126123
ShowOpacityAnimation.Duration = animDur;
127124
ShowOpacityAnimation.Target = "Opacity";

CollapseLauncher/Classes/RegionManagement/RegionManagement.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ private enum ResourceLoadingType
5656
private uint LoadTimeoutStep = 5; // Step 5 seconds for each timeout retries
5757
private CancellationTokenSourceWrapper CurrentRegionLoadTokenSource;
5858

59-
private string RegionToChangeName;
59+
private string RegionToChangeName { get => $"{GetGameTitleRegionTranslationString(CurrentConfigV2GameCategory, Lang._GameClientTitles)} - {GetGameTitleRegionTranslationString(CurrentConfigV2GameRegion, Lang._GameClientRegions)}"; }
6060
private List<object> LastNavigationItem;
6161
private HomeMenuPanel LastRegionNewsProp;
6262
public static string PreviousTag = string.Empty;
6363

6464
public async Task<bool> LoadRegionFromCurrentConfigV2(PresetConfigV2 preset)
6565
{
6666
IsExplicitCancel = false;
67-
RegionToChangeName = $"{GetGameTitleRegionTranslationString(CurrentConfigV2GameCategory, Lang._GameClientTitles)} - {GetGameTitleRegionTranslationString(CurrentConfigV2GameRegion, Lang._GameClientRegions)}";
6867
LogWriteLine($"Initializing {RegionToChangeName}...", LogType.Scheme, true);
6968

7069
// Set IsLoadRegionComplete and IsLoadRegionCancellationRequestEnabled to false

CollapseLauncher/Classes/RepairManagement/Honkai/Fetch.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ private async ValueTask<bool> IsCGFileAvailable(CGMetadata cgInfo, string baseUR
352352
if (cgInfo!.AppointmentDownloadScheduleID == 0) return true;
353353

354354
// Update the status
355-
_status!.ActivityStatus = string.Format("Trying to determine CG asset availability: {0}", cgInfo.CgExtraKey);
355+
_status!.ActivityStatus = string.Format(Lang._GameRepairPage.Status14, cgInfo.CgExtraKey);
356356
_status!.IsProgressTotalIndetermined = true;
357357
_status!.IsProgressPerFileIndetermined = true;
358358
UpdateStatus();
@@ -471,7 +471,7 @@ private async ValueTask<bool> IsAudioFileAvailable(ManifestAssetInfo audioInfo,
471471

472472
// Update the status
473473
// TODO: Localize
474-
_status!.ActivityStatus = string.Format("Trying to determine audio asset availability: {0}", audioInfo.Path);
474+
_status!.ActivityStatus = string.Format(Lang._GameRepairPage.Status15, audioInfo.Path);
475475
_status!.IsProgressTotalIndetermined = true;
476476
_status!.IsProgressPerFileIndetermined = true;
477477
UpdateStatus();

CollapseLauncher/XAMLs/MainApp/MainPage.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
Orientation="Horizontal">
127127
<ComboBox
128128
x:Name="ComboBoxGameCategory"
129-
Width="167"
129+
MinWidth="167"
130130
Margin="0,0,0,0"
131131
Canvas.ZIndex="2"
132132
CornerRadius="15,0,0,15"
@@ -135,7 +135,7 @@
135135
SelectionChanged="SetGameCategoryChange" />
136136
<ComboBox
137137
x:Name="ComboBoxGameRegion"
138-
Width="148"
138+
MinWidth="148"
139139
Margin="0,0,8,0"
140140
Canvas.ZIndex="2"
141141
CornerRadius="0,15,15,0"

CollapseLauncher/XAMLs/MainApp/MainPage.xaml.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ private async Task InitializeStartup()
187187
PresetConfigV2 Preset = LoadSavedGameSelection();
188188

189189
InitKeyboardShortcuts();
190-
InvokeLoadingRegionPopup(true, Lang._MainPage.RegionLoadingTitle, Preset.ZoneFullname);
190+
191+
InvokeLoadingRegionPopup(true, Lang._MainPage.RegionLoadingTitle, RegionToChangeName);
191192
if (await LoadRegionFromCurrentConfigV2(Preset))
192193
{
193194
MainFrameChanger.ChangeMainFrame(Page);
@@ -1914,7 +1915,7 @@ public void OpenAppActivation()
19141915

19151916
PresetConfigV2 Preset = LoadSavedGameSelection();
19161917

1917-
InvokeLoadingRegionPopup(true, Lang._MainPage.RegionLoadingTitle, Preset.ZoneFullname);
1918+
InvokeLoadingRegionPopup(true, Lang._MainPage.RegionLoadingTitle, RegionToChangeName);
19181919
if (await LoadRegionFromCurrentConfigV2(Preset))
19191920
{
19201921
#if !DISABLEDISCORD

CollapseLauncher/XAMLs/MainApp/Pages/CachesPage.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
Grid.Row="1"
141141
Margin="0,0,0,16"
142142
FontSize="18"
143+
TextTrimming="CharacterEllipsis"
143144
Text="{x:Bind helper:Locale.Lang._CachesPage.Status1}" />
144145
<Grid>
145146
<Grid.ColumnDefinitions>

CollapseLauncher/XAMLs/MainApp/Pages/Dialogs/InstallationConvert.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private async Task DoDownloadRecipe()
300300
{
301301
case ContentDialogResult.Primary:
302302
cPath = await FileDialogNative.GetFilePicker(
303-
new Dictionary<string, string> { { $"{SourceProfile.ProfileName} to {TargetProfile.ProfileName} Cookbook", FileName } });
303+
new Dictionary<string, string> { { string.Format(Lang._InstallConvert.CookbookFileBrowserFileTypeCategory, SourceProfile.ProfileName, TargetProfile.ProfileName), FileName } });
304304
IsChoosen = !string.IsNullOrEmpty(cPath);
305305
break;
306306
case ContentDialogResult.None:

0 commit comments

Comments
 (0)