Skip to content

Commit

Permalink
avatar info
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Oct 10, 2022
1 parent 560068c commit 55f16a6
Show file tree
Hide file tree
Showing 43 changed files with 1,560 additions and 515 deletions.
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ body:
id: shver
attributes:
label: Snap Hutao 版本
description: 在应用程序的设置界面中靠下的位置可以找到
placeholder: 例:1.0.30.0
description: 在应用标题,应用程序的设置界面中靠下的位置可以找到
placeholder: 例:1.1.0
validations:
required: true

Expand All @@ -51,7 +51,7 @@ body:
label: 相关的崩溃日志 位于 `%HOMEPATH%/Documents/Hutao/Log.db`
description: |
在资源管理器中直接输入`%HOMEPATH%/Documents/Hutao`即可进入文件夹
如果应用程序崩溃了,可以将崩溃日志复制后粘贴在此处,文件包含了敏感信息,谨慎上传
如果应用程序崩溃了,请将`log.db` 文件上传,文件包含了敏感信息,谨慎上传
如果这个表单是关于导入祈愿记录的问题,请包含你导入的`Json`文件
**务必不要上传`user.db`文件,该文件包含你的帐号敏感信息**
render: shell
Expand All @@ -68,9 +68,10 @@ body:
- type: checkboxes
id: confirm-no-duplicated-issue
attributes:
label: 我确认该问题是一个新问题,没有其他人已经提出相同的问题
label: 我确认没有他人提出相同或类似的问题
description: |
请先通过 Issue 搜索功能确认这不是相同的问题;
[BUG Issues](https://github.com/DGP-Studio/Snap.Hutao/issues?q=is%3Aissue+is%3Aopen+label%3ABUG)
你应该在原始 Issue 中通过回复添加有助于解决问题的信息,而不是创建重复的问题;
**没有帮助的重复问题可能会被直接关闭**
options:
Expand Down
2 changes: 2 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.UI.Xaml;
using Microsoft.Windows.AppLifecycle;
using Snap.Hutao.Core;
using Snap.Hutao.Core.Exception;
using Snap.Hutao.Core.LifeCycle;
using Snap.Hutao.Core.Logging;
Expand Down Expand Up @@ -48,6 +49,7 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args)
Activation.Activate(firstInstance, activatedEventArgs);
firstInstance.Activated += Activation.Activate;

logger.LogInformation(EventIds.CommonLog, "Snap Hutao : {version}", CoreEnvironment.Version);
logger.LogInformation(EventIds.CommonLog, "Cache folder : {folder}", ApplicationData.Current.TemporaryFolder.Path);

Ioc.Default
Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Control/Markup/I18NExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class I18NExtension : MarkupExtension
static I18NExtension()
{
string currentName = CultureInfo.CurrentUICulture.Name;
Type? languageType = ((IDictionary<string, Type>)TranslationMap).GetValueOrDefault(currentName, typeof(LanguagezhCN));
Type? languageType = ((IDictionary<string, Type>)TranslationMap).GetValueOrDefault2(currentName, typeof(LanguagezhCN));
Translation = (ITranslation)Activator.CreateInstance(languageType!)!;
}

Expand Down
29 changes: 29 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Control/Panel/PanelSelector.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<UserControl
x:Class="Snap.Hutao.Control.Panel.PanelSelector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
mc:Ignorable="d">

<SplitButton Padding="0,6" Click="SplitButtonClick" Loaded="SplitButtonLoaded">
<SplitButton.Content>
<FontIcon Name="IconPresenter" Glyph="&#xE8FD;"/>
</SplitButton.Content>
<SplitButton.Flyout>
<MenuFlyout>
<RadioMenuFlyoutItem
Tag="List"
Click="RadioMenuFlyoutItemClick"
Icon="{shcm:FontIcon Glyph=&#xE8FD;}"
Text="列表"/>
<RadioMenuFlyoutItem
Tag="Grid"
Click="RadioMenuFlyoutItemClick"
Icon="{shcm:FontIcon Glyph=&#xF0E2;}"
Text="网格"/>
</MenuFlyout>
</SplitButton.Flyout>
</SplitButton>
</UserControl>
82 changes: 82 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Control/Panel/PanelSelector.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Core;
using Snap.Hutao.Web.Hutao.Model;

namespace Snap.Hutao.Control.Panel;

/// <summary>
/// 面板选择器
/// </summary>
public sealed partial class PanelSelector : UserControl
{
private static readonly DependencyProperty CurrentProperty = Property<PanelSelector>.Depend(nameof(Current), "List");

/// <summary>
/// 构造一个新的面板选择器
/// </summary>
public PanelSelector()
{
InitializeComponent();
}

/// <summary>
/// 当前选择
/// </summary>
public string Current
{
get { return (string)GetValue(CurrentProperty); }
set { SetValue(CurrentProperty, value); }
}

private void SplitButtonLoaded(object sender, RoutedEventArgs e)
{
MenuFlyout menuFlyout = (MenuFlyout)((SplitButton)sender).Flyout;
((RadioMenuFlyoutItem)menuFlyout.Items[0]).IsChecked = true;
}

private void SplitButtonClick(SplitButton sender, SplitButtonClickEventArgs args)
{
MenuFlyout menuFlyout = (MenuFlyout)sender.Flyout;
int i = 0;
for (; i < menuFlyout.Items.Count; i++)
{
RadioMenuFlyoutItem current = (RadioMenuFlyoutItem)menuFlyout.Items[i];
if (current.IsChecked)
{
break;
}
}

i++;

if (i > menuFlyout.Items.Count)
{
i = 1;
}

if (i == menuFlyout.Items.Count)
{
i = 0;
}

RadioMenuFlyoutItem item = (RadioMenuFlyoutItem)menuFlyout.Items[i];
item.IsChecked = true;
UpdateState(item);
}

private void RadioMenuFlyoutItemClick(object sender, RoutedEventArgs e)
{
RadioMenuFlyoutItem item = (RadioMenuFlyoutItem)sender;
UpdateState(item);
}

private void UpdateState(RadioMenuFlyoutItem item)
{
Current = (string)item.Tag;
IconPresenter.Glyph = ((FontIcon)item.Icon).Glyph;
}
}
5 changes: 5 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Core/Logging/EventIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ internal static class EventIds
/// 祈愿统计生成
/// </summary>
public static readonly EventId GachaStatisticGeneration = 100140;

/// <summary>
/// 祈愿统计生成
/// </summary>
public static readonly EventId AvatarInfoGeneration = 100150;
#endregion

#region 杂项
Expand Down
12 changes: 4 additions & 8 deletions src/Snap.Hutao/Snap.Hutao/Core/Windowing/ExtendedWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Snap.Hutao.Core.Logging;
using Snap.Hutao.Extension;
using Snap.Hutao.Win32;
using Windows.Graphics;
using Windows.UI;
using Windows.Win32.Foundation;
Expand Down Expand Up @@ -149,14 +151,8 @@ private void UpdateDragRectangles(AppWindowTitleBar appTitleBar)
{
double scale = Persistence.GetScaleForWindow(handle);

List<RectInt32> dragRectsList = new();

// 48 is the navigation button leftInset
RectInt32 dragRect = new((int)(48 * scale), 0, (int)(titleBar.ActualWidth * scale), (int)(titleBar.ActualHeight * scale));
dragRectsList.Add(dragRect);

RectInt32[] dragRects = dragRectsList.ToArray();

appTitleBar.SetDragRectangles(dragRects);
RectInt32 dragRect = new RectInt32(48, 0, (int)titleBar.ActualWidth, (int)titleBar.ActualHeight).Scale(scale);
appTitleBar.SetDragRectangles(dragRect.Enumerate().ToArray());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static IEnumerable<TSource> Enumerate<TSource>(this TSource source)
/// <param name="key">键</param>
/// <param name="defaultValue">默认值</param>
/// <returns>结果值</returns>
public static TValue? GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue? defaultValue = default)
public static TValue? GetValueOrDefault2<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue? defaultValue = default)
where TKey : notnull
{
if (dictionary.TryGetValue(key, out TValue? value))
Expand Down
11 changes: 11 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Extension/NumberExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ namespace Snap.Hutao.Extension;
/// </summary>
public static class NumberExtensions
{
/// <summary>
/// 获取从右向左某位上的数字
/// </summary>
/// <param name="x">源</param>
/// <param name="place">位</param>
/// <returns>数字</returns>
public static int AtPlace(this int x, int place)
{
return (int)(x / Math.Pow(10, place - 1)) % 10;
}

/// <summary>
/// 计算给定整数的位数
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

namespace Snap.Hutao.Model.Binding.AvatarProperty;

/// <summary>
/// 词条评分
/// </summary>
public struct AffixScore
{
/// <summary>
/// 构造一个新的圣遗物评分
/// </summary>
/// <param name="score">评分</param>
/// <param name="weight">最大值</param>
public AffixScore(double score, double weight)
{
Score = score;
Weight = weight;
}

/// <summary>
/// 评分
/// </summary>
public double Score { get; }

/// <summary>
/// 权重
/// </summary>
public double Weight { get; }
}
10 changes: 10 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Model/Binding/AvatarProperty/Avatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ public class Avatar
/// 属性
/// </summary>
public List<Pair2<string, string, string?>> Properties { get; set; } = default!;

/// <summary>
/// 评分
/// </summary>
public string Score { get; set; } = default!;

/// <summary>
/// 双爆评分
/// </summary>
public string CritScore { get; set; } = default!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,4 @@ public class Player
/// 深渊层间
/// </summary>
public string SipralAbyssFloorLevel { get; set; } = default!;

/// <summary>
/// 头像
/// </summary>
public Uri ProfilePicture { get; set; } = default!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@ public class Reliquary : EquipBase
/// <summary>
/// 副属性列表
/// </summary>
public List<Pair<string, string>> SubProperties { get; set; } = default!;
}
public List<ReliquarySubProperty> SubProperties { get; set; } = default!;

/// <summary>
/// 评分
/// </summary>
public double Score { get; set; }

/// <summary>
/// 格式化评分
/// </summary>
public string ScoreFormatted { get => $"{Score:F2}"; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

namespace Snap.Hutao.Model.Binding.AvatarProperty;

/// <summary>
/// 圣遗物副词条
/// </summary>
public class ReliquarySubProperty
{
/// <summary>
/// 构造副属性
/// </summary>
/// <param name="name">名称</param>
/// <param name="value">值</param>
/// <param name="score">评分</param>
public ReliquarySubProperty(string name, string value, double score)
{
Name = name;
Value = value;
Score = score;

// only 0.2 | 0.4 | 0.6 | 0.8 | 1.0
Opacity = score switch
{
< 25 => 0.25,
< 50 => 0.5,
< 75 => 0.75,
_ => 1,
};
}

/// <summary>
/// 名称
/// </summary>
public string Name { get; }

/// <summary>
/// 值
/// </summary>
public string Value { get; }

/// <summary>
/// 评分
/// </summary>
public double Score { get; }

/// <summary>
/// 透明度
/// </summary>
public double Opacity { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ namespace Snap.Hutao.Model.Intrinsic;

/// <summary>
/// 成就信息状态
/// https://github.com/Grasscutters/Grasscutter/blob/development/proto/AchievementInfo.proto
/// https://github.com/Grasscutters/Grasscutter/blob/development/src/generated/main/java/emu/grasscutter/net/proto/AchievementInfoOuterClass.java#L163
/// </summary>
public enum AchievementInfoStatus
{
/// <summary>
/// 未识别
/// </summary>
UNRECOGNIZED = -1,

/// <summary>
/// 非法值
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Model/Metadata/Avatar/Avatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ public SummaryItem ToSummaryItem(int lastPull, DateTimeOffset time, bool isUp)
IsUp = isUp,
};
}
}
}
Loading

0 comments on commit 55f16a6

Please sign in to comment.