diff --git a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml
index de98b850b..bbca7b5e7 100644
--- a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml
+++ b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml
@@ -1,19 +1,18 @@
-
+
-
+
diff --git a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml.cs b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml.cs
index 569a7130f..1cc5155ae 100644
--- a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml.cs
+++ b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBH3.xaml.cs
@@ -1,139 +1,20 @@
-using CommunityToolkit.Mvvm.Input;
-using Microsoft.UI.Composition;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Hosting;
-using Microsoft.UI.Xaml.Input;
using Starward.Core;
-using System;
-using System.Numerics;
-using System.Windows.Input;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace Starward.Controls.TitleBarGameIcon;
-public sealed partial class TitleBarGameIconBH3 : UserControl
+public sealed partial class TitleBarGameIconBH3 : TitleBarGameIconBase
{
- private readonly Compositor compositor;
-
- public GameBiz GameBiz { get; set; } = GameBiz.Honkai3rd;
+ public override GameBiz GameBiz { get; protected init; } = GameBiz.Honkai3rd;
public TitleBarGameIconBH3()
{
this.InitializeComponent();
- compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
- this.Loaded += (_, _) => UpdateCornerRadius(false);
- }
-
-
-
- public ICommand Command
- {
- get { return (ICommand)GetValue(CommandProperty); }
- set { SetValue(CommandProperty, value); }
- }
-
- public static readonly DependencyProperty CommandProperty =
- DependencyProperty.Register("Command", typeof(ICommand), typeof(TitleBarGameIconBH3), new PropertyMetadata(default));
-
-
- public void Select(GameBiz biz)
- {
- IsSelected = biz.ToGame() == GameBiz;
- }
-
-
- private bool isSelected;
- public bool IsSelected
- {
- get => isSelected;
- set
- {
- isSelected = value;
- UpdateCornerRadius(value);
- Border_Mask.Opacity = value ? 0 : 1;
- }
- }
-
-
-
- private bool isTapped;
-
-
-
-
- [RelayCommand]
- private void Click(GameBiz biz)
- {
- IsSelected = true;
- Command?.Execute(biz);
- }
-
-
- private void Button_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
- {
- Click(GameBiz);
- }
-
- private void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
- {
- UpdateCornerRadius(true);
- }
-
- private void Button_PointerExited(object sender, PointerRoutedEventArgs e)
- {
- if (!isTapped)
- {
- UpdateCornerRadius(isSelected);
- }
- }
-
- private void Button_RightTapped(object sender, RightTappedRoutedEventArgs e)
- {
- isTapped = true;
- }
-
- private void MenuFlyout_Closed(object sender, object e)
- {
- isTapped = false;
- UpdateCornerRadius(isSelected);
- }
-
-
-
- private void UpdateCornerRadius(bool isSelect)
- {
- var visual = ElementCompositionPreview.GetElementVisual(this);
- CompositionRoundedRectangleGeometry geometry;
- if (visual.Clip is CompositionGeometricClip clip && clip.Geometry is CompositionRoundedRectangleGeometry geo)
- {
- geometry = geo;
- geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
- }
- else
- {
- geometry = compositor.CreateRoundedRectangleGeometry();
- geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
- geometry.CornerRadius = Vector2.Zero;
- clip = compositor.CreateGeometricClip(geometry);
- visual.Clip = clip;
- }
- var animation = compositor.CreateVector2KeyFrameAnimation();
- animation.Duration = TimeSpan.FromSeconds(0.3);
- if (isSelect)
- {
- animation.InsertKeyFrame(1, new Vector2(8, 8));
- }
- else
- {
- animation.InsertKeyFrame(1, new Vector2((float)ActualWidth / 2, (float)ActualHeight / 2));
- }
- geometry.StartAnimation(nameof(CompositionRoundedRectangleGeometry.CornerRadius), animation);
}
diff --git a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBase.cs b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBase.cs
new file mode 100644
index 000000000..363521256
--- /dev/null
+++ b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconBase.cs
@@ -0,0 +1,154 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.UI.Composition;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Hosting;
+using Microsoft.UI.Xaml.Input;
+using Starward.Core;
+using System;
+using System.Numerics;
+using System.Windows.Input;
+
+namespace Starward.Controls.TitleBarGameIcon;
+
+[INotifyPropertyChanged]
+public abstract partial class TitleBarGameIconBase : UserControl
+{
+
+
+
+ protected readonly Compositor compositor;
+
+
+ public abstract GameBiz GameBiz { get; protected init; }
+
+
+ public TitleBarGameIconBase()
+ {
+ compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
+ this.Loaded += (_, _) => UpdateCornerRadius(false);
+ }
+
+
+
+ public ICommand Command
+ {
+ get { return (ICommand)GetValue(CommandProperty); }
+ set { SetValue(CommandProperty, value); }
+ }
+
+ public static readonly DependencyProperty CommandProperty =
+ DependencyProperty.Register("Command", typeof(ICommand), typeof(TitleBarGameIconBase), new PropertyMetadata(default));
+
+
+ public void Select(GameBiz biz)
+ {
+ IsSelected = biz.ToGame() == GameBiz;
+ }
+
+
+ protected bool isSelected;
+ public bool IsSelected
+ {
+ get => isSelected;
+ set
+ {
+ isSelected = value;
+ UpdateCornerRadius(value);
+ BorderMaskOpacity = value ? 0 : 1;
+ }
+ }
+
+
+ [ObservableProperty]
+ protected double borderMaskOpacity = 1;
+
+
+ protected bool isTapped;
+
+
+
+
+ [RelayCommand]
+ protected void Click(GameBiz biz)
+ {
+ IsSelected = true;
+ Command?.Execute(biz);
+ }
+
+
+ protected void Button_Click(object sender, RoutedEventArgs e)
+ {
+ if (!IsSelected)
+ {
+ Click(GameBiz);
+ }
+ }
+
+
+ protected void Button_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
+ {
+ Click(GameBiz);
+ }
+
+ protected void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
+ {
+ UpdateCornerRadius(true);
+ }
+
+ protected void Button_PointerExited(object sender, PointerRoutedEventArgs e)
+ {
+ if (!isTapped)
+ {
+ UpdateCornerRadius(isSelected);
+ }
+ }
+
+ protected void Button_RightTapped(object sender, RightTappedRoutedEventArgs e)
+ {
+ isTapped = true;
+ }
+
+ protected void MenuFlyout_Closed(object sender, object e)
+ {
+ isTapped = false;
+ UpdateCornerRadius(isSelected);
+ }
+
+
+
+ protected void UpdateCornerRadius(bool isSelect)
+ {
+ var visual = ElementCompositionPreview.GetElementVisual(this);
+ CompositionRoundedRectangleGeometry geometry;
+ if (visual.Clip is CompositionGeometricClip clip && clip.Geometry is CompositionRoundedRectangleGeometry geo)
+ {
+ geometry = geo;
+ geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
+ }
+ else
+ {
+ geometry = compositor.CreateRoundedRectangleGeometry();
+ geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
+ geometry.CornerRadius = Vector2.Zero;
+ clip = compositor.CreateGeometricClip(geometry);
+ visual.Clip = clip;
+ }
+ var animation = compositor.CreateVector2KeyFrameAnimation();
+ animation.Duration = TimeSpan.FromSeconds(0.3);
+ if (isSelect)
+ {
+ animation.InsertKeyFrame(1, new Vector2(8, 8));
+ }
+ else
+ {
+ animation.InsertKeyFrame(1, new Vector2((float)ActualWidth / 2, (float)ActualHeight / 2));
+ }
+ geometry.StartAnimation(nameof(CompositionRoundedRectangleGeometry.CornerRadius), animation);
+ }
+
+
+
+
+}
diff --git a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml
index 3af380784..2f060a027 100644
--- a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml
+++ b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml
@@ -1,19 +1,18 @@
-
+
-
+
diff --git a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml.cs b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml.cs
index b0ba4d26b..6be223437 100644
--- a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml.cs
+++ b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconSR.xaml.cs
@@ -1,139 +1,20 @@
-using CommunityToolkit.Mvvm.Input;
-using Microsoft.UI.Composition;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Hosting;
-using Microsoft.UI.Xaml.Input;
using Starward.Core;
-using System;
-using System.Numerics;
-using System.Windows.Input;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace Starward.Controls.TitleBarGameIcon;
-public sealed partial class TitleBarGameIconSR : UserControl
+public sealed partial class TitleBarGameIconSR : TitleBarGameIconBase
{
- private readonly Compositor compositor;
-
- public GameBiz GameBiz { get; set; } = GameBiz.StarRail;
+ public override GameBiz GameBiz { get; protected init; } = GameBiz.StarRail;
public TitleBarGameIconSR()
{
this.InitializeComponent();
- compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
- this.Loaded += (_, _) => UpdateCornerRadius(false);
- }
-
-
-
- public ICommand Command
- {
- get { return (ICommand)GetValue(CommandProperty); }
- set { SetValue(CommandProperty, value); }
- }
-
- public static readonly DependencyProperty CommandProperty =
- DependencyProperty.Register("Command", typeof(ICommand), typeof(TitleBarGameIconBH3), new PropertyMetadata(default));
-
-
- public void Select(GameBiz biz)
- {
- IsSelected = biz.ToGame() == GameBiz;
- }
-
-
- private bool isSelected;
- public bool IsSelected
- {
- get => isSelected;
- set
- {
- isSelected = value;
- UpdateCornerRadius(value);
- Border_Mask.Opacity = value ? 0 : 1;
- }
- }
-
-
-
- private bool isTapped;
-
-
-
-
- [RelayCommand]
- private void Click(GameBiz biz)
- {
- IsSelected = true;
- Command?.Execute(biz);
- }
-
-
- private void Button_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
- {
- Click(GameBiz);
- }
-
- private void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
- {
- UpdateCornerRadius(true);
- }
-
- private void Button_PointerExited(object sender, PointerRoutedEventArgs e)
- {
- if (!isTapped)
- {
- UpdateCornerRadius(isSelected);
- }
- }
-
- private void Button_RightTapped(object sender, RightTappedRoutedEventArgs e)
- {
- isTapped = true;
- }
-
- private void MenuFlyout_Closed(object sender, object e)
- {
- isTapped = false;
- UpdateCornerRadius(isSelected);
- }
-
-
-
- private void UpdateCornerRadius(bool isSelect)
- {
- var visual = ElementCompositionPreview.GetElementVisual(this);
- CompositionRoundedRectangleGeometry geometry;
- if (visual.Clip is CompositionGeometricClip clip && clip.Geometry is CompositionRoundedRectangleGeometry geo)
- {
- geometry = geo;
- geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
- }
- else
- {
- geometry = compositor.CreateRoundedRectangleGeometry();
- geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
- geometry.CornerRadius = Vector2.Zero;
- clip = compositor.CreateGeometricClip(geometry);
- visual.Clip = clip;
- }
- var animation = compositor.CreateVector2KeyFrameAnimation();
- animation.Duration = TimeSpan.FromSeconds(0.3);
- if (isSelect)
- {
- animation.InsertKeyFrame(1, new Vector2(8, 8));
- }
- else
- {
- animation.InsertKeyFrame(1, new Vector2((float)ActualWidth / 2, (float)ActualHeight / 2));
- }
- geometry.StartAnimation(nameof(CompositionRoundedRectangleGeometry.CornerRadius), animation);
}
diff --git a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml
index a2c79b677..175bd4bd6 100644
--- a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml
+++ b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml
@@ -1,19 +1,18 @@
-
+
-
+
diff --git a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml.cs b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml.cs
index 32d93a7a7..fe959310a 100644
--- a/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml.cs
+++ b/src/Starward/Controls/TitleBarGameIcon/TitleBarGameIconYS.xaml.cs
@@ -1,139 +1,20 @@
-using CommunityToolkit.Mvvm.Input;
-using Microsoft.UI.Composition;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Hosting;
-using Microsoft.UI.Xaml.Input;
using Starward.Core;
-using System;
-using System.Numerics;
-using System.Windows.Input;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace Starward.Controls.TitleBarGameIcon;
-public sealed partial class TitleBarGameIconYS : UserControl
+public sealed partial class TitleBarGameIconYS : TitleBarGameIconBase
{
- private readonly Compositor compositor;
-
- public GameBiz GameBiz { get; set; } = GameBiz.GenshinImpact;
+ public override GameBiz GameBiz { get; protected init; } = GameBiz.GenshinImpact;
public TitleBarGameIconYS()
{
this.InitializeComponent();
- compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
- this.Loaded += (_, _) => UpdateCornerRadius(false);
- }
-
-
-
- public ICommand Command
- {
- get { return (ICommand)GetValue(CommandProperty); }
- set { SetValue(CommandProperty, value); }
- }
-
- public static readonly DependencyProperty CommandProperty =
- DependencyProperty.Register("Command", typeof(ICommand), typeof(TitleBarGameIconBH3), new PropertyMetadata(default));
-
-
- public void Select(GameBiz biz)
- {
- IsSelected = biz.ToGame() == GameBiz;
- }
-
-
- private bool isSelected;
- public bool IsSelected
- {
- get => isSelected;
- set
- {
- isSelected = value;
- UpdateCornerRadius(value);
- Border_Mask.Opacity = value ? 0 : 1;
- }
- }
-
-
-
- private bool isTapped;
-
-
-
-
- [RelayCommand]
- private void Click(GameBiz biz)
- {
- IsSelected = true;
- Command?.Execute(biz);
- }
-
-
- private void Button_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
- {
- Click(GameBiz);
- }
-
- private void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
- {
- UpdateCornerRadius(true);
- }
-
- private void Button_PointerExited(object sender, PointerRoutedEventArgs e)
- {
- if (!isTapped)
- {
- UpdateCornerRadius(isSelected);
- }
- }
-
- private void Button_RightTapped(object sender, RightTappedRoutedEventArgs e)
- {
- isTapped = true;
- }
-
- private void MenuFlyout_Closed(object sender, object e)
- {
- isTapped = false;
- UpdateCornerRadius(isSelected);
- }
-
-
-
- private void UpdateCornerRadius(bool isSelect)
- {
- var visual = ElementCompositionPreview.GetElementVisual(this);
- CompositionRoundedRectangleGeometry geometry;
- if (visual.Clip is CompositionGeometricClip clip && clip.Geometry is CompositionRoundedRectangleGeometry geo)
- {
- geometry = geo;
- geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
- }
- else
- {
- geometry = compositor.CreateRoundedRectangleGeometry();
- geometry.Size = new Vector2((float)ActualWidth, (float)ActualHeight);
- geometry.CornerRadius = Vector2.Zero;
- clip = compositor.CreateGeometricClip(geometry);
- visual.Clip = clip;
- }
- var animation = compositor.CreateVector2KeyFrameAnimation();
- animation.Duration = TimeSpan.FromSeconds(0.3);
- if (isSelect)
- {
- animation.InsertKeyFrame(1, new Vector2(8, 8));
- }
- else
- {
- animation.InsertKeyFrame(1, new Vector2((float)ActualWidth / 2, (float)ActualHeight / 2));
- }
- geometry.StartAnimation(nameof(CompositionRoundedRectangleGeometry.CornerRadius), animation);
}
diff --git a/src/Starward/Pages/MainPage.xaml.cs b/src/Starward/Pages/MainPage.xaml.cs
index 0df4a1a58..928860c2f 100644
--- a/src/Starward/Pages/MainPage.xaml.cs
+++ b/src/Starward/Pages/MainPage.xaml.cs
@@ -204,21 +204,30 @@ private void ChangeGameBiz(GameBiz biz)
_logger.LogInformation("Change game region to {gamebiz}", biz);
if (biz.ToGame() is GameBiz.None)
{
- GameBiz b = AppConfig.GetLastRegionOfGame(biz);
- if (b.ToGame() is GameBiz.None)
+ if (CurrentGameBiz.ToGame() == biz)
{
- biz++;
+ // double click, navigate to launcher page
+ NavigateTo(typeof(LauncherPage));
+ return;
}
else
{
- biz = b;
+ GameBiz b = AppConfig.GetLastRegionOfGame(biz);
+ if (b.ToGame() is GameBiz.None)
+ {
+ biz++;
+ }
+ else
+ {
+ biz = b;
+ }
}
}
lastGameBiz = CurrentGameBiz;
CurrentGameBiz = biz;
UpdateGameIcon();
UpdateNavigationViewItemsText();
- NavigateTo(MainPage_Frame.SourcePageType);
+ NavigateTo(MainPage_Frame.SourcePageType, gameBizChanged: true);
_ = UpdateBackgroundImageAsync();
}
@@ -642,10 +651,13 @@ private async void NavigationView_ItemInvoked(NavigationView sender, NavigationV
}
- public void NavigateTo(Type? page, object? param = null, NavigationTransitionInfo? infoOverride = null)
+ public void NavigateTo(Type? page, object? param = null, NavigationTransitionInfo? infoOverride = null, bool gameBizChanged = false)
{
+ if (gameBizChanged)
+ {
+ gameBizChanged = lastGameBiz.ToGame() != GameBiz.None && lastGameBiz.ToGame() != CurrentGameBiz.ToGame();
+ }
string? sourcePage = MainPage_Frame.CurrentSourcePageType?.Name, destPage = page?.Name;
- bool gameBizChanged = lastGameBiz.ToGame() != GameBiz.None && lastGameBiz.ToGame() != CurrentGameBiz.ToGame();
if (destPage is null or nameof(BlankPage)
|| (CurrentGameBiz.ToGame() is GameBiz.Honkai3rd && destPage is nameof(GachaLogPage) or nameof(HoyolabToolboxPage) or nameof(SelfQueryPage)))
{