mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Compare commits
4 Commits
fix/1347
...
feat/combo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cef1ad3a66 | ||
|
|
d5551e5cdf | ||
|
|
f016a4a27f | ||
|
|
8b931b6d89 |
@@ -49,7 +49,8 @@ internal struct Rgba32
|
||||
/// <param name="code">RGBA 代码</param>
|
||||
public unsafe Rgba32(uint code)
|
||||
{
|
||||
// RRGGBBAA -> AABBGGRR
|
||||
// uint layout: 0xRRGGBBAA -> AABBGGRR
|
||||
// AABBGGRR -> RRGGBBAA
|
||||
fixed (Rgba32* pSelf = &this)
|
||||
{
|
||||
*(uint*)pSelf = BinaryPrimitives.ReverseEndianness(code);
|
||||
|
||||
@@ -8,6 +8,7 @@ using Microsoft.UI.Xaml.Media;
|
||||
using Snap.Hutao.Control.Extension;
|
||||
using Snap.Hutao.Control.Media;
|
||||
using Snap.Hutao.Control.Theme;
|
||||
using System.Diagnostics;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI;
|
||||
|
||||
@@ -23,8 +24,11 @@ namespace Snap.Hutao.Control.Text;
|
||||
[DependencyProperty("TextStyle", typeof(Style), default(Style), nameof(OnTextStyleChanged))]
|
||||
internal sealed partial class DescriptionTextBlock : ContentControl
|
||||
{
|
||||
private static readonly int ColorTagFullLength = "<color=#FFFFFFFF></color>".Length;
|
||||
private static readonly int ColorTagLeftLength = "<color=#FFFFFFFF>".Length;
|
||||
private static readonly int RgbaColorTagFullLength = "<color=#FFFFFFFF></color>".Length;
|
||||
private static readonly int RgbaColorTagLeftLength = "<color=#FFFFFFFF>".Length;
|
||||
|
||||
private static readonly int RgbColorTagFullLength = "<color=#FFFFFF></color>".Length;
|
||||
private static readonly int RgbColorTagLeftLength = "<color=#FFFFFF>".Length;
|
||||
|
||||
private static readonly int ItalicTagFullLength = "<i></i>".Length;
|
||||
private static readonly int ItalicTagLeftLength = "<i>".Length;
|
||||
@@ -53,8 +57,15 @@ internal sealed partial class DescriptionTextBlock : ContentControl
|
||||
TextBlock textBlock = (TextBlock)((DescriptionTextBlock)d).Content;
|
||||
ReadOnlySpan<char> description = MetadataSpecialNames.Handle((string)e.NewValue);
|
||||
|
||||
try
|
||||
{
|
||||
UpdateDescription(textBlock, description);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ = ex;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnTextStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
@@ -80,14 +91,33 @@ internal sealed partial class DescriptionTextBlock : ContentControl
|
||||
|
||||
// color tag
|
||||
else if (description[i..].StartsWith("<c"))
|
||||
{
|
||||
switch (description[i..].IndexOf('>'))
|
||||
{
|
||||
case 16: // RgbaColorTag
|
||||
{
|
||||
AppendText(textBlock, description[last..i]);
|
||||
Rgba32 color = new(description.Slice(i + 8, 8).ToString());
|
||||
int length = description[(i + ColorTagLeftLength)..].IndexOf('<');
|
||||
AppendColorText(textBlock, description.Slice(i + ColorTagLeftLength, length), color);
|
||||
int length = description[(i + RgbaColorTagLeftLength)..].IndexOf('<');
|
||||
AppendColorText(textBlock, description.Slice(i + RgbaColorTagLeftLength, length), color);
|
||||
|
||||
i += length + ColorTagFullLength;
|
||||
i += length + RgbaColorTagFullLength;
|
||||
last = i;
|
||||
break;
|
||||
}
|
||||
|
||||
case 14: // RgbColorTag
|
||||
{
|
||||
AppendText(textBlock, description[last..i]);
|
||||
Rgba32 color = new(description.Slice(i + 8, 6).ToString());
|
||||
int length = description[(i + RgbColorTagLeftLength)..].IndexOf('<');
|
||||
AppendColorText(textBlock, description.Slice(i + RgbColorTagLeftLength, length), color);
|
||||
|
||||
i += length + RgbColorTagFullLength;
|
||||
last = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// italic
|
||||
|
||||
@@ -77,7 +77,7 @@ internal sealed partial class AnnouncementContentViewer : UserControl
|
||||
}
|
||||
|
||||
content = StyleRegex().Replace(content, string.Empty);
|
||||
content = RemRegex().Replace(content, "calc($1 * 10) rem");
|
||||
content = RemRegex().Replace(content, "calc($0 * 10)");
|
||||
|
||||
bool isDarkMode = ThemeHelper.IsDarkMode(theme);
|
||||
|
||||
@@ -127,7 +127,7 @@ internal sealed partial class AnnouncementContentViewer : UserControl
|
||||
[GeneratedRegex(" style=\"(?!\")*?vertical-align:middle;\"")]
|
||||
private static partial Regex StyleRegex();
|
||||
|
||||
[GeneratedRegex("([0-9]+\\.[0-9]+)rem")]
|
||||
[GeneratedRegex("[0-9]+\\.[0-9]+rem")]
|
||||
private static partial Regex RemRegex();
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -145,6 +145,14 @@ internal sealed partial class UserQRCodeDialog : ContentDialog, IDisposable
|
||||
ArgumentNullException.ThrowIfNull(uidGameToken);
|
||||
return uidGameToken;
|
||||
}
|
||||
|
||||
// only available when game id is 4
|
||||
else if (query is { ReturnCode: 0, Data: { Stat: "Confirmed", Payload.Proto: "Combo" } })
|
||||
{
|
||||
ComboTokenWrapper? comboTokenWrapper = JsonSerializer.Deserialize<ComboTokenWrapper>(query.Data.Payload.Raw);
|
||||
ArgumentNullException.ThrowIfNull(comboTokenWrapper);
|
||||
return UidGameToken.From(comboTokenWrapper);
|
||||
}
|
||||
else if (query.ReturnCode == (int)KnownReturnCode.QrCodeExpired)
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Passport;
|
||||
|
||||
internal sealed class ComboTokenWrapper
|
||||
{
|
||||
[JsonPropertyName("open_id")]
|
||||
public string OpenId { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("open_token")]
|
||||
public string OpenToken { get; set; } = default!;
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Core.Abstraction;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Passport;
|
||||
|
||||
[HighQuality]
|
||||
internal sealed class UidGameToken
|
||||
internal sealed class UidGameToken : IMappingFrom<UidGameToken, ComboTokenWrapper>
|
||||
{
|
||||
[JsonPropertyName("uid")]
|
||||
public string Uid { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("token")]
|
||||
public string GameToken { get; set; } = default!;
|
||||
|
||||
public static UidGameToken From(ComboTokenWrapper wrapper) => new()
|
||||
{
|
||||
Uid = wrapper.OpenId,
|
||||
GameToken = wrapper.OpenToken,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao;
|
||||
|
||||
internal sealed class HutaoReleaseDescription
|
||||
{
|
||||
[JsonPropertyName("cn")]
|
||||
public string CN { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("en")]
|
||||
public string EN { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("full")]
|
||||
public string Full { get; set; } = default!;
|
||||
}
|
||||
@@ -13,4 +13,10 @@ internal sealed class HutaoVersionInformation
|
||||
|
||||
[JsonPropertyName("sha256")]
|
||||
public string? Sha256 { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("archive_urls")]
|
||||
public List<string> ArchiveUrls { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("release_description")]
|
||||
public HutaoReleaseDescription ReleaseDescription { get; set; } = default!;
|
||||
}
|
||||
Reference in New Issue
Block a user