mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix gacha statistic pull prediction view
This commit is contained in:
18
src/Snap.Hutao/Snap.Hutao/Control/Markup/Int32Extension.cs
Normal file
18
src/Snap.Hutao/Snap.Hutao/Control/Markup/Int32Extension.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Microsoft.UI.Xaml.Markup;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Control.Markup;
|
||||||
|
|
||||||
|
[MarkupExtensionReturnType(ReturnType = typeof(int))]
|
||||||
|
internal sealed class Int32Extension : MarkupExtension
|
||||||
|
{
|
||||||
|
public string Value { get; set; } = default!;
|
||||||
|
|
||||||
|
protected override object ProvideValue()
|
||||||
|
{
|
||||||
|
_ = int.TryParse(Value, out int result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,6 +84,11 @@ internal static partial class EnumerableExtension
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RemoveLast<T>(this IList<T> collection)
|
||||||
|
{
|
||||||
|
collection.RemoveAt(collection.Count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 转换到新类型的列表
|
/// 转换到新类型的列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2094,6 +2094,33 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 预测 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewControlStatisticsSegmentedItemContentPrediction {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewControlStatisticsSegmentedItemContentPrediction", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 比例 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewControlStatisticsSegmentedItemContentProportion {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewControlStatisticsSegmentedItemContentProportion", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 统计 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewControlStatisticsSegmentedItemContentStatistics {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewControlStatisticsSegmentedItemContentStatistics", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 养成计划 的本地化字符串。
|
/// 查找类似 养成计划 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -3103,7 +3130,7 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 {1:00.000%} 概率 {0} 抽后获得五星物品 的本地化字符串。
|
/// 查找类似 {1:P3} 概率 {0} 抽后获得五星物品 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ViewModelGachaLogPredictedPullLeftToOrange {
|
internal static string ViewModelGachaLogPredictedPullLeftToOrange {
|
||||||
get {
|
get {
|
||||||
@@ -3112,7 +3139,7 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 {0:00.000%} 概率下一抽获得五星物品 的本地化字符串。
|
/// 查找类似 {0:P3} 概率下一抽获得五星物品 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ViewModelGachaLogProbabilityOfNextPullIsOrange {
|
internal static string ViewModelGachaLogProbabilityOfNextPullIsOrange {
|
||||||
get {
|
get {
|
||||||
|
|||||||
@@ -851,6 +851,15 @@
|
|||||||
<data name="ViewControlStatisticsCardUpText" xml:space="preserve">
|
<data name="ViewControlStatisticsCardUpText" xml:space="preserve">
|
||||||
<value>UP</value>
|
<value>UP</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ViewControlStatisticsSegmentedItemContentPrediction" xml:space="preserve">
|
||||||
|
<value>预测</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewControlStatisticsSegmentedItemContentProportion" xml:space="preserve">
|
||||||
|
<value>比例</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewControlStatisticsSegmentedItemContentStatistics" xml:space="preserve">
|
||||||
|
<value>统计</value>
|
||||||
|
</data>
|
||||||
<data name="ViewCultivationHeader" xml:space="preserve">
|
<data name="ViewCultivationHeader" xml:space="preserve">
|
||||||
<value>养成计划</value>
|
<value>养成计划</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -1188,10 +1197,10 @@
|
|||||||
<value>导入失败</value>
|
<value>导入失败</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ViewModelGachaLogPredictedPullLeftToOrange" xml:space="preserve">
|
<data name="ViewModelGachaLogPredictedPullLeftToOrange" xml:space="preserve">
|
||||||
<value>{1:00.000%} 概率 {0} 抽后获得五星物品</value>
|
<value>{1:P3} 概率 {0} 抽后获得五星物品</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ViewModelGachaLogProbabilityOfNextPullIsOrange" xml:space="preserve">
|
<data name="ViewModelGachaLogProbabilityOfNextPullIsOrange" xml:space="preserve">
|
||||||
<value>{0:00.000%} 概率下一抽获得五星物品</value>
|
<value>{0:P3} 概率下一抽获得五星物品</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ViewModelGachaLogRefreshFail" xml:space="preserve">
|
<data name="ViewModelGachaLogRefreshFail" xml:space="preserve">
|
||||||
<value>获取祈愿记录失败</value>
|
<value>获取祈愿记录失败</value>
|
||||||
|
|||||||
@@ -119,6 +119,7 @@
|
|||||||
<None Remove="View\Control\LoadingViewSlim.xaml" />
|
<None Remove="View\Control\LoadingViewSlim.xaml" />
|
||||||
<None Remove="View\Control\SkillPivot.xaml" />
|
<None Remove="View\Control\SkillPivot.xaml" />
|
||||||
<None Remove="View\Control\StatisticsCard.xaml" />
|
<None Remove="View\Control\StatisticsCard.xaml" />
|
||||||
|
<None Remove="View\Control\StatisticsSegmented.xaml" />
|
||||||
<None Remove="View\Control\Webview2Viewer.xaml" />
|
<None Remove="View\Control\Webview2Viewer.xaml" />
|
||||||
<None Remove="View\Dialog\AchievementArchiveCreateDialog.xaml" />
|
<None Remove="View\Dialog\AchievementArchiveCreateDialog.xaml" />
|
||||||
<None Remove="View\Dialog\AchievementImportDialog.xaml" />
|
<None Remove="View\Dialog\AchievementImportDialog.xaml" />
|
||||||
@@ -298,6 +299,12 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="View\Control\StatisticsSegmented.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Update="View\Dialog\GeetestCustomUrlDialog.xaml">
|
<Page Update="View\Dialog\GeetestCustomUrlDialog.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@@ -2,12 +2,10 @@
|
|||||||
x:Class="Snap.Hutao.View.Control.StatisticsCard"
|
x:Class="Snap.Hutao.View.Control.StatisticsCard"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:clws="using:CommunityToolkit.Labs.WinUI"
|
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
|
||||||
xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Converters"
|
xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Converters"
|
||||||
xmlns:cwucont="using:CommunityToolkit.WinUI.UI.Controls"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:shc="using:Snap.Hutao.Control"
|
|
||||||
xmlns:shci="using:Snap.Hutao.Control.Image"
|
xmlns:shci="using:Snap.Hutao.Control.Image"
|
||||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||||
xmlns:shcp="using:Snap.Hutao.Control.Panel"
|
xmlns:shcp="using:Snap.Hutao.Control.Panel"
|
||||||
@@ -237,15 +235,18 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<MenuFlyoutSeparator Margin="-12,0"/>
|
<MenuFlyoutSeparator Margin="-12,0"/>
|
||||||
<FlipView
|
<shvcont:StatisticsSegmented
|
||||||
Name="StatisticsFilpView"
|
IsPredictPullAvailable="{Binding IsPredictPullAvailable}"
|
||||||
Height="74"
|
x:Name="StatisticsSegmented"
|
||||||
Margin="-16,0"
|
Margin="0,16,0,0"
|
||||||
VerticalAlignment="Top"
|
HorizontalAlignment="Stretch"
|
||||||
Background="Transparent">
|
SelectedIndex="0"/>
|
||||||
|
<cwc:SwitchPresenter
|
||||||
<FlipViewItem>
|
Height="85"
|
||||||
<StackPanel Padding="16,12" Spacing="2">
|
Padding="0,12"
|
||||||
|
Value="{x:Bind StatisticsSegmented.SelectedIndex, Mode=OneWay}">
|
||||||
|
<cwc:Case Value="{shcm:Int32 Value=0}">
|
||||||
|
<StackPanel Spacing="2">
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeAveragePullText}"/>
|
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeAveragePullText}"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
@@ -276,18 +277,9 @@
|
|||||||
Text="{Binding MinOrangePullFormatted}"/>
|
Text="{Binding MinOrangePullFormatted}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</FlipViewItem>
|
</cwc:Case>
|
||||||
<FlipViewItem>
|
<cwc:Case Value="{shcm:Int32 Value=1}">
|
||||||
<StackPanel
|
<StackPanel Spacing="2">
|
||||||
Margin="16,12"
|
|
||||||
Spacing="2"
|
|
||||||
Visibility="{Binding IsPredictPullAvailable, Converter={StaticResource BoolToVisibilityConverter}}">
|
|
||||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding PredictedPullLeftToOrangeFormatted}"/>
|
|
||||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding ProbabilityOfNextPullIsOrangeFormatted}"/>
|
|
||||||
</StackPanel>
|
|
||||||
</FlipViewItem>
|
|
||||||
<FlipViewItem>
|
|
||||||
<StackPanel Padding="16,12" Spacing="2">
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Foreground="{StaticResource OrangeBrush}"
|
Foreground="{StaticResource OrangeBrush}"
|
||||||
@@ -325,14 +317,14 @@
|
|||||||
Text="{Binding TotalBlueFormatted}"/>
|
Text="{Binding TotalBlueFormatted}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</FlipViewItem>
|
</cwc:Case>
|
||||||
</FlipView>
|
<cwc:Case Value="{shcm:Int32 Value=2}">
|
||||||
<PipsPager
|
<StackPanel Spacing="2">
|
||||||
Height="16"
|
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding PredictedPullLeftToOrangeFormatted}"/>
|
||||||
Margin="0,-4,0,0"
|
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding ProbabilityOfNextPullIsOrangeFormatted}"/>
|
||||||
HorizontalAlignment="Center"
|
</StackPanel>
|
||||||
NumberOfPages="{x:Bind StatisticsFilpView.Items.Count}"
|
</cwc:Case>
|
||||||
SelectedPageIndex="{x:Bind StatisticsFilpView.SelectedIndex, Mode=TwoWay}"/>
|
</cwc:SwitchPresenter>
|
||||||
<MenuFlyoutSeparator Margin="-12,0,-12,0"/>
|
<MenuFlyoutSeparator Margin="-12,0,-12,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
@@ -341,23 +333,23 @@
|
|||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Margin="12,6,12,12"
|
Margin="12,6,12,12"
|
||||||
VerticalScrollBarVisibility="Hidden">
|
VerticalScrollBarVisibility="Hidden">
|
||||||
<cwucont:SwitchPresenter Value="{Binding ElementName=ItemsPanelSelector, Path=Current}">
|
<cwc:SwitchPresenter Value="{Binding ElementName=ItemsPanelSelector, Path=Current}">
|
||||||
<cwucont:SwitchPresenter.ContentTransitions>
|
<cwc:SwitchPresenter.ContentTransitions>
|
||||||
<TransitionCollection>
|
<TransitionCollection>
|
||||||
<ContentThemeTransition/>
|
<ContentThemeTransition/>
|
||||||
</TransitionCollection>
|
</TransitionCollection>
|
||||||
</cwucont:SwitchPresenter.ContentTransitions>
|
</cwc:SwitchPresenter.ContentTransitions>
|
||||||
<cwucont:Case Value="List">
|
<cwc:Case Value="List">
|
||||||
<ItemsControl ItemTemplate="{StaticResource OrangeListTemplate}" ItemsSource="{Binding OrangeList}"/>
|
<ItemsControl ItemTemplate="{StaticResource OrangeListTemplate}" ItemsSource="{Binding OrangeList}"/>
|
||||||
</cwucont:Case>
|
</cwc:Case>
|
||||||
<cwucont:Case Value="Grid">
|
<cwc:Case Value="Grid">
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
Margin="0,0,-4,0"
|
Margin="0,0,-4,0"
|
||||||
ItemTemplate="{StaticResource OrangeGridTemplate}"
|
ItemTemplate="{StaticResource OrangeGridTemplate}"
|
||||||
ItemsPanel="{StaticResource WrapPanelTemplate}"
|
ItemsPanel="{StaticResource WrapPanelTemplate}"
|
||||||
ItemsSource="{Binding OrangeList}"/>
|
ItemsSource="{Binding OrangeList}"/>
|
||||||
</cwucont:Case>
|
</cwc:Case>
|
||||||
</cwucont:SwitchPresenter>
|
</cwc:SwitchPresenter>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<cwc:Segmented
|
||||||
|
x:Class="Snap.Hutao.View.Control.StatisticsSegmented"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<cwc:SegmentedItem Content="{shcm:ResourceString Name=ViewControlStatisticsSegmentedItemContentStatistics}" Icon="{shcm:FontIcon Glyph=}"/>
|
||||||
|
<cwc:SegmentedItem Content="{shcm:ResourceString Name=ViewControlStatisticsSegmentedItemContentProportion}" Icon="{shcm:FontIcon Glyph=}"/>
|
||||||
|
</cwc:Segmented>
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using CommunityToolkit.WinUI.Controls;
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.View.Control;
|
||||||
|
|
||||||
|
[DependencyProperty("IsPredictPullAvailable", typeof(bool), false, nameof(OnIsPredictPullAvailableChanged))]
|
||||||
|
internal sealed partial class StatisticsSegmented : Segmented
|
||||||
|
{
|
||||||
|
private readonly SegmentedItem predictPullItem = new()
|
||||||
|
{
|
||||||
|
Content = SH.ViewControlStatisticsSegmentedItemContentPrediction,
|
||||||
|
Icon = new FontIcon() { Glyph = "\uEA80" },
|
||||||
|
};
|
||||||
|
|
||||||
|
public StatisticsSegmented()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnIsPredictPullAvailableChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||||
|
{
|
||||||
|
StatisticsSegmented segmented = (StatisticsSegmented)obj;
|
||||||
|
if (args.NewValue is true)
|
||||||
|
{
|
||||||
|
segmented.Items.Add(segmented.predictPullItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
segmented.Items.RemoveLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user