mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
guide window
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace Snap.Hutao.Test;
|
||||
|
||||
@@ -9,6 +9,7 @@ using Snap.Hutao.Service.DailyNote;
|
||||
using Snap.Hutao.Service.Hutao;
|
||||
using Snap.Hutao.Service.Metadata;
|
||||
using Snap.Hutao.Service.Navigation;
|
||||
using Snap.Hutao.ViewModel.Guide;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Snap.Hutao.Core.LifeCycle;
|
||||
@@ -149,7 +150,15 @@ internal sealed class Activation : IActivation
|
||||
// Increase launch times
|
||||
LocalSetting.Set(SettingKeys.LaunchTimes, LocalSetting.Get(SettingKeys.LaunchTimes, 0) + 1);
|
||||
|
||||
await WaitMainWindowAsync().ConfigureAwait(false);
|
||||
if (LocalSetting.Get(SettingKeys.Major1Minor7Revision0GuideState, (uint)GuideState.None) < (uint)GuideState.Completed)
|
||||
{
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
serviceProvider.GetRequiredService<GuideWindow>();
|
||||
}
|
||||
else
|
||||
{
|
||||
await WaitMainWindowAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task WaitMainWindowAsync()
|
||||
|
||||
@@ -45,6 +45,11 @@ internal static class SettingKeys
|
||||
/// </summary>
|
||||
public const string IsInfoBarToggleChecked = "IsInfoBarToggleChecked";
|
||||
|
||||
/// <summary>
|
||||
/// 1.7.0 版本指引状态
|
||||
/// </summary>
|
||||
public const string Major1Minor7Revision0GuideState = "Major1Minor7Revision0GuideState";
|
||||
|
||||
#region StaticResource
|
||||
|
||||
/// <summary>
|
||||
|
||||
35
src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml
Normal file
35
src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml
Normal file
@@ -0,0 +1,35 @@
|
||||
<Window
|
||||
x:Class="Snap.Hutao.GuideWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shvg="using:Snap.Hutao.View.Guide"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid x:Name="RootGrid">
|
||||
<mxi:Interaction.Behaviors>
|
||||
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid
|
||||
x:Name="DragableGrid"
|
||||
Grid.Row="0"
|
||||
Height="32">
|
||||
<TextBlock
|
||||
Margin="12,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=GuideWindowTitle}"
|
||||
TextWrapping="NoWrap"/>
|
||||
</Grid>
|
||||
<shvg:GuideView Grid.Row="1"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
40
src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml.cs
Normal file
40
src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
using Snap.Hutao.Core.Windowing;
|
||||
using Windows.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
namespace Snap.Hutao;
|
||||
|
||||
/// <summary>
|
||||
/// ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[Injection(InjectAs.Singleton)]
|
||||
internal sealed partial class GuideWindow : Window, IWindowOptionsSource
|
||||
{
|
||||
private const int MinWidth = 800;
|
||||
private const int MinHeight = 450;
|
||||
|
||||
private const int MaxWidth = 1200;
|
||||
private const int MaxHeight = 750;
|
||||
|
||||
private readonly WindowOptions windowOptions;
|
||||
|
||||
public GuideWindow(IServiceProvider serviceProvider)
|
||||
{
|
||||
InitializeComponent();
|
||||
windowOptions = new(this, DragableGrid, new(MinWidth, MinHeight));
|
||||
ExtendedWindow<GuideWindow>.Initialize(this, Ioc.Default);
|
||||
}
|
||||
|
||||
WindowOptions IWindowOptionsSource.WindowOptions { get => windowOptions; }
|
||||
|
||||
public unsafe void ProcessMinMaxInfo(MINMAXINFO* pInfo, double scalingFactor)
|
||||
{
|
||||
pInfo->ptMinTrackSize.X = (int)Math.Max(MinWidth * scalingFactor, pInfo->ptMinTrackSize.X);
|
||||
pInfo->ptMinTrackSize.Y = (int)Math.Max(MinHeight * scalingFactor, pInfo->ptMinTrackSize.Y);
|
||||
pInfo->ptMaxTrackSize.X = (int)Math.Min(MaxWidth * scalingFactor, pInfo->ptMaxTrackSize.X);
|
||||
pInfo->ptMaxTrackSize.Y = (int)Math.Min(MaxHeight * scalingFactor, pInfo->ptMaxTrackSize.Y);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Name="RootGrid" d:DataContext="{d:DesignInstance shvg:LaunchGameViewModel}">
|
||||
|
||||
<mxi:Interaction.Behaviors>
|
||||
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
|
||||
@@ -27,13 +27,13 @@ internal sealed partial class LaunchGameWindow : Window, IDisposable, IWindowOpt
|
||||
/// <summary>
|
||||
/// 构造一个新的启动游戏窗口
|
||||
/// </summary>
|
||||
/// <param name="scopeFactory">范围工厂</param>
|
||||
public LaunchGameWindow(IServiceScopeFactory scopeFactory)
|
||||
/// <param name="serviceProvider">服务提供器</param>
|
||||
public LaunchGameWindow(IServiceProvider serviceProvider)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
scope = scopeFactory.CreateScope();
|
||||
windowOptions = new(this, DragableGrid, new(320, 320));
|
||||
scope = serviceProvider.CreateScope();
|
||||
windowOptions = new(this, DragableGrid, new(MaxWidth, MaxHeight));
|
||||
ExtendedWindow<LaunchGameWindow>.Initialize(this, scope.ServiceProvider);
|
||||
RootGrid.DataContext = scope.ServiceProvider.GetRequiredService<LaunchGameViewModel>();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<Identity
|
||||
Name="60568DGPStudio.SnapHutao"
|
||||
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
|
||||
Version="1.6.5.0" />
|
||||
Version="1.6.6.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Snap Hutao</DisplayName>
|
||||
|
||||
@@ -267,6 +267,15 @@ namespace Snap.Hutao.Resource.Localization {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 欢迎使用胡桃 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string GuideWindowTitle {
|
||||
get {
|
||||
return ResourceManager.GetString("GuideWindowTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 选择账号并启动 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -2132,4 +2132,7 @@
|
||||
<data name="ViewModelGachaLogProbabilityOfNextPullIsOrange" xml:space="preserve">
|
||||
<value>{0:00.000%} 概率下一抽获得五星物品</value>
|
||||
</data>
|
||||
<data name="GuideWindowTitle" xml:space="preserve">
|
||||
<value>欢迎使用胡桃</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -41,7 +41,8 @@ internal static class GachaStatisticsExtension
|
||||
/// 完成添加
|
||||
/// </summary>
|
||||
/// <param name="summaryItems">简述物品列表</param>
|
||||
public static void CompleteAdding(this List<SummaryItem> summaryItems)
|
||||
/// <param name="guaranteeOrangeThreshold">五星保底阈值</param>
|
||||
public static void CompleteAdding(this List<SummaryItem> summaryItems, int guaranteeOrangeThreshold)
|
||||
{
|
||||
// we can't trust first item's prev state.
|
||||
bool isPreviousUp = true;
|
||||
@@ -56,6 +57,7 @@ internal static class GachaStatisticsExtension
|
||||
|
||||
isPreviousUp = item.IsUp;
|
||||
item.Color = GetColorByName(item.Name);
|
||||
item.GuaranteeOrangeThreshold = guaranteeOrangeThreshold;
|
||||
}
|
||||
|
||||
// reverse items
|
||||
|
||||
@@ -142,7 +142,7 @@ internal sealed class TypedWishSummaryBuilder
|
||||
/// <returns>类型化祈愿统计信息</returns>
|
||||
public TypedWishSummary ToTypedWishSummary()
|
||||
{
|
||||
summaryItems.CompleteAdding();
|
||||
summaryItems.CompleteAdding(guaranteeOrangeThreshold);
|
||||
double totalCount = totalCountTracker;
|
||||
|
||||
TypedWishSummary summary = new()
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
<None Remove="Assets\Wide310x150Logo.scale-400.png" />
|
||||
<None Remove="Control\Panel\PanelSelector.xaml" />
|
||||
<None Remove="Control\Theme\FontStyle.xaml" />
|
||||
<None Remove="GuideWindow.xaml" />
|
||||
<None Remove="IdentityStructs.json" />
|
||||
<None Remove="LaunchGameWindow.xaml" />
|
||||
<None Remove="NativeMethods.json" />
|
||||
@@ -137,6 +138,7 @@
|
||||
<None Remove="View\Dialog\LaunchGamePackageConvertDialog.xaml" />
|
||||
<None Remove="View\Dialog\SignInWebViewDialog.xaml" />
|
||||
<None Remove="View\Dialog\UserDialog.xaml" />
|
||||
<None Remove="View\Guide\GuideView.xaml" />
|
||||
<None Remove="View\InfoBarView.xaml" />
|
||||
<None Remove="View\MainView.xaml" />
|
||||
<None Remove="View\Page\AchievementPage.xaml" />
|
||||
@@ -302,6 +304,12 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="GuideWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="View\Control\HutaoStatisticsCard.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -596,4 +604,9 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="View\Guide\GuideView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<SolidColorBrush x:Key="OrangeBrush" Color="#FFBC6932"/>
|
||||
|
||||
<shvconv:Int32ToGradientColorConverter x:Key="Int32ToGradientColorConverter" MaximumValue="{Binding GuaranteeOrangeThreshold}"/>
|
||||
|
||||
<shc:BindingProxy x:Key="SummaryProxy" DataContext="{Binding}"/>
|
||||
|
||||
<DataTemplate x:Key="OrangeListTemplate" d:DataType="shvg:SummaryItem">
|
||||
@@ -36,7 +35,7 @@
|
||||
MinHeight="32"
|
||||
Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
|
||||
CornerRadius="{StaticResource CompatCornerRadius}"
|
||||
Maximum="{Binding Path=DataContext.GuaranteeOrangeThreshold, Source={StaticResource SummaryProxy}}"
|
||||
Maximum="{Binding GuaranteeOrangeThreshold}"
|
||||
Opacity="0.2"
|
||||
Value="{Binding LastPull}">
|
||||
<ProgressBar.Foreground>
|
||||
|
||||
28
src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml
Normal file
28
src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml
Normal file
@@ -0,0 +1,28 @@
|
||||
<UserControl
|
||||
x:Class="Snap.Hutao.View.Guide.GuideView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:shvg="using:Snap.Hutao.ViewModel.Guide"
|
||||
d:DataContext="{d:DesignInstance shvg:GuideViewModel}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<cwuc:SwitchPresenter/>
|
||||
<Grid Grid.Row="1">
|
||||
<PipsPager
|
||||
HorizontalAlignment="Center"
|
||||
CanBeScrollAnchor="False"
|
||||
IsEnabled="False"
|
||||
NumberOfPages="5"
|
||||
SelectedPageIndex="0"/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
20
src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml.cs
Normal file
20
src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Snap.Hutao.ViewModel.Guide;
|
||||
|
||||
namespace Snap.Hutao.View.Guide;
|
||||
|
||||
/// <summary>
|
||||
/// 指引视图
|
||||
/// </summary>
|
||||
internal sealed partial class GuideView : UserControl
|
||||
{
|
||||
public GuideView()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = Ioc.Default.GetRequiredService<GuideViewModel>();
|
||||
_ = 1;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,11 @@ internal sealed class SummaryItem : Item
|
||||
/// </summary>
|
||||
public bool IsGuarantee { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 五星保底阈值
|
||||
/// </summary>
|
||||
public int GuaranteeOrangeThreshold { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 据上次
|
||||
/// </summary>
|
||||
|
||||
20
src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/GuideState.cs
Normal file
20
src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/GuideState.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.ViewModel.Guide;
|
||||
|
||||
/// <summary>
|
||||
/// 指引状态
|
||||
/// </summary>
|
||||
internal enum GuideState : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// 尚未开始
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// 完成
|
||||
/// </summary>
|
||||
Completed,
|
||||
}
|
||||
16
src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/GuideViewModel.cs
Normal file
16
src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/GuideViewModel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.ViewModel.Guide;
|
||||
|
||||
/// <summary>
|
||||
/// 指引视图模型
|
||||
/// </summary>
|
||||
[Injection(InjectAs.Transient)]
|
||||
internal sealed class GuideViewModel : Abstraction.ViewModel
|
||||
{
|
||||
protected override Task OpenUIAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user