mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
metadata special name handling
This commit is contained in:
@@ -51,7 +51,7 @@ internal sealed partial class DescriptionTextBlock : ContentControl
|
||||
private static void OnDescriptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
TextBlock textBlock = (TextBlock)((DescriptionTextBlock)d).Content;
|
||||
ReadOnlySpan<char> description = (string)e.NewValue;
|
||||
ReadOnlySpan<char> description = MetadataSpecialNames.Handle((string)e.NewValue);
|
||||
|
||||
UpdateDescription(textBlock, description);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Snap.Hutao.Control.Text;
|
||||
|
||||
internal static partial class MetadataSpecialNames
|
||||
{
|
||||
public static string Handle(string input)
|
||||
{
|
||||
if (input.AsSpan()[0] is not '#')
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
StringBuilder resultBuilder = new(input);
|
||||
resultBuilder
|
||||
.Replace("{MATEAVATAR#SEXPRO[INFO_MALE_PRONOUN_BOYD|INFO_FEMALE_PRONOUN_GIRLD]}", SH.ControlTextMetadataSpecialNameMetaAvatarSexProD)
|
||||
.Replace("{PLAYERAVATAR#SEXPRO[INFO_MALE_PRONOUN_HE|INFO_FEMALE_PRONOUN_SHE]}", SH.ControlTextMetadataSpecialNamePlayerAvatarSexPro)
|
||||
.Replace("{REALNAME[ID(1)]}", SH.ControlTextMetadataSpecialNameRealNameId1);
|
||||
|
||||
input = resultBuilder.ToString();
|
||||
|
||||
// {M#.}{F#.}
|
||||
input = MaleFemaleRegex().Replace(input, SH.ControlTextMetadataSpecialNameMaleFemale);
|
||||
|
||||
return input[1..];
|
||||
}
|
||||
|
||||
[GeneratedRegex("\\{M#(.*?)\\}\\{F#(.*?)\\}")]
|
||||
private static partial Regex MaleFemaleRegex();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ internal sealed class WindowSubclass : IDisposable
|
||||
{
|
||||
if (window is IMinMaxInfoHandler handler)
|
||||
{
|
||||
handler.HandleMinMaxInfo(ref *(MINMAXINFO*)lParam.Value, options.GetRasterizationScale());
|
||||
handler.HandleMinMaxInfo(ref *(MINMAXINFO*)lParam, options.GetRasterizationScale());
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -118,7 +118,7 @@ internal sealed class WindowSubclass : IDisposable
|
||||
{
|
||||
if (window.SystemBackdrop is IBackdropNeedEraseBackground)
|
||||
{
|
||||
return (LRESULT)(int)(BOOL)true;
|
||||
return (LRESULT)(int)BOOL.TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -159,6 +159,18 @@
|
||||
<data name="ControlPanelPanelSelectorDropdownListName" xml:space="preserve">
|
||||
<value>列表</value>
|
||||
</data>
|
||||
<data name="ControlTextMetadataSpecialNameMaleFemale" xml:space="preserve">
|
||||
<value>旅行者(男):$1\r\n旅行者(女):$2</value>
|
||||
</data>
|
||||
<data name="ControlTextMetadataSpecialNameMetaAvatarSexProD" xml:space="preserve">
|
||||
<value>王子/公主</value>
|
||||
</data>
|
||||
<data name="ControlTextMetadataSpecialNamePlayerAvatarSexPro" xml:space="preserve">
|
||||
<value>他/她</value>
|
||||
</data>
|
||||
<data name="ControlTextMetadataSpecialNameRealNameId1" xml:space="preserve">
|
||||
<value>流浪者</value>
|
||||
</data>
|
||||
<data name="CoreExceptionServiceDatabaseCorruptedMessage" xml:space="preserve">
|
||||
<value>数据库已损坏:{0}</value>
|
||||
</data>
|
||||
|
||||
@@ -5,13 +5,17 @@ namespace Snap.Hutao.Win32.Foundation;
|
||||
|
||||
internal readonly struct BOOL
|
||||
{
|
||||
public static readonly BOOL TRUE = 1;
|
||||
|
||||
public readonly int Value;
|
||||
|
||||
public BOOL(bool value) => Value = value ? 1 : 0;
|
||||
|
||||
public static unsafe implicit operator int(BOOL value) => *(int*)&value;
|
||||
|
||||
public static unsafe implicit operator BOOL(int value) => *(BOOL*)&value;
|
||||
|
||||
public static implicit operator BOOL(bool value) => new(value);
|
||||
|
||||
public static implicit operator bool(BOOL value) => value.Value != 0;
|
||||
public static implicit operator bool(BOOL value) => value != 0;
|
||||
}
|
||||
@@ -6,4 +6,6 @@ namespace Snap.Hutao.Win32.Foundation;
|
||||
internal readonly struct LPARAM
|
||||
{
|
||||
public readonly nint Value;
|
||||
|
||||
public static unsafe implicit operator void*(LPARAM value) => *(void**)&value;
|
||||
}
|
||||
Reference in New Issue
Block a user