diff --git a/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/AppActivation.cs b/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/AppActivation.cs index 3a2acf8c..fd0bed4d 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/AppActivation.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/AppActivation.cs @@ -16,6 +16,8 @@ using Snap.Hutao.Service.Navigation; using Snap.Hutao.UI.Input.HotKey; using Snap.Hutao.UI.Shell; using Snap.Hutao.UI.Xaml; +using Snap.Hutao.UI.Xaml.View.Page; +using Snap.Hutao.UI.Xaml.View.Window; using Snap.Hutao.ViewModel.Guide; using System.Diagnostics; @@ -164,7 +166,7 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi case MainWindow: await serviceProvider .GetRequiredService() - .NavigateAsync(INavigationAwaiter.Default, true) + .NavigateAsync(INavigationAwaiter.Default, true) .ConfigureAwait(false); return; @@ -210,7 +212,7 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi // ViewModel requires the Metadata Service to be initialized. serviceProvider .GetRequiredService() - .Navigate(navigationAwaiter, true); + .Navigate(navigationAwaiter, true); #pragma warning restore CA1849 break; } diff --git a/src/Snap.Hutao/Snap.Hutao/Program.cs b/src/Snap.Hutao/Snap.Hutao/Program.cs index 0ff38f16..6d50f637 100644 --- a/src/Snap.Hutao/Snap.Hutao/Program.cs +++ b/src/Snap.Hutao/Snap.Hutao/Program.cs @@ -42,6 +42,8 @@ public static partial class Program [STAThread] private static void Main(string[] args) { + // WebView2 + Environment.SetEnvironmentVariable("WEBVIEW2_DEFAULT_BACKGROUND_COLOR", "00000000"); System.Diagnostics.Debug.WriteLine($"[Arguments]:[{args.ToString(',')}]"); XamlCheckProcessRequirements(); diff --git a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/QueryProvider/GachaLogQueryManualInputProvider.cs b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/QueryProvider/GachaLogQueryManualInputProvider.cs index cd1799ac..73f2b9b2 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/QueryProvider/GachaLogQueryManualInputProvider.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/QueryProvider/GachaLogQueryManualInputProvider.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. using Snap.Hutao.Factory.ContentDialog; -using Snap.Hutao.View.Dialog; +using Snap.Hutao.UI.Xaml.View.Dialog; using System.Collections.Specialized; using System.Web; diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/GameAccountService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/GameAccountService.cs index 0d2d3e8e..146c25bf 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/GameAccountService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/GameAccountService.cs @@ -6,7 +6,7 @@ using Snap.Hutao.Core.ExceptionService; using Snap.Hutao.Factory.ContentDialog; using Snap.Hutao.Model.Entity; using Snap.Hutao.Model.Entity.Primitive; -using Snap.Hutao.View.Dialog; +using Snap.Hutao.UI.Xaml.View.Dialog; using System.Collections.ObjectModel; namespace Snap.Hutao.Service.Game.Account; diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionEnsureGameResourceHandler.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionEnsureGameResourceHandler.cs index 127327f3..d29cd85e 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionEnsureGameResourceHandler.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionEnsureGameResourceHandler.cs @@ -9,7 +9,7 @@ using Snap.Hutao.Model.Intrinsic; using Snap.Hutao.Service.Game.Configuration; using Snap.Hutao.Service.Game.Package; using Snap.Hutao.UI.Xaml.Control; -using Snap.Hutao.View.Dialog; +using Snap.Hutao.UI.Xaml.View.Dialog; using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect; using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.ChannelSDK; using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile; diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/Island/IslandEnvironmentView.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/Island/IslandEnvironmentView.cs new file mode 100644 index 00000000..cb988734 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/Island/IslandEnvironmentView.cs @@ -0,0 +1,15 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; + +namespace Snap.Hutao.Service.Game.Unlocker.Island; + +internal struct IslandEnvironmentView +{ + public nuint Address; + public int Value; + public IslandState State; + public WIN32_ERROR LastError; + public int Reserved; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/Island/IslandGameFpsUnlocker.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/Island/IslandGameFpsUnlocker.cs index 8796a2b6..718229bf 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/Island/IslandGameFpsUnlocker.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/Island/IslandGameFpsUnlocker.cs @@ -40,8 +40,8 @@ internal sealed class IslandGameFpsUnlocker : GameFpsUnlocker context.Logger.LogInformation("context.GameProcess.HasExited: {Value}", context.GameProcess.HasExited); if (!context.GameProcess.HasExited && context.FpsAddress != 0U) { - IslandState state = UpdateIslandEnvironment(handle, context, launchOptions); - context.Logger.LogDebug("Island Environment State: {State}", state); + IslandEnvironmentView view = UpdateIslandEnvironment(handle, context, launchOptions); + context.Logger.LogDebug("Island Environment|{State}|{Error}", view.State, view.LastError); context.Report(); } else @@ -91,12 +91,12 @@ internal sealed class IslandGameFpsUnlocker : GameFpsUnlocker } } - private unsafe IslandState UpdateIslandEnvironment(nint handle, GameFpsUnlockerContext context, LaunchOptions launchOptions) + private unsafe IslandEnvironmentView UpdateIslandEnvironment(nint handle, GameFpsUnlockerContext context, LaunchOptions launchOptions) { IslandEnvironment* pIslandEnvironment = (IslandEnvironment*)handle; pIslandEnvironment->Address = context.FpsAddress; pIslandEnvironment->Value = launchOptions.TargetFps; - return pIslandEnvironment->State; + return *(IslandEnvironmentView*)&pIslandEnvironment; } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Navigation/NavigationService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Navigation/NavigationService.cs index eb9ce7ee..3014ce6f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Navigation/NavigationService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Navigation/NavigationService.cs @@ -6,8 +6,7 @@ using Snap.Hutao.Core.Logging; using Snap.Hutao.Core.Setting; using Snap.Hutao.Service.Notification; using Snap.Hutao.UI.Xaml.Control; -using Snap.Hutao.View.Helper; -using Snap.Hutao.View.Page; +using Snap.Hutao.UI.Xaml.View.Page; using Windows.Foundation; namespace Snap.Hutao.Service.Navigation; @@ -200,7 +199,7 @@ internal sealed class NavigationService : INavigationService, INavigationInitial else { NavigationViewItem? target = EnumerateMenuItems(NavigationView.MenuItems) - .SingleOrDefault(menuItem => NavHelper.GetNavigateTo(menuItem) == pageType); + .SingleOrDefault(menuItem => NavigationViewItemHelper.GetNavigateTo(menuItem) == pageType); NavigationView.SelectedItem = target; } @@ -214,12 +213,12 @@ internal sealed class NavigationService : INavigationService, INavigationInitial selected = NavigationView?.SelectedItem as NavigationViewItem; Type? targetType = args.IsSettingsInvoked ? typeof(SettingPage) - : NavHelper.GetNavigateTo(selected); + : NavigationViewItemHelper.GetNavigateTo(selected); // ignore item that doesn't have nav type specified if (targetType is not null) { - INavigationAwaiter navigationAwaiter = new NavigationExtra(NavHelper.GetExtraData(selected)); + INavigationAwaiter navigationAwaiter = new NavigationExtra(NavigationViewItemHelper.GetExtraData(selected)); Navigate(targetType, navigationAwaiter, false); } } diff --git a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj index 176210e5..793c48b2 100644 --- a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj +++ b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj @@ -145,6 +145,7 @@ + @@ -165,29 +166,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -386,66 +387,11 @@ MSBuild:Compile - - - MSBuild:Compile - - - - - MSBuild:Compile - - - - - MSBuild:Compile - - MSBuild:Compile - - - MSBuild:Compile - - - - - MSBuild:Compile - - - - - - MSBuild:Compile - - - - - - MSBuild:Compile - - - - - - MSBuild:Compile - - - - - - MSBuild:Compile - - - - - - MSBuild:Compile - - @@ -465,24 +411,12 @@ - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile @@ -544,11 +478,6 @@ - - - MSBuild:Compile - - MSBuild:Compile @@ -564,16 +493,6 @@ MSBuild:Compile - - - MSBuild:Compile - - - - - MSBuild:Compile - - MSBuild:Compile @@ -584,11 +503,6 @@ MSBuild:Compile - - - MSBuild:Compile - - MSBuild:Compile @@ -599,11 +513,6 @@ MSBuild:Compile - - - MSBuild:Compile - - MSBuild:Compile @@ -619,26 +528,11 @@ MSBuild:Compile - - - MSBuild:Compile - - MSBuild:Compile - - - MSBuild:Compile - - - - - MSBuild:Compile - - MSBuild:Compile @@ -699,31 +593,16 @@ MSBuild:Compile - - - MSBuild:Compile - - MSBuild:Compile - - - MSBuild:Compile - - MSBuild:Compile - - - MSBuild:Compile - - MSBuild:Compile @@ -764,11 +643,6 @@ MSBuild:Compile - - - - - MSBuild:Compile @@ -779,4 +653,13 @@ MSBuild:Compile + + + + + + + MSBuild:Compile + + diff --git a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Card/CardBlock.xaml b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Card/CardBlock.xaml index c4ea2e93..fe522df2 100644 --- a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Card/CardBlock.xaml +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Card/CardBlock.xaml @@ -1,6 +1,7 @@ @@ -12,7 +13,7 @@ - + + Visibility="{Binding (cw:FrameworkElementExtensions.Ancestor).IsDotVisible, RelativeSource={RelativeSource Self}, Converter={StaticResource BoolToVisibilityConverter}}"/> diff --git a/src/Snap.Hutao/Snap.Hutao/View/Helper/NavHelper.cs b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/NavigationViewItemHelper.cs similarity index 70% rename from src/Snap.Hutao/Snap.Hutao/View/Helper/NavHelper.cs rename to src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/NavigationViewItemHelper.cs index 39a6e52f..f3b2f23c 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Helper/NavHelper.cs +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/NavigationViewItemHelper.cs @@ -4,16 +4,11 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -namespace Snap.Hutao.View.Helper; +namespace Snap.Hutao.UI.Xaml.Control; -/// -/// 导航项帮助类 -/// This type can't be internal -/// -[HighQuality] [SuppressMessage("", "SH001")] [DependencyProperty("NavigateTo", typeof(Type), IsAttached = true, AttachedType = typeof(NavigationViewItem))] [DependencyProperty("ExtraData", typeof(object), IsAttached = true, AttachedType = typeof(NavigationViewItem))] -public sealed partial class NavHelper +public sealed partial class NavigationViewItemHelper { } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/ScopedPage.cs b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/ScopedPage.cs index 7c655c53..88659ac4 100644 --- a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/ScopedPage.cs +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/ScopedPage.cs @@ -6,7 +6,6 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Markup; using Microsoft.UI.Xaml.Navigation; using Snap.Hutao.Service.Navigation; -using Snap.Hutao.View.Helper; using Snap.Hutao.ViewModel.Abstraction; namespace Snap.Hutao.UI.Xaml.Control; @@ -15,7 +14,6 @@ namespace Snap.Hutao.UI.Xaml.Control; [SuppressMessage("", "CA1001")] internal class ScopedPage : Page { - private readonly RoutedEventHandler unloadEventHandler; private readonly CancellationTokenSource viewCancellationTokenSource = new(); private readonly IServiceScope pageScope; @@ -23,8 +21,7 @@ internal class ScopedPage : Page protected ScopedPage() { - unloadEventHandler = OnUnloaded; - Unloaded += unloadEventHandler; + Unloaded += OnUnloaded; pageScope = Ioc.Default.GetRequiredService().CreateScope(); } @@ -98,7 +95,7 @@ internal class ScopedPage : Page return; } - Unloaded -= unloadEventHandler; + Unloaded -= OnUnloaded; } private void DisposeViewModel() diff --git a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Theme/TransitionCollection.xaml b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Theme/TransitionCollection.xaml index fff27230..b4b87691 100644 --- a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Theme/TransitionCollection.xaml +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Control/Theme/TransitionCollection.xaml @@ -1,4 +1,7 @@  + + + @@ -11,13 +14,13 @@ + + + - - - \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Data/Converter/VisibilityToObjectConverter.cs b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Data/Converter/VisibilityToObjectConverter.cs index 125004fd..1d38574f 100644 --- a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Data/Converter/VisibilityToObjectConverter.cs +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/Data/Converter/VisibilityToObjectConverter.cs @@ -4,7 +4,7 @@ using Microsoft.UI.Xaml; using Snap.Hutao.UI.Xaml.Data.Converter; -namespace Snap.Hutao.View.Converter; +namespace Snap.Hutao.UI.Xaml.Data.Converter; [DependencyProperty("VisibleValue", typeof(object))] [DependencyProperty("CollapsedValue", typeof(object))] diff --git a/src/Snap.Hutao/Snap.Hutao/View/Helper/DeferContentLoader.cs b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/DeferContentLoader.cs similarity index 63% rename from src/Snap.Hutao/Snap.Hutao/View/Helper/DeferContentLoader.cs rename to src/Snap.Hutao/Snap.Hutao/UI/Xaml/DeferContentLoader.cs index 5d6f86b2..8bdb87a9 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Helper/DeferContentLoader.cs +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/DeferContentLoader.cs @@ -5,20 +5,20 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Markup; using Snap.Hutao.UI.Xaml.Control; -namespace Snap.Hutao.View.Helper; +namespace Snap.Hutao.UI.Xaml; internal sealed class DeferContentLoader : IDeferContentLoader { - private readonly WeakReference reference = new(default!); + private readonly WeakReference contentHost = new(default!); public DeferContentLoader(FrameworkElement element) { - reference.SetTarget(element); + contentHost.SetTarget(element); } public DependencyObject? Load(string name) { - if (reference.TryGetTarget(out FrameworkElement? element)) + if (contentHost.TryGetTarget(out FrameworkElement? element)) { return element.FindName(name) as DependencyObject; } @@ -28,9 +28,9 @@ internal sealed class DeferContentLoader : IDeferContentLoader public void Unload(DependencyObject @object) { - if (reference.TryGetTarget(out FrameworkElement? element) && element is ScopedPage scopedPage) + if (contentHost.TryGetTarget(out FrameworkElement? element) && element is ScopedPage scopedPage) { - scopedPage.UnloadObjectOverride(@object); + scopedPage.UnloadObjectOverride(@object); } else { diff --git a/src/Snap.Hutao/Snap.Hutao/View/Helper/IDeferContentLoader.cs b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/IDeferContentLoader.cs similarity index 87% rename from src/Snap.Hutao/Snap.Hutao/View/Helper/IDeferContentLoader.cs rename to src/Snap.Hutao/Snap.Hutao/UI/Xaml/IDeferContentLoader.cs index 542a5452..60052c76 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Helper/IDeferContentLoader.cs +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/IDeferContentLoader.cs @@ -3,7 +3,7 @@ using Microsoft.UI.Xaml; -namespace Snap.Hutao.View.Helper; +namespace Snap.Hutao.UI.Xaml; internal interface IDeferContentLoader { diff --git a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/UIElementHelper.cs b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/UIElementHelper.cs index e506369c..4a5a96a9 100644 --- a/src/Snap.Hutao/Snap.Hutao/UI/Xaml/UIElementHelper.cs +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/UIElementHelper.cs @@ -7,6 +7,7 @@ namespace Snap.Hutao.UI.Xaml; [SuppressMessage("", "SH001")] [DependencyProperty("VisibilityObject", typeof(object), null, nameof(OnVisibilityObjectChanged), IsAttached = true, AttachedType = typeof(UIElement))] +[DependencyProperty("VisibilityBoolean", typeof(bool), null, nameof(OnVisibilityBooleanChanged), IsAttached = true, AttachedType = typeof(UIElement))] [DependencyProperty("OpacityObject", typeof(object), null, nameof(OnOpacityObjectChanged), IsAttached = true, AttachedType = typeof(UIElement))] public sealed partial class UIElementHelper { @@ -21,4 +22,10 @@ public sealed partial class UIElementHelper UIElement element = (UIElement)dp; element.Opacity = e.NewValue is null ? 0D : 1D; } + + private static void OnVisibilityBooleanChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e) + { + UIElement element = (UIElement)dp; + element.Visibility = e.NewValue is true ? Visibility.Visible : Visibility.Collapsed; + } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/View/Card/AchievementCard.xaml b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/View/Card/AchievementCard.xaml similarity index 98% rename from src/Snap.Hutao/Snap.Hutao/View/Card/AchievementCard.xaml rename to src/Snap.Hutao/Snap.Hutao/UI/Xaml/View/Card/AchievementCard.xaml index 1fecd58e..bd2ba4d4 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Card/AchievementCard.xaml +++ b/src/Snap.Hutao/Snap.Hutao/UI/Xaml/View/Card/AchievementCard.xaml @@ -1,5 +1,5 @@