This commit is contained in:
DismissedLight
2024-07-23 10:49:29 +08:00
parent 618f55acbc
commit e7bcc6e3ae
5 changed files with 41 additions and 31 deletions

View File

@@ -12,4 +12,10 @@ internal static class LevelFormat
{
return $"Lv.{value}";
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Format(uint value, uint extra)
{
return extra > 0 ? $"Lv.{value + extra} ({value} +{extra})" : $"Lv.{value}";
}
}

View File

@@ -7,6 +7,7 @@ using Snap.Hutao.Model.Metadata.Avatar;
using Snap.Hutao.Model.Metadata.Converter;
using Snap.Hutao.Model.Primitive;
using Snap.Hutao.ViewModel.AvatarProperty;
using System.Collections.Immutable;
namespace Snap.Hutao.Service.AvatarInfo.Factory.Builder;
@@ -199,30 +200,29 @@ internal static class AvatarViewBuilderExtension
return [];
}
IReadOnlyDictionary<SkillGroupId, SkillLevel> extraLevelMap = proudSkillExtraLevelMap as IReadOnlyDictionary<SkillGroupId, SkillLevel> ?? ImmutableDictionary<SkillGroupId, SkillLevel>.Empty;
Dictionary<SkillId, SkillLevel> skillExtraLeveledMap = new(skillLevelMap);
if (proudSkillExtraLevelMap is not null)
foreach ((SkillGroupId groupId, SkillLevel extraLevel) in extraLevelMap)
{
foreach ((SkillGroupId groupId, SkillLevel extraLevel) in proudSkillExtraLevelMap)
{
skillExtraLeveledMap.IncreaseByValue(proudSkills.Single(p => p.GroupId == groupId).Id, extraLevel);
}
skillExtraLeveledMap.IncreaseByValue(proudSkills.Single(p => p.GroupId == groupId).Id, extraLevel);
}
return proudSkills.SelectList(proudableSkill =>
return proudSkills.SelectList(proudSkill =>
{
SkillId skillId = proudableSkill.Id;
SkillId skillId = proudSkill.Id;
// TODO: use builder here
return new SkillView()
{
Name = proudableSkill.Name,
Icon = SkillIconConverter.IconNameToUri(proudableSkill.Icon),
Description = proudableSkill.Description,
Name = proudSkill.Name,
Icon = SkillIconConverter.IconNameToUri(proudSkill.Icon),
Description = proudSkill.Description,
GroupId = proudableSkill.GroupId,
GroupId = proudSkill.GroupId,
Level = LevelFormat.Format(skillLevelMap[skillId], extraLevelMap.GetValueOrDefault(proudSkill.GroupId)),
LevelNumber = skillLevelMap[skillId],
Info = DescriptionsParametersDescriptor.Convert(proudableSkill.Proud, skillExtraLeveledMap[skillId]),
Info = DescriptionsParametersDescriptor.Convert(proudSkill.Proud, skillExtraLeveledMap[skillId]),
};
});
}

View File

@@ -59,7 +59,7 @@
x:Name="InfoBarPanelTransitionHelper"
DefaultEasingMode="EaseOut"
DefaultEasingType="Cubic"
Duration="0:0:0.3">
Duration="0:0:0.2">
<clw:TransitionConfig Id="Body" ScaleMode="ScaleX"/>
<clw:TransitionConfig Id="Header" ScaleMode="ScaleX"/>
</clw:TransitionHelper>
@@ -71,7 +71,7 @@
x:Name="ShowButtonBorder"
Margin="16"
HorizontalAlignment="Right"
VerticalAlignment="Top"
VerticalAlignment="Bottom"
clw:TransitionHelper.Id="Body"
Background="{ThemeResource SystemControlAcrylicElementBrush}"
CornerRadius="{ThemeResource ControlCornerRadius}">
@@ -104,17 +104,28 @@
x:Name="InfoBarItemsBorder"
Margin="16"
HorizontalAlignment="Right"
VerticalAlignment="Top"
VerticalAlignment="Bottom"
clw:TransitionHelper.Id="Body"
cw:Effects.Shadow="{ThemeResource CompatCardShadow}"
Visibility="Collapsed">
<Border Padding="16" Style="{ThemeResource AcrylicBorderCardStyle}">
<Grid RowSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid ColumnSpacing="8">
<ScrollView Grid.Row="0">
<ItemsControl
MaxWidth="480"
ItemContainerTransitions="{StaticResource AddDeleteThemeTransitions}"
ItemTemplateSelector="{StaticResource InfoBarTemplateSelector}"
ItemsPanel="{StaticResource StackPanelSpacing8Template}"
ItemsSource="{Binding InfoBars, Mode=OneWay}"/>
</ScrollView>
<Grid Grid.Row="1" ColumnSpacing="8">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
@@ -164,15 +175,6 @@
</Button>
</StackPanel>
</Grid>
<ScrollView Grid.Row="1">
<ItemsControl
MaxWidth="480"
ItemContainerTransitions="{StaticResource AddDeleteThemeTransitions}"
ItemTemplateSelector="{StaticResource InfoBarTemplateSelector}"
ItemsPanel="{StaticResource StackPanelSpacing8Template}"
ItemsSource="{Binding InfoBars, Mode=OneWay}"/>
</ScrollView>
</Grid>
</Border>
</Border>

View File

@@ -64,7 +64,9 @@
Source="{Binding Icon}"/>
</shuxcc:VerticalCard.Top>
<shuxcc:VerticalCard.Bottom>
<TextBlock Text="{Binding Level}"/>
<Viewbox MaxWidth="52" StretchDirection="DownOnly">
<TextBlock Text="{Binding Level}"/>
</Viewbox>
</shuxcc:VerticalCard.Bottom>
</shuxcc:VerticalCard>
</DataTemplate>
@@ -143,7 +145,7 @@
</shuxcc:VerticalCard>
<ItemsControl
Grid.Column="2"
VerticalAlignment="Bottom"
VerticalAlignment="Stretch"
ItemTemplate="{StaticResource AvatarGridViewSkillTemplate}"
ItemsPanel="{StaticResource HorizontalStackPanelSpacing6Template}"
ItemsSource="{Binding Skills}"/>
@@ -252,7 +254,7 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="48"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<shuxci:CachedImage
Grid.Column="0"
@@ -266,7 +268,7 @@
VerticalAlignment="Center"
Foreground="#FFFFFFFF"
Style="{StaticResource BaseTextBlockStyle}"
Text="{Binding Info.Level}"/>
Text="{Binding Level}"/>
</Grid>
</Button.Content>
<Button.Flyout>

View File

@@ -26,7 +26,7 @@ internal sealed class SkillView : NameIconDescription, ITypedCalculableSource<IC
/// <summary>
/// 不计算命座的技能等级字符串
/// </summary>
public string Level { get => LevelFormat.Format(LevelNumber); }
public string Level { get; set; } = default!;
/// <summary>
/// 技能组Id