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;
|
||||
}
|
||||
|
||||
public static void RemoveLast<T>(this IList<T> collection)
|
||||
{
|
||||
collection.RemoveAt(collection.Count - 1);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -3103,7 +3130,7 @@ namespace Snap.Hutao.Resource.Localization {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 {1:00.000%} 概率 {0} 抽后获得五星物品 的本地化字符串。
|
||||
/// 查找类似 {1:P3} 概率 {0} 抽后获得五星物品 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewModelGachaLogPredictedPullLeftToOrange {
|
||||
get {
|
||||
@@ -3112,7 +3139,7 @@ namespace Snap.Hutao.Resource.Localization {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 {0:00.000%} 概率下一抽获得五星物品 的本地化字符串。
|
||||
/// 查找类似 {0:P3} 概率下一抽获得五星物品 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewModelGachaLogProbabilityOfNextPullIsOrange {
|
||||
get {
|
||||
|
||||
@@ -851,6 +851,15 @@
|
||||
<data name="ViewControlStatisticsCardUpText" xml:space="preserve">
|
||||
<value>UP</value>
|
||||
</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">
|
||||
<value>养成计划</value>
|
||||
</data>
|
||||
@@ -1188,10 +1197,10 @@
|
||||
<value>导入失败</value>
|
||||
</data>
|
||||
<data name="ViewModelGachaLogPredictedPullLeftToOrange" xml:space="preserve">
|
||||
<value>{1:00.000%} 概率 {0} 抽后获得五星物品</value>
|
||||
<value>{1:P3} 概率 {0} 抽后获得五星物品</value>
|
||||
</data>
|
||||
<data name="ViewModelGachaLogProbabilityOfNextPullIsOrange" xml:space="preserve">
|
||||
<value>{0:00.000%} 概率下一抽获得五星物品</value>
|
||||
<value>{0:P3} 概率下一抽获得五星物品</value>
|
||||
</data>
|
||||
<data name="ViewModelGachaLogRefreshFail" xml:space="preserve">
|
||||
<value>获取祈愿记录失败</value>
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
<None Remove="View\Control\LoadingViewSlim.xaml" />
|
||||
<None Remove="View\Control\SkillPivot.xaml" />
|
||||
<None Remove="View\Control\StatisticsCard.xaml" />
|
||||
<None Remove="View\Control\StatisticsSegmented.xaml" />
|
||||
<None Remove="View\Control\Webview2Viewer.xaml" />
|
||||
<None Remove="View\Dialog\AchievementArchiveCreateDialog.xaml" />
|
||||
<None Remove="View\Dialog\AchievementImportDialog.xaml" />
|
||||
@@ -298,6 +299,12 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="View\Control\StatisticsSegmented.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="View\Dialog\GeetestCustomUrlDialog.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
x:Class="Snap.Hutao.View.Control.StatisticsCard"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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:cwucont="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shci="using:Snap.Hutao.Control.Image"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shcp="using:Snap.Hutao.Control.Panel"
|
||||
@@ -237,15 +235,18 @@
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<MenuFlyoutSeparator Margin="-12,0"/>
|
||||
<FlipView
|
||||
Name="StatisticsFilpView"
|
||||
Height="74"
|
||||
Margin="-16,0"
|
||||
VerticalAlignment="Top"
|
||||
Background="Transparent">
|
||||
|
||||
<FlipViewItem>
|
||||
<StackPanel Padding="16,12" Spacing="2">
|
||||
<shvcont:StatisticsSegmented
|
||||
IsPredictPullAvailable="{Binding IsPredictPullAvailable}"
|
||||
x:Name="StatisticsSegmented"
|
||||
Margin="0,16,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedIndex="0"/>
|
||||
<cwc:SwitchPresenter
|
||||
Height="85"
|
||||
Padding="0,12"
|
||||
Value="{x:Bind StatisticsSegmented.SelectedIndex, Mode=OneWay}">
|
||||
<cwc:Case Value="{shcm:Int32 Value=0}">
|
||||
<StackPanel Spacing="2">
|
||||
<Grid>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeAveragePullText}"/>
|
||||
<TextBlock
|
||||
@@ -276,18 +277,9 @@
|
||||
Text="{Binding MinOrangePullFormatted}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</FlipViewItem>
|
||||
<FlipViewItem>
|
||||
<StackPanel
|
||||
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">
|
||||
</cwc:Case>
|
||||
<cwc:Case Value="{shcm:Int32 Value=1}">
|
||||
<StackPanel Spacing="2">
|
||||
<Grid>
|
||||
<TextBlock
|
||||
Foreground="{StaticResource OrangeBrush}"
|
||||
@@ -325,14 +317,14 @@
|
||||
Text="{Binding TotalBlueFormatted}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</FlipViewItem>
|
||||
</FlipView>
|
||||
<PipsPager
|
||||
Height="16"
|
||||
Margin="0,-4,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
NumberOfPages="{x:Bind StatisticsFilpView.Items.Count}"
|
||||
SelectedPageIndex="{x:Bind StatisticsFilpView.SelectedIndex, Mode=TwoWay}"/>
|
||||
</cwc:Case>
|
||||
<cwc:Case Value="{shcm:Int32 Value=2}">
|
||||
<StackPanel Spacing="2">
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding PredictedPullLeftToOrangeFormatted}"/>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding ProbabilityOfNextPullIsOrangeFormatted}"/>
|
||||
</StackPanel>
|
||||
</cwc:Case>
|
||||
</cwc:SwitchPresenter>
|
||||
<MenuFlyoutSeparator Margin="-12,0,-12,0"/>
|
||||
</StackPanel>
|
||||
|
||||
@@ -341,23 +333,23 @@
|
||||
Grid.Row="2"
|
||||
Margin="12,6,12,12"
|
||||
VerticalScrollBarVisibility="Hidden">
|
||||
<cwucont:SwitchPresenter Value="{Binding ElementName=ItemsPanelSelector, Path=Current}">
|
||||
<cwucont:SwitchPresenter.ContentTransitions>
|
||||
<cwc:SwitchPresenter Value="{Binding ElementName=ItemsPanelSelector, Path=Current}">
|
||||
<cwc:SwitchPresenter.ContentTransitions>
|
||||
<TransitionCollection>
|
||||
<ContentThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</cwucont:SwitchPresenter.ContentTransitions>
|
||||
<cwucont:Case Value="List">
|
||||
</cwc:SwitchPresenter.ContentTransitions>
|
||||
<cwc:Case Value="List">
|
||||
<ItemsControl ItemTemplate="{StaticResource OrangeListTemplate}" ItemsSource="{Binding OrangeList}"/>
|
||||
</cwucont:Case>
|
||||
<cwucont:Case Value="Grid">
|
||||
</cwc:Case>
|
||||
<cwc:Case Value="Grid">
|
||||
<ItemsControl
|
||||
Margin="0,0,-4,0"
|
||||
ItemTemplate="{StaticResource OrangeGridTemplate}"
|
||||
ItemsPanel="{StaticResource WrapPanelTemplate}"
|
||||
ItemsSource="{Binding OrangeList}"/>
|
||||
</cwucont:Case>
|
||||
</cwucont:SwitchPresenter>
|
||||
</cwc:Case>
|
||||
</cwc:SwitchPresenter>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</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