mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Merge pull request #1552 from DGP-Studio/feat/unheld_statistics_items
This commit is contained in:
@@ -19,6 +19,7 @@ internal sealed partial class SettingEntry
|
||||
public const string AnnouncementRegion = "AnnouncementRegion";
|
||||
|
||||
public const string IsEmptyHistoryWishVisible = "IsEmptyHistoryWishVisible";
|
||||
public const string IsUnobtainedWishItemVisible = "IsUnobtainedWishItemVisible";
|
||||
|
||||
public const string GeetestCustomCompositeUrl = "GeetestCustomCompositeUrl";
|
||||
|
||||
|
||||
@@ -2702,6 +2702,12 @@
|
||||
<data name="ViewPageSettingTranslateNavigate" xml:space="preserve">
|
||||
<value>贡献翻译</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingUnobtainedWishItemVisibleDescription" xml:space="preserve">
|
||||
<value>在祈愿记录页面角色与武器页签显示未抽取到的祈愿物品</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingUnobtainedWishItemVisibleHeader" xml:space="preserve">
|
||||
<value>未抽取到的祈愿物品</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingUpdateCheckAction" xml:space="preserve">
|
||||
<value>前往商店</value>
|
||||
</data>
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Snap.Hutao.Service;
|
||||
internal sealed partial class AppOptions : DbStoreOptions
|
||||
{
|
||||
private bool? isEmptyHistoryWishVisible;
|
||||
private bool? isUnobtainedWishItemVisible;
|
||||
private BackdropType? backdropType;
|
||||
private ElementTheme? elementTheme;
|
||||
private BackgroundImageType? backgroundImageType;
|
||||
@@ -24,10 +25,16 @@ internal sealed partial class AppOptions : DbStoreOptions
|
||||
|
||||
public bool IsEmptyHistoryWishVisible
|
||||
{
|
||||
get => GetOption(ref isEmptyHistoryWishVisible, SettingEntry.IsEmptyHistoryWishVisible);
|
||||
get => GetOption(ref isEmptyHistoryWishVisible, SettingEntry.IsEmptyHistoryWishVisible, false);
|
||||
set => SetOption(ref isEmptyHistoryWishVisible, SettingEntry.IsEmptyHistoryWishVisible, value);
|
||||
}
|
||||
|
||||
public bool IsUnobtainedWishItemVisible
|
||||
{
|
||||
get => GetOption(ref isUnobtainedWishItemVisible, SettingEntry.IsUnobtainedWishItemVisible, false);
|
||||
set => SetOption(ref isUnobtainedWishItemVisible, SettingEntry.IsUnobtainedWishItemVisible, value);
|
||||
}
|
||||
|
||||
public List<NameValue<BackdropType>> BackdropTypes { get; } = CollectionsNameValue.FromEnum<BackdropType>(type => type >= 0);
|
||||
|
||||
public BackdropType BackdropType
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Core.ExceptionService;
|
||||
using Snap.Hutao.Model.Intrinsic;
|
||||
using Snap.Hutao.Model.Metadata;
|
||||
using Snap.Hutao.Model.Metadata.Avatar;
|
||||
using Snap.Hutao.Model.Metadata.Weapon;
|
||||
using Snap.Hutao.Service.Metadata;
|
||||
@@ -10,6 +11,7 @@ using Snap.Hutao.Service.Metadata.ContextAbstraction;
|
||||
using Snap.Hutao.ViewModel.GachaLog;
|
||||
using Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo;
|
||||
using Snap.Hutao.Web.Hutao.GachaLog;
|
||||
using System.Collections.Frozen;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Snap.Hutao.Service.GachaLog.Factory;
|
||||
@@ -22,7 +24,24 @@ namespace Snap.Hutao.Service.GachaLog.Factory;
|
||||
[Injection(InjectAs.Scoped, typeof(IGachaStatisticsFactory))]
|
||||
internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
{
|
||||
private readonly IMetadataService metadataService;
|
||||
private static readonly FrozenSet<uint> BlueStandardWeaponIdsSet = FrozenSet.ToFrozenSet(
|
||||
[
|
||||
11301U, 11302U, 11306U,
|
||||
12301U, 12302U, 12305U,
|
||||
13303U,
|
||||
14301U, 14302U, 14304U,
|
||||
15301U, 15302U, 15304U
|
||||
]);
|
||||
|
||||
private static readonly FrozenSet<uint> PurpleStandardWeaponIdsSet = FrozenSet.ToFrozenSet(
|
||||
[
|
||||
11401U, 11402U, 11403U, 11405U,
|
||||
12401U, 12402U, 12403U, 12405U,
|
||||
13401U, 13407U,
|
||||
14401U, 14402U, 14403U, 14409U,
|
||||
15401U, 15402U, 15403U, 15405U
|
||||
]);
|
||||
|
||||
private readonly HomaGachaLogClient homaGachaLogClient;
|
||||
private readonly ITaskContext taskContext;
|
||||
private readonly AppOptions options;
|
||||
@@ -33,7 +52,7 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
await taskContext.SwitchToBackgroundAsync();
|
||||
|
||||
List<HistoryWishBuilder> historyWishBuilders = context.GachaEvents.SelectList(gachaEvent => new HistoryWishBuilder(gachaEvent, context));
|
||||
return CreateCore(taskContext, homaGachaLogClient, items, historyWishBuilders, context, options.IsEmptyHistoryWishVisible);
|
||||
return CreateCore(taskContext, homaGachaLogClient, items, historyWishBuilders, context, options);
|
||||
}
|
||||
|
||||
private static GachaStatistics CreateCore(
|
||||
@@ -42,7 +61,7 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
List<Model.Entity.GachaItem> items,
|
||||
List<HistoryWishBuilder> historyWishBuilders,
|
||||
in GachaLogServiceMetadataContext context,
|
||||
bool isEmptyHistoryWishVisible)
|
||||
AppOptions appOptions)
|
||||
{
|
||||
TypedWishSummaryBuilderContext standardContext = TypedWishSummaryBuilderContext.StandardWish(taskContext, gachaLogClient);
|
||||
TypedWishSummaryBuilder standardWishBuilder = new(standardContext);
|
||||
@@ -62,6 +81,45 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
Dictionary<Weapon, int> purpleWeaponCounter = [];
|
||||
Dictionary<Weapon, int> blueWeaponCounter = [];
|
||||
|
||||
if (appOptions.IsUnobtainedWishItemVisible)
|
||||
{
|
||||
orangeAvatarCounter = context.IdAvatarMap.Values
|
||||
.Where(avatar => avatar.Quality == QualityType.QUALITY_ORANGE)
|
||||
.ToDictionary(avatar => avatar, _ => 0);
|
||||
purpleAvatarCounter = context.IdAvatarMap.Values
|
||||
.Where(avatar => avatar.Quality == QualityType.QUALITY_PURPLE)
|
||||
.ToDictionary(avatar => avatar, _ => 0);
|
||||
orangeWeaponCounter = context.IdWeaponMap.Values
|
||||
.Where(weapon => weapon.Quality == QualityType.QUALITY_ORANGE)
|
||||
.ToDictionary(weapon => weapon, _ => 0);
|
||||
|
||||
HashSet<Weapon> purpleWeapons = [];
|
||||
foreach (uint weaponId in PurpleStandardWeaponIdsSet)
|
||||
{
|
||||
purpleWeapons.Add(context.IdWeaponMap[weaponId]);
|
||||
}
|
||||
|
||||
foreach (GachaEvent gachaEvent in context.GachaEvents)
|
||||
{
|
||||
if (gachaEvent.Type is GachaType.ActivityWeapon)
|
||||
{
|
||||
foreach (uint weaponId in gachaEvent.UpPurpleList)
|
||||
{
|
||||
purpleWeapons.Add(context.IdWeaponMap[weaponId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<Weapon> blueWeapons = [];
|
||||
foreach (uint weaponId in BlueStandardWeaponIdsSet)
|
||||
{
|
||||
blueWeapons.Add(context.IdWeaponMap[weaponId]);
|
||||
}
|
||||
|
||||
purpleWeaponCounter = purpleWeapons.ToDictionary(weapon => weapon, _ => 0);
|
||||
blueWeaponCounter = blueWeapons.ToDictionary(weapon => weapon, _ => 0);
|
||||
}
|
||||
|
||||
// Pre group builders
|
||||
Dictionary<GachaType, List<HistoryWishBuilder>> historyWishBuilderMap = historyWishBuilders
|
||||
.GroupBy(b => b.ConfigType)
|
||||
@@ -148,7 +206,7 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
{
|
||||
// history
|
||||
HistoryWishes = historyWishBuilders
|
||||
.Where(b => isEmptyHistoryWishVisible || (!b.IsEmpty))
|
||||
.Where(b => appOptions.IsEmptyHistoryWishVisible || (!b.IsEmpty))
|
||||
.OrderByDescending(builder => builder.From)
|
||||
.ThenBy(builder => builder.ConfigType, GachaTypeComparer.Shared)
|
||||
.Select(builder => builder.ToHistoryWish())
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:cw="using:CommunityToolkit.WinUI"
|
||||
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:cwcont="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:cwconv="using:CommunityToolkit.WinUI.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
@@ -24,6 +25,11 @@
|
||||
</mxi:Interaction.Behaviors>
|
||||
|
||||
<Page.Resources>
|
||||
<cwconv:DoubleToObjectConverter x:Key="DoubleToOpacityConverter" GreaterThan="0">
|
||||
<cwconv:DoubleToObjectConverter.TrueValue>1.0</cwconv:DoubleToObjectConverter.TrueValue>
|
||||
<cwconv:DoubleToObjectConverter.FalseValue>0.4</cwconv:DoubleToObjectConverter.FalseValue>
|
||||
</cwconv:DoubleToObjectConverter>
|
||||
|
||||
<Flyout x:Key="HutaoCloudFlyout">
|
||||
<Grid>
|
||||
<mxi:Interaction.Behaviors>
|
||||
@@ -120,12 +126,12 @@
|
||||
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudNotAllowed}"
|
||||
TextAlignment="Center"/>
|
||||
<cwc:SettingsCard
|
||||
<cwcont:SettingsCard
|
||||
Command="{Binding HutaoCloudViewModel.NavigateToSpiralAbyssRecordCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudSpiralAbyssActivityDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudSpiralAbyssActivityHeader}"
|
||||
IsClickEnabled="True"/>
|
||||
<cwc:SettingsCard
|
||||
<cwcont:SettingsCard
|
||||
Command="{Binding HutaoCloudViewModel.NavigateToAfdianSkuCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudAfdianPurchaseDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudAfdianPurchaseHeader}"
|
||||
@@ -210,6 +216,7 @@
|
||||
<shvc:ItemIcon
|
||||
Badge="{Binding Badge}"
|
||||
Icon="{Binding Icon}"
|
||||
Opacity="{Binding Count, Converter={StaticResource DoubleToOpacityConverter}}"
|
||||
Quality="{Binding Quality}"/>
|
||||
<Border
|
||||
HorizontalAlignment="Right"
|
||||
@@ -328,14 +335,14 @@
|
||||
HorizontalAlignment="Left"
|
||||
cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
|
||||
<Grid HorizontalAlignment="Center" Style="{StaticResource GridCardStyle}">
|
||||
<cwc:ConstrainedBox AspectRatio="1080:533">
|
||||
<cwcont:ConstrainedBox AspectRatio="1080:533">
|
||||
<shci:CachedImage
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
CornerRadius="{ThemeResource ControlCornerRadius}"
|
||||
Source="{Binding SelectedHistoryWish.BannerImage}"
|
||||
Stretch="UniformToFill"/>
|
||||
</cwc:ConstrainedBox>
|
||||
</cwcont:ConstrainedBox>
|
||||
<Border Grid.ColumnSpan="2" Background="{ThemeResource DarkOnlyOverlayMaskColorBrush}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
@@ -501,35 +508,35 @@
|
||||
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewPageGachaLogHint}"/>
|
||||
<StackPanel Margin="0,24,0,0" Spacing="{StaticResource SettingsCardSpacing}">
|
||||
<cwc:SettingsCard
|
||||
<cwcont:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageGachaLogRefreshAction}"
|
||||
Command="{Binding RefreshBySTokenCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageGachaLogRefreshBySTokenDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageGachaLogRefreshBySToken}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||
IsClickEnabled="True"/>
|
||||
<cwc:SettingsCard
|
||||
<cwcont:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageGachaLogRefreshAction}"
|
||||
Command="{Binding RefreshByWebCacheCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageGachaLogRefreshByWebCacheDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageGachaLogRefreshByWebCache}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||
IsClickEnabled="True"/>
|
||||
<cwc:SettingsCard
|
||||
<cwcont:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageGachaLogInputAction}"
|
||||
Command="{Binding RefreshByManualInputCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageGachaLogRefreshByManualInputDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageGachaLogRefreshByManualInput}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||
IsClickEnabled="True"/>
|
||||
<cwc:SettingsCard
|
||||
<cwcont:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageGachaLogImportAction}"
|
||||
Command="{Binding ImportFromUIGFJsonCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageGachaLogImportDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageGachaLogImportHeader}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||
IsClickEnabled="True"/>
|
||||
<cwc:SettingsCard
|
||||
<cwcont:SettingsCard
|
||||
Description="{shcm:ResourceString Name=ViewPageGachaLogRecoverFromHutaoCloudDescription}"
|
||||
FlyoutBase.AttachedFlyout="{StaticResource HutaoCloudFlyout}"
|
||||
Header="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloud}"
|
||||
@@ -540,7 +547,7 @@
|
||||
<shcb:ShowAttachedFlyoutAction/>
|
||||
</mxic:EventTriggerBehavior>
|
||||
</mxi:Interaction.Behaviors>
|
||||
</cwc:SettingsCard>
|
||||
</cwcont:SettingsCard>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@@ -559,6 +559,15 @@
|
||||
OffContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOff}"
|
||||
OnContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOn}"/>
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsCard
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingUnobtainedWishItemVisibleDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingUnobtainedWishItemVisibleHeader}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}">
|
||||
<ToggleSwitch
|
||||
IsOn="{Binding AppOptions.IsUnobtainedWishItemVisible, Mode=TwoWay}"
|
||||
OffContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOff}"
|
||||
OnContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOn}"/>
|
||||
</cwc:SettingsCard>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Border>
|
||||
|
||||
Reference in New Issue
Block a user